bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#64824: 30.0.50; define-error not fontified in font-lock mode


From: nealsid
Subject: bug#64824: 30.0.50; define-error not fontified in font-lock mode
Date: Sun, 23 Jul 2023 19:28:56 -0400

In a buffer with emacs-lisp-mode active, 'define-error' is not fontified
by font-lock mode.  The keyword should be listed somewhere around line 360 in
emacs-lisp/lisp-mode.el.

Recipe:

- Start emacs
- Visit a file ending in .el
- Type: (define-error 'new-error "this is a new error")
- Wait for fontification to complete and notice it is not highlighted

In lisp-mode.el, there is a comment about constructs being updated
automatically from obarray, but I was not able to understand how this
happens, and thought maybe the comment is referring to symbols created
with those commands?

>From 39b0bfb5464ff59d11efb35d417bfb6b2b20c788 Mon Sep 17 00:00:00 2001
From: Neal Sidhwaney <nealsid@users.noreply.github.com>
Date: Sun, 23 Jul 2023 19:25:51 -0400
Subject: [PATCH] Add define-error to font lock keywords for emacs-lisp-mode

Also bump up test coverage for keywords to ensure they are fontified.
---
 lisp/emacs-lisp/lisp-mode.el            |  2 +-
 test/lisp/emacs-lisp/lisp-mode-tests.el | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 1990630608d..f1cacebb964 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -361,7 +361,7 @@ This will generate compile-time constants from BINDINGS."
                  "define-globalized-minor-mode" "define-skeleton"
                  "define-widget" "ert-deftest"))
      (el-vdefs '("defconst" "defcustom" "defvaralias" "defvar-local"
-                 "defface"))
+                 "defface" "define-error"))
      (el-tdefs '("defgroup" "deftheme"))
      (el-errs '("user-error"))
      ;; Common-Lisp constructs supported by EIEIO.  FIXME: namespace.
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el 
b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 3e906497020..5a2d1ed53a8 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -355,5 +355,29 @@ Expected initialization file: `%s'\"
   ;;   (should (equal (lisp-current-defun-name) "defblarg")))
   )
 
+(ert-deftest test-font-lock-keywords ()
+  "Keywords should be fontified in `font-lock-keyword-face`."
+  (with-temp-buffer
+    (emacs-lisp-mode)
+    (mapc (lambda (el-keyword)
+            (erase-buffer)
+            (insert (format "(%s some-symbol () \"hello\"" el-keyword))
+            (font-lock-ensure)
+            ;; Verify face property throughout the keyword
+            (let* ((begin (1+ (point-min)))
+                   (end (1- (+ begin (length el-keyword)))))
+              (mapc (lambda (pos)
+                      (message "%s %s" el-keyword pos)
+                      (should (equal (get-text-property pos 'face)
+                                     'font-lock-keyword-face)))
+                    (number-sequence begin end))))
+          '("defsubst" "cl-defsubst" "define-inline"
+            "define-advice" "defadvice" "defalias"
+            "define-derived-mode" "define-minor-mode"
+            "define-generic-mode" "define-global-minor-mode"
+            "define-globalized-minor-mode" "define-skeleton"
+            "define-widget" "ert-deftest" "defconst" "defcustom"
+            "defvaralias" "defvar-local" "defface" "define-error"))))
+
 (provide 'lisp-mode-tests)
 ;;; lisp-mode-tests.el ends here
-- 
2.41.0

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.17.8) of 2023-07-15 built on archlinux
Repository revision: c5fa58cbc4a33a0a65494b9ab2e35d4f30ab849b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-libotf --without-m17n-flt --without-gconf
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=gtk3
 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG
RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP
X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: C.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  which-function-mode: t
  shell-dirtrack-mode: t
  comint-fontify-input-mode: t
  server-mode: t
  global-auto-revert-mode: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/nealsid/.emacs.d/elpa/transient-20230501.1034/transient hides 
/usr/share/emacs/30.0.50/lisp/transient

Features:
(reveal smtpmail mailalias mailclient textsec uni-scripts idna-mapping
ucs-normalize uni-confusable textsec-check shadow sort mail-extr
emacsbug make-mode descr-text dabbrev erts-mode jka-compr apropos
cc-langs grep mode-local re-builder mule-util display-line-numbers ffap
cus-edit cus-start wid-edit cl-print shortdoc cl-indent inf-lisp
help-fns radix-tree paredit magit-gitignore pcmpl-git misearch
multi-isearch vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view
vc bug-reference pcmpl-unix sh-script smie treesit executable ert pp
ewoc debug backtrace sqlite flymake-proc flymake project cl compile
noutline outline lisp-mnt thingatpt find-func vc-git vc-dispatcher
magit-extras face-remap magit-submodule magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit magit-repos magit-apply magit-wip magit-log
magit-diff smerge-mode diff diff-mode easy-mmode git-commit log-edit
pcvs-util add-log magit-core magit-autorevert magit-margin
magit-transient magit-process with-editor magit-mode transient edmacro
kmacro magit-git magit-base magit-section format-spec cursor-sensor crm
dash compat compat-29 dired-aux mm-archive message sendmail yank-media
dired dired-loaddefs rfc822 mml mml-sec epa derived gnus-util
text-property-search time-date mailabbrev gmm-utils mailheader mm-decode
mm-bodies mm-encode mail-utils which-func imenu files-x shell pcomplete
comint ansi-osc ansi-color ring deeper-blue-theme server clarity-theme
autorevert filenotify cus-load cc-mode cc-fonts cc-guess cc-menus
cc-cmds windmove cc-styles cc-align cc-engine cc-vars cc-defs gnutls
network-stream url-cache url-http url-auth mail-parse rfc2231 rfc2047
rfc2045 mm-util ietf-drums mail-prsvr url-gw nsm puny comp comp-cstr
warnings icons rx cl-extra help-mode epg rfc6068 epg-config finder-inf
ido color-theme-modern-autoloads dirtree-autoloads
elisp-autofmt-autoloads flycheck-autoloads ggtags-autoloads pcase
paredit-autoloads pkg-info-autoloads epl-autoloads tree-mode-autoloads
windata-autoloads info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs password-cache json subr-x map byte-opt gv
bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo gtk
x-toolkit xinput2 x multi-tty move-toolbar make-network-process
native-compile emacs)

Memory information:
((conses 16 2411138 372988) (symbols 48 43051 24)
 (strings 32 390907 16216) (string-bytes 1 13976841)
 (vectors 16 117983) (vector-slots 8 2802866 272351)
 (floats 8 232 9407) (intervals 56 238397 3159) (buffers 984 77))

reply via email to

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