[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
a property "definition-type" would help find macro-defined tests
From: |
Stephen Gildea |
Subject: |
a property "definition-type" would help find macro-defined tests |
Date: |
Sat, 21 Dec 2024 08:53:47 -0800 |
The find-function feature of Emacs cannot find "ert-deftest"
forms generated by a macro. (The find-func library does look
through macro expansions in its search, but the search is too
specific to find "ert-deftest" forms.)
Function "find-function-search-for-symbol" is passed a "type"
for the thing to look for, but that type is based on the
caller's idea of what the thing is. We need a way to say what
the definer thinks the definition looks like.
The existing property "definition-name" isn't helpful here
because often the call to a test-defining macro contains test
data only.
I propose a new property, "definition-type", that a macro could
put on a symbol. If present, "find-function-search-for-symbol"
would use that type instead of the passed-in type.
With this enhancement, any subsystem that uses a macro to
define objects could
- have the macro set property "definition-type" on the
symbols it defines, and
- add an entry to "find-function-regexp-alist" saying how to
find the new type.
Concretely, here's the code change I'm proposing:
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index f3ddf9f81c9..df1eb8deae0 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -409,6 +409,8 @@ find-function-search-for-symbol
;; Some functions are defined as part of the construct
;; that defines something else.
(while (and (symbolp symbol) (get symbol 'definition-name))
(setq symbol (get symbol 'definition-name)))
+ (setq type (or (get symbol 'definition-type)
+ type))
(if (string-match "\\`src/\\(.*\\.\\(c\\|m\\)\\)\\'" library)
(find-function-C-source symbol (match-string 1 library) type)
Does this seem like a generally useful addition?
< Stephen
- a property "definition-type" would help find macro-defined tests,
Stephen Gildea <=