* bug#37458: 27.0.50; number-at-point misses hex
@ 2019-09-19 11:18 Andreas Röhler
2019-09-20 17:41 ` Lars Ingebrigtsen
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Röhler @ 2019-09-19 11:18 UTC (permalink / raw)
To: 37458
number-at-point from thingatpt.el doesn't recognize hex-numbers.
Currently defined like that:
(defun number-at-point ()
"Return the number at point, or nil if none is found."
(when (thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500)
(string-to-number
(buffer-substring (match-beginning 0) (match-end 0)))))
Maybe make the regexp customizable?
Thanks,
Andreas
In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32)
of 2019-09-12
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#37458: 27.0.50; number-at-point misses hex
2019-09-19 11:18 bug#37458: 27.0.50; number-at-point misses hex Andreas Röhler
@ 2019-09-20 17:41 ` Lars Ingebrigtsen
2019-09-22 15:44 ` Andreas Röhler
0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2019-09-20 17:41 UTC (permalink / raw)
To: Andreas Röhler; +Cc: 37458
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> number-at-point from thingatpt.el doesn't recognize hex-numbers.
>
> Currently defined like that:
>
> (defun number-at-point ()
> \240 "Return the number at point, or nil if none is found."
> \240 (when (thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500)
> \240\240\240 (string-to-number
> \240\240\240\240 (buffer-substring (match-beginning 0) (match-end 0)))))
(You have something odd in your emails -- it seems like leading spaces
are transformed into char 240.)
I've now changed this to recognise some hex numbers if they're preceded
by #x or 0x. Just looking for "bare" hex numbers may return too many
false positives.
> Maybe make the regexp customizable?
That wouldn't help much since the string has to be transformed to a
number in the right base.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#37458: 27.0.50; number-at-point misses hex
2019-09-20 17:41 ` Lars Ingebrigtsen
@ 2019-09-22 15:44 ` Andreas Röhler
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Röhler @ 2019-09-22 15:44 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: 37458
On 20.09.19 19:41, Lars Ingebrigtsen wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> number-at-point from thingatpt.el doesn't recognize hex-numbers.
>>
>> Currently defined like that:
>>
>> (defun number-at-point ()
>> \240 "Return the number at point, or nil if none is found."
>> \240 (when (thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500)
>> \240\240\240 (string-to-number
>> \240\240\240\240 (buffer-substring (match-beginning 0) (match-end 0)))))
> (You have something odd in your emails -- it seems like leading spaces
> are transformed into char 240.)
Sent from thunderbird. Not visible here. Also don't get the error when
copying back from previous mail.
>
> I've now changed this to recognise some hex numbers if they're preceded
> by #x or 0x. Just looking for "bare" hex numbers may return too many
> false positives.
Thanks.
>> Maybe make the regexp customizable?
> That wouldn't help much since the string has to be transformed to a
> number in the right base.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-22 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-19 11:18 bug#37458: 27.0.50; number-at-point misses hex Andreas Röhler
2019-09-20 17:41 ` Lars Ingebrigtsen
2019-09-22 15:44 ` Andreas Röhler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.