summaryrefslogtreecommitdiff
path: root/ivy.el
diff options
context:
space:
mode:
Diffstat (limited to 'ivy.el')
-rw-r--r--ivy.el27
1 files changed, 17 insertions, 10 deletions
diff --git a/ivy.el b/ivy.el
index 47b3a36..a6aca7a 100644
--- a/ivy.el
+++ b/ivy.el
@@ -4796,25 +4796,32 @@ Otherwise, forward to `ivy-kill-line'."
(ivy-set-actions
t
- '(("i" ivy--action-insert "insert")
- ("w" ivy--action-copy "copy")))
+ `(("i" ,#'ivy--action-insert "insert")
+ ("w" ,#'ivy--action-copy "copy")))
(defun ivy--trim-grep-line-number (x)
(if (string-match ":[0-9]+:" x)
(substring x (match-end 0))
x))
+(defun ivy--action-cand-to-str (x)
+ "Try to return Ivy action argument X as a string."
+ (let ((x (if (consp x) (car x) x)))
+ (if (symbolp x) (symbol-name x) x)))
+
(defun ivy--action-insert (x)
- (insert
- (if (stringp x)
- (ivy--trim-grep-line-number x)
- (car x))))
+ "Insert completion candidate X into current buffer at point."
+ (insert (funcall (if (stringp x)
+ #'ivy--trim-grep-line-number
+ #'ivy--action-cand-to-str)
+ x)))
(defun ivy--action-copy (x)
- (kill-new
- (if (stringp x)
- (ivy--trim-grep-line-number x)
- (car x))))
+ "Add completion candidate X to the kill ring."
+ (kill-new (funcall (if (stringp x)
+ #'ivy--trim-grep-line-number
+ #'ivy--action-cand-to-str)
+ x)))
(defun ivy--switch-buffer-matcher (regexp candidates)
"Return REGEXP matching CANDIDATES.