aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/textmodes
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/textmodes')
-rw-r--r--lisp/textmodes/emacs-authors-mode.el145
-rw-r--r--lisp/textmodes/emacs-news-mode.el13
-rw-r--r--lisp/textmodes/etc-authors-mode.el133
3 files changed, 154 insertions, 137 deletions
diff --git a/lisp/textmodes/emacs-authors-mode.el b/lisp/textmodes/emacs-authors-mode.el
new file mode 100644
index 00000000000..af78ab605e9
--- /dev/null
+++ b/lisp/textmodes/emacs-authors-mode.el
@@ -0,0 +1,145 @@
1;;; emacs-authors-mode.el --- font-locking for etc/AUTHORS -*- lexical-binding: t -*-
2
3;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
4
5;; Author: Stefan Kangas <stefan@marxist.se>
6;; Keywords: internal
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; Major mode to display the etc/AUTHORS file from the Emacs
26;; distribution. Provides some basic font locking and not much else.
27
28;;; Code:
29
30(require 'subr-x) ; `emacs-etc--hide-local-variables'
31
32(defgroup emacs-authors-mode nil
33 "Display the \"etc/AUTHORS\" file from the Emacs distribution."
34 :version "29.1"
35 :group 'internal)
36
37(defface emacs-authors-default
38 '((t :inherit variable-pitch))
39 "Default face used to display the \"etc/AUTHORS\" file.
40See also `emacs-authors-mode'."
41 :version "29.1")
42
43(defface emacs-authors-author
44 '((((class color) (min-colors 88) (background light))
45 :foreground "midnight blue"
46 :weight bold :height 1.05
47 :inherit variable-pitch)
48 (((class color) (min-colors 88) (background dark))
49 :foreground "cyan"
50 :weight bold :height 1.05
51 :inherit variable-pitch)
52 (((supports :weight bold) (supports :height 1.05))
53 :weight bold :height 1.05
54 :inherit variable-pitch)
55 (((supports :weight bold))
56 :weight bold :inherit variable-pitch)
57 (t :inherit variable-pitch))
58 "Face used for the author in the \"etc/AUTHORS\" file.
59See also `emacs-authors-mode'."
60 :version "29.1")
61
62(defface emacs-authors-descriptor
63 '((((class color) (min-colors 88) (background light))
64 :foreground "sienna" :inherit variable-pitch)
65 (((class color) (min-colors 88) (background dark))
66 :foreground "peru" :inherit variable-pitch)
67 (t :inherit variable-pitch))
68 "Face used for the description text in the \"etc/AUTHORS\" file.
69See also `emacs-authors-mode'."
70 :version "29.1")
71
72(defface emacs-authors-other-files
73 '((t :inherit emacs-authors-descriptor))
74 "Face used for the \"other files\" text in the \"etc/AUTHORS\" file.
75See also `emacs-authors-mode'."
76 :version "29.1")
77
78(defconst emacs-authors--author-re
79 (rx bol (group (not (any blank "\n")) (+? (not (any ":" "\n")))) ":")
80 "Regexp matching an author in \"etc/AUTHORS\".")
81
82(defvar emacs-authors-mode-font-lock-keywords
83 `((,emacs-authors--author-re
84 1 'emacs-authors-author)
85 (,(rx (or "wrote"
86 (seq (? "and ") (or "co-wrote" "changed"))))
87 0 'emacs-authors-descriptor)
88 (,(rx "and " (+ digit) " other files")
89 0 'emacs-authors-other-files)
90 (,(rx bol (not space) (+ not-newline) eol)
91 0 'emacs-authors-default)))
92
93(defun emacs-authors-next-author (&optional arg)
94 "Move point to the next author in \"etc/AUTHORS\".
95With a prefix arg ARG, move point that many authors forward."
96 (interactive "p" emacs-authors-mode)
97 (if (< 0 arg)
98 (progn
99 (when (looking-at emacs-authors--author-re)
100 (forward-line 1))
101 (re-search-forward emacs-authors--author-re nil t arg))
102 (when (looking-at emacs-authors--author-re)
103 (forward-line -1))
104 (re-search-backward emacs-authors--author-re nil t (abs arg)))
105 (goto-char (line-beginning-position)))
106
107(defun emacs-authors-prev-author (&optional arg)
108 "Move point to the previous author in \"etc/AUTHORS\".
109With a prefix arg ARG, move point that many authors backward."
110 (interactive "p" emacs-authors-mode)
111 (emacs-authors-next-author (- arg)))
112
113(defvar emacs-authors-imenu-generic-expression
114 `((nil ,(rx bol (group (+ (not ":"))) ": "
115 (or "wrote" "co-wrote" "changed")
116 " ")
117 1)))
118
119(define-obsolete-variable-alias 'etc-authors-mode-map 'emacs-authors-mode-map "29.1")
120(defvar-keymap emacs-authors-mode-map
121 :doc "Keymap for `emacs-authors-mode'."
122 "n" #'emacs-authors-next-author
123 "p" #'emacs-authors-prev-author)
124
125;;;###autoload
126(define-derived-mode emacs-authors-mode special-mode "Authors View"
127 "Major mode for viewing \"etc/AUTHORS\" from the Emacs distribution.
128Provides some basic font locking and not much else."
129 (setq-local font-lock-defaults
130 '(emacs-authors-mode-font-lock-keywords nil nil ((?_ . "w"))))
131 (setq font-lock-multiline nil)
132 (setq imenu-generic-expression emacs-authors-imenu-generic-expression)
133 (emacs-etc--hide-local-variables))
134
135(define-obsolete-face-alias 'etc-authors-default 'emacs-authors-default "29.1")
136(define-obsolete-face-alias 'etc-authors-author 'emacs-authors-author "29.1")
137(define-obsolete-face-alias 'etc-authors-descriptor 'emacs-authors-descriptor "29.1")
138(define-obsolete-face-alias 'etc-authors-other-files 'emacs-authors-other-files "29.1")
139(define-obsolete-function-alias 'etc-authors-next-author #'emacs-authors-next-author "29.1")
140(define-obsolete-function-alias 'etc-authors-prev-author #'emacs-authors-prev-author "29.1")
141;;;###autoload
142(define-obsolete-function-alias 'etc-authors-mode #'emacs-authors-mode "29.1")
143
144(provide 'emacs-authors-mode)
145;;; emacs-authors-mode.el ends here
diff --git a/lisp/textmodes/emacs-news-mode.el b/lisp/textmodes/emacs-news-mode.el
index e6e1f037284..022e17c9343 100644
--- a/lisp/textmodes/emacs-news-mode.el
+++ b/lisp/textmodes/emacs-news-mode.el
@@ -25,6 +25,7 @@
25 25
26(eval-when-compile (require 'cl-lib)) 26(eval-when-compile (require 'cl-lib))
27(require 'outline) 27(require 'outline)
28(require 'subr-x) ; `emacs-etc--hide-local-variables'
28 29
29(defgroup emacs-news-mode nil 30(defgroup emacs-news-mode nil
30 "Major mode for editing and viewing the Emacs NEWS file." 31 "Major mode for editing and viewing the Emacs NEWS file."
@@ -59,9 +60,12 @@
59 "C-x C-q" #'emacs-news-view-mode 60 "C-x C-q" #'emacs-news-view-mode
60 "<remap> <open-line>" #'emacs-news-open-line) 61 "<remap> <open-line>" #'emacs-news-open-line)
61 62
62(defvar-keymap emacs-news-view-mode-map 63(defvar emacs-news-view-mode-map
63 :parent emacs-news-common-map 64 ;; This is defined this way instead of inheriting because we're
64 "C-x C-q" #'emacs-news-mode) 65 ;; deriving the mode from `special-mode' and want the keys from there.
66 (let ((map (copy-keymap emacs-news-common-map)))
67 (keymap-set map "C-x C-q" #'emacs-news-mode)
68 map))
65 69
66(defvar emacs-news-mode-font-lock-keywords 70(defvar emacs-news-mode-font-lock-keywords
67 `(("^---$" 0 'emacs-news-does-not-need-documentation) 71 `(("^---$" 0 'emacs-news-does-not-need-documentation)
@@ -73,7 +77,8 @@
73 outline-minor-mode-cycle t 77 outline-minor-mode-cycle t
74 outline-level (lambda () (length (match-string 2))) 78 outline-level (lambda () (length (match-string 2)))
75 outline-minor-mode-highlight 'append) 79 outline-minor-mode-highlight 'append)
76 (outline-minor-mode)) 80 (outline-minor-mode)
81 (emacs-etc--hide-local-variables))
77 82
78;;;###autoload 83;;;###autoload
79(define-derived-mode emacs-news-mode text-mode "NEWS" 84(define-derived-mode emacs-news-mode text-mode "NEWS"
diff --git a/lisp/textmodes/etc-authors-mode.el b/lisp/textmodes/etc-authors-mode.el
deleted file mode 100644
index 7eabdd4c2b8..00000000000
--- a/lisp/textmodes/etc-authors-mode.el
+++ /dev/null
@@ -1,133 +0,0 @@
1;;; etc-authors-mode.el --- font-locking for etc/AUTHORS -*- lexical-binding: t -*-
2
3;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
4
5;; Author: Stefan Kangas <stefan@marxist.se>
6;; Keywords: internal
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22
23;;; Commentary:
24
25;; Major mode to display the etc/AUTHORS file from the Emacs
26;; distribution. Provides some basic font locking and not much else.
27
28;;; Code:
29
30(defgroup etc-authors-mode nil
31 "Display the \"etc/AUTHORS\" file from the Emacs distribution."
32 :version "28.1"
33 :group 'internal)
34
35(defface etc-authors-default '((t :inherit variable-pitch))
36 "Default face used to display the \"etc/AUTHORS\" file.
37See also `etc-authors-mode'."
38 :version "28.1")
39
40(defface etc-authors-author '((((class color) (min-colors 88) (background light))
41 :foreground "midnight blue"
42 :weight bold :height 1.05
43 :inherit variable-pitch)
44 (((class color) (min-colors 88) (background dark))
45 :foreground "cyan"
46 :weight bold :height 1.05
47 :inherit variable-pitch)
48 (((supports :weight bold) (supports :height 1.05))
49 :weight bold :height 1.05
50 :inherit variable-pitch)
51 (((supports :weight bold))
52 :weight bold :inherit variable-pitch)
53 (t :inherit variable-pitch))
54 "Face used for the author in the \"etc/AUTHORS\" file.
55See also `etc-authors-mode'."
56 :version "28.1")
57
58(defface etc-authors-descriptor '((((class color) (min-colors 88) (background light))
59 :foreground "sienna" :inherit variable-pitch)
60 (((class color) (min-colors 88) (background dark))
61 :foreground "peru" :inherit variable-pitch)
62 (t :inherit variable-pitch))
63 "Face used for the description text in the \"etc/AUTHORS\" file.
64See also `etc-authors-mode'."
65 :version "28.1")
66
67(defface etc-authors-other-files '((t :inherit etc-authors-descriptor))
68 "Face used for the \"other files\" text in the \"etc/AUTHORS\" file.
69See also `etc-authors-mode'."
70 :version "28.1")
71
72(defconst etc-authors--author-re
73 (rx bol (group (not (any blank "\n")) (+? (not (any ":" "\n")))) ":")
74 "Regexp matching an author in \"etc/AUTHORS\".")
75
76(defvar etc-authors-mode-font-lock-keywords
77 `((,etc-authors--author-re
78 1 'etc-authors-author)
79 (,(rx (or "wrote"
80 (seq (? "and ") (or "co-wrote" "changed"))))
81 0 'etc-authors-descriptor)
82 (,(rx "and " (+ digit) " other files")
83 0 'etc-authors-other-files)
84 (,(rx bol (not space) (+ not-newline) eol)
85 0 'etc-authors-default)))
86
87(defun etc-authors-mode--hide-local-variables ()
88 "Hide local variables in \"etc/AUTHORS\". Used by `etc-authors-mode'."
89 (narrow-to-region (point-min)
90 (save-excursion
91 (goto-char (point-min))
92 ;; Obfuscate to avoid this being interpreted
93 ;; as a local variable section itself.
94 (if (re-search-forward "^Local\sVariables:$" nil t)
95 (progn (forward-line -1) (point))
96 (point-max)))))
97
98(defun etc-authors-next-author (&optional arg)
99 "Move point to the next author in \"etc/AUTHORS\".
100With a prefix arg ARG, move point that many authors forward."
101 (interactive "p" etc-authors-mode)
102 (if (< 0 arg)
103 (progn
104 (when (looking-at etc-authors--author-re)
105 (forward-line 1))
106 (re-search-forward etc-authors--author-re nil t arg))
107 (when (looking-at etc-authors--author-re)
108 (forward-line -1))
109 (re-search-backward etc-authors--author-re nil t (abs arg)))
110 (goto-char (line-beginning-position)))
111
112(defun etc-authors-prev-author (&optional arg)
113 "Move point to the previous author in \"etc/AUTHORS\".
114With a prefix arg ARG, move point that many authors backward."
115 (interactive "p" etc-authors-mode)
116 (etc-authors-next-author (- arg)))
117
118(defvar-keymap etc-authors-mode-map
119 :doc "Keymap for `etc-authors-mode'."
120 "n" #'etc-authors-next-author
121 "p" #'etc-authors-prev-author)
122
123;;;###autoload
124(define-derived-mode etc-authors-mode special-mode "Authors View"
125 "Major mode for viewing \"etc/AUTHORS\" from the Emacs distribution.
126Provides some basic font locking and not much else."
127 (setq-local font-lock-defaults
128 '(etc-authors-mode-font-lock-keywords nil nil ((?_ . "w"))))
129 (setq font-lock-multiline nil)
130 (etc-authors-mode--hide-local-variables))
131
132(provide 'etc-authors-mode)
133;;; etc-authors-mode.el ends here