it will give me a listing of all predicates accessible from that module’s context, including imports, not just those that actually belong to that module. Is there a way to just list the ones with mymodule as their module? Or, also good, a way to list all clauses defined in that module’s file (including e.g. user:portray clauses) without clauses defined elsewhere?
Similarly, is there any way to:
hook trace/1 onto all predicates defined in a specific module? mymodule:_ picks up imports, like I mentioned.
remove trace/1 wrappers from any predicates in a current module that are currently wrapped?
remove trace/1 wrappers from all predicates, like nospyall/0 does for spy points?
If I load the module and get a listing of it, I see only the predicates defined in the module, and no imported predicates (not even if I re-export them, as I’ve done here with append/3):
To list the content of the module mymodule, use one of the calls below.
?- mymodule:listing.
?- listing(mymodule:_).
But potato:listing gives me the same result as listing(potato:_).
I don’t know any good way to get all clauses from a certain file. But for a specific predicate, you can use clause/3 to enumerate all of its clauses, and use the returned clause reference with clause_property/2 to look up what file the clause was defined in. For example, to find all places where SWI defines goal_expansion/2 clauses:
You could use this to find all clauses from a certain file, by iterating over all predicates using current_predicate/2 and then checking where their clauses come from, but that’s not exactly nice or efficient…
Okay, that’s weird, because now I can’t get that behavior either! We’ll see if I remember what project I was working on when it happened, until then, thanks for the second pair of eyes