From: Stefan Kangas Date: Mon, 19 Sep 2022 14:02:28 +0000 (+0200) Subject: Support imenu in emacs-news-mode X-Git-Tag: emacs-29.0.90~1856^2~372^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ba0e989c11ebe05bb519845a6d3ab5af1e2715d8;p=emacs.git Support imenu in emacs-news-mode * lisp/outline.el (outline-imenu-generic-expression): New variable broken out from... (outline-mode): ...here. * lisp/textmodes/emacs-news-mode.el (emacs-news--mode-common): Use above new variable to add imenu support. --- diff --git a/lisp/outline.el b/lisp/outline.el index 25ef1616b93..e3fbd8b3272 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -341,6 +341,10 @@ data reflects the `outline-regexp'.") :safe #'booleanp :version "22.1") +(defvar outline-imenu-generic-expression + (list (list nil (concat "^\\(?:" outline-regexp "\\).*$") 0)) + "Value for `imenu-generic-expression' in Outline mode.") + ;;;###autoload (define-derived-mode outline-mode text-mode "Outline" "Set major mode for editing outlines with selective display. @@ -375,8 +379,7 @@ Turning on outline mode calls the value of `text-mode-hook' and then of (concat paragraph-separate "\\|\\(?:" outline-regexp "\\)")) (setq-local font-lock-defaults '(outline-font-lock-keywords t nil nil backward-paragraph)) - (setq-local imenu-generic-expression - (list (list nil (concat "^\\(?:" outline-regexp "\\).*$") 0))) + (setq-local imenu-generic-expression outline-imenu-generic-expression) (add-hook 'change-major-mode-hook #'outline-show-all nil t) (add-hook 'hack-local-variables-hook #'outline-apply-default-state nil t)) diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el index 88e89480609..d9decae4df6 100644 --- a/lisp/textmodes/emacs-news-mode.el +++ b/lisp/textmodes/emacs-news-mode.el @@ -80,6 +80,7 @@ outline-minor-mode-cycle t outline-minor-mode-highlight 'append) (outline-minor-mode) + (setq-local imenu-generic-expression outline-imenu-generic-expression) (emacs-etc--hide-local-variables)) ;;;###autoload