unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Nelson <ultrono@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: 74140@debbugs.gnu.org, eliz@gnu.org
Subject: bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package
Date: Thu, 19 Dec 2024 23:02:10 +0100	[thread overview]
Message-ID: <uxsg7tv7vfz5zx.fsf@gmail.com> (raw)
In-Reply-To: <87y10edtlr.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 17 Dec 2024 20:58:40 +0200)

Juri Linkov <juri@linkov.net> writes:

>> I think the repeat-map property is fine as is, but the logic should be a
>> bit different:
>>
>> - If a command is called while repeat map MAP is active, then:
>>
>>   - If the command's repeat-continue-only property contains MAP, then
>>     MAP remains active (i.e., that map "continues").  [Maybe a better
>>     name for the property would be simply "repeat-continue".]
>
> So the property is renamed now to 'repeat-continue'.
>
>>   - Otherwise, if the command has a repeat-map property, then that
>>     becomes the new repeat map.
>>
>>   - Otherwise, the repeat map deactivates.
>>
>> - If a command is called while no repeat map is active, then we proceed
>>   as before.
>>
>> Do you agree that this is the desired behavior?  The difference is that
>> with the current implementation, only the repeat-map property is
>> relevant for determining which repeat map a command activates or
>> continues.
>
> Thanks for the clear explanation.  Now this is completely implemented
> with tests.

Thanks Juri, I tried it out and have noticed an issue.  Consider as
before the example:

(defvar-keymap repeat-list-map
  :doc "Keymap for repeating sequences."
  :repeat ( :continue (yank undo))
  "n" 'forward-list
  "p" 'backward-list
  "C-/" 'undo
  "y" 'yank)

(defvar-keymap repeat-paragraph-map
  :doc "Keymap for repeating sequences."
  :repeat ( :continue (yank undo))
  "]" 'forward-paragraph
  "}" 'forward-paragraph
  "[" 'backward-paragraph
  "{" 'backward-paragraph
  "C-/" 'undo
  "y" 'yank)

If we now do forward-list followed by two repeat-map yanks (i.e., C-M-n
y y), then we wind up in repeat-paragraph-map (but we should have never
left repeat-list-map).

To diagnose, let's look at (symbol-plist #'yank):

(... repeat-continue (repeat-paragraph-map repeat-list-map)
     repeat-map repeat-paragraph-map)

Here the precise value of the repeat-map property of yank should not
affect behavior (and so that property should not exist), but it does,
due to the way repeat-post-hook is currently coded.  What happens is
that when we are continuing a repeat map via repeat-continue, the value
of map-sym is discarded in the evaluation of

  (repeat-get-map map-sym)

but gets used later in

  (setq repeat-in-progress map-sym)

In such cases, we should instead (somehow) first modify map-sym so that
it is the symbol describing the "continue" map whose value is ultimately
returned via (repeat-get-map map-sym).  I'm not sure how best to do so.

Hope that makes sense; happy to clarify or think further if it'd help.

Paul





      reply	other threads:[~2024-12-19 22:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31 17:36 bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package Paul Nelson
2024-11-01  7:54 ` Juri Linkov
2024-11-01  8:29   ` Paul Nelson
2024-11-01  8:58     ` Paul Nelson
2024-11-04 19:22       ` Juri Linkov
2024-11-04 20:45         ` Paul Nelson
2024-11-05 18:25           ` Juri Linkov
2024-11-05 20:51             ` Paul Nelson
2024-11-07 19:41               ` Juri Linkov
2024-11-23 18:44                 ` Paul Nelson
2024-11-27  7:46                   ` Juri Linkov
2024-11-27 15:19                     ` Paul Nelson
2024-11-28 19:12                       ` Juri Linkov
2024-12-03 18:12                         ` Juri Linkov
2024-12-03 18:18                           ` Paul Nelson
2024-12-04 12:08                           ` Eli Zaretskii
2024-12-04 17:29                             ` Juri Linkov
2024-12-11 12:27                               ` Paul Nelson
2024-12-16  5:57                               ` Paul Nelson
2024-12-16 17:30                                 ` Juri Linkov
2024-12-16 20:01                                   ` Paul Nelson
2024-12-17 18:58                                     ` Juri Linkov
2024-12-19 22:02                                       ` Paul Nelson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uxsg7tv7vfz5zx.fsf@gmail.com \
    --to=ultrono@gmail.com \
    --cc=74140@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).