>> >> Is this a good idea? Probably not. The emacs-lisp embedded in your Org-mode file is only re-tangled when the Org-mode file changes, so it is better to have the conditional in the tangled Emacs Lisp file so it is run every time you start Emacs. >> or should I work in conditions in the emacs src blocks instead? I >> realize now when I'm typing it out that it might come with some other >> issues like first time running it I would have to reinitialize emacs >> after package installs to get my settings but after that I guess it >> would be fine. > > Instead of trying to put the "look if package is present" constraint on > Babel's side (and have a configuration file which you cannot exchange), I'd do > it on the Emacs (Lisp) side, as I did in my configuration file [1] with a > "try-require" function: > > --8<---------------cut here---------------start------------->8--- > (defvar leuven--missing-packages nil > "List of packages that `try-require' or `locate-library' can't find.") > > ;; require a feature/library if available; if not, fail silently > (defun try-require (feature) > "Attempt to load a library or module. Return true if the > library given as argument is successfully loaded. If not, instead > of an error, just add the package to a list of missing packages." > (let (time-start) > (condition-case err > ;; protected form > (progn > (when leuven-load-verbose > (message "(info) Checking for `%s'..." feature)) > (if (stringp feature) > (load-library feature) > (setq time-start (float-time)) > (require feature)) > t) > ;; error handler > (file-error ;; condition > (progn > (when leuven-load-verbose > (message "(info) Checking for `%s'... missing" feature)) > (add-to-list 'leuven--missing-packages feature 'append)) > nil)))) > --8<---------------cut here---------------end--------------->8--- > > Best regards, > Fabrice > > [1] https://github.com/fniessen/emacs-leuven/blob/master/emacs-leuven.el -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D