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

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

[elpa] master 105efc8 037/110: avy.el (avy-action-copy): Copy line for a


From: Oleh Krehel
Subject: [elpa] master 105efc8 037/110: avy.el (avy-action-copy): Copy line for avy-goto-line
Date: Sat, 11 May 2019 10:15:39 -0400 (EDT)

branch: master
commit 105efc84827cb764cac1e1e3a793abf106837021
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    avy.el (avy-action-copy): Copy line for avy-goto-line
    
    * avy.el (avy-command): New defvar.
    (avy-with): Actions can now access the symbol from `avy-with' using
    `avy-command'.
    (avy-action-copy): Copy line for `avy-goto-line'. Copy sexp for all
    other commands.
    
    Fixes #191
---
 avy.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/avy.el b/avy.el
index 00720fa..af4fe80 100644
--- a/avy.el
+++ b/avy.el
@@ -489,6 +489,10 @@ multiple DISPLAY-FN invokations."
 Commands using `avy-with' macro can be resumed."
   (interactive))
 
+(defvar avy-command nil
+  "Store the current command symbol.
+E.g. 'avy-goto-line or 'avy-goto-char.")
+
 (defmacro avy-with (command &rest body)
   "Set `avy-keys' according to COMMAND and execute BODY.
 Set `avy-style' according to COMMMAND as well."
@@ -497,7 +501,8 @@ Set `avy-style' according to COMMMAND as well."
   `(let ((avy-keys (or (cdr (assq ',command avy-keys-alist))
                        avy-keys))
          (avy-style (or (cdr (assq ',command avy-styles-alist))
-                        avy-style)))
+                        avy-style))
+         (avy-command ',command))
      (setq avy-action nil)
      (setf (symbol-function 'avy-resume)
            (lambda ()
@@ -523,7 +528,9 @@ Set `avy-style' according to COMMMAND as well."
   (save-excursion
     (let (str)
       (goto-char pt)
-      (forward-sexp)
+      (if (eq avy-command 'avy-goto-line)
+          (end-of-line)
+        (forward-sexp))
       (setq str (buffer-substring pt (point)))
       (kill-new str)
       (message "Copied: %s" str)))



reply via email to

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