# HG changeset patch # User Chong Yidong # Date 1240025968 0 # Node ID 3df429718fa4a30835dbaa449a3ce60247bef131 # Parent 31ae0e578b40811f2a905b52de5d9e7580cc8cfa * thingatpt.el (thing-at-point-bounds-of-list-at-point): New function (Bug#3027). diff -r 31ae0e578b40 -r 3df429718fa4 lisp/ChangeLog --- a/lisp/ChangeLog Sat Apr 18 01:41:53 2009 +0000 +++ b/lisp/ChangeLog Sat Apr 18 03:39:28 2009 +0000 @@ -1,3 +1,8 @@ +2009-04-18 Chong Yidong + + * thingatpt.el (thing-at-point-bounds-of-list-at-point): New + function (Bug#3027). + 2009-04-17 Kenichi Handa * international/uni-decomposition.el: Re-generated. diff -r 31ae0e578b40 -r 3df429718fa4 lisp/thingatpt.el --- a/lisp/thingatpt.el Sat Apr 18 01:41:53 2009 +0000 +++ b/lisp/thingatpt.el Sat Apr 18 03:39:28 2009 +0000 @@ -188,8 +188,26 @@ ;; 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