[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 05/13: New format of easy-kill-alist to support append separator
From: |
Leo Liu |
Subject: |
[elpa] 05/13: New format of easy-kill-alist to support append separator |
Date: |
Sun, 13 Apr 2014 07:34:46 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit acfff098ccfb5df420190b1ba56083902659b5dd
Author: Leo Liu <address@hidden>
Date: Fri Apr 11 13:28:15 2014 +0800
New format of easy-kill-alist to support append separator
---
README.rst | 6 +++++-
easy-kill.el | 50 +++++++++++++++++++++++++++++++++++++-------------
2 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/README.rst b/README.rst
index 548b074..3d21e02 100644
--- a/README.rst
+++ b/README.rst
@@ -90,7 +90,11 @@ NEWS
+++++
#. Mouse over the selection now shows description.
-#. Echo js2 node name
+#. Echo js2 node name.
+#. Append now uses sensible separator (customisable via
+ ``easy-kill-alist``).
+#. The format of easy-kill-alist has changed. The old ``(CHAR .
+ THING)`` format is still supported but may be removed in future.
Bugs
~~~~
diff --git a/easy-kill.el b/easy-kill.el
index 6823d6a..c6989ab 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -71,16 +71,22 @@
(push alist emulation-mode-map-alists))))))
(defcustom easy-kill-alist
- '((?w . word)
- (?s . sexp)
- (?l . list)
- (?f . filename)
- (?d . defun)
- (?e . line)
- (?b . buffer-file-name))
- "A list of (CHAR . THING).
-CHAR is used immediately following `easy-kill' to select THING."
- :type '(repeat (cons character symbol))
+ '((?w word " ")
+ (?s sexp "\n")
+ (?l list "\n")
+ (?f filename "\n")
+ (?d defun "\n\n")
+ (?e line "\n")
+ (?b buffer-file-name))
+ "A list of (CHAR THING APPEND).
+CHAR is used immediately following `easy-kill' to select THING.
+APPEND is optional and if non-nil specifies the separator (a
+string) for appending current selection to previous kill.
+
+Note: each element can also be (CHAR . THING) but this is
+deprecated."
+ :type '(repeat (list character symbol
+ (choice string (const :tag "None" nil))))
:group 'killing)
(defcustom easy-kill-try-things '(url email line)
@@ -134,6 +140,14 @@ Do nothing if `easy-kill-inhibit-message' is non-nil."
(let (message-log-max)
(apply 'message format-string args))))
+(defun easy-kill-trim (s &optional how)
+ (let ((wchars "[ \t\n\r\f\v]*"))
+ (pcase how
+ (`left (and (string-match (concat "\\`" wchars) s)
+ (substring s (match-end 0))))
+ (`right (substring s 0 (string-match-p (concat wchars "\\'") s)))
+ (_ (easy-kill-trim (easy-kill-trim s 'left) 'right)))))
+
(defun easy-kill-interprogram-cut (text)
"Make non-empty TEXT available to other programs."
(cl-check-type text string)
@@ -260,8 +274,16 @@ candidate property instead."
;; `easy-kill-adjust-candidate' already did that.
(let ((interprogram-cut-function nil)
(interprogram-paste-function nil))
- (kill-new (if easy-kill-append
- (concat (car kill-ring) (easy-kill-candidate))
+ (kill-new (if (and easy-kill-append kill-ring)
+ (cl-labels ((join (x sep y)
+ (if sep (concat (easy-kill-trim x 'right)
+ sep
+ (easy-kill-trim y 'left))
+ (concat x y))))
+ (join (car kill-ring)
+ (nth 2 (cl-rassoc (easy-kill-get thing)
+ easy-kill-alist :key #'car))
+ (easy-kill-candidate)))
(easy-kill-candidate))
easy-kill-append))
t))
@@ -319,7 +341,9 @@ candidate property instead."
(defun easy-kill-thing (&optional thing n inhibit-handler)
;; N can be -, + and digits
(interactive
- (list (cdr (assq last-command-event easy-kill-alist))
+ (list (pcase (assq last-command-event easy-kill-alist)
+ (`(,_ ,th . ,_) th)
+ (`(,_ . ,th) th))
(prefix-numeric-value current-prefix-arg)))
(let ((thing (or thing (easy-kill-get thing)))
(n (or n 1)))
- [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 <=
- [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, 2014/04/13
- [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