1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

(thing-at-point 'list) return nil if no list at point

* 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.
This commit is contained in:
Tino Calancha 2016-11-03 20:33:19 +09:00
parent 76735c116d
commit 76e297c15f
2 changed files with 10 additions and 16 deletions

View 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