Calling `devdocs-install` from code
dcaixinha opened this issue Β· comments
Hi! First of all, thanks for this great package π I'd like to automate the setup of the devdocs install process, and I'm trying to setup some functions in my doftiles, with something like:
(devdocs-install "bash")
But I always get a "wrong argument" error when doing so. Is this feasible? Thanks!
I've changed devdocs-install
do you can pass a symbol (or string) argument to it, see a433fab.
However, this doesn't do what you want since it will (as before) reinstall/update a document that is already installed.
I see why you want to check at startup that some documents are installed, and I could add a function devdocs-ensure
for that. But this has a problem which is hard to avoid: it will load devdocs eagerly at init time. You could wrap the call to devdocs-ensure
in an eval-after-load
, but then Emacs might freeze for a possibly long amount of time at a seemingly random moment (when devdocs is loaded).
Neither of these are good user experience, so I'm hesitating to provide such a function. The code is simple enough that you could copy to your init file and not break the autoloading setup.
(defun devdocs-ensure (&rest slugs)
"Ensure that all documents listed in SLUGS are installed."
(dolist (slug slugs)
(unless (file-exists-p (expand-file-name (format "devdocs/%s/metadata" slug)
user-emacs-directory)) ;; This assumes you didn't customize `devdocs-data-dir'.
(devdocs-install slug))))
What do you think?
Hey @astoff β thank you very much for the quick reply (and that mine was so slow).\
What you changed on a433fab was exactly what I was after. I wanted to have a way to "bulk install" devdocs documents, mainly useful when setting up on a new computer. I'll save these in a function that I then call at will on an eshell (not at Emacs start-up!). That's working flawlessly now π― Either way, thanks for the devdocs-ensure
snippet π