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

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

[elpa] 07/16: Fix #15: Make `M-w l' in strings save to clipboard


From: Leo Liu
Subject: [elpa] 07/16: Fix #15: Make `M-w l' in strings save to clipboard
Date: Tue, 22 Apr 2014 00:33:39 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 308d6142b7b78130bfb09436c5a190382e435262
Author: Leo Liu <address@hidden>
Date:   Thu Apr 17 02:16:02 2014 +0800

    Fix #15: Make `M-w l' in strings save to clipboard
---
 easy-kill.el |   44 ++++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index 9189a3d..8f876dd 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -371,6 +371,22 @@ candidate property instead."
   (interactive)
   (easy-kill-thing nil '-))
 
+(defun easy-kill-bounds-of-list-at-point ()
+  (let ((bos (and (nth 3 (syntax-ppss)) ;bounds of string
+                  (save-excursion
+                    (easy-kill-backward-up)
+                    (bounds-of-thing-at-point 'sexp))))
+        (b (bounds-of-thing-at-point 'list))
+        (b1-in-b2 (lambda (b1 b2)
+                    (and (> (car b1) (car b2))
+                         (< (cdr b1) (cdr b2))))))
+    (cond
+     ((not b)                  bos)
+     ((not bos)                b)
+     ((= (car b) (point))      bos)
+     ((funcall b1-in-b2 b bos) b)
+     (t                        bos))))
+
 ;; Helper for `easy-kill-thing'.
 (defun easy-kill-thing-forward (n)
   (when (and (easy-kill-get thing) (/= n 0))
@@ -446,7 +462,9 @@ on the parent mode. Finally `easy-kill-on-list' is checked."
                                  (`+ 1)
                                  (`- -1)
                                  (_ n))))
-     (t (pcase (bounds-of-thing-at-point thing)
+     (t (pcase (if (eq thing 'list)
+                   (easy-kill-bounds-of-list-at-point)
+                 (bounds-of-thing-at-point thing))
           (`nil (easy-kill-echo "No `%s'" thing))
           (`(,start . ,end)
            (easy-kill-adjust-candidate thing start end)
@@ -654,35 +672,13 @@ inspected."
       (_ (error "Unsupported argument `%s'" n)))
     (bounds-of-thing-at-point 'sexp)))
 
-(defun easy-kill-bounds-of-list-at-point ()
-  (let ((bos (and (nth 3 (syntax-ppss)) ;bounds of string
-                  (save-excursion
-                    (easy-kill-backward-up)
-                    (bounds-of-thing-at-point 'sexp))))
-        (b (bounds-of-thing-at-point 'list))
-        (b1-in-b2 (lambda (b1 b2)
-                    (and (> (car b1) (car b2))
-                         (< (cdr b1) (cdr b2))))))
-    (cond
-     ((not b)                  bos)
-     ((not bos)                b)
-     ((= (car b) (point))      bos)
-     ((funcall b1-in-b2 b bos) b)
-     (t                        bos))))
-
 (defun easy-kill-on-list (n)
   (pcase n
     ((or `+ `-)
      (pcase (easy-kill-bounds-of-list n)
        (`(,beg . ,end)
         (easy-kill-adjust-candidate 'list beg end))))
-    (_ (pcase (easy-kill-get thing)
-         (`list (easy-kill-thing 'list n t))
-         (_ (pcase (easy-kill-bounds-of-list-at-point)
-              (`(,beg . ,end)
-               (setf (easy-kill-get thing) 'list)
-               (setf (easy-kill-get bounds) (cons beg end)))
-              (`nil (easy-kill-echo "No `list' at point"))))))))
+    (_ (easy-kill-thing 'list n t))))
 
 (defun easy-kill-on-sexp (n)
   (pcase n



reply via email to

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