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?

2
  • 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. Commented Mar 28, 2015 at 23:41
  • 1
    Yes, use-package installs :ensured packages at macro-expansion-time, which seems like a bug, but is probably a feature. Commented Mar 29, 2015 at 23:02

2 Answers 2

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)) 
2
  • 1
    While the idea behind this answer is fine, it would be best if you addressed the multiple PCs thing. Commented Mar 28, 2015 at 23:39
  • 1
    Just combine this with an un-:ensured use-package directive as 2 forms inside the (unless ....). Commented Mar 29, 2015 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)))) 
1
  • :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. Commented Mar 30, 2015 at 17:56

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.