From 24dcda13ceb5c31159abb174e62efa9b45e672c2 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 18 Jan 2025 18:43:50 +0100 Subject: [PATCH] scope.el,elisp-mode.el: Recognize some more definition types --- lisp/emacs-lisp/scope.el | 34 +++++++++++++++++++++++++++++++++- lisp/progmodes/elisp-mode.el | 6 ++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/scope.el b/lisp/emacs-lisp/scope.el index 970fc99f62c..87920831384 100644 --- a/lisp/emacs-lisp/scope.el +++ b/lisp/emacs-lisp/scope.el @@ -804,7 +804,39 @@ a (possibly empty) list of safe macros.") (prnt (cadr prnt-form)) (beg (scope-sym-pos prnt)) (bare (scope-sym-bare prnt))) - (funcall scope-callback 'widget-type beg (length (symbol-name bare)) nil)))) + (funcall scope-callback 'widget-type beg (length (symbol-name bare)) nil))) + ((define-error) + (when-let* ((name-form (car forms)) + ((memq (scope-sym-bare (car-safe name-form)) '(quote \`))) + (name (cadr name-form)) + (beg (scope-sym-pos name)) + (bare (scope-sym-bare name))) + (funcall scope-callback 'condition beg (length (symbol-name bare)) nil)) + (when-let* ((prnt-form (caddr forms)) + ((memq (scope-sym-bare (car-safe prnt-form)) '(quote \`)))) + (dolist (prnt (ensure-list (cadr prnt-form))) + (when-let* ((beg (scope-sym-pos prnt)) (bare (scope-sym-bare prnt))) + (funcall scope-callback 'condition beg (length (symbol-name bare)) nil))))) + ((provide-theme custom-declare-theme) + (when-let* ((name-form (car forms)) + ((memq (scope-sym-bare (car-safe name-form)) '(quote \`))) + (name (cadr name-form)) + (beg (scope-sym-pos name)) + (bare (scope-sym-bare name))) + (funcall scope-callback 'theme beg (length (symbol-name bare)) nil))) + ((defvaralias) + (when-let* ((new-form (car forms)) + ((memq (scope-sym-bare (car-safe new-form)) '(quote \`))) + (name (cadr new-form)) + (beg (scope-sym-pos name)) + (bare (scope-sym-bare name))) + (funcall scope-callback 'defvar beg (length (symbol-name bare)) nil)) + (when-let* ((base-form (cadr forms)) + ((memq (scope-sym-bare (car-safe base-form)) '(quote \`))) + (name (cadr base-form)) + (beg (scope-sym-pos name)) + (bare (scope-sym-bare name))) + (funcall scope-callback 'variable beg (length (symbol-name bare)) nil)))) (when (symbol-with-pos-p f) (funcall scope-callback 'function (symbol-with-pos-pos f) (length (symbol-name bare)) diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 83f5cf6d9a0..f2fd5722413 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -359,6 +359,10 @@ happens in interactive invocations." "Face for highlighting feature names in Emacs Lisp code." :group 'lisp) +(defface elisp-theme '((t :inherit font-lock-constant-face)) + "Face for highlighting custom theme names in Emacs Lisp code." + :group 'lisp) + (defface elisp-binding-variable '((t :slant italic :inherit font-lock-variable-name-face)) "Face for highlighting binding occurrences of variables in Emacs Lisp code." @@ -426,6 +430,7 @@ happens in interactive invocations." (special-form "Special form") (throw-tag "`throw'/`catch' tag") (feature "Feature") + (theme "Theme") (widget-type "Widget type") (type "Type") (group "Customization group") @@ -448,6 +453,7 @@ happens in interactive invocations." (special-form 'elisp-special-form) (throw-tag 'elisp-throw-tag) (feature 'elisp-feature) + (theme 'elisp-theme) (widget-type 'font-lock-type-face) (type 'font-lock-type-face) (group 'font-lock-type-face) -- 2.39.5