diff options
author | Remington Furman <remington@remcycles.net> | 2021-07-16 11:47:36 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-07-16 11:47:36 +0200 |
commit | 865535a24cd07efee3c2d323de6e9baae8bc817d (patch) | |
tree | 8f3a56f94215063840733972b7aa3445c38173c8 /lisp/thingatpt.el | |
parent | dc85ffffc88c08742072573539f8bfae9dcbbccb (diff) | |
download | emacs-865535a24cd07efee3c2d323de6e9baae8bc817d.tar.gz |
Make `number-at-point' work for more hex numbers
* lisp/thingatpt.el (number-at-point): Rewrite to actually catch
the hex numbers (bug#49588).
Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp/thingatpt.el')
-rw-r--r-- | lisp/thingatpt.el | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 8ca0f429ca1..4c2470fbcb6 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -677,14 +677,14 @@ Signal an error if the entire string was not used." "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 recognized." - (when (thing-at-point-looking-at - "\\(-?[0-9]+\\.?[0-9]*\\)\\|\\(0x\\|#x\\)\\([a-zA-Z0-9]+\\)" 500) - (if (match-beginning 1) - (string-to-number - (buffer-substring (match-beginning 1) (match-end 1))) - (string-to-number - (buffer-substring (match-beginning 3) (match-end 3)) - 16)))) + (cond + ((thing-at-point-looking-at "\\(0x\\|#x\\)\\([a-fA-F0-9]+\\)" 500) + (string-to-number + (buffer-substring (match-beginning 2) (match-end 2)) + 16)) + ((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 |