diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 9920fa0..1c630f7 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -128,7 +128,7 @@ bounds-of-thing-at-point ;;;###autoload (defun thing-at-point (thing &optional no-properties) - "Return the THING at point. + "Return the THING at point as a string. THING should be a symbol specifying a type of syntactic entity. Possibilities include `symbol', `list', `sexp', `defun', `filename', `url', `email', `word', `sentence', `whitespace', @@ -145,7 +145,7 @@ thing-at-point (let ((bounds (bounds-of-thing-at-point thing))) (when bounds (buffer-substring (car bounds) (cdr bounds))))))) - (when (and text no-properties (sequencep text)) + (when (and text no-properties) (set-text-properties 0 (length text) nil text)) text)) @@ -557,6 +557,14 @@ thing-at-point-email-regexp (put 'buffer 'end-op (lambda () (goto-char (point-max)))) (put 'buffer 'beginning-op (lambda () (goto-char (point-min)))) +;; Number + +(put 'number 'thing-at-point + (lambda () + (let ((thing (thing-at-point 'sexp))) + (when (numberp (thing-at-point--read-from-whole-string thing)) + thing)))) + ;; Aliases (defun word-at-point () @@ -604,7 +612,6 @@ symbol-at-point (defun number-at-point () "Return the number at point, or nil if none is found." (form-at-point 'sexp 'numberp)) -(put 'number 'thing-at-point 'number-at-point) ;;;###autoload (defun list-at-point () "Return the Lisp list at point, or nil if none is found."