[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#8634: 24.0.50; `number-at-point' returns char value for `?' construc
From: |
Nicolas Richard |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Drew Adams <drew.adams@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.
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Lars Ingebrigtsen, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Eli Zaretskii, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Lars Ingebrigtsen, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Drew Adams, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Lars Ingebrigtsen, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Drew Adams, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Eli Zaretskii, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Eli Zaretskii, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Lars Ingebrigtsen, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns, Drew Adams, 2014/02/09
- bug#8634: 24.0.50; `number-at-point' returns char value for `?' constructs - 1) doc, 2) new fns,
Nicolas Richard <=