[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Geiser-users] geiser-xref-callers does not seem to work

From: Jose A. Ortega Ruiz
Subject: Re: [Geiser-users] geiser-xref-callers does not seem to work
Date: Tue, 30 Jan 2018 23:55:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.91 (gnu/linux)

On Tue, Jan 30 2018, Andy Wingo wrote:

> On Mon 29 Jan 2018 18:52, "Jose A. Ortega Ruiz" <address@hidden> 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))

Thanks, this is working for me!  And replacing program-arities was
trivial given the new debug utilities.

Chris, as a result, xref is working for me too in the latest geiser in
git: please give it a try when you can, and thanks for your patience :)

Patriotism is a kind of religion; it is the egg from which wars are
hatched. -Guy de Maupassant, short story writer and novelist (1850-1893)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]