[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use-package :after ??
From: |
David Masterson |
Subject: |
Re: use-package :after ?? |
Date: |
Sun, 07 May 2023 21:05:23 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Thanks for the followup.
Ruijie Yu via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> David Masterson <dsmasterson@gmail.com> writes:
>
>> 1. If any of the listed packages are not loaded currently, then the
>> current package will not be loaded. Period.
>> 2. #1 + "magic" will be done to ensure that, once the listed packages
>> are loaded, the current package will be (auto?) loaded.
>>
>> If #1 is correct, I do not know how the current package will ever be
>> loaded if ":after" fails. If #2 is correct, I do not know what the
>> "magic" could be to safely do this.
>
> TL;DR: #2, see below.
I tried to write it to be skimmable. ;)
>> For instance:
>>
>> (use-package org-ac :after org)
>> (use-package org)
>
> This is what I get when I `macroexpand' the first `use-package' call
> with `use-package-always-defer' set to nil.
Which I assumed is the default and goal (defer all packages until you
need them).
> [ If `u-p-a-defer' is set to t when I `macroexpand', the
> `eval-after-load' call reduces to nil on expand-time because this
> package is not installed, nor does `package.el' know how to install it
> because I only have gnu and nongnu elpa configured. ]
Understood
> (progn
> (defvar use-package--warning3
> #'(lambda
> (keyword err)
> (let
> ((msg
> (format "%s/%s: %s" 'org-ac keyword
> (error-message-string err))))
> (display-warning 'use-package msg :error))))
> (condition-case-unless-debug err
> (eval-after-load 'org
> '(if
> (not
> (require 'org-ac nil t))
> (display-warning 'use-package
> (format "Cannot load %s" 'org-ac)
> :error)))
> (error
> (funcall use-package--warning3 :catch err))))
Hmm.
> So, this might help you understand what is happening under the hood.
> Essentially, it will try to load org-ac, only after *all packages*
> listed in the :after section, showing a warning if loading org-ac fails.
I presume the 'if' gets more complicated and more 'eval-after-load'
calls are done if :after lists more than one item, correct?
> Keep in mind, according to the macroexpand result, that this also means
> that if you load the subpackage `org-ac' manually (via a hook, autoload,
> etc), it is not going to try to load `org' at all. I feel that this is
> kind of strange, but maybe it has its reasons.
Hmm.
> It seems that you opted to go with setting `u-p-a-defer' to t. And
> since you didn't mention :ensure at all, I assume you set `u-p-a-ensure'
> to t as well.
I'm looking at 'ensure'. I currently use 'auto-update' package.
> In this case, order doesn't _really_ matter, you just need to
> `(use-package sub-pkg :after main-pkg :config your-other-configs)' on
> all your subpackages.
I thought I had. I even had 'org' before 'org-ac' (but after
'auto-complete') in .emacs, but things weren't working right until I
hand loaded 'org-ac'. I'll have to test this some more.
How did you do the macroexpand to debug this? I haven't seen that
technique. Looks interesting.
> Note, since you use `org' as an example, that you should probably
> `(use-package org)' first thing in your init.el, because otherwise
> something else is probably going to load builtin `org', and the Elpa
> `org' will complain afterwards about mismatched versions.
Yes, I ran into that. I wound up removing the builtin manually. I
believe org has been trying to fix this.
Thanks
--
David Masterson
- use-package :after ??, David Masterson, 2023/05/07
- Re: use-package :after ??, Eli Zaretskii, 2023/05/08
- Re: use-package :after ??, David Masterson, 2023/05/10
- Re: use-package :after ??, David Masterson, 2023/05/10
- Re: use-package :after ??, Eli Zaretskii, 2023/05/11
- Re: use-package :after ??, David Masterson, 2023/05/11
- Re: use-package :after ??, Ruijie Yu, 2023/05/11
- Re: use-package :after ??, Eli Zaretskii, 2023/05/12
- Re: use-package :after ??, Emanuel Berg, 2023/05/13