[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The new keymap functions
From: |
Robert Pluim |
Subject: |
Re: The new keymap functions |
Date: |
Thu, 18 Nov 2021 11:25:55 +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.
Re: The new keymap functions, Juri Linkov, 2021/11/16
- Re: The new keymap functions, Richard Stallman, 2021/11/16
- Re: The new keymap functions, Lars Ingebrigtsen, 2021/11/17
- Re: The new keymap functions, Juri Linkov, 2021/11/17
- Re: The new keymap functions, Robert Pluim, 2021/11/17
- Re: The new keymap functions, Juri Linkov, 2021/11/17
- Re: The new keymap functions, Lars Ingebrigtsen, 2021/11/18
- Re: The new keymap functions,
Robert Pluim <=
- Re: The new keymap functions, Lars Ingebrigtsen, 2021/11/18
- Re: The new keymap functions, Lars Ingebrigtsen, 2021/11/18
- Re: The new keymap functions, Robert Pluim, 2021/11/18
- Re: The new keymap functions, Lars Ingebrigtsen, 2021/11/18
Re: The new keymap functions, Bob Rogers, 2021/11/17
Re: The new keymap functions, Richard Stallman, 2021/11/17
Re: The new keymap functions, xenodasein, 2021/11/13