From 6d61d6018c00fd952937966a8cadfd1e7c102efa Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 15 Sep 2022 11:27:57 +0200 Subject: [PATCH] Add rudimentary font-locking to edit-abbrevs-mode * lisp/abbrev.el (abbrev-table-name): New face. (edit-abbrevs-mode-font-lock-keywords): New defvar. (edit-abbrevs-mode): Support font-locking. --- etc/NEWS | 5 +++++ lisp/abbrev.el | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index decaff7fe6f..c88af4e90cf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2444,6 +2444,11 @@ remote host are shown. Alternatively, the user option *** 'outlineify-sticky' command is renamed to 'allout-outlinify-sticky'. The old name is still available as an obsolete function alias. +--- +*** 'edit-abbrevs' now uses font-locking. +The new face 'abbrev-table-name' is used to display the abbrev table +name. + * New Modes and Packages in Emacs 29.1 diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 718938df0cb..a4f0196a789 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -1,7 +1,6 @@ ;;; abbrev.el --- abbrev mode commands for Emacs -*- lexical-binding: t -*- -;; Copyright (C) 1985-1987, 1992, 2001-2022 Free Software Foundation, -;; Inc. +;; Copyright (C) 1985-2022 Free Software Foundation, Inc. ;; Maintainer: emacs-devel@gnu.org ;; Keywords: abbrev convenience @@ -1220,13 +1219,28 @@ SORTFUN is passed to `sort' to change the default ordering." (sort entries (lambda (x y) (funcall sortfun (nth 2 x) (nth 2 y))))))) +(defface abbrev-table-name + '((t :inherit font-lock-function-name-face)) + "Face used for displaying the abbrev table name in `edit-abbrev-mode'." + :version "29.1") + +(defvar edit-abbrevs-mode-font-lock-keywords + `((,(rx bol "(" + ;; lisp-mode-symbol-regexp + (regexp "\\(?:\\sw\\|\\s_\\|\\\\.\\)+") + ")" eol) + 0 'abbrev-table-name))) + ;; Keep it after define-abbrev-table, since define-derived-mode uses ;; define-abbrev-table. (define-derived-mode edit-abbrevs-mode fundamental-mode "Edit-Abbrevs" "Major mode for editing the list of abbrev definitions. This mode is for editing abbrevs in a buffer prepared by `edit-abbrevs', which see." - :interactive nil) + :interactive nil + (setq-local font-lock-defaults + '(edit-abbrevs-mode-font-lock-keywords nil nil ((?_ . "w")))) + (setq font-lock-multiline nil)) (defun abbrev--possibly-save (query &optional arg) ;; Query mode. -- 2.39.2