[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/rfc-mode 355f25ee2a 31/52: Add commands to move to the
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/rfc-mode 355f25ee2a 31/52: Add commands to move to the previous/next RFC section |
Date: |
Wed, 12 Oct 2022 16:29:20 -0400 (EDT) |
branch: scratch/rfc-mode
commit 355f25ee2a83b9c8adf4e30fac8dbc58a59946d2
Author: Daniel Martín <mardani29@yahoo.es>
Commit: Daniel Martín <mardani29@yahoo.es>
Add commands to move to the previous/next RFC section
* rfc-mode.el (rfc-mode-map): Bind "n" and "p" to
`rfc-mode-next-section' and `rfc-mode-previous-section', respectively.
(rfc-mode-next-section): Add `rfc-mode-next-section' and
`rfc-mode-previous-section', which move point to the next and previous
RFC section, respectively.
---
rfc-mode.el | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/rfc-mode.el b/rfc-mode.el
index cb64693b3f..91443b4dac 100644
--- a/rfc-mode.el
+++ b/rfc-mode.el
@@ -102,6 +102,8 @@ Assume RFC documents are named as e.g. rfc21.txt,
rfc-index.txt."
(define-key map (kbd "q") 'rfc-mode-quit)
(define-key map (kbd "<prior>") 'rfc-mode-backward-page)
(define-key map (kbd "<next>") 'rfc-mode-forward-page)
+ (define-key map (kbd "n") 'rfc-mode-next-section)
+ (define-key map (kbd "p") 'rfc-mode-previous-section)
map)
"The keymap for `rfc-mode'.")
@@ -133,6 +135,31 @@ Assume RFC documents are named as e.g. rfc21.txt,
rfc-index.txt."
(rfc-mode-previous-header)
(recenter 0))
+(defun rfc-mode-next-section (n)
+ "Move point to Nth next section (default 1)."
+ (interactive "p")
+ (let ((case-fold-search nil)
+ (start (point)))
+ (if (looking-at rfc-mode-title-regexp)
+ (forward-line 1))
+ (if (re-search-forward rfc-mode-title-regexp (point-max) t n)
+ (beginning-of-line)
+ (goto-char (point-max))
+ ;; The last line doesn't belong to any section.
+ (forward-line -1))
+ ;; Ensure we never move back from the starting point.
+ (if (< (point) start) (goto-char start))))
+
+(defun rfc-mode-previous-section (n)
+ "Move point to Nth previous section (default 1)."
+ (interactive "p")
+ (let ((case-fold-search nil))
+ (if (looking-at rfc-mode-title-regexp)
+ (forward-line -1))
+ (if (re-search-backward rfc-mode-title-regexp (point-min) t n)
+ (beginning-of-line)
+ (goto-char (point-min)))))
+
;;;###autoload
(defun rfc-mode-read (number)
"Read the RFC document NUMBER."
- [nongnu] branch scratch/rfc-mode created (now a734721104), Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 5bda3310af 17/52: remove useless groups for custom variables, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 91bf9ff561 34/52: Avoid rfc-mode-read replacing the current buffer, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode b651eac96c 09/52: add repository link to group, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 1ae16d2fb8 35/52: Implement a command to navigate to existing sections, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode ff1e3251e9 01/52: initial import, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode dc1a3a978f 02/52: improve the readme, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 3719b9ce9f 20/52: derive rfc-mode from text-mode, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 821a039ae6 18/52: autoload rfc-mode-read, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 355f25ee2a 31/52: Add commands to move to the previous/next RFC section,
Stefan Monnier <=
- [nongnu] scratch/rfc-mode a3a58e9883 15/52: better section title detection, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 55c0c24f9b 28/52: Make rfc-mode inherit from special-mode, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode e037a7ce5c 33/52: Add Tab and S-Tab to navigate through RFC button links, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 02d8dfeb70 16/52: do not fail if helm is not available, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 7819cb64b9 25/52: add a changelog, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode e2608adbac 36/52: Make hyperlinks clickable with the mouse too, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 390659e19c 10/52: automatically download indices and documents if they don't exist, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode e7d9e2f4cb 12/52: add melpa badges to readme, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 55d28321b4 26/52: 1.2.0, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode e34df2b983 46/52: Free rfc-mode-browse of the dependency on Helm, Stefan Monnier, 2022/10/12