Commit 385bb140 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Make number-at-point recognize some hex numbers

* lisp/thingatpt.el (number-at-point): Also return common hex
numbers (bug#37458).
parent 1646e448
Pipeline #3216 failed with stage
in 90 minutes and 2 seconds
......@@ -1661,6 +1661,10 @@ backtrace with 'b'.
A symbol 'uuid' can be passed to 'thing-at-point' and it returns the
UUID at point.
*** 'number-at-point' will now recognize hex number like 0xAb09 and #xAb09
and return them as numbers.
*** 'word-at-point' and 'sentence-at-point' accept NO-PROPERTIES.
Just like 'thing-at-point' itself.
......@@ -632,10 +632,17 @@ Signal an error if the entire string was not used."
(if thing (intern thing))))
(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)
(buffer-substring (match-beginning 0) (match-end 0)))))
"Return the number at point, or nil if none is found.
Decimal numbers like \"14\" or \"-14.5\", as well as hex numbers
like \"0xBEEF09\" or \"#xBEEF09\", are regognized."
(when (thing-at-point-looking-at
"\\(-?[0-9]+\\.?[0-9]*\\)\\|\\(0x\\|#x\\)\\([a-zA-Z0-9]+\\)" 500)
(if (match-beginning 1)
(buffer-substring (match-beginning 1) (match-end 1)))
(buffer-substring (match-beginning 3) (match-end 3))
(put 'number 'thing-at-point 'number-at-point)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment