From c4505fed538455a3637a293f10655d31c57ecff7 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 12 Aug 2022 22:22:17 +0200 Subject: Hide local variable section in emacs-news-modes * lisp/textmodes/emacs-authors-mode.el (emacs-authors-mode--hide-local-variables): Move from here... * lisp/emacs-lisp/subr-x.el (emacs-etc--hide-local-variables): ...to here. * lisp/textmodes/emacs-authors-mode.el (subr-x): Require. (emacs-authors-mode): Use above renamed function. * lisp/textmodes/emacs-news-mode.el (subr-x): Require. (emacs-news--mode-common): Call 'emacs-etc--hide-local-variables' to hide local variables section. --- lisp/emacs-lisp/subr-x.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 1cce97cdb10..bd7c3c82f97 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -467,6 +467,18 @@ be marked unmodified, effectively ignoring those changes." (equal ,hash (buffer-hash))) (restore-buffer-modified-p nil)))))))) +(defun emacs-etc--hide-local-variables () + "Hide local variables. +Used by `emacs-authors-mode' and `emacs-news-mode'." + (narrow-to-region (point-min) + (save-excursion + (goto-char (point-max)) + ;; Obfuscate to avoid this being interpreted + ;; as a local variable section itself. + (if (re-search-backward "^Local\sVariables:$" nil t) + (progn (forward-line -1) (point)) + (point-max))))) + (provide 'subr-x) ;;; subr-x.el ends here -- cgit v1.2.3