> +;;;###autoload
> +(defun package-recompile (pkg)
> + "Byte-compile package PKG again.
> +PKG should be either a symbol, the package name, or a `package-desc'
> +object."
> + (interactive (list (intern (completing-read
> + "Recompile package: "
> + (mapcar #'symbol-name
> + (mapcar #'car package-alist))))))
> + (let ((pkg-desc (if (package-desc-p pkg)
> + pkg
> + (cadr (assq pkg package-alist)))))
> + ;; Delete the old .elc files to ensure that we don't inadvertently
> + ;; load them (in case they contain byte code/macros that are now
> + ;; invalid).
> + (dolist (elc (directory-files (package-desc-dir pkg-desc) t "\\.elc\\'"))
> + (delete-file elc))
> + (package--compile pkg-desc)))
Thanks, Lars. But note that there are packages with ELisp files in
subdirectories (Hyperbole and Proof-General come to mind, tho I'm sure
there are others) so we should work a bit harder than the above
`directory-files`.
The realgud family of packages employs a (single-file) package load-relative to manage
a fairly large number of elisp files, including munging the feature symbol.
Looking at my 1000+ package sample, I see the following appear to have more
mundane occurrences of elisp file in subdirectories: