leoliu pushed a commit to branch master in repository elpa. commit 1c7f946dfa83aba9fc18be603993e6e7790abb0c Author: Leo Liu <sdl....@gmail.com> Date: Sun Oct 13 10:03:16 2013 +0800
Fix #7: Add new command easy-kill-abort for key C-g --- easy-kill.el | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 7523844..15059ee 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -67,6 +67,7 @@ CHAR is used immediately following `easy-kill' to select THING." (define-key map "@" 'easy-kill-append) (define-key map " " 'easy-kill-mark-region) (define-key map "\C-w" 'easy-kill-region) + (define-key map "\C-g" 'easy-kill-abort) (mapc (lambda (d) (define-key map (number-to-string d) 'easy-kill-digit-argument)) (number-sequence 0 9)) @@ -241,6 +242,14 @@ candidate property instead." (when easy-kill-mark (easy-kill-adjust-candidate (overlay-get easy-kill-candidate 'thing))))) +(put 'easy-kill-abort 'easy-kill-exit t) +(defun easy-kill-abort () + (interactive) + (when easy-kill-mark + (goto-char (overlay-get easy-kill-candidate 'origin)) + (setq deactivate-mark t)) + (ding)) + (put 'easy-kill-region 'easy-kill-exit t) (defun easy-kill-region () "Kill current selection and exit." @@ -285,8 +294,7 @@ candidate property instead." (easy-kill-destroy-candidate) (unless (and (symbolp this-command) (get this-command 'easy-kill-exit)) - (easy-kill-save-candidate)) - (setq easy-kill-mark nil)))))))) + (easy-kill-save-candidate))))))))) ;;;###autoload (defun easy-kill (&optional n) @@ -303,6 +311,7 @@ Temporally activate additional key bindings as follows: (interactive "p") (if (use-region-p) (kill-ring-save (region-beginning) (region-end)) + (setq easy-kill-mark nil) (setq easy-kill-append (eq last-command 'kill-region)) (easy-kill-init-candidate n) (when (zerop (buffer-size))