]> git.eshelyaron.com Git - emacs.git/commitdiff
(thing-at-point 'list) return nil if no list at point
authorTino Calancha <tino.calancha@gmail.com>
Thu, 3 Nov 2016 11:33:19 +0000 (20:33 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Thu, 3 Nov 2016 11:33:19 +0000 (20:33 +0900)
* lisp/thingatpt.el (thing-at-point-bounds-of-list-at-point):
Check first if we are at the beginning of a top-level sexp (Bug#24627).
If point is inside a comment or string, look for a list out of the
comment/string.
Escape '[' in doc string.
* test/lisp/thingatpt-tests.el (thing-at-point-bug24627): Update
expected test result as pass.

lisp/thingatpt.el
test/lisp/thingatpt-tests.el

index 6d1014bb92d087aa7f717988be3c1f08126b70aa..e4236309529ac9bd5768e39e4aa3fb1c7a98a2ee 100644 (file)
@@ -219,22 +219,17 @@ The bounds of THING are determined by `bounds-of-thing-at-point'."
 
 (defun thing-at-point-bounds-of-list-at-point ()
   "Return the bounds of the list at point.
-[Internal function used by `bounds-of-thing-at-point'.]"
+\[Internal function used by `bounds-of-thing-at-point'.]"
   (save-excursion
-    (let ((opoint (point))
-         (beg (ignore-errors
-                (up-list -1)
-                (point))))
-      (ignore-errors
-       (if beg
-           (progn (forward-sexp)
-                  (cons beg (point)))
-         ;; Are we are at the beginning of a top-level sexp?
-         (forward-sexp)
-         (let ((end (point)))
-           (backward-sexp)
-           (if (>= opoint (point))
-               (cons opoint end))))))))
+    (let* ((st (parse-partial-sexp (point-min) (point)))
+           (beg (or (and (eq 4 (car (syntax-after (point))))
+                         (not (nth 8 st))
+                         (point))
+                    (nth 1 st))))
+      (when beg
+        (goto-char beg)
+        (forward-sexp)
+        (cons beg (point))))))
 
 ;; Defuns
 
index 71d2c88d84b543f64a93ec73d5296812e9f57df1..9d72db4016230484a79c598d60b303f192561ed3 100644 (file)
@@ -88,7 +88,6 @@ position to retrieve THING.")
 ;; `thing-at-point-bounds-of-list-at-point'.
 (ert-deftest thing-at-point-bug24627 ()
   "Test for http://debbugs.gnu.org/24627 ."
-  :expected-result :failed
   (let ((string-result '(("(a \"b\" c)" . (a "b" c))
                          (";(a \"b\" c)")
                          ("(a \"b\" c\n)" . (a "b" c))