[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 08/13: Implement #10: allow `-' to move before first selection
From: |
Leo Liu |
Subject: |
[elpa] 08/13: Implement #10: allow `-' to move before first selection |
Date: |
Sun, 13 Apr 2014 07:34:51 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 0ca3785a0f32a079424831a4f2f6fb915e286a07
Author: Leo Liu <address@hidden>
Date: Sat Apr 12 16:58:42 2014 +0800
Implement #10: allow `-' to move before first selection
---
README.rst | 1 +
easy-kill.el | 45 +++++++++++++++++++++++++++------------------
2 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/README.rst b/README.rst
index 3d21e02..dec0a04 100644
--- a/README.rst
+++ b/README.rst
@@ -89,6 +89,7 @@ NEWS
0.9.2
+++++
+#. ``-`` can move pass the first selection.
#. Mouse over the selection now shows description.
#. Echo js2 node name.
#. Append now uses sensible separator (customisable via
diff --git a/easy-kill.el b/easy-kill.el
index 74cbe11..924ea91 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -155,6 +155,11 @@ The value is the function's symbol if non-nil."
(string (easy-kill-fboundp (intern-soft name)))
(symbol (and (fboundp name) name))))
+(defun easy-kill-pair-to-list (pair)
+ (pcase pair
+ (`(,beg . ,end) (list beg end))
+ (_ (signal 'wrong-type-argument (list pair "Not a dot pair")))))
+
(defun easy-kill-interprogram-cut (text)
"Make non-empty TEXT available to other programs."
(cl-check-type text string)
@@ -325,25 +330,29 @@ candidate property instead."
(interactive)
(easy-kill-thing nil '-))
-;; helper for `easy-kill-thing'.
+;; Helper for `easy-kill-thing'.
(defun easy-kill-thing-forward (n)
- (let ((step (if (cl-minusp n) -1 +1))
- (thing (easy-kill-get thing))
- (start (easy-kill-get start))
- (end (easy-kill-get end)))
- (when (and thing (/= n 0))
- (let ((new-end (save-excursion
- (goto-char end)
- (with-demoted-errors
- (cl-dotimes (_ (abs n))
- (forward-thing thing step)
- (when (<= (point) start)
- (forward-thing thing 1)
- (cl-return))))
- (point))))
- (when (/= end new-end)
- (easy-kill-adjust-candidate thing nil new-end)
- t)))))
+ (when (and (easy-kill-get thing) (/= n 0))
+ (let* ((step (if (cl-minusp n) -1 +1))
+ (thing (easy-kill-get thing))
+ (bounds1 (easy-kill-pair-to-list (bounds-of-thing-at-point thing)))
+ (start (easy-kill-get start))
+ (end (easy-kill-get end))
+ (front (or (car (cl-set-difference (list end start) bounds1))
+ (pcase step
+ (`-1 start)
+ (`1 end))))
+ (new-front (save-excursion
+ (goto-char front)
+ (with-demoted-errors
+ (cl-dotimes (_ (abs n))
+ (forward-thing thing step)))
+ (point))))
+ (pcase (and (/= front new-front)
+ (sort (cons new-front bounds1) #'<))
+ (`(,start ,_ ,end)
+ (easy-kill-adjust-candidate thing start end)
+ t)))))
(defun easy-kill-thing-handler (thing mode)
"Get the handler for THING or nil if none is defined.
- [elpa] branch master updated (d1dd484 -> 47d5d5b), Leo Liu, 2014/04/13
- [elpa] 01/13: Improve README.rst to include some use examples, Leo Liu, 2014/04/13
- [elpa] 02/13: Provide a universal accessor easy-kill-get and use it, Leo Liu, 2014/04/13
- [elpa] 03/13: New function easy-kill-interprogram-cut, Leo Liu, 2014/04/13
- [elpa] 04/13: Show tooltip describing kill candidate and echo js2 node, Leo Liu, 2014/04/13
- [elpa] 05/13: New format of easy-kill-alist to support append separator, Leo Liu, 2014/04/13
- [elpa] 06/13: New function easy-kill-thing-handler for mode-based dispatch, Leo Liu, 2014/04/13
- [elpa] 07/13: Make js2 dependency optional, Leo Liu, 2014/04/13
- [elpa] 08/13: Implement #10: allow `-' to move before first selection,
Leo Liu <=
- [elpa] 09/13: Fix last change for the case of no thing at point, Leo Liu, 2014/04/13
- [elpa] 10/13: Fix #12: don't silenty change to `list' when +/- on `sexp', Leo Liu, 2014/04/13
- [elpa] 11/13: Fix thinko in last change, Leo Liu, 2014/04/13
- [elpa] 12/13: Fix #11: Work around http://debbugs.gnu.org/17247, Leo Liu, 2014/04/13
- [elpa] 13/13: Merge branch 'master' of https://github.com/leoliu/easy-kill, Leo Liu, 2014/04/13