GNU bug report logs -
#24969
26.0.50; number-at-point
Previous Next
Reported by: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
Date: Sun, 20 Nov 2016 12:40:02 UTC
Severity: minor
Tags: unreproducible
Found in version 26.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #46 received at 24969 <at> debbugs.gnu.org (full text, mbox):
On 22.11.2016 00:07, Drew Adams wrote:
>>> In Emacs 25.1 (emacs -Q), `number-at-point' at either
>>> the `-' or the `1' returns nil, for me. And I do not
>>> see why it should return a number.
>>>
>>> `number-at-point' is defined using `form-at-point' with
>>> THING `sexp' and predicate `numberp'. The sexp picked
>>> up at point is `foo-1', and that fails `numberp'.
>> From the time when i opened Bug#24605, the
>> implementation, in master branch, of `number-at-point'
>> was different: it changed in commit 786ab4a5 (Bug#8634).
>> My patch was driven by this implementation. I didn't notice
>> that `number-at-point' behaves different in emacs-25.
> It behaves the same in Emacs 25.1 as previously. If something
> broke this after Emacs 25.1 then it should be reverted.
>
>>> What am I missing? Why should this rightfully return
>>> a number? I'm guessing that you are all using a more
>>> recent version of `number-at-point' than what is in
>>> Emacs 25.1 (?). But to me the Emacs 25.1 behavior I
>>> see (i.e., returning nil) is correct.
>>>
>>> Did someone change the meaning of `number-at-point'
>>> so that it now picks up a numeral that is not isolated?
>>> If so, why would that be considered proper behavior?
>>> At the very least it is not backward-compatible behavior.
>> That's right. Commit above breaks backward-compatibility.
> If it returns a number for point on a numeral in the middle
> of a symbol name etc. then it breaks not only backward
> compatibility - it breaks the very notion of a number at
> point. A number at point should be a number as delimited
> and distinguished in the current mode.
>
> The longstanding definition uses Lisp `read', so it distinguishes
> a _Lisp_ number. It uses what Lisp uses to delimit a numeral.
>
> A better implementation of `number-at-point' than what has
> always existed would do this:
>
> 1. Get (thing-at-point 'sexp)
> 2. If it is not a string, return nil.
> 3. Else match it against a regexp that tests for a numeral
> in the current mode/context. Or use another such test
> other than regexp matching. If there the mode/context
> defines numeric syntax then perhaps use a function that
> tests that way.
> 4. For Lisp, the result must coincide with the longstanding
> behavior, one way or another.
>
> Unless `number-at-point' is extended in such a way, it should
> simply be restored to what it has always been. It's behavior
> in Lisp should in any case be to return a Lisp number.
>
Why? A lisp-number is useful for further computations, for adding them
for example.
It's not useful when editing the numbers text at point.
As (thing-at-point 'sexp) internally will get the buffer-substring with
the number's literal, why not make is accessible for edits?
This bug report was last modified 3 years and 288 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.