emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c4505fed53: Hide local variable section in emacs-news-modes


From: Stefan Kangas
Subject: master c4505fed53: Hide local variable section in emacs-news-modes
Date: Fri, 12 Aug 2022 16:31:04 -0400 (EDT)

branch: master
commit c4505fed538455a3637a293f10655d31c57ecff7
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    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 ++++++++++++
 lisp/textmodes/emacs-authors-mode.el | 17 ++++-------------
 lisp/textmodes/emacs-news-mode.el    |  4 +++-
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 1cce97cdb1..bd7c3c82f9 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
diff --git a/lisp/textmodes/emacs-authors-mode.el 
b/lisp/textmodes/emacs-authors-mode.el
index ffb713fd68..af78ab605e 100644
--- a/lisp/textmodes/emacs-authors-mode.el
+++ b/lisp/textmodes/emacs-authors-mode.el
@@ -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")
diff --git a/lisp/textmodes/emacs-news-mode.el 
b/lisp/textmodes/emacs-news-mode.el
index 9afa7ead98..022e17c934 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -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"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]