[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
- [elpa] branch master updated (a1fe7f0 -> 6e73bbb), Leo Liu, 2014/04/21
- [elpa] 01/16: New command easy-kill-help, Leo Liu, 2014/04/21
- [elpa] 02/16: Teach easy-kill-help to handle old format of easy-kill-alist, Leo Liu, 2014/04/21
- [elpa] 05/16: Stricter check on bounds of list in strings, Leo Liu, 2014/04/21
- [elpa] 06/16: New command easy-kill-exchange-point-and-mark, Leo Liu, 2014/04/21
- [elpa] 03/16: For #14: Treat strings like lists, Leo Liu, 2014/04/21
- [elpa] 07/16: Fix #15: Make `M-w l' in strings save to clipboard, Leo Liu, 2014/04/21
- [elpa] 04/16: Improve last change for easy-kill-thing-forward, Leo Liu, 2014/04/21
- [elpa] 09/16: Make digit key 0 shrink selection to its initial size,
Leo Liu <=
- [elpa] 14/16: Fix easy-kill-org-up-element, Leo Liu, 2014/04/21
- [elpa] 08/16: Add wrappers for thingatpt.el for better code organisation, Leo Liu, 2014/04/21
- [elpa] 16/16: Merge branch 'master' of https://github.com/leoliu/easy-kill, Leo Liu, 2014/04/21
- [elpa] 13/16: Some tests and bug fixes for org, Leo Liu, 2014/04/21
- [elpa] 12/16: Localize two global states using overlay properties, Leo Liu, 2014/04/21
- [elpa] 11/16: Add tests and enable travis-ci, Leo Liu, 2014/04/21
- [elpa] 15/16: Fix emacs-snapshot in travis-ci and use svg badge, Leo Liu, 2014/04/21
- [elpa] 10/16: Support Org mode with list-wise +/- and sexp selection, Leo Liu, 2014/04/21