branch: scratch/rfc-mode commit 697158dc0feffd35531f9ccd0cb63702c03eca8d Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Nicolas Martyanoff <khae...@gmail.com>
Extract rfc-mode--integer-at-point from rfc-mode-read --- rfc-mode.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/rfc-mode.el b/rfc-mode.el index cce1d3b01c..d031cb8144 100644 --- a/rfc-mode.el +++ b/rfc-mode.el @@ -201,19 +201,7 @@ Offer the number at point as default." (interactive (if (and current-prefix-arg (not (consp current-prefix-arg))) (list (prefix-numeric-value current-prefix-arg)) - (let ((default - ;; Note that we don't use `number-at-point' as it will - ;; match number formats that make no sense as RFC numbers - ;; (floating point, hexadecimal, etc.). - (save-excursion - (skip-chars-backward "0-9") - (if (looking-at "[0-9]") - (string-to-number - (buffer-substring-no-properties - (point) - (progn (skip-chars-forward "0-9") - (point)))))))) - (list (read-number "RFC number: " default))))) + (list (read-number "RFC number: " (rfc-mode--integer-at-point))))) (display-buffer (rfc-mode--document-buffer number))) (defun rfc-mode-reload-index () @@ -436,6 +424,19 @@ The buffer is created if it does not exist." ;;; Misc utils: +(defun rfc-mode--integer-at-point () + ;; Note that we don't use `number-at-point' as it will match + ;; number formats that make no sense as RFC numbers (floating + ;; point, hexadecimal, etc.). + (save-excursion + (skip-chars-backward "0-9") + (and (looking-at "[0-9]") + (string-to-number + (buffer-substring-no-properties + (point) + (progn (skip-chars-forward "0-9") + (point))))))) + (defun rfc-mode--fetch-document (suffix document-path) "Ensure an RFC document with SUFFIX exists at DOCUMENT-PATH. If no such file exists, fetch it from `rfc-document-url'."