branch: externals/transient commit f0213e05438ba044f0469b00bb8b4fef8b6122cb Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
Add commands to scroll transient window --- docs/CHANGELOG | 3 +++ docs/transient.org | 24 ++++++++++++++++++++++-- docs/transient.texi | 31 +++++++++++++++++++++++++++++-- lisp/transient.el | 30 +++++++++++++++++++++++++++++- 4 files changed, 83 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 990d7ab44d..71836707e8 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -11,6 +11,9 @@ non-standard value for ~transient-display-buffer-action~ it may be necessary to do that. #17 +- Added new commands ~transient-scroll-up~ and ~transient-scroll-down~, + which scroll the transient window. #17 + - The window that was selected before the transient window was shown is no longer re-selected before calling a suffix that exits the transient. If a suffix changes the selected window unintentionally, diff --git a/docs/transient.org b/docs/transient.org index 7e6251e830..f18c9ad0da 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.1.0 (v0.1.0-29-g7e45a57+1) +#+SUBTITLE: for version 0.1.0 (v0.1.0-30-g2033ac1+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.1.0 (v0.1.0-29-g7e45a57+1). +This manual is for Transient version 0.1.0 (v0.1.0-30-g2033ac1+1). #+BEGIN_QUOTE Copyright (C) 2018-2019 Jonas Bernoulli <jo...@bernoul.li> @@ -489,6 +489,26 @@ as many additional suffixes as you hoped.) Therefore, to control which suffixes are available given a certain state, you have to make sure that that state is currently active. +** Other Commands + +When invoking a transient in a small frame, the transient window may +not show the complete buffer, making it necessary to scroll, using the +following commands. These commands are never shown in the transient +window, and the key bindings are the same as for ~scroll-up-command~ and +~scroll-down-command~ in other buffers. + +- Command: transient-scroll-up arg + + This command scrolls text of transient popup window upward ARG + lines. If ARG is ~nil~, then it scrolls near full screen. This + is a wrapper around ~scroll-up-command~ (which see). + +- Command: transient-scroll-down arg + + This command scrolls text of transient popup window down ARG + lines. If ARG is ~nil~, then it scrolls near full screen. This + is a wrapper around ~scroll-down-command~ (which see). + * Other Options - User Option: transient-show-popup diff --git a/docs/transient.texi b/docs/transient.texi index f217791141..92d52414ea 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.1.0 (v0.1.0-29-g7e45a57+1) +@subtitle for version 0.1.0 (v0.1.0-30-g2033ac1+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.1.0 (v0.1.0-29-g7e45a57+1). +This manual is for Transient version 0.1.0 (v0.1.0-30-g2033ac1+1). @quotation Copyright (C) 2018-2019 Jonas Bernoulli <jonas@@bernoul.li> @@ -108,6 +108,7 @@ Usage * Using History:: * Getting Help for Suffix Commands:: * Enabling and Disabling Suffixes:: +* Other Commands:: Defining New Commands @@ -279,6 +280,7 @@ to implementing yet). * Using History:: * Getting Help for Suffix Commands:: * Enabling and Disabling Suffixes:: +* Other Commands:: @end menu @node Invoking Transients @@ -644,6 +646,31 @@ Therefore, to control which suffixes are available given a certain state, you have to make sure that that state is currently active. @end table +@node Other Commands +@section Other Commands + +When invoking a transient in a small frame, the transient window may +not show the complete buffer, making it necessary to scroll, using the +following commands. These commands are never shown in the transient +window, and the key bindings are the same as for @code{scroll-up-command} and +@code{scroll-down-command} in other buffers. + +@cindex transient-scroll-up arg +@deffn Command transient-scroll-up arg + +This command scrolls text of transient popup window upward ARG +lines. If ARG is @code{nil}, then it scrolls near full screen. This +is a wrapper around @code{scroll-up-command} (which see). +@end deffn + +@cindex transient-scroll-down arg +@deffn Command transient-scroll-down arg + +This command scrolls text of transient popup window down ARG +lines. If ARG is @code{nil}, then it scrolls near full screen. This +is a wrapper around @code{scroll-down-command} (which see). +@end deffn + @node Other Options @chapter Other Options diff --git a/lisp/transient.el b/lisp/transient.el index 453b116ee4..74958d2986 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1110,6 +1110,8 @@ but unfortunately that does not exist (yet?)." (define-key map (kbd "C-q") 'transient-quit-all) (define-key map (kbd "C-z") 'transient-suspend) (define-key map (kbd "ESC ESC ESC") 'transient-quit-all) + (define-key map [remap scroll-up-command] 'transient-scroll-up) + (define-key map [remap scroll-down-command]'transient-scroll-down) map) "Base keymap used by all transients.") @@ -1122,6 +1124,8 @@ but unfortunately that does not exist (yet?)." (define-key map (kbd "C-q") 'transient-quit-all) (define-key map (kbd "C-z") 'transient-suspend) (define-key map (kbd "ESC ESC ESC") 'transient-quit-all) + (define-key map [remap scroll-up-command] 'transient-scroll-up) + (define-key map [remap scroll-down-command]'transient-scroll-down) map) "Keymap that is active while a transient in is in \"edit mode\".") @@ -1131,6 +1135,8 @@ but unfortunately that does not exist (yet?)." (define-key map (kbd "C-q") 'transient-quit-all) (define-key map (kbd "C-z") 'transient-suspend) (define-key map (kbd "ESC ESC ESC") 'transient-quit-all) + (define-key map [remap scroll-up-command] 'transient-scroll-up) + (define-key map [remap scroll-down-command]'transient-scroll-down) map) "Keymap that is active while an incomplete key sequence is active.") @@ -1186,6 +1192,9 @@ but unfortunately that does not exist (yet?)." (define-key map [transient-save] 'transient--do-call) (define-key map [describe-key-briefly] 'transient--do-stay) (define-key map [describe-key] 'transient--do-stay) + (define-key map [transient-scroll-up] 'transient--do-stay) + (define-key map [transient-scroll-down] 'transient--do-stay) + (define-key map [mwheel-scroll] 'transient--do-stay) map) "Base keymap used to map common commands to their transient behavior. @@ -1599,7 +1608,10 @@ EDIT may be non-nil." (defun transient--redisplay () (if (or (eq transient-show-popup t) transient--showp) - (transient--show) + (unless (memq this-command '(transient-scroll-up + transient-scroll-down + mwheel-scroll)) + (transient--show)) (when (and (numberp transient-show-popup) (not transient--timer)) (transient--timer-start)) @@ -1844,6 +1856,22 @@ transient is active." (oset obj value (nth pos hst)) (mapc #'transient-init-value transient--suffixes)))) +(defun transient-scroll-up (&optional arg) + "Scroll text of transient popup window upward ARG lines. +If ARG is nil scroll near full screen. This is a wrapper +around `scroll-up-command' (which see)." + (interactive "^P") + (with-selected-window transient--window + (scroll-up-command arg))) + +(defun transient-scroll-down (&optional arg) + "Scroll text of transient popup window down ARG lines. +If ARG is nil scroll near full screen. This is a wrapper +around `scroll-down-command' (which see)." + (interactive "^P") + (with-selected-window transient--window + (scroll-up-command arg))) + (defun transient-resume () "Resume a previously suspended stack of transients." (interactive)