HCoop
/
bpt
/
emacs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* keyboard.c (parse_tool_bar_item): For QClabel, set TOOL_BAR_ITEM_LABEL not HELP.
[bpt/emacs.git]
/
lisp
/
thingatpt.el
diff --git
a/lisp/thingatpt.el
b/lisp/thingatpt.el
index
ce26344
..
62686e2
100644
(file)
--- a/
lisp/thingatpt.el
+++ b/
lisp/thingatpt.el
@@
-1,7
+1,8
@@
;;; thingatpt.el --- get the `thing' at point
;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
;;; 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 Free Software Foundation, Inc.
+;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Free Software Foundation, Inc.
;; Author: Mike Williams <mikew@gopher.dosli.govt.nz>
;; Maintainer: FSF
;; Author: Mike Williams <mikew@gopher.dosli.govt.nz>
;; Maintainer: FSF
@@
-10,16
+11,19
@@
;; This file is part of GNU Emacs.
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software
;
you can redistribute it and/or modify
+;; GNU Emacs is free software
:
you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation
; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation
, either version 3 of the License, or
+;;
(at your option)
any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
;;; Commentary:
;; This file provides routines for getting the "thing" at the location of
;;; Commentary:
;; This file provides routines for getting the "thing" at the location of
@@
-165,7
+169,7
@@
a symbol as a valid THING."
(nth 3 (parse-partial-sexp (point) orig)))))
(defun end-of-sexp ()
(nth 3 (parse-partial-sexp (point) orig)))))
(defun end-of-sexp ()
- (let ((char-syntax (char-syntax (char-after
(point)
))))
+ (let ((char-syntax (char-syntax (char-after))))
(if (or (eq char-syntax ?\))
(and (eq char-syntax ?\") (in-string-p)))
(forward-char 1)
(if (or (eq char-syntax ?\))
(and (eq char-syntax ?\") (in-string-p)))
(forward-char 1)
@@
-174,7
+178,7
@@
a symbol as a valid THING."
(put 'sexp 'end-op 'end-of-sexp)
(defun beginning-of-sexp ()
(put 'sexp 'end-op 'end-of-sexp)
(defun beginning-of-sexp ()
- (let ((char-syntax (char-syntax (char-before
(point)
))))
+ (let ((char-syntax (char-syntax (char-before))))
(if (or (eq char-syntax ?\()
(and (eq char-syntax ?\") (in-string-p)))
(forward-char -1)
(if (or (eq char-syntax ?\()
(and (eq char-syntax ?\") (in-string-p)))
(forward-char -1)
@@
-184,8
+188,26
@@
a symbol as a valid THING."
;; Lists
;; 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
;; Filenames and URLs www.com/foo%32bar
@@
-204,7
+226,7
@@
a symbol as a valid THING."
(goto-char (point-min)))))
(defvar thing-at-point-url-path-regexp
(goto-char (point-min)))))
(defvar thing-at-point-url-path-regexp
- "[^]\t\n \"'
()<>[^`{}]*[^]\t\n \"'()
<>[^`{}.,;]+"
+ "[^]\t\n \"'
<>[^`{}]*[^]\t\n \"'
<>[^`{}.,;]+"
"A regular expression probably matching the host and filename or e-mail part of a URL.")
(defvar thing-at-point-short-url-regexp
"A regular expression probably matching the host and filename or e-mail part of a URL.")
(defvar thing-at-point-short-url-regexp
@@
-401,10
+423,10
@@
with angle brackets.")
(interactive "p")
(while (< arg 0)
(skip-syntax-backward
(interactive "p")
(while (< arg 0)
(skip-syntax-backward
- (char-to-string (char-syntax (char-
after (1- (point))
))))
+ (char-to-string (char-syntax (char-
before
))))
(setq arg (1+ arg)))
(while (> arg 0)
(setq arg (1+ arg)))
(while (> arg 0)
- (skip-syntax-forward (char-to-string (char-syntax (char-after
(point)
))))
+ (skip-syntax-forward (char-to-string (char-syntax (char-after))))
(setq arg (1- arg))))
;; Aliases
(setq arg (1- arg))))
;; Aliases
@@
-433,15
+455,22
@@
Signal an error if the entire string was not used."
(if (or (not pred) (funcall pred sexp)) sexp)))
;;;###autoload
(if (or (not pred) (funcall pred sexp)) sexp)))
;;;###autoload
-(defun sexp-at-point () (form-at-point 'sexp))
+(defun sexp-at-point ()
+ "Return the sexp at point, or nil if none is found."
+ (form-at-point 'sexp))
;;;###autoload
(defun symbol-at-point ()
;;;###autoload
(defun symbol-at-point ()
+ "Return the symbol at point, or nil if none is found."
(let ((thing (thing-at-point 'symbol)))
(if thing (intern thing))))
;;;###autoload
(let ((thing (thing-at-point 'symbol)))
(if thing (intern thing))))
;;;###autoload
-(defun number-at-point () (form-at-point 'sexp 'numberp))
+(defun number-at-point ()
+ "Return the number at point, or nil if none is found."
+ (form-at-point 'sexp 'numberp))
;;;###autoload
;;;###autoload
-(defun list-at-point () (form-at-point 'list 'listp))
+(defun list-at-point ()
+ "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
;; arch-tag: bb65a163-dae2-4055-aedc-fe11f497f698
;;; thingatpt.el ends here