summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-07-23 14:08:48 -0400
committerKyle Meyer <kyle@kyleam.com>2017-07-23 14:08:48 -0400
commitbfd015badf58b7bb235652c9bf9544cbb9a1bb05 (patch)
tree3d8976b093eb5714e97a249b6f66938483c70d21
parentce44fdc8222ccc1adc7a94ac33e93d478bc3754f (diff)
downloademacs.d-bfd015badf58b7bb235652c9bf9544cbb9a1bb05.tar.gz
Add copy line action to avy-dispatch-alist
-rw-r--r--init.el4
-rw-r--r--lisp/km-avy.el17
2 files changed, 20 insertions, 1 deletions
diff --git a/init.el b/init.el
index e04c0e3..8befc43 100644
--- a/init.el
+++ b/init.el
@@ -596,7 +596,9 @@
(define-key magit-cherry-mode-map "j" #'km/magit-avy-goto-subword-1))
(after 'notmuch
(define-key notmuch-common-keymap "j" #'km/notmuch-avy-goto-subword-1))
- (define-key occur-mode-map "j" #'km/occur-avy-goto-subword-1))
+ (define-key occur-mode-map "j" #'km/occur-avy-goto-subword-1)
+ :config
+ (add-to-list 'avy-dispatch-alist (cons ?w #'km/avy-action-copy-line)))
;;; Buffers and files
diff --git a/lisp/km-avy.el b/lisp/km-avy.el
index e0be1d7..c17f1f0 100644
--- a/lisp/km-avy.el
+++ b/lisp/km-avy.el
@@ -86,5 +86,22 @@
(notmuch-tree-mode
(call-interactively #'notmuch-tree-show-message)))))
+;;;###autoload
+(defun km/avy-action-copy-line (pt)
+ "Copy line containing PT."
+ ;; Modified from `avy-action-copy'.
+ (save-excursion
+ (let (str)
+ (goto-char pt)
+ (setq str (buffer-substring (line-beginning-position)
+ (line-end-position)))
+ (kill-new str)
+ (message "Copied: %s" str)))
+ (let ((dat (ring-ref avy-ring 0)))
+ (select-frame-set-input-focus
+ (window-frame (cdr dat)))
+ (select-window (cdr dat))
+ (goto-char (car dat))))
+
(provide 'km-avy)
;;; km-avy.el ends here