]> git.eshelyaron.com Git - emacs.git/commitdiff
* thingatpt.el (thing-at-point-bounds-of-list-at-point): New
authorChong Yidong <cyd@stupidchicken.com>
Sat, 18 Apr 2009 03:39:28 +0000 (03:39 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Sat, 18 Apr 2009 03:39:28 +0000 (03:39 +0000)
function (Bug#3027).

lisp/ChangeLog
lisp/thingatpt.el

index 76fd5df25de70fe8985f7f6ca201e5245dfe9dcf..c7628f281989ffc01d34569542be21e0b27a9e3c 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-18  Chong Yidong  <cyd@stupidchicken.com>
+
+       * thingatpt.el (thing-at-point-bounds-of-list-at-point): New
+       function (Bug#3027).
+
 2009-04-17  Kenichi Handa  <handa@m17n.org>
 
        * international/uni-decomposition.el: Re-generated.
index 96a79247790b5a5ac02289001517c737b12ba2b6..dfd2fc916783191d613ee1d2d3593dc38287fd43 100644 (file)
@@ -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