Post-Candide
After the garden...
Reloading a package under dev with straight
While developing an emacs package, I do that from within the straight/repos folder.
If the changes only concern one file, it’s easy to just eval-buffer to check things out.
If the changes impact several files and/or it includes non-elisp files that needs to be copied to the straight/build folder, it’s a pain in the neck: I need to eval-buffer each file and call straight-rebuild-package.
The following is a small function that will, interactively if you want, rebuild the package, handle the autoloads and eval-buffer the other files.
Nothing fancy, but useful.
(defun 151e/straight-reload-package (pkg)
"Rebuild PKG and reload all its files."
(interactive
(list (straight--select-package
"Reload package"
(lambda (recipe)
(file-directory-p
(straight--build-dir (plist-get recipe :package)))))))
(straight-rebuild-package pkg)
(let* ((build-dir (straight--build-dir pkg))
(el-files (seq-remove
(lambda (f)
(or (string-suffix-p "-autoloads.el" f)
(string-suffix-p "-pkg.el" f)))
(directory-files build-dir t "\\.el$"))))
(load (expand-file-name (concat pkg "-autoloads") build-dir) t t)
(dolist (file el-files)
(load (file-name-sans-extension file) nil t))))