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

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

[elpa] 05/16: Stricter check on bounds of list in strings


From: Leo Liu
Subject: [elpa] 05/16: Stricter check on bounds of list in strings
Date: Tue, 22 Apr 2014 00:33:38 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit cc1111e2635bb88d1f8655e35b385062121e6b86
Author: Leo Liu <address@hidden>
Date:   Tue Apr 15 23:21:53 2014 +0800

    Stricter check on bounds of list in strings
    
    When in a string, (bounds-of-thing-at-point 'list) may return a
    boundary outside of the string.
---
 easy-kill.el |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/easy-kill.el b/easy-kill.el
index bc0d07b..9397aca 100644
--- a/easy-kill.el
+++ b/easy-kill.el
@@ -643,16 +643,20 @@ inspected."
     (bounds-of-thing-at-point 'sexp)))
 
 (defun easy-kill-bounds-of-list-at-point ()
-  (cl-labels ((bos ()                   ;bounds of string
-                   (and (nth 3 (syntax-ppss))
-                        (save-excursion
-                          (easy-kill-backward-up)
-                          (bounds-of-thing-at-point 'sexp)))))
-    (pcase (cons (point)
-                 (easy-kill-pair-to-list (bounds-of-thing-at-point 'list)))
-      (`(,beg ,beg ,end) (or (bos) (cons beg end)))
-      (`(,_ ,beg ,end)   (cons beg end))
-      (_                 (bos)))))
+  (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



reply via email to

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