diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-02-08 23:15:22 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-02-09 15:30:43 -0700 |
commit | f01532c2c9d35198b0a3a2e044773c1b0ac60e36 (patch) | |
tree | 10a1e55241d82756229732701e08a85878aa122d /.emacs.d/site-lisp | |
parent | 7a04e5dc1b13565177d9bde9599b224f8f03a1f8 (diff) | |
download | dotfiles-f01532c2c9d35198b0a3a2e044773c1b0ac60e36.tar.gz |
transient-cycles: add an echo area message when cycling begins
Diffstat (limited to '.emacs.d/site-lisp')
-rw-r--r-- | .emacs.d/site-lisp/transient-cycles.el | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/.emacs.d/site-lisp/transient-cycles.el b/.emacs.d/site-lisp/transient-cycles.el index fb6c8a37..03851e9f 100644 --- a/.emacs.d/site-lisp/transient-cycles.el +++ b/.emacs.d/site-lisp/transient-cycles.el @@ -69,9 +69,16 @@ (require 'cl-lib) (defgroup transient-cycles nil - "Defaults when defining variants of commands with transient cycling." + "Defaults and options when defining variants of commands with +transient cycling." :group 'convenience) +(defcustom transient-cycles-show-cycling-keys t + "Whether to show the cycling keys in the echo area when +commencing transient cycling." + :type 'boolean + :group 'transient-cycles) + (defcustom transient-cycles-default-cycle-backwards-key [left] "Default key for cycling backwards in the transient maps set by commands augmented with transient cycling." @@ -147,6 +154,7 @@ argument to `set-transient-map'." (macroexp-progn (cl-loop with on-exit = (and on-exit `(lambda () ,on-exit)) and arg = (gensym) and cycler = (gensym) and tmap = (gensym) + and kforwards = (gensym) and kbackwards = (gensym) for command in commands for (original args . body) = (if (proper-list-p command) @@ -178,21 +186,25 @@ argument to `set-transient-map'." body (cons (interactive-form original*) body)))))) (when-let ((,cycler (funcall ,cycler-generator ,arg)) - (,tmap (make-sparse-keymap))) + (,tmap (make-sparse-keymap)) + (,kforwards ,cycle-forwards-key) + (,kbackwards ,cycle-backwards-key)) ;; It might be additionally useful to bind something in the ;; transient map to kill the current buffer and cycle once. ;; ;; For the forward direction we could elide this lambda and ;; just bind the key to the cycler. But this way means we are ;; consistent in always supplying an integer. - (define-key ,tmap ,cycle-forwards-key - (lambda (,arg) - (interactive "p") - (funcall ,cycler ,arg))) - (define-key ,tmap ,cycle-backwards-key - (lambda (,arg) - (interactive "p") - (funcall ,cycler (* -1 ,arg)))) + (define-key ,tmap ,kforwards (lambda (,arg) + (interactive "p") + (funcall ,cycler ,arg))) + (define-key ,tmap ,kbackwards (lambda (,arg) + (interactive "p") + (funcall ,cycler (* -1 ,arg)))) + (when transient-cycles-show-cycling-keys + (message "Cycle forwards with %s, backwards with %s" + (key-description ,kforwards) + (key-description ,kbackwards))) (set-transient-map ,tmap t ,on-exit)))) when key collect `(define-key ,keymap ,key #',name)))) (put 'transient-cycles-define-commands 'common-lisp-indent-function |