diff options
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/thingatpt.el | 15 |
2 files changed, 15 insertions, 4 deletions
| @@ -1662,6 +1662,10 @@ A symbol 'uuid' can be passed to 'thing-at-point' and it returns the | |||
| 1662 | UUID at point. | 1662 | UUID at point. |
| 1663 | 1663 | ||
| 1664 | --- | 1664 | --- |
| 1665 | *** 'number-at-point' will now recognize hex number like 0xAb09 and #xAb09 | ||
| 1666 | and return them as numbers. | ||
| 1667 | |||
| 1668 | --- | ||
| 1665 | *** 'word-at-point' and 'sentence-at-point' accept NO-PROPERTIES. | 1669 | *** 'word-at-point' and 'sentence-at-point' accept NO-PROPERTIES. |
| 1666 | Just like 'thing-at-point' itself. | 1670 | Just like 'thing-at-point' itself. |
| 1667 | 1671 | ||
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 319f4b2cf8a..1ce4b98fd1b 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el | |||
| @@ -632,10 +632,17 @@ Signal an error if the entire string was not used." | |||
| 632 | (if thing (intern thing)))) | 632 | (if thing (intern thing)))) |
| 633 | ;;;###autoload | 633 | ;;;###autoload |
| 634 | (defun number-at-point () | 634 | (defun number-at-point () |
| 635 | "Return the number at point, or nil if none is found." | 635 | "Return the number at point, or nil if none is found. |
| 636 | (when (thing-at-point-looking-at "-?[0-9]+\\.?[0-9]*" 500) | 636 | Decimal numbers like \"14\" or \"-14.5\", as well as hex numbers |
| 637 | (string-to-number | 637 | like \"0xBEEF09\" or \"#xBEEF09\", are regognized." |
| 638 | (buffer-substring (match-beginning 0) (match-end 0))))) | 638 | (when (thing-at-point-looking-at |
| 639 | "\\(-?[0-9]+\\.?[0-9]*\\)\\|\\(0x\\|#x\\)\\([a-zA-Z0-9]+\\)" 500) | ||
| 640 | (if (match-beginning 1) | ||
| 641 | (string-to-number | ||
| 642 | (buffer-substring (match-beginning 1) (match-end 1))) | ||
| 643 | (string-to-number | ||
| 644 | (buffer-substring (match-beginning 3) (match-end 3)) | ||
| 645 | 16)))) | ||
| 639 | 646 | ||
| 640 | (put 'number 'thing-at-point 'number-at-point) | 647 | (put 'number 'thing-at-point 'number-at-point) |
| 641 | ;;;###autoload | 648 | ;;;###autoload |