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

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

[elpa] 03/16: For #14: Treat strings like lists


From: Leo Liu
Subject: [elpa] 03/16: For #14: Treat strings like lists
Date: Tue, 22 Apr 2014 00:33:38 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 843d81db4d226063e7115a20ff65fd974bd0fabd
Author: Leo Liu <address@hidden>
Date:   Tue Apr 15 17:17:16 2014 +0800

    For #14: Treat strings like lists
    
    When inside a string and no enclosing list at point, treat the whole
    string as the list.
---
 easy-kill.el |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index 0eda453..0407a46 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -70,14 +70,13 @@
         (add-hook 'pre-command-hook clearfunsym)
         (push alist emulation-mode-map-alists))))))
 
-(defcustom easy-kill-alist
-  '((?w word     " ")
-    (?s sexp     "\n")
-    (?l list     "\n")
-    (?f filename "\n")
-    (?d defun    "\n\n")
-    (?e line     "\n")
-    (?b buffer-file-name))
+(defcustom easy-kill-alist '((?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
@@ -646,7 +645,20 @@ inspected."
      (pcase (easy-kill-bounds-of-list n)
        (`(,beg . ,end)
         (easy-kill-adjust-candidate 'list beg end))))
-    (_ (easy-kill-thing 'list n t))))
+    (_ (pcase (easy-kill-get thing)
+         (`list (easy-kill-thing 'list n t))
+         (_ (let ((bounds (bounds-of-thing-at-point 'list)))
+              (cond ((and bounds (or (/= (car bounds) (point))
+                                     (not (nth 3 (syntax-ppss)))))
+                     (setf (easy-kill-get thing) 'list
+                           (easy-kill-get bounds) bounds))
+                    ((nth 3 (syntax-ppss))
+                     (save-excursion
+                       (easy-kill-backward-up)
+                       (setf (easy-kill-get thing) 'list)
+                       (setf (easy-kill-get bounds)
+                             (bounds-of-thing-at-point 'sexp))))
+                    (t (easy-kill-echo "No `list' at point")))))))))
 
 (defun easy-kill-on-sexp (n)
   (pcase n



reply via email to

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