[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
use-package: local package file
From: |
Trevor Arjeski |
Subject: |
use-package: local package file |
Date: |
Mon, 11 Nov 2024 14:28:21 +0300 |
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.
- use-package: local package file,
Trevor Arjeski <=