leoliu pushed a commit to branch master in repository elpa. commit 9c808a661c93513103a95f95d770467f729e8e3a Author: Leo Liu <sdl....@gmail.com> Date: Wed Oct 9 12:38:28 2013 +0800
Fix #2: just call kill-ring-save when region is active --- easy-kill.el | 40 +++++++++++++++++++--------------------- 1 files changed, 19 insertions(+), 21 deletions(-) diff --git a/easy-kill.el b/easy-kill.el index 547840d..98aff18 100644 --- a/easy-kill.el +++ b/easy-kill.el @@ -237,29 +237,26 @@ Temporally activate additional key bindings as follows: C-SPC => turn current selection into active region others => save current selection to kill ring and exit." (interactive "p") - (setq easy-kill-candidate - (let ((o (make-overlay (point) (point)))) - (overlay-put o 'face 'easy-kill-face) - ;; Use higher priority to avoid shadowing by, for example, - ;; `hl-line-mode'. - (overlay-put o 'priority 999) - o)) - (setq deactivate-mark t) - (dolist (thing '(region url email line)) - (easy-kill-thing thing n 'nomsg) - (or (string= (easy-kill-candidate) "") - (return))) - (when (zerop (buffer-size)) - (easy-kill-message-nolog "Warn: `easy-kill' activated in empty buffer")) - (easy-kill-activate-keymap)) + (if (use-region-p) + (kill-ring-save (region-beginning) (region-end)) + (setq easy-kill-candidate + (let ((o (make-overlay (point) (point)))) + (overlay-put o 'face 'easy-kill-face) + ;; Use higher priority to avoid shadowing by, for example, + ;; `hl-line-mode'. + (overlay-put o 'priority 999) + o)) + (setq deactivate-mark t) + (dolist (thing '(url email line)) + (easy-kill-thing thing n 'nomsg) + (or (string= (easy-kill-candidate) "") + (return))) + (when (zerop (buffer-size)) + (easy-kill-message-nolog "Warn: `easy-kill' activated in empty buffer")) + (easy-kill-activate-keymap))) ;;; Extended things -(put 'region 'bounds-of-thing-at-point - (lambda () - (when (use-region-p) - (cons (region-beginning) (region-end))))) - (defun easy-kill-on-buffer-file-name (n) "Get `buffer-file-name' or `default-directory'. If N is zero, remove the directory part; -, remove the file name @@ -328,7 +325,8 @@ inspected." (defun easy-kill-on-list (n) (if (memq n '(+ -)) (let ((bounds (easy-kill-bounds-of-list n))) - (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds))) + (when bounds + (easy-kill-adjust-candidate 'list (car bounds) (cdr bounds)))) (easy-kill-thing 'list n nil t))) (defun easy-kill-on-sexp (n)