all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Liliana Marie Prikler <liliana.prikler@ist.tugraz.at>
Cc: Liliana Marie Prikler <liliana.prikler@gmail.com>, 65575@debbugs.gnu.org
Subject: bug#65575: [PATCH 3/3] gnu: emacs: Reload subdirs.el files in 'guix-emacs-autoload-packages'.
Date: Mon, 28 Aug 2023 11:20:48 -0400	[thread overview]
Message-ID: <87il8zgpm7.fsf@gmail.com> (raw)
In-Reply-To: <88f150c1356008a1d1c4251a8ec98afcd6e1b6f2.camel@ist.tugraz.at> (Liliana Marie Prikler's message of "Mon, 28 Aug 2023 08:16:53 +0200")

Hi Liliana,

Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:

> Hi Maxim,
>
> Am Montag, dem 28.08.2023 um 01:11 -0400 schrieb Maxim Cournoyer:
>> This fixes a regression introduced with 79cfe30f3 ("build-system:
>> emacs: Use subdirectories again.") which caused the
>> 'guix-emacs-autoload-packages' to no
>> longer be able to autoload all packages.
>>
>> * gnu/packages/aux-files/emacs/guix-emacs.el
>> (guix-emacs-autoload-packages-called): New variable.
>> (guix-emacs-autoload-packages): Reload subdirs.el files an all but
>> the first call of this procedure.
>> * doc/guix.texi (Application Setup): Document that
>> 'guix-emacs-autoload-packages' can be invoked interactively to auto-
>> reload newly installed Emacs packages.
>>
>> ---
> Thank you for looking at this.  I agree that even if we don't want to
> generally load new packages into existing Emacs processes for the
> breakages they might induce, not being able to do so at all is also not
> a great option.  However, I don't think that tracking is the right
> solution here, see below.

[...]

>> diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el
>> b/gnu/packages/aux-files/emacs/guix-emacs.el
>> index ed0c913163..b4a4fd1d91 100644
>> --- a/gnu/packages/aux-files/emacs/guix-emacs.el
>> +++ b/gnu/packages/aux-files/emacs/guix-emacs.el
>> @@ -54,6 +54,9 @@ The files in the list do not have extensions (.el,
>> .elc)."
>>                          (expand-file-name "subdirs.el" dir))
>>                        (guix-emacs--non-core-load-path))))
>>  
>> +(defvar guix-emacs-autoload-packages-called nil
>> +  "True if `guix-emacs-autoload-packages' was already run.")
>> +
>>  ;;;###autoload
>>  (defun guix-emacs-autoload-packages ()
>>    "Autoload Emacs packages found in EMACSLOADPATH.
>> @@ -61,6 +64,15 @@ The files in the list do not have extensions (.el,
>> .elc)."
>>  'Autoload' means to load the 'autoloads' files matching
>>  `guix-emacs-autoloads-regexp'."
>>    (interactive)
>> +  ;; Reload the subdirs.el files such as the one generated by the
>> Guix profile
>> +  ;; hook, so that newly installed Emacs packages located under
>> +  ;; sub-directories are put on the load-path without having to
>> restart Emacs.
>> +  (if guix-emacs-autoload-packages-called
>> +      (progn
>> +        (mapc #'load-file (guix-emacs--subdirs-files))
>> +        (setq load-path (delete-dups load-path)))
>> +    (setq guix-emacs-autoload-packages-called t))
>> +
> Rather than keeping track of whether the function was already called
> (which would make debugging more tedious if you also have e.g. broken
> packages from another source on your EMACSLOADPATH), I think the user
> ought to signal their intent to reload the subdirs files via the
> universal argument.
>
> e.g. 
> (defun guix-emacs-autoload-packages (&optional reload)
>   "..."
>   (interactive "P")
>   (when reload (mapc #'load-file (guix-emacs--subdirs-files)))
>   ...)
>
> WDYT?

The reason for avoiding loading the subdirs.el files on the first call
is just an optimization, since it would at this time duplicate work
already done by Emacs itself when it first executes.  This shouldn't
fail; I've now employed the same 'noerror strategy as used for autoloads
to ensure that.

There's one edge case I've just thought though, which is if a user
invoked emacs with the documented '--no-site-file' option disabling
loading autoloads; this would cause guix-emacs-autoload-packages-called
to be nil.

To balance between making things both convenient and flexible, I've
preserved the tracking but also added the reload override you suggested.
Let me know what you think.

Thank you for the review!

-- 
Thanks,
Maxim




  reply	other threads:[~2023-08-28 15:48 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28  4:50 bug#65575: guix-emacs-autoload-packages does not autoreload newly installed packages Maxim Cournoyer
2023-08-28  5:07 ` bug#65575: [PATCH 1/3] gnu: emacs: Use lexical binding for guix-emacs.el startup library Maxim Cournoyer
2023-08-28  5:11 ` Maxim Cournoyer
2023-08-28  5:11   ` bug#65575: [PATCH 2/3] gnu: emacs: Factorize a 'guix-emacs--subdirs-files' procedure Maxim Cournoyer
2023-08-28  5:11   ` bug#65575: [PATCH 3/3] gnu: emacs: Reload subdirs.el files in 'guix-emacs-autoload-packages' Maxim Cournoyer
2023-08-28  6:16     ` Liliana Marie Prikler
2023-08-28 15:20       ` Maxim Cournoyer [this message]
2023-08-29 20:07         ` Liliana Marie Prikler
2023-08-28 15:16 ` bug#65575: [PATCH v2 1/4] gnu: emacs: Use lexical binding for guix-emacs.el startup library Maxim Cournoyer
2023-08-28 15:16   ` bug#65575: [PATCH v2 2/4] gnu: emacs: Factorize a 'guix-emacs--subdirs-files' procedure Maxim Cournoyer
2023-08-28 15:16   ` bug#65575: [PATCH v2 3/4] gnu: emacs: Allow producing verbose messages when loading autoloads Maxim Cournoyer
2023-08-28 15:16   ` bug#65575: [PATCH v2 4/4] gnu: emacs: Reload subdirs.el files in 'guix-emacs-autoload-packages' Maxim Cournoyer
2023-08-28 16:55     ` Liliana Marie Prikler
2023-09-01  4:53 ` bug#65575: [PATCH v3 1/4] gnu: emacs: Use lexical binding for guix-emacs.el startup library Maxim Cournoyer
2023-09-01  4:53   ` bug#65575: [PATCH v3 2/4] gnu: emacs: Factorize a 'guix-emacs--subdirs-files' procedure Maxim Cournoyer
2023-09-01  4:53   ` bug#65575: [PATCH v3 3/4] gnu: emacs: Allow producing verbose messages when loading autoloads Maxim Cournoyer
2023-09-01  4:53   ` bug#65575: [PATCH v3 4/4] gnu: emacs: Reload subdirs.el files in 'guix-emacs-autoload-packages' Maxim Cournoyer
2023-09-02  4:49     ` Liliana Marie Prikler
2023-09-03 14:51       ` Maxim Cournoyer
2023-09-03 19:59         ` Liliana Marie Prikler
2023-09-09  8:20           ` Liliana Marie Prikler
2023-09-09 13:04             ` Maxim Cournoyer

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87il8zgpm7.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=65575@debbugs.gnu.org \
    --cc=liliana.prikler@gmail.com \
    --cc=liliana.prikler@ist.tugraz.at \
    /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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.