|
From: | Tino Calancha |
Subject: | bug#21391: 24.5; `thing-at-point' should return a string |
Date: | Fri, 11 Nov 2016 23:13:55 +0900 (JST) |
User-agent: | Alpine 2.20 (DEB 67 2015-01-07) |
On Fri, 11 Nov 2016, Eli Zaretskii wrote:
From: Tino Calancha <tino.calancha@gmail.com> Date: Fri, 11 Nov 2016 19:07:15 +0900 (JST) cc: Eli Zaretskii <eliz@gnu.org>, tino.calancha@gmail.com, 21391@debbugs.gnu.orgOn 10.11.2016 21:59, Eli Zaretskii wrote:Because currently they can call thing-at-point without defining foo-at-point. AFAIU, you suggest to deny them this possibility, and force them to define foo-at-point for every foo.They'll really have to do that only for string-unrepresentable foos. Like currently (thing-at-point 'symbol) returns a string, whereas (symbol-at-point) returns an interned symbol. That's nothing new.Indeed, this sounds the right usage for me, and for an user who has read the part of the manual refering to `thing-at-point'.I disagree, sorry.
The current implementation makes the things harder to understand. Currently one user need to read the source code to know the actual type this function returns. Depending of what is foo in: (thing-at-point 'foo nil) you could get: 1) a non-string 2) a string with properties 3) a string without properties. That's true even after you pass nil to the second argument (see examples below). Then it's not clear to me the motivation of the second argument: if non-nil means strip the properties, i guess a nil value should means do not strip them. Let's say i want to get some things as strings keeping their properties (in this example warning face). ;; list: OK (with-temp-buffer (insert (propertize "(foo)" 'face 'warning)) (goto-char 2) (thing-at-point 'list)) => #("(foo)" 0 5 (face warning)) ;; sexp: OK (with-temp-buffer (insert (propertize "(foo)" 'face 'warning)) (goto-char 2) (thing-at-point 'sexp)) => #("foo" 0 3 (face warning)) ;; symbol: OK (with-temp-buffer (insert (propertize "(foo)" 'face 'warning)) (goto-char 2) (thing-at-point 'symbol)) => #("foo" 0 3 (face warning)) ;; filename: OK (with-temp-buffer (insert (propertize "thingatpt.el" 'face 'warning)) (goto-char 2) (thing-at-point 'filename)) => #("thingatpt.el" 0 12 (face warning)) ;; url: Opps! And the properties? (with-temp-buffer (insert (propertize "https://www.example.com" 'face 'warning)) (goto-char 2) (thing-at-point 'url)) => "https://www.example.com" ;; email: Again No properties (with-temp-buffer (insert (propertize "foo@bar.edu" 'face 'warning)) (goto-char 2) (thing-at-point 'email)) => "foo@bar.edu" ;; number: Cannot get even a string. (with-temp-buffer (insert (propertize "4" 'face 'warning)) (goto-char 1) (thing-at-point 'number)) => 4
[Prev in Thread] | Current Thread | [Next in Thread] |