emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/leaf b6276d7faa 15/28: Change the expand form of leaf-k


From: ELPA Syncer
Subject: [elpa] externals/leaf b6276d7faa 15/28: Change the expand form of leaf-key, when binding to lambda or menu-item
Date: Wed, 19 Jan 2022 18:58:41 -0500 (EST)

branch: externals/leaf
commit b6276d7faa0ddf423d5fb0c22936152bb795e454
Author: Caowei <igooo.v@gmail.com>
Commit: Caowei <igooo.v@gmail.com>

    Change the expand form of leaf-key, when binding to lambda or menu-item
---
 leaf-tests.el |  8 +++++++-
 leaf.el       | 15 +++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/leaf-tests.el b/leaf-tests.el
index ed3108e5f2..c5b72b11a0 100644
--- a/leaf-tests.el
+++ b/leaf-tests.el
@@ -2454,7 +2454,13 @@ Example:
        (let* ((old (lookup-key global-map (kbd "M-s O")))
               (value `(global-map "M-s O" *lambda-function* ,(and old (not 
(numberp old)) old) nil)))
          (leaf-safe-push value leaf-key-bindlist)
-         (define-key global-map (kbd "M-s O") (lambda () "color-moccur" 
(interactive) (color-moccur))))))))
+         (define-key global-map (kbd "M-s O") '(lambda () "color-moccur" 
(interactive) (color-moccur)))))
+
+      ((leaf-key "M-s O" '(menu-item "" nil :filter (lambda (&optional _) 
#'other-window)))
+       (let* ((old (lookup-key global-map (kbd "M-s O")))
+              (value `(global-map "M-s O" *menu-item* ,(and old (not (numberp 
old)) old) nil)))
+         (leaf-safe-push value leaf-key-bindlist)
+         (define-key global-map (kbd "M-s O") '(menu-item "" nil :filter 
(lambda (&optional _) #'other-window))))))))
 
 (when (version< "24.0" emacs-version)
   (cort-deftest-with-macroexpand leaf/leaf-key-bind-keymap
diff --git a/leaf.el b/leaf.el
index 83f289bfb3..b4fce2a3e4 100644
--- a/leaf.el
+++ b/leaf.el
@@ -836,9 +836,6 @@ keystrokes.  See documentation of `edmacro-mode' for 
details.
 
 COMMAND must be an interactive function. lambda form, menu-item,
 or the form that returned one of them also be accepted.
-If lambda's docstring in non-nil, shall bind the lambda to the symbol
-using docstring; if not, shall bind the lambda to the symbol
-generated by `gensym'.
 
 KEYMAP, if present, should be a keymap and not a quoted symbol.
 For example:
@@ -848,20 +845,18 @@ You can also use [remap COMMAND] as KEY.
 For example:
   (leaf-key [remap backward-sentence] 'sh-beginning-of-command)"
   (let* ((key*     (eval key))
-         (psucmd   (eval command))
-         (symbol   (if (eq (car-safe psucmd) 'lambda)
-                       (if (documentation psucmd)
-                           (make-symbol (documentation psucmd))
-                         (gensym "cmd-"))))
-         (command* (if symbol (progn (fset symbol psucmd) symbol) psucmd))
+         (command* (eval command))
          (keymap*  (eval keymap))
+         (bindto   (cond ((symbolp command*) command*)
+                         ((eq (car-safe command*) 'lambda) '*lambda-function*)
+                         ((eq (car-safe command*) 'menu-item) '*menu-item*)))
          (mmap     (or keymap* 'global-map))
          (vecp     (vectorp key*))
          (path     (leaf-this-file))
          (_mvec    (if (vectorp key*) key* (read-kbd-macro key*)))
          (mstr     (if (stringp key*) key* (key-description key*))))
     `(let* ((old (lookup-key ,mmap ,(if vecp key* `(kbd ,key*))))
-            (value ,(list '\` `(,mmap ,mstr ,command* ,',(and old (not 
(numberp old)) old) ,path))))
+            (value ,(list '\` `(,mmap ,mstr ,bindto ,',(and old (not (numberp 
old)) old) ,path))))
        (leaf-safe-push value leaf-key-bindlist)
        (define-key ,mmap ,(if vecp key* `(kbd ,key*)) ',command*))))
 



reply via email to

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