[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 26/77: Fix #2: just call kill-ring-save when region is active
From: |
Leo Liu |
Subject: |
[elpa] 26/77: Fix #2: just call kill-ring-save when region is active |
Date: |
Sat, 05 Apr 2014 04:08:15 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 9c808a661c93513103a95f95d770467f729e8e3a
Author: Leo Liu <address@hidden>
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)
- [elpa] 15/77: Some string and comment fixes, (continued)
- [elpa] 15/77: Some string and comment fixes, Leo Liu, 2014/04/05
- [elpa] 23/77: Use parse-partial-sexp in easy-kill-bounds-of-list, Leo Liu, 2014/04/05
- [elpa] 20/77: Replace `enlarge' with `expand' in strings and comments, Leo Liu, 2014/04/05
- [elpa] 19/77: Add lispy treatment for +/- on list and sexp, Leo Liu, 2014/04/05
- [elpa] 14/77: Doc fix and release v0.7.0, Leo Liu, 2014/04/05
- [elpa] 22/77: Handle the case when overlay has already been destroyed, Leo Liu, 2014/04/05
- [elpa] 25/77: Fix thinko in easy-kill-backward-down, Leo Liu, 2014/04/05
- [elpa] 21/77: New command easy-kill-mark-region, Leo Liu, 2014/04/05
- [elpa] 24/77: Improve list expand/shrink support in smie-based modes, Leo Liu, 2014/04/05
- [elpa] 18/77: Consolidate all kill features in easy-kill-thing, Leo Liu, 2014/04/05
- [elpa] 26/77: Fix #2: just call kill-ring-save when region is active,
Leo Liu <=
- [elpa] 27/77: Declare dependency on emacs 24, Leo Liu, 2014/04/05
- [elpa] 29/77: Merge pull request #4 from purcell/patch-1, Leo Liu, 2014/04/05
- [elpa] 31/77: Simplify the interactive form of easy-kill-thing, Leo Liu, 2014/04/05
- [elpa] 28/77: [remap kill-ring-save] should be a better key binding for this feature., Leo Liu, 2014/04/05
- [elpa] 35/77: Doc fix and release v0.8.0, Leo Liu, 2014/04/05
- [elpa] 36/77: New variable easy-kill-base-map for customising key bindings, Leo Liu, 2014/04/05
- [elpa] 33/77: Support append kill for append-next-kill and easy-kill, Leo Liu, 2014/04/05
- [elpa] 34/77: Better support for defining commands that exit easy-kill, Leo Liu, 2014/04/05
- [elpa] 30/77: Merge pull request #6 from knu/usage-remap, Leo Liu, 2014/04/05
- [elpa] 32/77: Improve easy-kill-bounds-of-list, Leo Liu, 2014/04/05