[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 03/13: New function easy-kill-interprogram-cut
From: |
Leo Liu |
Subject: |
[elpa] 03/13: New function easy-kill-interprogram-cut |
Date: |
Sun, 13 Apr 2014 07:34:41 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit fc319cba103809d5f8db3b6da6cf621f1fbb341a
Author: Leo Liu <address@hidden>
Date: Fri Apr 11 09:00:01 2014 +0800
New function easy-kill-interprogram-cut
---
easy-kill.el | 35 +++++++++++++++++++----------------
1 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/easy-kill.el b/easy-kill.el
index 3346c43..fa8135e 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -134,6 +134,13 @@ Do nothing if `easy-kill-inhibit-message' is non-nil."
(let (message-log-max)
(apply 'message format-string args))))
+(defun easy-kill-interprogram-cut (text)
+ "Make non-empty TEXT available to other programs."
+ (cl-check-type text string)
+ (and interprogram-cut-function
+ (not (equal text ""))
+ (funcall interprogram-cut-function text)))
+
(defvar easy-kill-candidate nil)
(defvar easy-kill-append nil)
(defvar easy-kill-mark nil)
@@ -215,20 +222,17 @@ Otherwise, it is the value of the overlay's candidate
property."
If BEG is a string, shrink the overlay to zero length and set its
candidate property instead."
(setf (easy-kill-get thing) thing)
- (let* ((beg (or beg (easy-kill-get start)))
- (end (or end (easy-kill-get end))))
- (if (stringp beg)
- (progn
- (setf (easy-kill-get bounds) (cons (point) (point)))
- (setf (easy-kill-get candidate) beg)
- (let ((easy-kill-inhibit-message nil))
- (easy-kill-echo "%s" beg)))
- (setf (easy-kill-get bounds) (cons beg end)))
- (cond (easy-kill-mark (easy-kill-mark-region)
- (easy-kill-indicate-origin))
- ((and interprogram-cut-function
- (not (string= (easy-kill-candidate) "")))
- (funcall interprogram-cut-function (easy-kill-candidate))))))
+ (cond ((stringp beg)
+ (setf (easy-kill-get bounds) (cons (point) (point)))
+ (setf (easy-kill-get candidate) beg)
+ (let ((easy-kill-inhibit-message nil))
+ (easy-kill-echo "%s" beg)))
+ (t
+ (setf (easy-kill-get bounds) (cons (or beg (easy-kill-get start))
+ (or end (easy-kill-get end))))))
+ (cond (easy-kill-mark (easy-kill-mark-region)
+ (easy-kill-indicate-origin))
+ (t (easy-kill-interprogram-cut (easy-kill-candidate)))))
(defun easy-kill-save-candidate ()
(unless (string= (easy-kill-candidate) "")
@@ -355,8 +359,7 @@ candidate property instead."
(interactive)
(setq easy-kill-append t)
(when (easy-kill-save-candidate)
- (and interprogram-cut-function
- (funcall interprogram-cut-function (car kill-ring)))
+ (easy-kill-interprogram-cut (car kill-ring))
(setq deactivate-mark t)
(easy-kill-echo "Appended")))
- [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 <=
- [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, 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