1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| | ;;; etc-authors-mode.el --- font-locking for etc/AUTHORS -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Free Software Foundation, Inc.
;; Author: Stefan Kangas <stefan@marxist.se>
;; Keywords: internal
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Major mode to display the etc/AUTHORS file in the Emacs
;; distribution. Provides some basic font locking and not much else.
;;; Code:
(defgroup etc-authors-mode nil
"Display the \"etc/AUTHORS\" file from the Emacs distribution."
:version "28.1")
(defface etc-authors-default '((t :inherit variable-pitch))
"Default face used to display the \"etc/AUTHORS\" file.
See also `etc-authors-mode'."
:version "28.1")
(defface etc-authors-author '((((class color) (min-colors 88) (background light))
:foreground "midnight blue"
:weight bold :height 1.05
:inherit variable-pitch)
(((class color) (min-colors 88) (background dark))
:foreground "cyan"
:weight bold :height 1.05
:inherit variable-pitch)
(((supports :weight bold) (supports :height 1.05))
:weight bold :height 1.05
:inherit variable-pitch)
(((supports :weight bold))
:weight bold :inherit variable-pitch)
(t :inherit variable-pitch))
"Face used for the author in the \"etc/AUTHORS\" file.
See also `etc-authors-mode'."
:version "28.1")
(defface etc-authors-descriptor '((((class color) (min-colors 88) (background light))
:foreground "sienna" :inherit variable-pitch)
(((class color) (min-colors 88) (background dark))
:foreground "peru" :inherit variable-pitch)
(t :inherit variable-pitch))
"Face used for the description text in the \"etc/AUTHORS\" file.
See also `etc-authors-mode'."
:version "28.1")
(defface etc-authors-other-files '((t :inherit etc-authors-descriptor))
"Face used for the \"other files\" text in the \"etc/AUTHORS\" file.
See also `etc-authors-mode'."
:version "28.1")
(defvar etc-authors-mode-font-lock-keywords
`((,(rx bol (group (not (any blank "\n")) (+? (not (any ":" "\n")))) ":")
1 'etc-authors-author)
(,(rx (or "wrote"
(seq (? "and ") (or "co-wrote" "changed"))))
0 'etc-authors-descriptor)
(,(rx "and " (+ digit) " other files")
0 'etc-authors-other-files)
(,(rx bol (not space) (+ not-newline) eol)
0 'etc-authors-default)))
(defun etc-authors-mode--hide-local-variables ()
"Hide local variables in \"etc/AUTHORS\". Used by `etc-authors-mode'."
(narrow-to-region (point-min)
(save-excursion
(goto-char (point-min))
(if (re-search-forward "^Local Variables:$" nil t)
(progn (forward-line -1) (point))
(point-max)))))
;;;###autoload
(define-derived-mode etc-authors-mode special-mode "Authors View"
"Major mode for viewing \"etc/AUTHORS\" from the Emacs distribution.
Provides some basic font locking and not much else."
(setq-local font-lock-defaults
'(etc-authors-mode-font-lock-keywords nil nil ((?_ . "w"))))
(setq font-lock-multiline nil)
(etc-authors-mode--hide-local-variables))
(provide 'etc-authors-mode)
;;; etc-authors-mode.el ends here
|