New major mode with font-locking for etc/AUTHORS
* lisp/textmodes/etc-authors-mode.el: New file. (Bug#50674) * etc/AUTHORS (mode): Add "mode: etc-authors" to local variables. * admin/authors.el (authors): Add "mode: etc-authors" to local variables of the generated AUTHORS file.
This commit is contained in:
parent
e4a9aa940b
commit
7b62ea95c9
4 changed files with 138 additions and 1 deletions
|
@ -1676,7 +1676,7 @@ list of their contributions.\n")
|
|||
(insert "\n "))
|
||||
(insert " " file))
|
||||
(insert "\n")))))
|
||||
(insert "\nLocal" " Variables:\ncoding: "
|
||||
(insert "\nLocal" " Variables:\nmode: etc-authors\ncoding: "
|
||||
(symbol-name authors-coding-system) "\nEnd:\n")
|
||||
(message "Generating buffer %s... done" buffer-name)
|
||||
(unless noninteractive
|
||||
|
|
|
@ -5521,5 +5521,6 @@ Zoran Milojevic: changed avoid.el
|
|||
উৎসব রায়: changed quail/indian.el
|
||||
|
||||
Local Variables:
|
||||
mode: etc-authors
|
||||
coding: utf-8
|
||||
End:
|
||||
|
|
5
etc/NEWS
5
etc/NEWS
|
@ -3080,6 +3080,11 @@ similar to prefix arguments, but are more flexible and discoverable.
|
|||
It's a library to create, query, navigate and display hierarchical
|
||||
structures.
|
||||
|
||||
---
|
||||
** New major mode for displaying the "etc/AUTHORS" file.
|
||||
This new 'etc-authors-mode' provides font-locking for displaying the
|
||||
"etc/AUTHORS" file from the Emacs distribution, and not much else.
|
||||
|
||||
|
||||
* Incompatible Editing Changes in Emacs 28.1
|
||||
|
||||
|
|
131
lisp/textmodes/etc-authors-mode.el
Normal file
131
lisp/textmodes/etc-authors-mode.el
Normal file
|
@ -0,0 +1,131 @@
|
|||
;;; 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 from 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"
|
||||
:group 'internal)
|
||||
|
||||
(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")
|
||||
|
||||
(defconst etc-authors--author-re
|
||||
(rx bol (group (not (any blank "\n")) (+? (not (any ":" "\n")))) ":")
|
||||
"Regexp matching an author in \"etc/AUTHORS\".")
|
||||
|
||||
(defvar etc-authors-mode-font-lock-keywords
|
||||
`((,etc-authors--author-re
|
||||
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)))))
|
||||
|
||||
(defun etc-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."
|
||||
(interactive "p" etc-authors-mode)
|
||||
(if (< 0 arg)
|
||||
(progn
|
||||
(when (looking-at etc-authors--author-re)
|
||||
(forward-line 1))
|
||||
(re-search-forward etc-authors--author-re nil t arg))
|
||||
(when (looking-at etc-authors--author-re)
|
||||
(forward-line -1))
|
||||
(re-search-backward etc-authors--author-re nil t (abs arg)))
|
||||
(goto-char (line-beginning-position)))
|
||||
|
||||
(defun etc-authors-prev-author (&optional arg)
|
||||
"Move point to the previous author in \"etc/AUTHORS\".
|
||||
With a prefix arg ARG, move point that many authors backward."
|
||||
(interactive "p" etc-authors-mode)
|
||||
(etc-authors-next-author (- arg)))
|
||||
|
||||
(defvar etc-authors-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map "n" #'etc-authors-next-author)
|
||||
(define-key map "p" #'etc-authors-prev-author)
|
||||
map)
|
||||
"Keymap for `etc-authors-mode'.")
|
||||
|
||||
;;;###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
|
Loading…
Add table
Reference in a new issue