emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 22/77: Handle the case when overlay has already been destroyed


From: Leo Liu
Subject: [elpa] 22/77: Handle the case when overlay has already been destroyed
Date: Sat, 05 Apr 2014 04:08:14 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit c1935fa3518ca48dc32d25b2a42230cab2a9a0b2
Author: Leo Liu <address@hidden>
Date:   Tue Oct 8 19:03:42 2013 +0800

    Handle the case when overlay has already been destroyed
---
 easy-kill.el |   40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index 48319d6..8e56de4 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -79,7 +79,9 @@ CHAR is used immediately following `easy-kill' to select 
THING."
         (t "")))
 
 (defvar easy-kill-exit nil
-  "Tell `set-temporary-overlay-map' to exit if non-nil.")
+  "Tell `set-temporary-overlay-map' to exit if non-nil.
+Note: exit only happens right before next command per
+`set-temporary-overlay-map'.")
 
 (defvar easy-kill-candidate nil)
 
@@ -177,25 +179,29 @@ candidate property instead."
 (defun easy-kill-region ()
   "Kill current selection and exit."
   (interactive "*")
-  (let ((beg (overlay-start easy-kill-candidate))
-        (end (overlay-end easy-kill-candidate)))
-    (if (= beg end)
-        (easy-kill-message-nolog "Empty region")
-      (setq easy-kill-exit t)
-      (easy-kill-adjust-candidate nil "")
-      (kill-region beg end))))
+  (if (not easy-kill-candidate)         ; `easy-kill' has exited
+      (push last-input-event unread-command-events)
+    (let ((beg (overlay-start easy-kill-candidate))
+          (end (overlay-end easy-kill-candidate)))
+      (if (= beg end)
+          (easy-kill-message-nolog "Empty region")
+        (setq easy-kill-exit t)
+        (easy-kill-adjust-candidate nil "")
+        (kill-region beg end)))))
 
 (defun easy-kill-mark-region ()
   (interactive)
-  (let ((beg (overlay-start easy-kill-candidate))
-        (end (overlay-end easy-kill-candidate)))
-    (if (= beg end)
-        (easy-kill-message-nolog "Empty region")
-      (setq easy-kill-exit t)
-      (easy-kill-adjust-candidate nil "")
-      (set-mark beg)
-      (goto-char end)
-      (activate-mark))))
+  (if (not easy-kill-candidate)
+      (push last-input-event unread-command-events)
+    (let ((beg (overlay-start easy-kill-candidate))
+          (end (overlay-end easy-kill-candidate)))
+      (if (= beg end)
+          (easy-kill-message-nolog "Empty region")
+        (setq easy-kill-exit t)
+        (easy-kill-adjust-candidate nil "")
+        (set-mark beg)
+        (goto-char end)
+        (activate-mark)))))
 
 (defun easy-kill-activate-keymap ()
   (let ((map (easy-kill-map)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]