* xdisp.c (SKIP_GLYPHS): Removed unused macro.
[bpt/emacs.git] / lisp / thingatpt.el
index c85b8f8..020faa1 100644 (file)
@@ -1,8 +1,6 @@
 ;;; thingatpt.el --- get the `thing' at point
 
-;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1991-1998, 2000-2011  Free Software Foundation, Inc.
 
 ;; Author: Mike Williams <mikew@gopher.dosli.govt.nz>
 ;; Maintainer: FSF
@@ -188,8 +186,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
 
@@ -454,5 +470,4 @@ Signal an error if the entire string was not used."
   "Return the Lisp list at point, or nil if none is found."
   (form-at-point 'list 'listp))
 
-;; arch-tag: bb65a163-dae2-4055-aedc-fe11f497f698
 ;;; thingatpt.el ends here