Subject: 30.0.50; Help Elisp xref recognize defclass parent classes
From: Eric Abrahamsen <[email-masked]>
To: [email-masked]
Date: Sun, 19 Feb 2023 14:08:42 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

In a form such as this:

(defclass ebdb-field-id (ebdb-field-labeled ebdb-field-obfuscated ebdb-field-user)
  ((label-list :initform 'ebdb-id-label-list)
   ...
   ))

All the symbols in

(ebdb-field-labeled ebdb-field-obfuscated ebdb-field-user)

should be recognized by `elisp--xref-infer-namespace' as 'function.
Right now, this is treated like a function call (ie like '(function
variable variable)).

I can't promise that the attached patch is exactly the right thing, but
it ought to be pretty close.

Thanks,
Eric

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 1c339d08148..f7cd9e90926 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -943,6 +943,10 @@ elisp--xref-infer-namespace
                                  cl-defmethod cl-defgeneric)))
             ;; (defun FUNC (... IDENT
             'variable)
+           ((and (eql j 2)
+                 (eq j-head 'defclass))
+            ;; (defclass CLASS (... IDENT
+            'function)
            ((eq j-head 'cond)
             ;; (cond ... (... IDENT
             'variable)