diff options
author | Oleh Krehel <ohwoeowho@gmail.com> | 2017-04-07 10:11:17 +0200 |
---|---|---|
committer | Oleh Krehel <ohwoeowho@gmail.com> | 2017-04-07 10:11:17 +0200 |
commit | 105efc84827cb764cac1e1e3a793abf106837021 (patch) | |
tree | daac141bc787edd6c189c6e7a32c502ffe848da8 | |
parent | 54bce2cfb07aab6c0b2a5a9d22c9df748649fecd (diff) |
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
-rw-r--r-- | avy.el | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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))) |