GNU bug report logs -
#21391
24.5; `thing-at-point' returns error when called with arguments 'number t
Previous Next
Reported by: Tino Calancha <f92capac <at> gmail.com>
Date: Tue, 1 Sep 2015 01:57:01 UTC
Severity: minor
Found in version 24.5
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Fri, 11 Nov 2016, Eli Zaretskii wrote:
>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Fri, 11 Nov 2016 19:07:15 +0900 (JST)
>> cc: Eli Zaretskii <eliz <at> gnu.org>, tino.calancha <at> gmail.com,
>> 21391 <at> debbugs.gnu.org
>>
>>> On 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 <at> bar.edu" 'face 'warning))
(goto-char 2)
(thing-at-point 'email))
=> "foo <at> bar.edu"
;; number: Cannot get even a string.
(with-temp-buffer
(insert (propertize "4" 'face 'warning))
(goto-char 1)
(thing-at-point 'number))
=> 4
This bug report was last modified 4 years and 329 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.