From 965b9376cfde6ff247695ae277671df58cdcbb7a Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 18 Apr 2009 03:39:28 +0000 Subject: [PATCH] * thingatpt.el (thing-at-point-bounds-of-list-at-point): New function (Bug#3027). --- lisp/ChangeLog | 5 +++++ lisp/thingatpt.el | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 76fd5df25de..c7628f28198 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 --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 -- 2.39.2