master 602cde31636: elisp-scope: Improve support for :inherit face specs (bug#81534)

Eshel Yaron via Mailing list for Emacs changes <[email protected]> Mon, 3 Aug 2026 15:25:23 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: master
commit 602cde316363dd1048c7718e9a9af6d78d3d0921
Author: Zach Shaftel <[email protected]>
Commit: Eshel Yaron <[email protected]>

    elisp-scope: Improve support for :inherit face specs (bug#81534)
    
    * lisp/emacs-lisp/elisp-scope.el (elisp-scope--match-spec-to-arg):
    Update to support lists of faces in :inherit.  Update analyzers for
    a few functions to use it.
    
    * test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el:
    Extra testing for lists of faces.
---
 lisp/emacs-lisp/elisp-scope.el                         | 13 +++++++++----
 .../elisp-mode-resources/semantic-highlighting.el      | 18 +++++++++++++++---
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/lisp/emacs-lisp/elisp-scope.el b/lisp/emacs-lisp/elisp-scope.el
index a81a7dfacaf..5286e682b5a 100644
--- a/lisp/emacs-lisp/elisp-scope.el
+++ b/lisp/emacs-lisp/elisp-scope.el
@@ -1818,7 +1818,10 @@ ARGS bound to the analyzed arguments."
 
 (elisp-scope-define-function-analyzer custom-declare-face (face spec doc &rest args)
   (elisp-scope-1 face '(symbol . defface))
-  (elisp-scope-1 spec '(repeat . (cons t . (plist (:inherit . (symbol . face))))))
+  (elisp-scope-1
+   spec
+   '(repeat . (cons t . (plist (:inherit . (or (symbol . face)
+                                               (repeat . (symbol . face))))))))
   (elisp-scope-1 doc)
   (while-let ((kw (car-safe args))
               (bkw (elisp-scope--sym-bare kw))
@@ -1831,7 +1834,7 @@ ARGS bound to the analyzed arguments."
 (elisp-scope-define-function-spec cl-typep (nil cl-type))
 
 (elisp-scope-define-function-spec pulse-momentary-highlight-region
-  (nil nil (symbol . face)))
+  (nil nil face))
 
 (elisp-scope--define-function-analyzer throw (&optional tag val) non-local-exit
   (elisp-scope-1 tag '(symbol . throw-tag))
@@ -2495,10 +2498,12 @@ ARGS bound to the analyzed arguments."
    (if (consp arg)
        (if (keywordp (elisp-scope--sym-bare (car arg)))
            ;; One face, given as a plist of face attributes.
-           '(plist (:inherit . (symbol . face)))
+           '(plist (:inherit . (or (symbol . face)
+                                   (repeat . (symbol . face)))))
          ;; Multiple faces.
          '(repeat . (or (symbol . face)
-                        (plist (:inherit . (symbol . face))))))
+                        (plist (:inherit . (or (symbol . face)
+                                               (repeat . (symbol . face))))))))
      '(symbol . face))
    arg))
 
diff --git a/test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el b/test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el
index 307ca49cc85..43aefb050a7 100644
--- a/test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el
+++ b/test/lisp/progmodes/elisp-mode-resources/semantic-highlighting.el
@@ -15,6 +15,16 @@
 ;;                  ^ elisp-bound-variable
   )
 
+(pulse-momentary-highlight-region (point) (point-max)
+;; ^ elisp-function
+;;                                 ^ elisp-function
+;;                                         ^ elisp-function
+                                  (or (and t '(bold success))
+;;                                             ^ elisp-face
+;;                                                  ^ elisp-face
+                                      'warning))
+;;                                     ^ elisp-face
+
 (add-face-text-property
 ;; ^ elisp-function
  (point) (mark)
@@ -163,10 +173,12 @@
 ;;                  ^ elisp-function
 
 (defface foobar
-  '((default :inherit font-lock-function-call-face)
+  '((default :inherit (font-lock-function-call-face error))
 ;;            ^ (elisp-constant font-lock-builtin-face)
-;;                    ^ elisp-face
-    (((background light)) :foreground "#00008b")
+;;                     ^ elisp-face
+;;                                                  ^ elisp-face
+    (((background light)) :foreground "#00008b" :inherit bold)
+;;                                                       ^ elisp-face
     (((background dark))  :foreground "#5c9cff"))
   "Face for highlighting symbol role names in Emacs Lisp code."
   :version "31.1")