emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 12409c9: New transient mode 'repeat-mode' to allow shorter ke


From: Stefan Monnier
Subject: Re: master 12409c9: New transient mode 'repeat-mode' to allow shorter key sequences (bug#46515)
Date: Thu, 18 Feb 2021 10:32:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>>> +(defvar next-error-repeat-map
>>> +  (let ((map (make-sparse-keymap)))
>>> +    (define-key map    "n" 'next-error)
>>> +    (define-key map "\M-n" 'next-error)
>>> +    (define-key map    "p" 'previous-error)
>>> +    (define-key map "\M-p" 'previous-error)
>>> +    map)
>>> +  "Keymap to repeat next-error key sequences.  Used in `repeat-mode'.")
>>> +(put 'next-error 'repeat-map 'next-error-repeat-map)
>>> +(put 'previous-error 'repeat-map 'next-error-repeat-map)
>>
>> Could we avoid this duplication between the map and the
>> `repeat-map` property?
>>
>>> +            (set-transient-map map)))))))
>>
>> For example passing a second argument t to `set-transient-map` makes
>> `set-transient-map` look to see if the key just typed was found in the
>> map and if so keep the transient alive, which seems to [after an
>> admittedly cursory check of the code] play the same role as what your
>> `repeat-map` property does, but without the duplication.
>
> The current design relies on post-command-hook that runs after every command.
> Using the second argument KEEP-PRED of set-transient-map will add duplication:
> the same map will be set by both post-command-hook and KEEP-PRED.

My point was not to say "use `keep-pred`", but to point out that
`keep-pred` found a way to solve the same problem without the duplication.

[ I'd be nice to be able to use `keep-pred` directly since it would
  likely make the code simpler, but it may well be that this is
  incompatible with the current code's design or with its intended
  behavior, or that it would require further changes that would make the
  overall code more complex.  ]

> So currently there is no duplication.

There is in the above code snippet: the `put` statements are redundant
since the same info is fundamentally already available from
`next-error-repeat-map`.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]