Skip to content

Commit

Permalink
Add support for imenu
Browse files Browse the repository at this point in the history
Allow navigation within a spec file using imenu.
  • Loading branch information
omajid committed Sep 23, 2014
1 parent 74d95fb commit dde79cd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rpm-spec-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ with no args, if that value is non-nil."
(easy-menu-define rpm-spec-call-menu rpm-spec-mode-map
"Post menu for `rpm-spec-mode'." rpm-spec-mode-menu)
(easy-menu-add rpm-spec-mode-menu)
(rpm-spec--initialize-imenu)

(if (and (= (buffer-size) 0) rpm-spec-initialize-sections)
(run-hooks 'rpm-spec-mode-new-file-hook))
Expand Down Expand Up @@ -1052,6 +1053,13 @@ leave point at previous location."
(and (re-search-forward "^%files\\b" nil t) (forward-line -1))
(goto-char (point-max))))))

(defun rpm-spec--initialize-imenu ()
(setq imenu-generic-expression
`(("Sections"
,(concat "^%" (regexp-opt rpm-spec-sections) ".*$") 0)
("Scripts"
,(concat "^%" (regexp-opt rpm-spec-scripts) ".*$") 0))))

(defun rpm-spec-insert-true-prefix ()
(interactive)
(insert "%{prefix}"))
Expand Down

0 comments on commit dde79cd

Please sign in to comment.