]> git.eshelyaron.com Git - emacs.git/commitdiff
Hide local variable section in emacs-news-modes
authorStefan Kangas <stefan@marxist.se>
Fri, 12 Aug 2022 20:22:17 +0000 (22:22 +0200)
committerStefan Kangas <stefan@marxist.se>
Fri, 12 Aug 2022 20:28:17 +0000 (22:28 +0200)
* 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
lisp/textmodes/emacs-authors-mode.el
lisp/textmodes/emacs-news-mode.el

index 1cce97cdb10d1f60f434b21a0a484b993073e56e..bd7c3c82f971e08d87cd9793a180f9ccbdb51618 100644 (file)
@@ -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
index ffb713fd6826d1d66ea56b185ee213fd3df11e0d..af78ab605e91febc36cc23f9574721d855435ca1 100644 (file)
@@ -27,6 +27,8 @@
 
 ;;; Code:
 
+(require 'subr-x)    ; `emacs-etc--hide-local-variables'
+
 (defgroup emacs-authors-mode nil
   "Display the \"etc/AUTHORS\" file from the Emacs distribution."
   :version "29.1"
@@ -88,17 +90,6 @@ See also `emacs-authors-mode'."
     (,(rx bol (not space) (+ not-newline) eol)
      0 'emacs-authors-default)))
 
-(defun emacs-authors-mode--hide-local-variables ()
-  "Hide local variables in \"etc/AUTHORS\".  Used by `emacs-authors-mode'."
-  (narrow-to-region (point-min)
-                    (save-excursion
-                      (goto-char (point-min))
-                      ;; Obfuscate to avoid this being interpreted
-                      ;; as a local variable section itself.
-                      (if (re-search-forward "^Local\sVariables:$" nil t)
-                          (progn (forward-line -1) (point))
-                        (point-max)))))
-
 (defun emacs-authors-next-author (&optional arg)
   "Move point to the next author in \"etc/AUTHORS\".
 With a prefix arg ARG, move point that many authors forward."
@@ -109,7 +100,7 @@ With a prefix arg ARG, move point that many authors forward."
           (forward-line 1))
         (re-search-forward emacs-authors--author-re nil t arg))
     (when (looking-at emacs-authors--author-re)
-          (forward-line -1))
+      (forward-line -1))
     (re-search-backward emacs-authors--author-re nil t (abs arg)))
   (goto-char (line-beginning-position)))
 
@@ -139,7 +130,7 @@ Provides some basic font locking and not much else."
               '(emacs-authors-mode-font-lock-keywords nil nil ((?_ . "w"))))
   (setq font-lock-multiline nil)
   (setq imenu-generic-expression emacs-authors-imenu-generic-expression)
-  (emacs-authors-mode--hide-local-variables))
+  (emacs-etc--hide-local-variables))
 
 (define-obsolete-face-alias 'etc-authors-default 'emacs-authors-default "29.1")
 (define-obsolete-face-alias 'etc-authors-author 'emacs-authors-author "29.1")
index 9afa7ead98def11b6c894eb5e9bbc8e0bef31163..022e17c934355e408339e2eac14f33a6efb1c5c2 100644 (file)
@@ -25,6 +25,7 @@
 
 (eval-when-compile (require 'cl-lib))
 (require 'outline)
+(require 'subr-x)    ; `emacs-etc--hide-local-variables'
 
 (defgroup emacs-news-mode nil
   "Major mode for editing and viewing the Emacs NEWS file."
@@ -76,7 +77,8 @@
               outline-minor-mode-cycle t
               outline-level (lambda () (length (match-string 2)))
               outline-minor-mode-highlight 'append)
-  (outline-minor-mode))
+  (outline-minor-mode)
+  (emacs-etc--hide-local-variables))
 
 ;;;###autoload
 (define-derived-mode emacs-news-mode text-mode "NEWS"