From: Trevor Arjeski <tmarjeski@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: use-package: local package file
Date: Mon, 11 Nov 2024 14:28:21 +0300 [thread overview]
Message-ID: <871pziko16.fsf@gmail.com> (raw)
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.
next reply other threads:[~2024-11-11 11:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-11 11:28 Trevor Arjeski [this message]
2024-11-11 12:16 ` use-package: local package file Trevor Arjeski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871pziko16.fsf@gmail.com \
--to=tmarjeski@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).