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

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

[elpa] externals/ivy-hydra c5517fc 228/395: ivy.el: Trim grep line numbe


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra c5517fc 228/395: ivy.el: Trim grep line numbers for "M-o w" and "M-o i"
Date: Thu, 25 Feb 2021 08:32:08 -0500 (EST)

branch: externals/ivy-hydra
commit c5517fc3592bcd89e9e1dd3fa203a4e3418640df
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    ivy.el: Trim grep line numbers for "M-o w" and "M-o i"
    
    Fixes #1472
---
 ivy.el | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/ivy.el b/ivy.el
index 1ad379b..3c844cc 100644
--- a/ivy.el
+++ b/ivy.el
@@ -4532,8 +4532,25 @@ Otherwise, forward to `ivy-kill-line'."
 
 (ivy-set-actions
  t
- `(("i" ,(lambda (x) (insert (if (stringp x) x (car x)))) "insert")
-   ("w" ,(lambda (x) (kill-new (if (stringp x) x (car x)))) "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-insert (x)
+  (insert
+   (if (stringp x)
+       (ivy--trim-grep-line-number x)
+       x (car x))))
+
+(defun ivy--action-copy (x)
+  (kill-new
+   (if (stringp x)
+       (ivy--trim-grep-line-number x)
+     (car x))))
 
 (defun ivy--switch-buffer-matcher (regexp candidates)
   "Return REGEXP matching CANDIDATES.



reply via email to

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