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

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

[elpa] 09/16: Make digit key 0 shrink selection to its initial size


From: Leo Liu
Subject: [elpa] 09/16: Make digit key 0 shrink selection to its initial size
Date: Tue, 22 Apr 2014 00:33:39 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 1b2172d33c440fa6d5123736425dd81a6a51a27f
Author: Leo Liu <address@hidden>
Date:   Sun Apr 20 09:48:53 2014 +0800

    Make digit key 0 shrink selection to its initial size
---
 README.rst   |    6 +++++-
 easy-kill.el |   20 ++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/README.rst b/README.rst
index b221e97..b4d4625 100644
--- a/README.rst
+++ b/README.rst
@@ -34,7 +34,9 @@ The following keys modify the selection:
 #. address@hidden: append selection to previous kill and exit. For example,
    ``M-w d @`` will append current function to last kill.
 #. ``C-w``: kill selection and exit
-#. ``+``, ``-`` and ``0..9``: expand/shrink selection
+#. ``+``, ``-`` and ``1..9``: expand/shrink selection
+#. ``0`` shrink the selection to the intitial size i.e. before any
+   expansion
 #. ``C-SPC``: turn selection into an active region
 #. ``C-g``: abort
 #. ``?``: help
@@ -93,6 +95,8 @@ 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`` now sets the selection to its initial size before any
+   expansion.
 
 0.9.2
 +++++
diff --git a/easy-kill.el b/easy-kill.el
index f23598e..67ac1a0 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -359,6 +359,9 @@ candidate property instead."
   (easy-kill-thing nil '+))
 
 (defun easy-kill-digit-argument (n)
+  "Expand selection by N number of things.
+If N is 0 shrink the selection to the initial size before any
+expansion."
   (interactive
    (list (- (logand (if (integerp last-command-event)
                         last-command-event
@@ -443,8 +446,9 @@ on the parent mode. Finally `easy-kill-on-list' is checked."
       (goto-char (easy-kill-get origin)))
     (cond
      (handler (funcall handler n))
-     ((or (eq thing (easy-kill-get thing))
-          (memq n '(+ -)))
+     ((or (memq n '(+ -))
+          (and (eq thing (easy-kill-get thing))
+               (not (zerop n))))
       (easy-kill-thing-forward (pcase n
                                  (`+ 1)
                                  (`- -1)
@@ -453,7 +457,8 @@ on the parent mode. Finally `easy-kill-on-list' is checked."
           (`nil (easy-kill-echo "No `%s'" thing))
           (`(,start . ,end)
            (easy-kill-adjust-candidate thing start end)
-           (easy-kill-thing-forward (1- n))))))
+           (unless (zerop n)
+             (easy-kill-thing-forward (1- n)))))))
     (when easy-kill-mark
       (easy-kill-adjust-candidate (easy-kill-get thing)))))
 
@@ -534,7 +539,8 @@ on the parent mode. Finally `easy-kill-on-list' is checked."
 Temporally activate additional key bindings as follows:
 
   letters => select or expand selection according to `easy-kill-alist';
-  0..9    => expand selection by that number;
+  1..9    => expand selection by that number;
+  0       => shrink to the initial selection;
   +,=/-   => expand or shrink selection;
   @       => append selection to previous kill;
   ?       => help;
@@ -710,7 +716,8 @@ inspected."
      ((memq n '(+ -))
       (pcase (easy-kill-bounds-of-list n)
         (`(,beg . ,end) (easy-kill-adjust-candidate 'list beg end))))
-     ((eq 'list (easy-kill-get thing))
+     ((and (eq 'list (easy-kill-get thing))
+           (not (zerop n)))
       (let ((new-end (save-excursion
                        (goto-char (easy-kill-get end))
                        (forward-sexp n)
@@ -747,7 +754,8 @@ inspected."
                  (easy-kill-find-js2-node (easy-kill-get start)
                                           (easy-kill-get end)
                                           (eq n '-)))
-                ((guard (eq 'list (easy-kill-get thing)))
+                ((guard (and (eq 'list (easy-kill-get thing))
+                             (not (zerop n))))
                  (error "List forward not supported in js2-mode"))
                 (_ (js2-node-at-point)))))
     (easy-kill-adjust-candidate 'list



reply via email to

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