[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rpm-spec-mode 594a2c588d 24/67: Add basic Imenu support fo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rpm-spec-mode 594a2c588d 24/67: Add basic Imenu support for easy navigation. |
Date: |
Wed, 26 Mar 2025 16:03:22 -0400 (EDT) |
branch: elpa/rpm-spec-mode
commit 594a2c588d38a7e9d63e287ed55257d8a68290c2
Author: Carl Xiong <xiongc05@gmail.com>
Commit: Carl Xiong <xiongc05@gmail.com>
Add basic Imenu support for easy navigation.
---
rpm-spec-mode.el | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/rpm-spec-mode.el b/rpm-spec-mode.el
index ac9d797614..1b9cbce8d8 100644
--- a/rpm-spec-mode.el
+++ b/rpm-spec-mode.el
@@ -646,7 +646,45 @@ value returned by function `user-mail-address'."
(define-abbrev-table 'rpm-spec-mode-abbrev-table ())
;;------------------------------------------------------------
+;; Imenu support
+(defun rpm-spec-mode-imenu-setup ()
+ "An all-in-one setup function to add `imenu' support to
+`rpm-spec-mode'."
+ (setq imenu-create-index-function
+ #'rpm-spec-mode-imenu-create-index-function))
+
+(defun rpm-spec-mode-imenu-create-index-function ()
+ "Creating a buffer index for `rpm-spec-mode' The function
+should take no arguments, and return an index alist for the
+current buffer. It is called within `save-excursion', so where it
+leaves point makes no difference."
+ (goto-char (point-min))
+ (let (rpm-imenu-index
+ (sub-package-name-regexp
"[[:space:]]+-n[[:space:]]+\\([-_[:alnum:]]+\\)")
+ rpm-spec-imenu-index-alist
+ section
+ pos-marker
+ subpkg-name
+ submenu
+ new-index)
+ (while (re-search-forward rpm-section-regexp nil t)
+ (setq pos-marker (point-marker))
+ (setq section (match-string-no-properties 1))
+ ;; try to extract sub package name
+ (if (re-search-forward sub-package-name-regexp
+ (line-end-position) t)
+ (setq subpkg-name (match-string-no-properties 1))
+ (setq subpkg-name "__default"))
+ ;; create/add the matched item to the index list
+ (setq new-index (cons subpkg-name pos-marker))
+ (if (setq submenu (assoc section rpm-imenu-index))
+ (setf (cdr submenu)
+ (cons new-index (cdr submenu)))
+ (add-to-list 'rpm-imenu-index
+ (list section new-index))))
+ rpm-imenu-index))
+;;------------------------------------------------------------
(add-hook 'rpm-spec-mode-new-file-hook 'rpm-spec-initialize)
;;;###autoload
@@ -707,6 +745,7 @@ with no args, if that value is non-nil."
;;Initialize font lock for GNU emacs.
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(rpm-spec-font-lock-keywords nil t))
+ (rpm-spec-mode-imenu-setup)
(run-hooks 'rpm-spec-mode-hook))
(defun rpm-command-filter (process string)
- [nongnu] elpa/rpm-spec-mode 8603ea1d45 64/67: Fix interactive functions, (continued)
- [nongnu] elpa/rpm-spec-mode 8603ea1d45 64/67: Fix interactive functions, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode afe4307679 28/67: Convert to UTF-8, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode f099e01fdb 43/67: Fix font-lock, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode e050606029 30/67: Merge branch 'pr-17', ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode d04ef6afd4 22/67: Merge pull request #3 from scop/license-face, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 9e4fcfe7cd 53/67: Quote/unquote macros when commenting/uncommenting, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 4438caf37f 54/67: Align docstring of comment-region functions with newcomment.el, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 077c9501b2 62/67: Add Maintainer header., ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 5d23bbf0d3 66/67: Add defcustom variable for rpm _topdir insteado existing the list further, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode d628b77f9d 03/67: Added 5 patches from Fedora emacs-rpm-spec-mode., ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 594a2c588d 24/67: Add basic Imenu support for easy navigation.,
ELPA Syncer <=
- [nongnu] elpa/rpm-spec-mode 796114105f 12/67: add myself to contributor list, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode c5c04c4d3c 40/67: Remove unused variable, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode df6fb6a3d9 34/67: Fix documentation strings and error output, ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode c69847de7a 47/67: Eliminate redundant variable `rpm-section-list`., ELPA Syncer, 2025/03/26
- [nongnu] elpa/rpm-spec-mode 73f4abb50b 45/67: Tell shell-script-mode that the shell is always rpm, ELPA Syncer, 2025/03/26