[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/transient 7c67773735 279/366: More flexible display of
From: |
Jonas Bernoulli |
Subject: |
[elpa] externals/transient 7c67773735 279/366: More flexible display of transient buffer |
Date: |
Tue, 25 Jan 2022 18:54:47 -0500 (EST) |
branch: externals/transient
commit 7c67773735dea5a0c41ad8afb69fdafb62c46c7c
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>
More flexible display of transient buffer
Display buffer after populating it and set additional display actions
and window parameters using the display alist instead of hardcoding
them. (`set-window-hscroll' should be unnecessary so drop that.)
Use a wrapper function around `fit-window-to-buffer' so that users can
override it (but do not go as far as to provide a hook).
Continue to call that function explicitly because the `window-height'
display action is ignored when reusing an existing window, and while
we don't encourage doing that, we still want to support it. If an
existing window is repurposed, then avoid shrinking it.
---
docs/transient.org | 47 +++++++++++++++++++++++++++-----------
docs/transient.texi | 46 ++++++++++++++++++++++++++-----------
lisp/transient.el | 66 ++++++++++++++++++++++++++++++++++-------------------
3 files changed, 110 insertions(+), 49 deletions(-)
diff --git a/docs/transient.org b/docs/transient.org
index 305684eb86..8e44939f67 100644
--- a/docs/transient.org
+++ b/docs/transient.org
@@ -8,7 +8,7 @@
#+TEXINFO_DIR_CATEGORY: Emacs
#+TEXINFO_DIR_TITLE: Transient: (transient).
#+TEXINFO_DIR_DESC: Transient Commands
-#+SUBTITLE: for version 0.3.6
+#+SUBTITLE: for version 0.3.6 (v0.3.6-10-gbe119ee4+1)
#+TEXINFO_DEFFN: t
#+OPTIONS: H:4 num:4 toc:2
@@ -37,7 +37,7 @@ Calling a suffix command usually causes the transient to be
exited
but suffix commands can also be configured to not exit the transient.
#+TEXINFO: @noindent
-This manual is for Transient version 0.3.6.
+This manual is for Transient version 0.3.6 (v0.3.6-10-gbe119ee4+1).
#+BEGIN_QUOTE
Copyright (C) 2018-2021 Jonas Bernoulli <jonas@bernoul.li>
@@ -517,24 +517,45 @@ window, and the key bindings are the same as for
~scroll-up-command~ and
buffer. The transient popup buffer is displayed in a window using
~(display-buffer BUFFER transient-display-buffer-action)~.
- The value of this option has the form ~(FUNCTION . ALIST)~, where
- FUNCTION is a function or a list of functions. Each such function
- should accept two arguments: a buffer to display and an alist of the
- same form as ALIST. See [[info:elisp#Choosing Window]].
+ The value of this option has the form ~(FUNCTION . ALIST)~,
+ where FUNCTION is a function or a list of functions. Each such
+ function should accept two arguments: a buffer to display and an
+ alist of the same form as ALIST. See [[info:elisp#Choosing Window]]
+ for details.
+
+ The value of this option has the form ~(FUNCTION . ALIST)~,
+ where FUNCTION is a function or a list of functions. Each such
+ function should accept two arguments: a buffer to display and
+ an alist of the same form as ALIST. See ~display-buffer~ for
+ details.
+
+ The default is:
+
+ (display-buffer-in-side-window
+ (side . bottom)
+ (inhibit-same-window . t)
+ (window-parameters (no-other-window . t)))
- The default is ~(display-buffer-in-side-window (side . bottom))~.
This displays the window at the bottom of the selected frame.
- Another useful value is ~(display-buffer-below-selected)~. This is
- what ~magit-popup~ used by default. For more alternatives see
- [[info:elisp#Display Action Functions]].
+ Another useful FUNCTION is `display-buffer-below-selected', which
+ is what `magit-popup' used by default. For more alternatives see
+ [[info:elisp#Display Action Functions]] and [[info:elisp#Buffer Display
+ Action Alists]].
+
+ Note that the buffer that was current before the transient buffer
+ is shown should remain the current buffer. Many suffix commands
+ act on the thing at point, if appropriate, and if the transient
+ buffer became the current buffer, then that would change what is
+ at point. To that effect ~inhibit-same-window~ ensures that the
+ selected window is not used to show the transient buffer.
It may be possible to display the window in another frame, but
whether that works in practice depends on the window-manager.
If the window manager selects the new window (Emacs frame),
- then it doesn't work.
+ then that unfortunately changes which buffer is current.
- If you change the value of this option, then you might also want
- to change the value of ~transient-mode-line-format~.
+ If you change the value of this option, then you might also
+ want to change the value of ~transient-mode-line-format~.
- User Option: transient-mode-line-format
diff --git a/docs/transient.texi b/docs/transient.texi
index 9134e20651..8c873b317a 100644
--- a/docs/transient.texi
+++ b/docs/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
@finalout
@titlepage
@title Transient User and Developer Manual
-@subtitle for version 0.3.6
+@subtitle for version 0.3.6 (v0.3.6-10-gbe119ee4+1)
@author Jonas Bernoulli
@page
@vskip 0pt plus 1filll
@@ -65,7 +65,7 @@ Calling a suffix command usually causes the transient to be
exited
but suffix commands can also be configured to not exit the transient.
@noindent
-This manual is for Transient version 0.3.6.
+This manual is for Transient version 0.3.6 (v0.3.6-10-gbe119ee4+1).
@quotation
Copyright (C) 2018-2021 Jonas Bernoulli <jonas@@bernoul.li>
@@ -708,24 +708,44 @@ This option specifies the action used to display the
transient popup
buffer. The transient popup buffer is displayed in a window using
@code{(display-buffer BUFFER transient-display-buffer-action)}.
-The value of this option has the form @code{(FUNCTION . ALIST)}, where
-FUNCTION is a function or a list of functions. Each such function
-should accept two arguments: a buffer to display and an alist of the
-same form as ALIST@. See @ref{Choosing Window,,,elisp,}.
+The value of this option has the form @code{(FUNCTION . ALIST)},
+where FUNCTION is a function or a list of functions. Each such
+function should accept two arguments: a buffer to display and an
+alist of the same form as ALIST@. See @ref{Choosing Window,,,elisp,}
+for details.
+
+The value of this option has the form @code{(FUNCTION . ALIST)},
+where FUNCTION is a function or a list of functions. Each such
+function should accept two arguments: a buffer to display and
+an alist of the same form as ALIST@. See @code{display-buffer} for
+details.
+
+The default is:
+
+(display-buffer-in-side-window
+ (side . bottom)
+ (inhibit-same-window . t)
+ (window-parameters (no-other-window . t)))
-The default is @code{(display-buffer-in-side-window (side . bottom))}.
This displays the window at the bottom of the selected frame.
-Another useful value is @code{(display-buffer-below-selected)}. This is
-what @code{magit-popup} used by default. For more alternatives see
-@ref{Display Action Functions,,,elisp,}.
+Another useful FUNCTION is `display-buffer-below-selected', which
+is what `magit-popup' used by default. For more alternatives see
+@ref{Display Action Functions,,,elisp,} and @ref{Buffer Display Action
Alists,,,elisp,}.
+
+Note that the buffer that was current before the transient buffer
+is shown should remain the current buffer. Many suffix commands
+act on the thing at point, if appropriate, and if the transient
+buffer became the current buffer, then that would change what is
+at point. To that effect @code{inhibit-same-window} ensures that the
+selected window is not used to show the transient buffer.
It may be possible to display the window in another frame, but
whether that works in practice depends on the window-manager.
If the window manager selects the new window (Emacs frame),
-then it doesn't work.
+then that unfortunately changes which buffer is current.
-If you change the value of this option, then you might also want
-to change the value of @code{transient-mode-line-format}.
+If you change the value of this option, then you might also
+want to change the value of @code{transient-mode-line-format}.
@end defopt
@defopt transient-mode-line-format
diff --git a/lisp/transient.el b/lisp/transient.el
index abae5b770d..6b4fc4523c 100644
--- a/lisp/transient.el
+++ b/lisp/transient.el
@@ -148,34 +148,46 @@ features are available:
(defcustom transient-display-buffer-action
'(display-buffer-in-side-window
(side . bottom)
- (inhibit-same-window . t))
+ (dedicated . t)
+ (inhibit-same-window . t)
+ (window-parameters (no-other-window . t)))
"The action used to display the transient popup buffer.
The transient popup buffer is displayed in a window using
- \(display-buffer buf transient-display-buffer-action)
+ (display-buffer BUFFER transient-display-buffer-action)
The value of this option has the form (FUNCTION . ALIST),
where FUNCTION is a function or a list of functions. Each such
-function should accept two arguments: a buffer to display and
-an alist of the same form as ALIST. See `display-buffer' for
-details.
+function should accept two arguments: a buffer to display and an
+alist of the same form as ALIST. See info node `(elisp)Choosing
+Window' for details.
The default is:
(display-buffer-in-side-window
(side . bottom)
- (inhibit-same-window . t))
+ (dedicated . t)
+ (inhibit-same-window . t)
+ (window-parameters (no-other-window . t)))
This displays the window at the bottom of the selected frame.
-Another useful value is (display-buffer-below-selected). This
-is what `magit-popup' used by default. For more alternatives
-see info node `(elisp)Display Action Functions'.
+Another useful FUNCTION is `display-buffer-below-selected', which
+is what `magit-popup' used by default. For more alternatives see
+info node `(elisp)Display Action Functions' and info node
+`(elisp)Buffer Display Action Alists'.
+
+Note that the buffer that was current before the transient buffer
+is shown should remain the current buffer. Many suffix commands
+act on the thing at point, if appropriate, and if the transient
+buffer became the current buffer, then that would change what is
+at point. To that effect `inhibit-same-window' ensures that the
+selected window is not used to show the transient buffer.
It may be possible to display the window in another frame, but
whether that works in practice depends on the window-manager.
If the window manager selects the new window (Emacs frame),
-then it doesn't work.
+then that unfortunately changes which buffer is current.
If you change the value of this option, then you might also
want to change the value of `transient-mode-line-format'."
@@ -1954,8 +1966,10 @@ value. Otherwise return CHILDREN as is."
(defun transient--delete-window ()
(when (window-live-p transient--window)
(let ((buf (window-buffer transient--window)))
- (with-demoted-errors "Error while exiting transient: %S"
- (delete-window transient--window))
+ ;; Only delete the window if it never showed another buffer.
+ (unless (eq (car (window-parameter transient--window 'quit-restore))
'other)
+ (with-demoted-errors "Error while exiting transient: %S"
+ (delete-window transient--window)))
(kill-buffer buf))))
(defun transient--export ()
@@ -2871,17 +2885,11 @@ have a history of their own.")
(setq transient--showp t)
(let ((buf (get-buffer-create transient--buffer-name))
(focus nil))
- (unless (window-live-p transient--window)
- (setq transient--window
- (display-buffer buf transient-display-buffer-action)))
- (with-selected-window transient--window
+ (with-current-buffer buf
(when transient-enable-popup-navigation
(setq focus (or (button-get (point) 'command)
(transient--heading-at-point))))
(erase-buffer)
- (set-window-hscroll transient--window 0)
- (set-window-dedicated-p transient--window t)
- (set-window-parameter transient--window 'no-other-window t)
(setq window-size-fixed t)
(when (bound-and-true-p tab-line-format)
(setq tab-line-format nil))
@@ -2908,14 +2916,26 @@ have a history of their own.")
'transient-separator)))
(insert (propertize "__" 'face face 'display '(space :height (1))))
(insert (propertize "\n" 'face face 'line-height t))))
- (let ((window-resize-pixelwise t)
- (window-size-fixed nil))
- (fit-window-to-buffer nil nil 1))
(goto-char (point-min))
(when transient-force-fixed-pitch
(transient--force-fixed-pitch))
(when transient-enable-popup-navigation
- (transient--goto-button focus)))))
+ (transient--goto-button focus)))
+ (unless (window-live-p transient--window)
+ (setq transient--window
+ (display-buffer buf transient-display-buffer-action)))
+ (when (window-live-p transient--window)
+ (with-selected-window transient--window
+ (magit--fit-window-to-buffer transient--window)))))
+
+(defun magit--fit-window-to-buffer (window)
+ (let ((window-resize-pixelwise t)
+ (window-size-fixed nil))
+ (if (eq (car (window-parameter window 'quit-restore)) 'other)
+ ;; Grow but never shrink window that previously displayed
+ ;; another buffer and is going to display that again.
+ (fit-window-to-buffer window nil (window-height window))
+ (fit-window-to-buffer window nil 1))))
(defun transient--insert-groups ()
(let ((groups (cl-mapcan (lambda (group)
- [elpa] externals/transient b343e2a3bb 202/366: transient-infix-read: Fix ivy specific kludge, (continued)
- [elpa] externals/transient b343e2a3bb 202/366: transient-infix-read: Fix ivy specific kludge, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4fc9aa53db 230/366: manual: Fix small typo, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient a6e4cced30 162/366: Remove the Package-Version header keyword again, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient eb39c9620b 233/366: transient--debug: Always show symbol representing command, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 162698aa9d 248/366: Release version 0.3.2, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6ceddc4d8c 250/366: news: Fix language and a prediction, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7d3d8d795a 249/366: Add SPDX-License-Identifier library header, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient d9878476fc 264/366: transient-force-single-column: New option, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 51e833e515 268/366: Release version 0.3.6, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 65f4eac82c 277/366: Silence type-compiler, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7c67773735 279/366: More flexible display of transient buffer,
Jonas Bernoulli <=
- [elpa] externals/transient 2281d95259 285/366: manual: Fix recent copy-paste errors, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 56fb7a91c8 292/366: transient-setup: Cosmetics, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 7126d6aa76 293/366: Fix hydra-inspired colors, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 791588d118 294/366: transient--emergency-exit: Fix doc-string, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 0695b617cc 310/366: manual: No longer use dissolvable sections, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 61af234d41 314/366: make: Update stats target, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 09b436fad0 329/366: transient--debug: Ignore error in transient--suffix-symbol, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 4a36b1d922 336/366: Interpret t and nil for sub-prefixes in define-transient-prefix, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 714e348296 337/366: No longer always suspend when handle-switch-frame is called, Jonas Bernoulli, 2022/01/25
- [elpa] externals/transient 6c9ae1f46a 346/366: manual: Replace some inaccurate information, Jonas Bernoulli, 2022/01/25