unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* A small use-package puzzle
@ 2024-08-30 11:32 R. Clayton
  2024-08-30 14:59 ` Suhail Singh
  0 siblings, 1 reply; 3+ messages in thread
From: R. Clayton @ 2024-08-30 11:32 UTC (permalink / raw)
  To: help-gnu-emacs

I'm running GNU Emacs 29.4 (build 1, i686-pc-linux-gnu, GTK+ Version 3.24.42,
cairo version 1.18.0) of 2024-06-29, modified by Debian, and I'm wondering how
this can happen:

  ELISP> (file-exists-p "/home/rclayton/.emacs.d/elpa/dart-mode-1.0.7")
  nil
  ELISP> (package-installed-p 'dart-mode)
  nil
  ELISP> (executable-find "dart")
  nil
  ELISP> (use-package dart-mode :if (executable-find "dart"))
  nil
  ELISP> (package-installed-p 'dart-mode)
  t
  ELISP> (file-exists-p "/home/rclayton/.emacs.d/elpa/dart-mode-1.0.7")
  t
  ELISP> (executable-find "dart")
  nil
  ELISP>

Maybe there's some weird interaction between ielm and use-package, but when
init.el contains (use-package dart-mode :if (executable-find "dart")) the same
behavior occurs.

Note that

  (when (executable-find "dart")
    (use-package dart-mode))

in init.el behaves as expected.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A small use-package puzzle
  2024-08-30 11:32 A small use-package puzzle R. Clayton
@ 2024-08-30 14:59 ` Suhail Singh
  2024-08-31  9:53   ` R. Clayton
  0 siblings, 1 reply; 3+ messages in thread
From: Suhail Singh @ 2024-08-30 14:59 UTC (permalink / raw)
  To: R. Clayton; +Cc: help-gnu-emacs

"R. Clayton" <factotum@rclayton.org> writes:

> I'm wondering how this can happen:

When it comes to understanding macro expansion, I find macrostep-expand
(from the package macrostep) quite invaluable.

If the value of `use-package-always-ensure' is t , use-package is
behaving as expected.  Keywords such as `:if' are meant to _load_
packages conditionally.  As noted in the [manual]:

#+begin_quote
  If you need to make a use-package form conditional so that the condition
  occurs before even ‘:ensure’ (*note Install package::) or ‘:preface’
  (*note Preface keyword::), use ‘when’ around the ‘use-package’ form
  itself.  For example:

       (when (memq window-system '(mac ns))
         (use-package foo
           :ensure t))
#+end_quote

[manual]: [[info:use-package#Conditional loading]]

-- 
Suhail



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A small use-package puzzle
  2024-08-30 14:59 ` Suhail Singh
@ 2024-08-31  9:53   ` R. Clayton
  0 siblings, 0 replies; 3+ messages in thread
From: R. Clayton @ 2024-08-31  9:53 UTC (permalink / raw)
  To: help-gnu-emacs

  If the value of `use-package-always-ensure' is t

It was.  I over-interpreted what :if meant, not understanding the phase
ordering going on in use-package.  Thanks for the reply.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-31  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 11:32 A small use-package puzzle R. Clayton
2024-08-30 14:59 ` Suhail Singh
2024-08-31  9:53   ` R. Clayton

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).