Closed gsingh93 closed 1 year ago
Does using :after
here cover your use case?
(eval-after-load 'org
'(progn
(require 'org-anki nil nil)
(bind-keys :package org-anki
([(meta shift c)]
. org-anki-cloze-dwim))))
Which expands to:
(eval-after-load 'org
'(progn
(require 'org-anki nil nil)
(bind-keys :package org-anki
([(meta shift c)]
. org-anki-cloze-dwim))))
You should just use :if (package-installed-p 'org-anki)
in this case. This is documented in the new use-package manual that will be distributed as part of Emacs 29.
It's kind of pointless and redundant to write this:
(use-package org-anki
:if (package-installed-p 'org-anki)
:after org
:bind ([(meta shift c)] . 'org-anki-cloze-dwim))
Instead of this:
(use-package-optional org-anki
:after org
:bind ([(meta shift c)] . 'org-anki-cloze-dwim))
But that's fine, this was just a suggestion and I can leave this in my own config.
I've been using this macro in my config to only load a package if it's installed:
And I use it like this:
This makes it easy for me to share config files between machines and launch emacs without running into issues when packages aren't installed and without installing a bunch of packages that are unnecessary on some of my machines (which is why I'm not using
:ensure t
for these packages). I also don't want to defer loading these to solve this issue, as when they are installed I don't want them to be deferred.I've been finding this useful, so I was wondering if it would make sense to have something like this merged upstream? In this case, it would be better to have an
:optional
keyword instead of a new macro, I only created a new macro because it was easier for me to implement in my own config files.