diff options
author | Sam Steingold <sds@gnu.org> | 2013-05-08 11:13:25 -0400 |
---|---|---|
committer | Sam Steingold <sds@gnu.org> | 2013-05-08 11:13:25 -0400 |
commit | 72d3cfca0a6a0dafaaa0fa271ac1934c9f836134 (patch) | |
tree | 726d4b5d5f00263c95e97dbd1bb65ea3d8bc6ef8 /lisp/thingatpt.el | |
parent | 5cb15713d8575fae940c9f177874ea98e5e7c7e0 (diff) | |
download | emacs-72d3cfca0a6a0dafaaa0fa271ac1934c9f836134.tar.gz |
* lisp/thingatpt.el (thing-at-point): Accept optional second argument
NO-PROPERTIES to strip the text properties from the return value.
* lisp/net/browse-url.el (browse-url-url-at-point): Pass NO-PROPERTIES
to `thing-at-point' instead of stripping the properties ourselves.
Also, when `thing-at-point' fails to find a url, prepend "http://"
to the filename at point on the assumption that the user is
pointing at something like gnu.org/gnu.
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r-- | lisp/thingatpt.el | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index f71a0d4647c..b7ecdb513f5 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -128,20 +128,27 @@ positions of the thing found." (error nil))))) ;;;###autoload -(defun thing-at-point (thing) +(defun thing-at-point (thing &optional no-properties) "Return the THING at point. THING should be a symbol specifying a type of syntactic entity. Possibilities include `symbol', `list', `sexp', `defun', `filename', `url', `email', `word', `sentence', `whitespace', `line', `number', and `page'. +When the optional argument NO-PROPERTIES is non-nil, +strip text properties from the return value. + See the file `thingatpt.el' for documentation on how to define a symbol as a valid THING." - (if (get thing 'thing-at-point) - (funcall (get thing 'thing-at-point)) - (let ((bounds (bounds-of-thing-at-point thing))) - (if bounds - (buffer-substring (car bounds) (cdr bounds)))))) + (let ((text + (if (get thing 'thing-at-point) + (funcall (get thing 'thing-at-point)) + (let ((bounds (bounds-of-thing-at-point thing))) + (when bounds + (buffer-substring (car bounds) (cdr bounds))))))) + (when (and text no-properties) + (set-text-properties 0 (length text) nil text)) + text)) ;; Go to beginning/end |