diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2009-04-18 03:39:28 +0000 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2009-04-18 03:39:28 +0000 |
commit | 965b9376cfde6ff247695ae277671df58cdcbb7a (patch) | |
tree | 23f1a18de288d0f3a1ef829979529d35581a75eb /lisp/thingatpt.el | |
parent | bc323c0489c158d8014cf52f8646e7080a5b27f1 (diff) | |
download | emacs-965b9376cfde6ff247695ae277671df58cdcbb7a.tar.gz |
* thingatpt.el (thing-at-point-bounds-of-list-at-point): New
function (Bug#3027).
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r-- | lisp/thingatpt.el | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 96a79247790..dfd2fc91678 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -188,8 +188,26 @@ a symbol as a valid THING." ;; Lists -(put 'list 'end-op (lambda () (up-list 1))) -(put 'list 'beginning-op 'backward-sexp) +(put 'list 'bounds-of-thing-at-point 'thing-at-point-bounds-of-list-at-point) + +(defun thing-at-point-bounds-of-list-at-point () + (save-excursion + (let ((opoint (point)) + (beg (condition-case nil + (progn (up-list -1) + (point)) + (error nil)))) + (condition-case nil + (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)))) + (error nil))))) ;; Filenames and URLs www.com/foo%32bar |