From: Andy Wingo <wingo-wEGTBA9jqPzQT0dZR+AlfA@public.gmane.org>
To: "Jose A. Ortega Ruiz" <jao-mXXj517/zsQ@public.gmane.org>
Cc: guix-devel-mXXj517/zsQ@public.gmane.org,
geiser-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
Subject: Re: geiser-xref-callers does not seem to work
Date: Tue, 30 Jan 2018 09:09:37 +0100 [thread overview]
Message-ID: <87tvv34vjy.fsf@igalia.com> (raw)
In-Reply-To: <87d11sblir.fsf@imladris> (Jose A. Ortega Ruiz's message of "Mon, 29 Jan 2018 18:52:12 +0100")
On Mon 29 Jan 2018 18:52, "Jose A. Ortega Ruiz" <jao-mXXj517/zsQ@public.gmane.org> writes:
> i've figured out how to find the filename for a procedure, but i'm
> missing what is probably the easier part: give the latter, how do i get
> hold of the module object?
On the one side there's no 100% reliable way. E.g. some files don't
declare what module they're in, and so if they are loaded (e.g. via
"include") from within some other module, then they inherit the current
module from the caller.
However there is the very common case in which each file defines a
module -- there, I would actually go about this in the other way. Walk
the module tree and record source file names that map to modules.
However like source-procedures, probably Guile should bake this facility
into (system xref). Anyway here is a procedure that will do it:
;; Return hash table mapping filename to list of modules defined in that
;; file.
(define (compute-source->module-mapping)
(let ((ret (make-hash-table)))
(define (record-module m)
(let ((f (module-filename m)))
(hash-set! ret f (cons m (hash-ref ret f '())))))
(define (visit-module m)
(record-module m)
(hash-for-each (lambda (k v) (visit-module v))
(module-submodules m)))
(visit-module (resolve-module '() #f))
ret))
Cheers,
Andy
next prev parent reply other threads:[~2018-01-30 8:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-16 7:55 geiser-xref-callers does not seem to work Chris Marusich
2017-12-16 8:38 ` Chris Marusich
[not found] ` <87y3m3hxts.fsf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-16 18:45 ` Jose A. Ortega Ruiz
2017-12-18 9:34 ` Andy Wingo
2017-12-19 7:47 ` Chris Marusich
[not found] ` <87shc8qt0p.fsf-wEGTBA9jqPzQT0dZR+AlfA@public.gmane.org>
2018-01-27 16:41 ` Jose A. Ortega Ruiz
2018-01-29 8:53 ` Andy Wingo
[not found] ` <87mv0x59n3.fsf-wEGTBA9jqPzQT0dZR+AlfA@public.gmane.org>
2018-01-29 17:52 ` Jose A. Ortega Ruiz
2018-01-30 8:09 ` Andy Wingo [this message]
2018-01-30 22:55 ` [Geiser-users] " Jose A. Ortega Ruiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tvv34vjy.fsf@igalia.com \
--to=wingo-wegtba9jqpzqt0dzr+alfa@public.gmane.org \
--cc=geiser-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org \
--cc=guix-devel-mXXj517/zsQ@public.gmane.org \
--cc=jao-mXXj517/zsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.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).