From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Trevor Arjeski Newsgroups: gmane.emacs.help Subject: use-package: local package file Date: Mon, 11 Nov 2024 14:28:21 +0300 Message-ID: <871pziko16.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11228"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 11 16:01:41 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tAVvA-0002pC-Nw for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 11 Nov 2024 16:01:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tAVuk-0008AH-31; Mon, 11 Nov 2024 10:01:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tASaq-00005T-Mr for help-gnu-emacs@gnu.org; Mon, 11 Nov 2024 06:28:28 -0500 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tASap-0003ZB-1k for help-gnu-emacs@gnu.org; Mon, 11 Nov 2024 06:28:28 -0500 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2fb5014e2daso35930171fa.0 for ; Mon, 11 Nov 2024 03:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731324505; x=1731929305; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=hKHRGNOGLLAe0uqg6VVYq8BiRZGz+hCjJCoY7ufLVfo=; b=bObnS2GdyfMWdVztftZgj7/w7Ws0qvR4ywgNld8NAxc+ozXGpXIEbUH3Eitnrpuqca gj39sJAV2nanT2rbh2HCQFTUag6m+L/IusNB3yA9wRQpdmijk1dvwK9hwHOjQ29IeMTD QlDRBD4dKqqQMmDmyce/I5Xq/iOvMH3bwxdwWY+l0dDvgCANU2/iC0sJDDhiYmSnNeO2 I7bbPt1qLwO76ZEVMUfCe6NKaMlcK7Ahpib6bxgbf1yfXQ4MzOyIHvUvLiQb9VzW5btX WZ3PmbL16IO2wn4XGz2H8cfFJrfokYTGNPB26L5deU6GCdtjB5HOUOphx+Au4mEPxAfN lD1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731324505; x=1731929305; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hKHRGNOGLLAe0uqg6VVYq8BiRZGz+hCjJCoY7ufLVfo=; b=ImQE24BhknbYa/z+egiakNxlcSshepf1Rwz81Q/u6JaPQ4K6xbFnXkE90qEbHt7V0H q3n21tPEfN3QnjnjWGnbpjpZHnEaIe3qlGtm8SCx5xgqgbOOk2+9zHKW8ZucYKtNiUa8 Np/txELKlIBqBitjwWMS4H4zDZ5jXzhG7Dllpk1nYOuNC2CSSinWVJipLkVjcQLDv9Am GFiyEyp7HpeeUYpyh9b5PD6/YSmsADmu/yriHiAMjWmbDQzlZGmU73JjdT7Rw/7zJsbP 7bTMTfYCMHocrhS32ecClDDsJ5RFjUlASESLLoJePySYpfmNHsM8VFDwRcLfSOgw/op7 iMrA== X-Gm-Message-State: AOJu0YxZxIoLmgOq7VVTNT4S1vwiG19F3F0QzIcYJyXlJYfmvV06RowU 21Ob6gJ1jssV/thy4ft7c44teMNamECDg4SCLmczZIlQJdfKPT14D5maT2Rk X-Google-Smtp-Source: AGHT+IFd80CvRYE0rpj1nPQUYU+BB3ztvwIRKjDXIW7JTtBlRXzU9tMaG7wkchrHLjzIE322s/S12A== X-Received: by 2002:a05:651c:2116:b0:2fb:61c0:103 with SMTP id 38308e7fff4ca-2ff201622a7mr54157801fa.4.1731324504297; Mon, 11 Nov 2024 03:28:24 -0800 (PST) Original-Received: from trevarch (109-252-36-249.nat.spd-mgts.ru. [109.252.36.249]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ff179d4d17sm16826091fa.99.2024.11.11.03.28.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 03:28:23 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=tmarjeski@gmail.com; helo=mail-lj1-x235.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 11 Nov 2024 10:01:08 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148311 Archived-At: 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 start= up: error: Package =E2=80=98foo-dependency=E2=80=99 (version 1.0.0) is una= vailable ...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.