From: Robert Pluim <rpluim@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Emacs developers <emacs-devel@gnu.org>, Juri Linkov <juri@linkov.net>
Subject: Re: The new keymap functions
Date: Thu, 18 Nov 2021 11:25:55 +0100 [thread overview]
Message-ID: <877dd5n4jw.fsf@gmail.com> (raw)
In-Reply-To: <87bl2hn7td.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 18 Nov 2021 10:15:26 +0100")
>>>>> On Thu, 18 Nov 2021 10:15:26 +0100, Lars Ingebrigtsen <larsi@gnus.org> said:
Lars> Juri Linkov <juri@linkov.net> writes:
>> But this macro should put a special property to all commands bound
>> to repeatable keys. This means that `defvar-keymap' should include
>> special-handling of repeatable commands.
Lars> I think that should be possible.
Iʼm sure Iʼve forgotten some subtlety of key definitions, but
something like this:
diff --git a/lisp/subr.el b/lisp/subr.el
index 7ba764880e..b405c80c96 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6613,27 +6613,44 @@ defvar-keymap
In addition to the keywords accepted by `define-keymap', this
macro also accepts a `:doc' keyword, which (if present) is used
-as the variable documentation string.
+as the variable documentation string. Passing in a non-nil
+`:repeat' keyword will cause the definitions to be marked as
+repeatable.
-\(fn VARIABLE-NAME &key DOC FULL PARENT SUPPRESS NAME PREFIX KEYMAP &rest [KEY DEFINITION]...)"
+\(fn VARIABLE-NAME &key DOC FULL PARENT SUPPRESS NAME PREFIX KEYMAP REPEAT &rest [KEY DEFINITION]...)"
(declare (indent 1))
(let ((opts nil)
- doc)
+ doc repeatable props)
(while (and defs
(keywordp (car defs))
(not (eq (car defs) :menu)))
(let ((keyword (pop defs)))
(unless defs
(error "Uneven number of keywords"))
- (if (eq keyword :doc)
- (setq doc (pop defs))
+ (cond
+ ((eq keyword :doc)
+ (setq doc (pop defs)))
+ ((eq keyword :repeat)
+ (setq repeatable (pop defs)))
+ (t
(push keyword opts)
- (push (pop defs) opts))))
+ (push (pop defs) opts)))))
(unless (zerop (% (length defs) 2))
(error "Uneven number of key/definition pairs: %s" defs))
- `(defvar ,variable-name
+ (when repeatable
+ (let ((defs defs)
+ def)
+ (while defs
+ (pop defs)
+ (setq def (pop defs))
+ (when (or (eq (car def) 'function)
+ (eq (car def) 'quote))
+ (push `(put ,def 'repeat-map ',variable-name) props)))))
+ `(progn
+ ,@props
+ (defvar ,variable-name
(define-keymap--define (list ,@(nreverse opts) ,@defs))
- ,@(and doc (list doc)))))
+ ,@(and doc (list doc))))))
(defmacro with-delayed-message (args &rest body)
"Like `progn', but display MESSAGE if BODY takes longer than TIMEOUT seconds.
next prev parent reply other threads:[~2021-11-18 10:25 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-13 6:56 The new keymap functions Lars Ingebrigtsen
2021-11-13 7:31 ` Stefan Kangas
2021-11-13 7:50 ` Lars Ingebrigtsen
2021-11-13 11:36 ` Joost Kremers
2021-11-13 12:07 ` Lars Ingebrigtsen
2021-11-15 13:01 ` Dmitry Gutov
2021-11-15 16:53 ` Lars Ingebrigtsen
2021-11-16 7:28 ` Lars Ingebrigtsen
2021-11-16 14:08 ` Eli Zaretskii
2021-11-16 14:24 ` Lars Ingebrigtsen
2021-11-16 15:13 ` Eli Zaretskii
2021-11-16 15:19 ` Lars Ingebrigtsen
2021-11-16 17:16 ` Eli Zaretskii
2021-11-17 7:30 ` Lars Ingebrigtsen
2021-11-13 15:09 ` Stefan Monnier
2021-11-13 15:24 ` Lars Ingebrigtsen
2021-11-14 3:17 ` Lars Ingebrigtsen
2021-11-14 5:05 ` Phil Sainty
2021-11-14 5:14 ` Lars Ingebrigtsen
2021-11-14 7:15 ` Eli Zaretskii
2021-11-14 10:53 ` Lars Ingebrigtsen
2021-11-14 11:01 ` Lars Ingebrigtsen
2021-11-14 7:41 ` Yuri Khan
2021-11-15 4:52 ` Richard Stallman
2021-11-15 5:14 ` Lars Ingebrigtsen
2021-11-16 4:05 ` Richard Stallman
2021-11-16 7:38 ` Lars Ingebrigtsen
2021-11-16 16:25 ` [External] : " Drew Adams
2021-11-17 4:16 ` Richard Stallman
2021-11-17 7:55 ` Lars Ingebrigtsen
2021-11-17 16:06 ` [External] : " Drew Adams
2021-11-16 16:24 ` Drew Adams
2021-11-16 20:14 ` Juri Linkov
2021-11-17 4:16 ` Richard Stallman
2021-11-17 7:36 ` Lars Ingebrigtsen
2021-11-17 8:10 ` Juri Linkov
2021-11-17 9:42 ` Robert Pluim
2021-11-17 17:03 ` Juri Linkov
2021-11-18 9:15 ` Lars Ingebrigtsen
2021-11-18 10:25 ` Robert Pluim [this message]
2021-11-18 10:33 ` Lars Ingebrigtsen
2021-11-18 10:37 ` Lars Ingebrigtsen
2021-11-18 10:54 ` Robert Pluim
2021-11-18 10:59 ` Lars Ingebrigtsen
2022-11-15 18:38 ` Juri Linkov
2022-11-17 7:31 ` Juri Linkov
2022-11-17 8:35 ` Robert Pluim
2022-11-17 15:04 ` Robert Pluim
2022-11-17 17:29 ` Juri Linkov
2022-11-18 8:33 ` Robert Pluim
2022-11-18 15:41 ` Robert Pluim
2023-03-17 14:48 ` Robert Pluim
2023-03-18 18:04 ` Juri Linkov
2023-03-20 8:54 ` Robert Pluim
2021-11-17 20:57 ` Bob Rogers
2021-11-18 3:53 ` Richard Stallman
-- strict thread matches above, loose matches on Subject: below --
2021-11-13 18:59 xenodasein--- via Emacs development discussions.
2021-11-14 0:42 ` Lars Ingebrigtsen
2021-11-14 4:56 ` Lars Ingebrigtsen
2021-11-14 15:41 ` Stefan Monnier
2021-11-14 18:00 ` Lars Ingebrigtsen
2021-11-14 12:04 ` xenodasein--- via Emacs development discussions.
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=877dd5n4jw.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=juri@linkov.net \
--cc=larsi@gnus.org \
/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).