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

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

[elpa] master 4e07e6f 048/399: ivy.el (ivy-make-magic-action): Add docst


From: Oleh Krehel
Subject: [elpa] master 4e07e6f 048/399: ivy.el (ivy-make-magic-action): Add docstring to the generated lambda
Date: Sat, 20 Jul 2019 14:56:46 -0400 (EDT)

branch: master
commit 4e07e6f738b93a5b3e97af990975df527bd67893
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    ivy.el (ivy-make-magic-action): Add docstring to the generated lambda
    
    Fixes #1956
---
 counsel.el |  2 +-
 ivy.el     | 23 ++++++++++++++++-------
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/counsel.el b/counsel.el
index a1e43f6..349762b 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1757,7 +1757,7 @@ currently checked out."
     (define-key map (kbd "C-DEL") 'counsel-up-directory)
     (define-key map (kbd "C-<backspace>") 'counsel-up-directory)
     (define-key map (kbd "C-M-y") 'counsel-yank-directory)
-    (define-key map (kbd "`") (ivy-make-magic-action "b"))
+    (define-key map (kbd "`") (ivy-make-magic-action 'counsel-find-file "b"))
     map))
 
 (defun counsel-yank-directory ()
diff --git a/ivy.el b/ivy.el
index 261075c..ce26c1d 100644
--- a/ivy.el
+++ b/ivy.el
@@ -2855,17 +2855,26 @@ Possible choices are 
'ivy-magic-slash-non-match-cd-selected,
         (ivy--cd-maybe))
     (insert last-input-event)))
 
-(defun ivy-make-magic-action (key)
+(defun ivy-make-magic-action (caller key)
   "Return a command that does the equivalent of `ivy-read-action' and KEY.
 This happens only when the input is empty.
 The intention is to bind the result to keys that are typically
 bound to `self-insert-command'."
-  (lambda (&optional arg)
-    (interactive "p")
-    (if (string= "" ivy-text)
-        (execute-kbd-macro
-         (kbd (concat "M-o " key)))
-      (self-insert-command arg))))
+  (let ((alist (assoc key
+                      (plist-get
+                       ivy--actions-list
+                       caller)))
+        (action (nth 1 alist))
+        (doc (concat (nth 2 alist)
+                     "\n\n"
+                     (documentation action))))
+    `(lambda (&optional arg)
+       ,doc
+       (interactive "p")
+       (if (string= "" ivy-text)
+           (execute-kbd-macro
+            (kbd (concat "M-o " key)))
+         (self-insert-command arg)))))
 
 (defcustom ivy-magic-tilde t
   "When non-nil, ~ will move home when selecting files.



reply via email to

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