[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Repeat lambda (was: Some minor suggestions to Tab Bar)
From: |
Zhiwei Chen |
Subject: |
Re: Repeat lambda (was: Some minor suggestions to Tab Bar) |
Date: |
Fri, 26 Mar 2021 06:00:23 +0000 |
> On Mar 24, 2021, at 2:30 AM, Juri Linkov <juri@linkov.net> wrote:
>
>>> (defvar tab-bar-move-repeat-map
>>> (let ((map (make-sparse-keymap)))
>>> (define-key map "m" 'tab-move)
>>> (define-key map "M" (lambda ()
>>> (interactive)
>>> (tab-move -1)))
>>> map)
>>> "Keymap to repeat tab move key sequences `C-x t m m'.
>>> Used in `repeat-mode'.")
>>> (put 'tab-move 'repeat-map 'tab-bar-move-repeat-map)
>>
>> One nitpicking is that `C-x t m M m’ is not allowed
>> since `(tab-move -1)` hasn’t a `repeat-map’ property.
>> Maybe name it tab-move-prev and set the property?
>
> This can't be a general solution since there are other keymaps
> where repeating lambda is required.
>
> For example, other-window-repeat-map currently has no keybinding
> that could switch to navigating windows in the opposite direction.
> There were proposals to bind it to "O", but since there is no such
> command as "previous-window" to cycle windows backwards,
> using a lambda is required, but currently this doesn't work:
>
> (define-key other-window-repeat-map "O"
> (lambda ()
> (interactive)
> (other-window -1)))
>
> Stefan already asked about this, but I had no idea
> how it could be improved. Now I tried to set
> the KEEP-PRED arg of set-transient-map to t, and
> it seems both lambdas above can be used with this change:
>
> diff --git a/lisp/repeat.el b/lisp/repeat.el
> index 84a613da0c..4be4f766ef 100644
> --- a/lisp/repeat.el
> +++ b/lisp/repeat.el
> @@ -398,7 +398,7 @@ repeat-post-hook
> (when repeat-exit-key
> (define-key map repeat-exit-key 'ignore))
> - (set-transient-map map)))))))
> + (set-transient-map map t)))))))
So there is no help message “[Repeat with o, O, ...]” displayed when use 'C-x o
O’.
Maybe we can wrap all commands in `repeat-map’ and show the help message first,
then invoke the bound function?
--
Zhiwei Chen
- Re: Some minor suggestions to Tab Bar, (continued)
Re: Some minor suggestions to Tab Bar, Juri Linkov, 2021/03/24