[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/rfc-mode 697158dc0f 45/52: Extract rfc-mode--integer-at
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/rfc-mode 697158dc0f 45/52: Extract rfc-mode--integer-at-point from rfc-mode-read |
Date: |
Wed, 12 Oct 2022 16:29:21 -0400 (EDT) |
branch: scratch/rfc-mode
commit 697158dc0feffd35531f9ccd0cb63702c03eca8d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Nicolas Martyanoff <khaelin@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'."
- [nongnu] scratch/rfc-mode e21fb7e134 05/52: fix comment, (continued)
- [nongnu] scratch/rfc-mode e21fb7e134 05/52: fix comment, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode c550aa0530 03/52: v1.0.0, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode ff7a36b810 44/52: Offer number at point as default in rfc-mode-read, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 3a7afa19e7 08/52: make some functions private, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode ea349f3441 41/52: Improve doc-strings, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 0f95e3f79b 21/52: fix mode detection regexp, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 8587416c21 40/52: Add prefix argument support to rfc-mode-read, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 3ef663203b 51/52: Consistently use spaces for indentation, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode b885d6bd2b 50/52: Fix completing-read default argument, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 21c966a02c 47/52: update changelog, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 697158dc0f 45/52: Extract rfc-mode--integer-at-point from rfc-mode-read,
Stefan Monnier <=
- [nongnu] scratch/rfc-mode 5d0c8096b2 48/52: * rfc-mode.el: Explicitly load cl-lib dependency., Stefan Monnier, 2022/10/12