Re: [PATCH v2] .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable.

2020-10-27 Thread Miguel Ángel Arruga Vivas
Hi Maxim!

Maxim Cournoyer  writes:
> Thanks for your comments, they've already made this proposed change much
> better!

You did that, they only may have pointed somewhere, but the effort is
yours, so thank you again.

>> That cleanup seems to me responsibility of that .emacs maintainer
>> instead of something to take into account in .dir-locals. ;-)
>
> Indeed, it could be seen that way!  The good news is that it doesn't
> seem to cause any problems anyway, should they forget an entry for Guix
> there.

Cool, one thing less to worry then.

>> If there is some way this may happen, then this call is OK, but I'd try
>> to stay with a cheaper push unless it's really needed, as O(1) < O(n),
>> for almost every n. :-)
>
> The way I could easily trigger this was to open a dired buffer, and
> hitting 'g' to refresh its contents.

That usually is bind to revert-buffer, and they're being loaded again,
so you're right.  Was the definition for other modes intended?  I didn't
noticed because I copied directly the code onto scheme-mode sexp without
looking at the context, what a reviewer... ;-P

> I'll be sending a v3 with the fboundp woopsie above fixed.

I've taken a look to v3 and LGTM.  Even the answer to the question is
no, I wouldn't send another patch only for that hypothetical change.
Anybody can speak up if they have any objection; if they don't, I think
you should push the patch.

Happy hacking!
Miguel


signature.asc
Description: PGP signature


Re: [PATCH v2] .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable.

2020-10-27 Thread Maxim Cournoyer
Hello Miguel!

Miguel Ángel Arruga Vivas  writes:

> Hello, Maxim!
>
> Thanks for your effort in this, some comments with the quotes for
> context.

Thanks for your comments, they've already made this proposed change much
better!

> Maxim Cournoyer  writes:
>>> This fails if geiser-guile-load-path does not exist (void-variable).
>>> The cleanup removes other guixes, isn't it?  I suggest making the
>>> variable buffer-local and forget about hard-coded names. :-)
>>
>> That's a good suggestion!  I toyed with it and it's a bit tricky but I
>> think the v2 patch I'll send as a follow-up does the trick.  My concern
>> was also supporting when a user has previously set
>> geiser-guile-load-path in their .emacs init file, e.g.:
>>
>> (setq geiser-guile-load-path (list (expand-file-name "~/src/guix")
>>(expand-file-name "~/src/shepherd")))
>>
>> That would mean their entries don't get cleaned up (it seems this
>> doesn't matter in my latest tests with the v2 patch though!).
>
> That cleanup seems to me responsibility of that .emacs maintainer
> instead of something to take into account in .dir-locals. ;-)

Indeed, it could be seen that way!  The good news is that it doesn't
seem to cause any problems anyway, should they forget an entry for Guix
there.

>>> (eval . (setq guix-directory
>>>   (locate-dominating-file default-directory ".dir-locals.el")))
>>> (eval . (when (boundp 'geiser-guile-load-path)
>>
>> This check makes it so that if geiser-guile-load-path is not already
>> defined, nothing happens.  It is likely that this is the case, as when
>> relying on just Geiser's autoloads, it is not loaded.  The user would
>> have to either set explicitly before hand or call (require
>> 'geiser-guile), which we can't rely on.  But we can drop this check.
>
> You're right, as you can only bind the keys and enable it when used, not
> at file load as I do, great catch. :-)
>
>> One thing that worried me was the %load-compiled-path not appearing in
>> the order defined from guile-geiser-load-path, but in my latest tests as
>> mentioned above it didn't matter.
>
> With the right directories (meaning no-conflicts between modules) it
> shouldn't matter, but it's weird.  Looking into geiser-guile.el the load
> path is provided to guile through -L parameters in
> geiser-guile--parameters, and the extra path for Geiser code is added
> with geiser-guile--set-geiser-load-path (that's why it is not added to
> %load-compiled-path)...  I'd have to check Guile to be sure why are the
> differences, but they seem harmless.

OK, thank you for investigating!

>> +   (unless (fboundp 'geiser-guile-load-path)
>> + (defvar geiser-guile-load-path '()))
>
> This checks the function definition, not the variable, as Emacs Lisp has
> two separate namespaces.

Oops, good catch!

>> I ended up using `cl-pushnew' here instead of push, as otherwise
>> repeated entries were accumulated.
>
> I wanted to avoid exactly that check, as the variable should end up with
> duplicated entries only when you call it twice from the same buffer, how
> could that happen?
>
>> +   (make-local-variable 'geiser-guile-load-path)
>> +   (cl-pushnew root-dir* geiser-guile-load-path
>> +   :test #'string-equal)
>
> If there is some way this may happen, then this call is OK, but I'd try
> to stay with a cheaper push unless it's really needed, as O(1) < O(n),
> for almost every n. :-)

The way I could easily trigger this was to open a dired buffer, and
hitting 'g' to refresh its contents.

> Again, thank you very much for taking care of this, as it would make
> life easier for everybody of us who uses Geiser.

I'm glad to read it! :-)

I'll be sending a v3 with the fboundp woopsie above fixed.

Maxim



Re: [PATCH v2] .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable.

2020-10-26 Thread Miguel Ángel Arruga Vivas
Hello, Maxim!

Thanks for your effort in this, some comments with the quotes for
context.

Maxim Cournoyer  writes:
>> This fails if geiser-guile-load-path does not exist (void-variable).
>> The cleanup removes other guixes, isn't it?  I suggest making the
>> variable buffer-local and forget about hard-coded names. :-)
>
> That's a good suggestion!  I toyed with it and it's a bit tricky but I
> think the v2 patch I'll send as a follow-up does the trick.  My concern
> was also supporting when a user has previously set
> geiser-guile-load-path in their .emacs init file, e.g.:
>
> (setq geiser-guile-load-path (list (expand-file-name "~/src/guix")
>(expand-file-name "~/src/shepherd")))
>
> That would mean their entries don't get cleaned up (it seems this
> doesn't matter in my latest tests with the v2 patch though!).

That cleanup seems to me responsibility of that .emacs maintainer
instead of something to take into account in .dir-locals. ;-)

>> (eval . (setq guix-directory
>>   (locate-dominating-file default-directory ".dir-locals.el")))
>> (eval . (when (boundp 'geiser-guile-load-path)
>
> This check makes it so that if geiser-guile-load-path is not already
> defined, nothing happens.  It is likely that this is the case, as when
> relying on just Geiser's autoloads, it is not loaded.  The user would
> have to either set explicitly before hand or call (require
> 'geiser-guile), which we can't rely on.  But we can drop this check.

You're right, as you can only bind the keys and enable it when used, not
at file load as I do, great catch. :-)

> One thing that worried me was the %load-compiled-path not appearing in
> the order defined from guile-geiser-load-path, but in my latest tests as
> mentioned above it didn't matter.

With the right directories (meaning no-conflicts between modules) it
shouldn't matter, but it's weird.  Looking into geiser-guile.el the load
path is provided to guile through -L parameters in
geiser-guile--parameters, and the extra path for Geiser code is added
with geiser-guile--set-geiser-load-path (that's why it is not added to
%load-compiled-path)...  I'd have to check Guile to be sure why are the
differences, but they seem harmless.

> +   (unless (fboundp 'geiser-guile-load-path)
> + (defvar geiser-guile-load-path '()))

This checks the function definition, not the variable, as Emacs Lisp has
two separate namespaces.

> I ended up using `cl-pushnew' here instead of push, as otherwise
> repeated entries were accumulated.

I wanted to avoid exactly that check, as the variable should end up with
duplicated entries only when you call it twice from the same buffer, how
could that happen?

> +   (make-local-variable 'geiser-guile-load-path)
> +   (cl-pushnew root-dir* geiser-guile-load-path
> +   :test #'string-equal)

If there is some way this may happen, then this call is OK, but I'd try
to stay with a cheaper push unless it's really needed, as O(1) < O(n),
for almost every n. :-)

Again, thank you very much for taking care of this, as it would make
life easier for everybody of us who uses Geiser.

Happy hacking!
Miguel


signature.asc
Description: PGP signature


Re: [PATCH v2] .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable.

2020-10-26 Thread Pierre Neidhardt
I haven't tested but looking good to me otherwise :)

-- 
Pierre Neidhardt
https://ambrevar.xyz/


signature.asc
Description: PGP signature