* use-package: local package file
@ 2024-11-11 11:28 Trevor Arjeski
2024-11-11 12:16 ` Trevor Arjeski
0 siblings, 1 reply; 2+ messages in thread
From: Trevor Arjeski @ 2024-11-11 11:28 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I'm obsessed with containing everything inside of (use-package ...)
forms, and I've been trying to figure out an elegant way to "lazy" load
a local package.
For example, I keep my personal elisp package files at ~/.emacs.d/lisp/,
which is a directory that is added to `load-path'. I would like to write
a use-package form for a package located at `~/.emacs.d/lisp/foo.el':
(use-package foo
...)
and have package.el automatically install all of foo.el's dependencies,
listed under `Package-Requires' in the header.
So far, I figure out that overriding `use-package-ensure-function' with
a custom function that checks if a library can be located and is not
installed, as follows:
(defun my/use-package-ensure (name args _state &optional _no-refresh)
"Checks for local package before checking remote archives."
(if-let* ((path (locate-library (symbol-name name)))
(_ (not (package-installed-p name))))
(package-install-file path)
(use-package-ensure-elpa name args _state _no-refresh)))
This somewhat works, but for some reason I receive the error on Emacs startup:
error: Package ‘foo-dependency’ (version 1.0.0) is unavailable
...when, in fact, the version is available from nongnu and melpa.
`package-install-file foo' works perfectly fine when called
interactively after Emacs starts, so I suspect something isn't loaded in
time when `use-package-ensure-function' is called.
Any advice would be appreciated. Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-11 12:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 11:28 use-package: local package file Trevor Arjeski
2024-11-11 12:16 ` Trevor Arjeski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).