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

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

[elpa] 06/16: New command easy-kill-exchange-point-and-mark


From: Leo Liu
Subject: [elpa] 06/16: New command easy-kill-exchange-point-and-mark
Date: Tue, 22 Apr 2014 00:33:38 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit beb4fd57c0a91e9dd1f9cb5845a3bd7bcf2ec901
Author: Leo Liu <address@hidden>
Date:   Wed Apr 16 10:25:47 2014 +0800

    New command easy-kill-exchange-point-and-mark
---
 README.rst   |    1 +
 easy-kill.el |   16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/README.rst b/README.rst
index c1153b9..b221e97 100644
--- a/README.rst
+++ b/README.rst
@@ -92,6 +92,7 @@ NEWS
 
 #. Key ``?`` in ``easy-kill`` or ``easy-mark`` prints help info.
 #. ``M-w l`` can select the enclosing string.
+#. ``easy-mark`` learns exchanging point & mark.
 
 0.9.2
 +++++
diff --git a/easy-kill.el b/easy-kill.el
index 9397aca..9189a3d 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -117,6 +117,8 @@ deprecated."
     (define-key map [remap set-mark-command] 'easy-kill-mark-region)
     (define-key map [remap kill-region] 'easy-kill-region)
     (define-key map [remap keyboard-quit] 'easy-kill-abort)
+    (define-key map [remap exchange-point-and-mark]
+      'easy-kill-exchange-point-and-mark)
     (mapc (lambda (d)
             (define-key map (number-to-string d) 'easy-kill-digit-argument))
           (number-sequence 0 9))
@@ -477,10 +479,20 @@ on the parent mode. Finally `easy-kill-on-list' is 
checked."
     (`(,_x . ,_x)
      (easy-kill-echo "Empty region"))
     (`(,beg . ,end)
-     (set-mark beg)
-     (goto-char end)
+     (pcase (if (eq (easy-kill-get mark) 'end)
+                (list end beg) (list beg end))
+       (`(,m ,pt)
+        (set-mark m)
+        (goto-char pt)))
      (activate-mark))))
 
+(defun easy-kill-exchange-point-and-mark ()
+  (interactive)
+  (exchange-point-and-mark)
+  (setf (easy-kill-get mark)
+        (if (eq (point) (easy-kill-get start))
+            'end 'start)))
+
 (put 'easy-kill-append 'easy-kill-exit t)
 (defun easy-kill-append ()
   (interactive)



reply via email to

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