aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2013-05-08 11:13:25 -0400
committerSam Steingold2013-05-08 11:13:25 -0400
commit72d3cfca0a6a0dafaaa0fa271ac1934c9f836134 (patch)
tree726d4b5d5f00263c95e97dbd1bb65ea3d8bc6ef8
parent5cb15713d8575fae940c9f177874ea98e5e7c7e0 (diff)
downloademacs-72d3cfca0a6a0dafaaa0fa271ac1934c9f836134.tar.gz
emacs-72d3cfca0a6a0dafaaa0fa271ac1934c9f836134.zip
* 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.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/net/browse-url.el7
-rw-r--r--lisp/thingatpt.el19
3 files changed, 27 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 119e46e52d8..bab58a62551 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12013-05-08 Sam Steingold <sds@gnu.org>
2
3 * thingatpt.el (thing-at-point): Accept optional second argument
4 NO-PROPERTIES to strip the text properties from the return value.
5 * net/browse-url.el (browse-url-url-at-point): Pass NO-PROPERTIES
6 to `thing-at-point' instead of stripping the properties ourselves.
7 Also, when `thing-at-point' fails to find a url, prepend "http://"
8 to the filename at point on the assumption that the user is
9 pointing at something like gnu.org/gnu.
10
12013-05-08 Juanma Barranquero <lekktu@gmail.com> 112013-05-08 Juanma Barranquero <lekktu@gmail.com>
2 12
3 * emacs-lisp/bytecomp.el (byte-compile-insert-header): 13 * emacs-lisp/bytecomp.el (byte-compile-insert-header):
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 19e513a3354..695b7a11424 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -658,9 +658,10 @@ regarding its parameter treatment."
658;; URL input 658;; URL input
659 659
660(defun browse-url-url-at-point () 660(defun browse-url-url-at-point ()
661 (let ((url (thing-at-point 'url))) 661 (or (thing-at-point 'url t)
662 (set-text-properties 0 (length url) nil url) 662 ;; assume that the user is pointing at something like gnu.org/gnu
663 url)) 663 (let ((f (thing-at-point 'filename t)))
664 (and f (concat "http://" f)))))
664 665
665;; Having this as a separate function called by the browser-specific 666;; Having this as a separate function called by the browser-specific
666;; functions allows them to be stand-alone commands, making it easier 667;; functions allows them to be stand-alone commands, making it easier
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."
128 (error nil))))) 128 (error nil)))))
129 129
130;;;###autoload 130;;;###autoload
131(defun thing-at-point (thing) 131(defun thing-at-point (thing &optional no-properties)
132 "Return the THING at point. 132 "Return the THING at point.
133THING should be a symbol specifying a type of syntactic entity. 133THING should be a symbol specifying a type of syntactic entity.
134Possibilities include `symbol', `list', `sexp', `defun', 134Possibilities include `symbol', `list', `sexp', `defun',
135`filename', `url', `email', `word', `sentence', `whitespace', 135`filename', `url', `email', `word', `sentence', `whitespace',
136`line', `number', and `page'. 136`line', `number', and `page'.
137 137
138When the optional argument NO-PROPERTIES is non-nil,
139strip text properties from the return value.
140
138See the file `thingatpt.el' for documentation on how to define 141See the file `thingatpt.el' for documentation on how to define
139a symbol as a valid THING." 142a symbol as a valid THING."
140 (if (get thing 'thing-at-point) 143 (let ((text
141 (funcall (get thing 'thing-at-point)) 144 (if (get thing 'thing-at-point)
142 (let ((bounds (bounds-of-thing-at-point thing))) 145 (funcall (get thing 'thing-at-point))
143 (if bounds 146 (let ((bounds (bounds-of-thing-at-point thing)))
144 (buffer-substring (car bounds) (cdr bounds)))))) 147 (when bounds
148 (buffer-substring (car bounds) (cdr bounds)))))))
149 (when (and text no-properties)
150 (set-text-properties 0 (length text) nil text))
151 text))
145 152
146;; Go to beginning/end 153;; Go to beginning/end
147 154