[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/rfc-mode bec092989b 30/52: Add imenu support for rfc-mo
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/rfc-mode bec092989b 30/52: Add imenu support for rfc-mode |
Date: |
Wed, 12 Oct 2022 16:29:20 -0400 (EDT) |
branch: scratch/rfc-mode
commit bec092989b1d1696555e5c0f2e00d87058e08137
Author: Daniel MartÃn <mardani29@yahoo.es>
Commit: Nicolas Martyanoff <khaelin@gmail.com>
Add imenu support for rfc-mode
* rfc-mode.el (rfc-mode-imenu-title): Customizable variable to set the
menu bar title for imenu.
(rfc-mode-title-regexp): Extracted regular expression to identify RFC
section titles.
(rfc-mode-init): Configure imenu and add it to the menu bar.
(rfc-mode-highlight): Use the extracted regular expression to identify
RFC section titles.
---
rfc-mode.el | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/rfc-mode.el b/rfc-mode.el
index 86a0cb2117..cb64693b3f 100644
--- a/rfc-mode.el
+++ b/rfc-mode.el
@@ -81,11 +81,19 @@ Assume RFC documents are named as e.g. rfc21.txt,
rfc-index.txt."
"The width of the column containing RFC titles in the browser."
:type 'integer)
+(defcustom rfc-mode-imenu-title "RFC Contents"
+ "The title to use if `rfc-mode' adds a RFC Contents menu to the menubar."
+ :type 'string
+ :group 'rfc-mode-group)
+
;;; Misc variables:
(defvar rfc-mode-index-entries nil
"The list of entries in the RFC index.")
+(defconst rfc-mode-title-regexp "^\\(?:[0-9]+\\.\\)+\\(?:[0-9]+\\)? .*$"
+ "Regular expression to model section titles in RFC documents.")
+
;;; Keys:
(defvar rfc-mode-map
@@ -102,7 +110,9 @@ Assume RFC documents are named as e.g. rfc21.txt,
rfc-index.txt."
(defun rfc-mode-init ()
"Initialize the current buffer for `rfc-mode'."
(setq-local page-delimiter "^.*?\n")
- (rfc-mode-highlight))
+ (rfc-mode-highlight)
+ (setq imenu-generic-expression (list (list nil rfc-mode-title-regexp 0)))
+ (imenu-add-to-menubar rfc-mode-imenu-title))
(defun rfc-mode-quit ()
"Quit the current window and bury its buffer."
@@ -173,7 +183,7 @@ Assume RFC documents are named as e.g. rfc21.txt,
rfc-index.txt."
;; Section titles
(save-excursion
(goto-char (point-min))
- (while (search-forward-regexp "^\\(?:[0-9]+\\.\\)+\\(?:[0-9]+\\)? .*$"
nil t)
+ (while (search-forward-regexp rfc-mode-title-regexp nil t)
(let ((start (match-beginning 0))
(end (match-end 0)))
(put-text-property start end
- [nongnu] scratch/rfc-mode 390659e19c 10/52: automatically download indices and documents if they don't exist, (continued)
- [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
- [nongnu] scratch/rfc-mode 408bd186c8 49/52: Use closures instead of quoted lambda lists, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode a734721104 52/52: rfc-mode: Simplify the code by fetching&reading more lazily, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode 8fbf469c9b 19/52: improve function name and docstring, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode d4ca95b973 37/52: Add changelog entries for the next version, Stefan Monnier, 2022/10/12
- [nongnu] scratch/rfc-mode ec4269cc91 38/52: fix backtab key name, Stefan Monnier, 2022/10/12
- [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 <=
- [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, 2022/10/12
- [nongnu] scratch/rfc-mode e1a255fb59 32/52: Explain the meaning of rfc-mode-use-original-buffer-names better, Stefan Monnier, 2022/10/12