GNU bug report logs - #8634
24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns

Previous Next

Package: emacs;

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

Date: Sat, 7 May 2011 15:31:02 UTC

Severity: minor

Tags: fixed

Found in version 24.0.50

Fixed in version 26.1

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Nicolas Richard <theonewiththeevillook <at> yahoo.fr>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 8634 <at> debbugs.gnu.org, Lars Ingebrigtsen <larsi <at> gnus.org>, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2)	new fns
Date: Mon, 10 Feb 2014 15:27:27 +0100
Drew Adams <drew.adams <at> oracle.com> writes:

>> I just tried saying the same in the *scratch* buffer, and there it
>> returns 65!
>> 
>> Here in the Message buffer it returns nil.  It does in a
>> fundamental-mode buffer, too...
>
> Sounds like we might be getting somewhere now.  Something in
> certain buffers causes `number-at-point' to do the wrong thing.

That is because number-at-point uses the 'sexp at point, which depends
on the syntax table.

The following definition seems to fix that dependance (500 is arbitrary
choice -- the same arbitrary choice as for emails) :

diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 9a40049..7b4cf56 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -581,7 +581,10 @@ Signal an error if the entire string was not used."
 ;;;###autoload
 (defun number-at-point ()
   "Return the number at point, or nil if none is found."
-  (form-at-point 'sexp 'numberp))
+  (when (thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500)
+    (string-to-number
+     (buffer-substring (match-beginning 0) (match-end 0)))))
+
 (put 'number 'thing-at-point 'number-at-point)
 ;;;###autoload
 (defun list-at-point ()


-- 
Nico.




This bug report was last modified 8 years and 167 days ago.

Previous Next


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