From: Eric Abrahamsen Date: Mon, 20 Feb 2023 01:01:41 +0000 (+0200) Subject: Help Elisp xref recognize defclass parent classes X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cac13e360547f95ec64d34f38003dfc7ff1a97ee;p=emacs.git Help Elisp xref recognize defclass parent classes * lisp/progmodes/elisp-mode.el (elisp--xref-infer-namespace): Handle defclass parents (bug#61640). * test/lisp/progmodes/elisp-mode-tests.el (elisp-mode-infer-namespace): New case in the test. --- 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 @@ namespace but with lower confidence." 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) diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el index 57b39a49801..5b6ef88dceb 100644 --- a/test/lisp/progmodes/elisp-mode-tests.el +++ b/test/lisp/progmodes/elisp-mode-tests.el @@ -1003,6 +1003,11 @@ evaluation of BODY." (should (equal (elisp--xref-infer-namespace p5) 'variable)) (should (equal (elisp--xref-infer-namespace p6) 'function))) + (elisp-mode-test--with-buffer + (concat "(defclass child-class ({p1}parent-1 {p2}parent-2))\n") + (should (equal (elisp--xref-infer-namespace p1) 'function)) + (should (equal (elisp--xref-infer-namespace p2) 'function))) + (elisp-mode-test--with-buffer (concat "(require '{p1}alpha)\n" "(fboundp '{p2}beta)\n"