?- setof(M,current_module(M),Modules). Modules = [ansi_term,apply,apply_macros,base32,dcg_basics,editline,error|...].
Sadly, this is not at all about getting the module of the currently executing code.
That's something that is just missing. Something like
would be useful to get at the qualifier which may have to be passed to predicates in other modules.
Do not be confused
Note that there is also a
current_module(?Module, ?File) : True if Module is a module loaded from File.
which is a deprecated version of