* a property "definition-type" would help find macro-defined tests
@ 2024-12-21 16:53 Stephen Gildea
2024-12-22 17:12 ` Richard Lawrence
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Gildea @ 2024-12-21 16:53 UTC (permalink / raw)
To: emacs-devel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: a property "definition-type" would help find macro-defined tests
2024-12-21 16:53 a property "definition-type" would help find macro-defined tests Stephen Gildea
@ 2024-12-22 17:12 ` Richard Lawrence
0 siblings, 0 replies; 2+ messages in thread
From: Richard Lawrence @ 2024-12-22 17:12 UTC (permalink / raw)
To: Stephen Gildea, emacs-devel
Stephen Gildea <stepheng+emacs@gildea.com> writes:
> 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.
> ...
> Does this seem like a generally useful addition?
As someone who's recently written a macro to define a bunch of tests,
and was then mildly frustrated that e.g.
ert-results-pop-to-should-forms-for-test-at-point didn't even come close
to finding the definitions, something like this sounds useful to me!
I wonder if there isn't already some better way to do this, though, that
find-function-search-for-symbol could make use of. I got curious and
briefly went down a rabbit hole looking for one, since there are
functions like `symbol-file' and the intriguing `symbol-with-pos-pos'.
The latter extracts a position from a mysterious-to-me entity called a
"symbol with position". Perhaps there's *already* a standard way to tag
a symbol with a position in a source file somehow, and what's needed is
to encourage macro writers to use it, and to adjust the find-function*
functions to look for it? Someone who knows more than me about Emacs
internals could shed more light here...but anyway, if there isn't, I
like the idea!
Best,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-22 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-21 16:53 a property "definition-type" would help find macro-defined tests Stephen Gildea
2024-12-22 17:12 ` Richard Lawrence
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).