From 965b9376cfde6ff247695ae277671df58cdcbb7a Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 18 Apr 2009 03:39:28 +0000 Subject: * thingatpt.el (thing-at-point-bounds-of-list-at-point): New function (Bug#3027). --- lisp/thingatpt.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'lisp/thingatpt.el') 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 -- cgit v1.2.1