2

Basically, I want to ensure that the elfeed package is available and load it with use-package, but only on one computer, so I wrote something like this:

(unless (string= system-name "here-elfeed-shall-not-run")
  (use-package elfeed
    :ensure t
    :config
     (setq elfeed-feeds '(blabla doesnt matter))))  

The problem is that even though the use-package part is not supposed to run (because system-name == "here-elfeed-shall-not-run"), it, in fact, runs. I dealt with this by using an if keyword:

(use-package elfeed
  :if (not (string= system-name "here-elfeed..."))
  ...)

Which would be great, if I could still ensure that elfeed is available on the computer on which I want it to be.

What can I do to ensure that elfeed exists on one PC, but shouldn't be downloaded on the other?

  • If you're sure that the package is getting installed by use-package (and not by some other forgotten code you have) then you should file an issue at use-package. – Malabarba Mar 28 '15 at 23:41
  • 1
    Yes, use-package installs :ensured packages at macro-expansion-time, which seems like a bug, but is probably a feature. – politza Mar 29 '15 at 23:02
2

No need to complicate things. The code is as simple as:

(unless (or (string= system-name "here-elfeed-shall-not-run")
            (package-installed-p 'elfeed))
  (package-install 'elfeed))
  • 1
    While the idea behind this answer is fine, it would be best if you addressed the multiple PCs thing. – Malabarba Mar 28 '15 at 23:39
  • 1
    Just combine this with an un-:ensured use-package directive as 2 forms inside the (unless ....). – politza Mar 29 '15 at 23:03
0

Well, it turns out there's a keyword one can use to fix this: :unless, though it still needs elisp's unless, otherwise it throws an error.

(unless (string= system-name "here-elfeed-shall-not-run")
  (use-package elfeed
    :unless (string= system-name "here-elfeed-shall-not-run")
    :ensure t
    :config
      (setq elfeed-feeds '(blabla doesnt matter))))
  • :unless (and :if) currently don't affect :ensure, see use-package #190. The outer unless can't be doing anything since it only affects runtime, not macroexpansion. – npostavs Mar 30 '15 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.