GNU bug report logs - #9300
24.0.50; `bounds-of-thing-at-point' does not return nil when just after THING

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Sun, 14 Aug 2011 22:39:03 UTC

Severity: minor

Found in version 24.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #29 received at 9300 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Drew Adams <drew.adams <at> oracle.com>, 9300 <at> debbugs.gnu.org
Subject: Re: bug#9300: 24.0.50; `bounds-of-thing-at-point' does not return nil
 when just after THING
Date: Wed, 24 Feb 2016 02:52:36 +0200
On 02/23/2016 06:15 PM, Drew Adams wrote:

> Yes, it should return nil, as there is NO symbol at point.

If we ask the users, I'm guessing we'll get mixed answers on that, at 
least as a result of this long-standing thing-at-point behavior.

> It is your expectation that is wrong.  There are plenty of uses
> of thing-at-point that go far beyond just looking for a default
> value of a name near point or trying to complete a name before
> (not at) point.

What I'm saying is, "fixing" it will most likely break code in the wild. 
Not just mine.

> Those other uses include the need to test whether or not there
> IS a given THING at point.  The design itself depends on this
> difference: Is there a THING at point or not?

They can call (bounds-of-thing-at-point 'foo), and then compare the cdr 
with the value of point.

> The purpose of
> thingatpt.el is not only to maximize finding a THING that is
> _near_ point.  One purpose is to test whether there IS a THING
> AT point.

We're a long way from maximizing it. To see something closer to the 
other end of the spectrum, see the definition of find-tag-default-bounds 
before 
http://git.savannah.gnu.org/cgit/emacs.git/commit/?h=emacs-25&id=e72a26e00981a508569a0856125061310a3f64ac.

> I see (in emacs-devel) that you are now looking into
> picking up a name near point - but you are limiting that to the
> same line.

Not at all, see above.

>>> This is the design of the thingatpt code, and the reason why
>>> `<=' instead of `<' is a bug:
>>>
>>>    the function that is (get THING 'end-op) moves PAST the THING,
>>>    so that point is not on the THING.  This is true generally, no
>>>    matter the type of THING.
>>
>> That's not a quote from thingatpt.el.
>
> It is nevertheless the design (intention), clear from the code.

I'm not so clear on that. The following comment tells me the opposite 
(the position where a substring ends is normally the one _after_ its 
last character):

    ;; Try a second time, moving backward first and then forward,
    ;; so that we can find a thing that ends at ORIG.

If we didn't need to be able to find a thing that ends just before 
point, I don't think the implementation would need the "Try a second 
time" branch at all: when point if before the last character of a 
symbol, (forward-symbol) still works.




This bug report was last modified 3 years and 30 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.