all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package
@ 2024-10-31 17:36 Paul Nelson
  2024-11-01  7:54 ` Juri Linkov
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Nelson @ 2024-10-31 17:36 UTC (permalink / raw)
  To: 74140

[-- Attachment #1: Type: text/plain, Size: 1488 bytes --]

For a command and its key in a repeat map:
- "activate" means the command makes the repeat map active
- "continue" means pressing the key keeps the repeat map active

With this patch, the available directives are:
:continue (default) - activates and continues
:exit - neither activates nor continues
:continue-only (new) - continues, but does not activate

A similar feature has been available for many years in the package
https://tildegit.org/acdw/define-repeat-map.el.  The inclusion here
was motivated by the discussions at
https://github.com/jwiegley/use-package/issues/964 and
https://github.com/jwiegley/use-package/pull/974.

A basic example indicating why this might be useful:

(bind-keys
 :repeat-map paragraph-repeat-map
 :continue
 ("]" . forward-paragraph)
 ("}" . forward-paragraph)
 ("[" . backward-paragraph)
 ("{" . backward-paragraph)
 ("k" . kill-paragraph)
 :continue-only
 ;; These commands will be available during paragraph manipulation
 ;; but won't activate paragraph-repeat-map themselves
 ("y" . yank)
 ("C-/" . undo))

Or equivalently, with use-package:

(use-package emacs
  :ensure nil
  :bind
  (:repeat-map
   paragraph-repeat-map
   ("]" . forward-paragraph)
   ("}" . forward-paragraph)
   ("[" . backward-paragraph)
   ("{" . backward-paragraph)
   ("k" . kill-paragraph)
   :continue-only
   ;; These commands will be available during paragraph manipulation
   ;; but won't activate paragraph-repeat-map themselves
   ("y" . yank)
   ("C-/" . undo)))

[-- Attachment #2: 0001-Add-continue-only-directive-to-bind-keys-and-use-pac.patch --]
[-- Type: application/x-patch, Size: 5059 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2024-11-01  7:54 UTC (permalink / raw)
  To: Paul Nelson; +Cc: 74140

> For a command and its key in a repeat map:
> - "activate" means the command makes the repeat map active
> - "continue" means pressing the key keeps the repeat map active
>
> With this patch, the available directives are:
> :continue (default) - activates and continues
> :exit - neither activates nor continues
> :continue-only (new) - continues, but does not activate

How does this map to the properties ':enter' and ':exit' of 'defvar-keymap'?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package
  2024-11-01  7:54 ` Juri Linkov
@ 2024-11-01  8:29   ` Paul Nelson
  2024-11-01  8:58     ` Paul Nelson
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Nelson @ 2024-11-01  8:29 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 74140

On Fri, Nov 1, 2024 at 9:15 AM Juri Linkov <juri@linkov.net> wrote:
>
> > For a command and its key in a repeat map:
> > - "activate" means the command makes the repeat map active
> > - "continue" means pressing the key keeps the repeat map active
> >
> > With this patch, the available directives are:
> > :continue (default) - activates and continues
> > :exit - neither activates nor continues
> > :continue-only (new) - continues, but does not activate
>
> How does this map to the properties ':enter' and ':exit' of 'defvar-keymap'?

:exit has the same meaning in both.

In defvar-keymap, :enter means "activate, but do not continue".





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#74140: [PATCH] Add :continue-only directive for repeat maps in bind-keys, use-package
  2024-11-01  8:29   ` Paul Nelson
@ 2024-11-01  8:58     ` Paul Nelson
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Nelson @ 2024-11-01  8:58 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 74140

On Fri, Nov 1, 2024 at 9:29 AM Paul Nelson <ultrono@gmail.com> wrote:
>
> On Fri, Nov 1, 2024 at 9:15 AM Juri Linkov <juri@linkov.net> wrote:
> >
> > > For a command and its key in a repeat map:
> > > - "activate" means the command makes the repeat map active
> > > - "continue" means pressing the key keeps the repeat map active
> > >
> > > With this patch, the available directives are:
> > > :continue (default) - activates and continues
> > > :exit - neither activates nor continues
> > > :continue-only (new) - continues, but does not activate
> >
> > How does this map to the properties ':enter' and ':exit' of 'defvar-keymap'?
>
> :exit has the same meaning in both.
>
> In defvar-keymap, :enter means "activate, but do not continue".

Another difference is that :enter from defvar-keymap does not actually
bind a key in the keymap, thus:

                  activate    continue     bind
:continue         yes         yes          yes
:continue-only    no          yes          yes
:exit             no          no           yes
:enter            yes         no           no

The ergonomics between the two macros are also quite different.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-01  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.