From: Lars Ingebrigtsen Date: Sat, 16 Apr 2022 17:42:33 +0000 (+0200) Subject: Don't leave `C-h N' in a text-mode derived mode X-Git-Tag: emacs-29.0.90~1931^2~490^2~1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1a339d6ba5372e93ce62d7cfa0dcc2072610cdd7;p=emacs.git Don't leave `C-h N' in a text-mode derived mode * lisp/help.el (view-emacs-news): Use emacs-news-view-mode. * lisp/textmodes/emacs-news-mode.el (emacs-news-view-mode): Split into own mode to avoid confusion. --- diff --git a/lisp/help.el b/lisp/help.el index e326ea5d002..9cde65f7975 100644 --- a/lisp/help.el +++ b/lisp/help.el @@ -453,10 +453,9 @@ With argument, display info only for the selected version." ((< vn 18) "NEWS.1-17") (t (format "NEWS.%d" vn)))) res) - (find-file (expand-file-name file data-directory)) - (setq buffer-read-only t) - (emacs-news-mode) - (widen) + (let ((inhibit-local-variables-regexps '(".*"))) + (find-file (expand-file-name file data-directory)) + (emacs-news-view-mode)) (goto-char (point-min)) (when (stringp version) (when (re-search-forward diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el index a766352917e..e31a7105b80 100644 --- a/lisp/textmodes/emacs-news-mode.el +++ b/lisp/textmodes/emacs-news-mode.el @@ -50,18 +50,26 @@ `(("^---$" 0 'emacs-news-does-not-need-documentation) ("^\\+\\+\\+$" 0 'emacs-news-is-documented))) -;;;###autoload -(define-derived-mode emacs-news-mode text-mode "NEWS" - "Major mode for editing and viewind the Emacs NEWS file." +(defun emacs-news--mode-common () (setq-local font-lock-defaults '(emacs-news-mode-font-lock-keywords t)) (setq-local outline-regexp "^\\*+ " outline-minor-mode-cycle t outline-minor-mode-highlight 'append) + (outline-minor-mode)) + +;;;###autoload +(define-derived-mode emacs-news-mode text-mode "NEWS" + "Major mode for editing the Emacs NEWS file." (setq-local fill-paragraph-function #'emacs-news--fill-paragraph) - (outline-minor-mode 1) - (when buffer-read-only - (emacs-news--buttonize) - (button-mode))) + (emacs-news--mode-common)) + +;;;###autoload +(define-derived-mode emacs-news-view-mode special-mode "NEWS" + "Major mode for viewing the Emacs NEWS file." + (setq buffer-read-only t) + (emacs-news--buttonize) + (button-mode) + (emacs-news--mode-common)) (defun emacs-news--fill-paragraph (&optional justify) (cond