[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/rfc-mode 5cdf7172e3 11/52: Merge pull request #1 from r
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/rfc-mode 5cdf7172e3 11/52: Merge pull request #1 from riscy/master |
Date: |
Wed, 12 Oct 2022 16:29:18 -0400 (EDT) |
branch: scratch/rfc-mode
commit 5cdf7172e307c0e23bb5342c61263d4439292ede
Merge: 3a7afa19e7 390659e19c
Author: Nicolas Martyanoff <khaelin@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #1 from riscy/master
add repository url; automatically fetch some documents
---
rfc-mode.el | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/rfc-mode.el b/rfc-mode.el
index a89f11538a..bfd9b7d8de 100644
--- a/rfc-mode.el
+++ b/rfc-mode.el
@@ -32,6 +32,7 @@
(defgroup rfc-mode-group nil
"Tools to browse and read RFC documents."
:prefix "rfc-mode-"
+ :link '(url-link :tag "GitHub" "https://github.com/galdor/rfc-mode")
:group 'external)
(defface rfc-mode-document-header-face
@@ -66,6 +67,13 @@
:type 'directory
:group 'rfc-mode)
+(defcustom rfc-mode-document-url
+ "https://www.rfc-editor.org/rfc/rfc%s.txt"
+ "A `format'able URL for fetching arbitrary RFC documents.
+Assume RFC documents are named as e.g. rfc21.txt, rfc-index.txt."
+ :type 'string
+ :group 'rfc-mode)
+
(defcustom rfc-mode-browser-entry-title-width 60
"The width of the column containing RFC titles in the browser."
:type 'integer
@@ -127,6 +135,7 @@
(defun rfc-mode-browse ()
"Browse through all RFC documents referenced in the index using Helm."
(interactive)
+ (rfc-mode--fetch-document "-index" rfc-mode-index-path)
(unless rfc-mode-index-entries
(setq rfc-mode-index-entries
(rfc-mode-read-index-file rfc-mode-index-path)))
@@ -315,6 +324,7 @@ ENTRY is a RFC index entry in the browser."
The buffer is created if it does not exist."
(let* ((buffer-name (rfc-mode--document-buffer-name number))
(document-path (rfc-mode--document-path number)))
+ (rfc-mode--fetch-document number document-path)
(find-file document-path)
(rename-buffer buffer-name)
(rfc-mode)
@@ -322,6 +332,19 @@ The buffer is created if it does not exist."
;;; Misc utils
+(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'."
+ (rfc-mode--check-directory)
+ (unless (file-exists-p document-path)
+ (url-copy-file (format rfc-mode-document-url suffix) document-path)))
+
+(defun rfc-mode--check-directory ()
+ "Check that `rfc-mode-directory' exists -- create if not."
+ (when (and (not (file-exists-p rfc-mode-directory))
+ (y-or-n-p (format "Create directory %s? " rfc-mode-directory)))
+ (make-directory rfc-mode-directory t)))
+
(defun rfc-mode--parse-rfc-ref (string)
"Parse a reference to a RFC document from STRING.
- [nongnu] scratch/rfc-mode 02546beecf 39/52: v1.3.0, (continued)
- [nongnu] scratch/rfc-mode 02546beecf 39/52: v1.3.0, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode bec092989b 30/52: Add imenu support for rfc-mode, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 918d38f901 24/52: compute the index path dynamically, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 4454af644e 13/52: update version tag, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 088d81002e 04/52: make checkdoc happy, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 88e6577a0e 27/52: update the readme regarding document download, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 234890d3a8 23/52: Use expand-file-name instead of concat, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 8aff885877 07/52: fix formatting escape sequence, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 9ec648cdf7 14/52: cosmetic, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 622ce988a8 06/52: add missing requires, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 5cdf7172e3 11/52: Merge pull request #1 from riscy/master,
Stefan Monnier <=
- [nongnu] scratch/rfc-mode e1a255fb59 32/52: Explain the meaning of rfc-mode-use-original-buffer-names better, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 5a8a3a238e 29/52: Make the rfc-mode-map inherit from special-mode-map, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode f766c141ac 22/52: introduce a custom variable to use original buffer names, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 476bff817d 42/52: Don't turn the beginning of every page into a button, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 6e41dcd82f 43/52: Autoload rfc-mode-browse, Stefan Monnier, 2022/10/12
- [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