From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sMGRH3f/qGD8HQEAgWs5BA (envelope-from ) for ; Sat, 22 May 2021 14:56:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id IL9aG3f/qGCxDQAAB5/wlQ (envelope-from ) for ; Sat, 22 May 2021 12:56:23 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 055AE2A325 for ; Sat, 22 May 2021 14:56:22 +0200 (CEST) Received: from localhost ([::1]:36632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lkRAw-0003Hs-6s for larch@yhetil.org; Sat, 22 May 2021 08:56:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lkRAg-0003Gx-SD for bug-guix@gnu.org; Sat, 22 May 2021 08:56:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lkRAg-0007SB-K8 for bug-guix@gnu.org; Sat, 22 May 2021 08:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lkRAg-00087N-If for bug-guix@gnu.org; Sat, 22 May 2021 08:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#48331: [PATCH 2/2] gnu: emacs: Load package descriptors from packages referenced by subdirs.el Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 22 May 2021 12:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48331 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 48331@debbugs.gnu.org Received: via spool by 48331-submit@debbugs.gnu.org id=B48331.162168812531156 (code B ref 48331); Sat, 22 May 2021 12:56:02 +0000 Received: (at 48331) by debbugs.gnu.org; 22 May 2021 12:55:25 +0000 Received: from localhost ([127.0.0.1]:38510 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lkRA4-00086R-9E for submit@debbugs.gnu.org; Sat, 22 May 2021 08:55:24 -0400 Received: from mailrelay.tugraz.at ([129.27.2.202]:46554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lkRA2-00086D-1l for 48331@debbugs.gnu.org; Sat, 22 May 2021 08:55:22 -0400 Received: from localhost.localdomain (91-114-247-246.adsl.highway.telekom.at [91.114.247.246]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4FnNjz2zclz3xbj; Sat, 22 May 2021 14:55:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1621688119; bh=yIVEFRMMsi0NPEWkcrT7cmnFFw8kEODNzcDYCMQ83yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Aw/rkBq/A+X+2bUbqq3MwRxZlcx4+bIRTBJR/9YJFpNoP8ltYc9PzY6GZQdbKk6V8 eBD/s+vWAGETDWXUobNSuKvvzZELyrapzRuR2TxNUf7wZYhe5F0xHtgpXAO0NMgtf6 xWJ8V8jksQV7wqw5jIaajONpv9QvmisodOyfF914= From: Leo Prikler Date: Sat, 22 May 2021 14:54:28 +0200 Message-Id: <20210522125428.12859-2-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210522125428.12859-1-leo.prikler@student.tugraz.at> References: <20210522125428.12859-1-leo.prikler@student.tugraz.at> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maxim.cournoyer@gmail.com, andrew@trop.in Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621688182; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=yIVEFRMMsi0NPEWkcrT7cmnFFw8kEODNzcDYCMQ83yc=; b=ppJLCTuWEb4vJ/5HLpJkWRdlTdvH2fk/LJRr1uN5jmw7vCmoFSukSe0yMdf9qvYw0uKB/p g8Dgo8BGNuPbQkCv8jGWDg3YYPFcvUMsLeyj81E69+Ie50Kw4NxgnZxbHGvv6GGg5U7ahR mwnJbSpjrNtE8h5Bi4Vskx+PDjIePuwGozEUkN3gv5KSgLbe9oX7zy72R2npGQllZGYu4Y fPqCgqX+Itd7cE0ufnu9oq56tQW0aYqWS37zkfhwS/xXc+13+k7sUPZ3UI+Uy8uZqCb5rm aEskZAnAMLojzmgd+tQ0dlT5afsD6Y5Gthty3XWRhJHjTu+80OLUFJKXxJB2Kw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1621688182; a=rsa-sha256; cv=none; b=PeDtyT7MjEUM/JcJYAY9jD5ddiw3A9g5B6uJIAjLfyTMBIyY2qHVFzSbESdUULkms9H9H5 D9sGlEdlq2VmTR1Rsodk9fWaUkcwBX1041HpQ4pLpLlz2nGpMHTS0V4QI+kOwRifuQMk8C /aFrs0Cd469mNS6EulJIw+3gOCS2mNEn1i2qfvayYwFtRH70dLZGOkw1hBsb+mgudKxR7a Fea4WbFDpH4QEydKS4RFSqYbqlqKj42DEm9gxNY3KdWKvHmDH5aQ5quoK+0ge+2KGrTRHW rCD5UtDUS9twDvc2A7Y99y15Ar4Eqlxcx8ofRqgv7yNpk4oYRGQ2RIe+fy/OmA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tugraz.at header.s=mailrelay header.b="Aw/rkBq/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=student.tugraz.at (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -0.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tugraz.at header.s=mailrelay header.b="Aw/rkBq/"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=student.tugraz.at (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 055AE2A325 X-Spam-Score: -0.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: jvN+U3mr0f33 * gnu/packages/aux-files/emacs/guix-emacs.el (guix-emacs--non-core-load-path): New procedure. (guix-emacs-autoload-packages): Use it here. (guix-emacs-load-package-descriptors): New procedure. * gnu/packages/emacs.scm (emacs)[install-site-start]: Install advice to run ‘guix-emacs-load-package-descriptors’. --- gnu/packages/aux-files/emacs/guix-emacs.el | 34 +++++++++++++++++----- gnu/packages/emacs.scm | 7 +++-- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el b/gnu/packages/aux-files/emacs/guix-emacs.el index ca9146c535..eff44bfe90 100644 --- a/gnu/packages/aux-files/emacs/guix-emacs.el +++ b/gnu/packages/aux-files/emacs/guix-emacs.el @@ -26,6 +26,7 @@ ;;; Code: (require 'seq) +(declare-function package-load-descriptor "package" (pkg-dir)) (defvar guix-emacs-autoloads-regexp (rx (* any) "-autoloads.el" (zero-or-one "c") string-end) @@ -39,6 +40,12 @@ The files in the list do not have extensions (.el, .elc)." (directory-files directory 'full-name guix-emacs-autoloads-regexp)))) +(defun guix-emacs--non-core-load-path () + ;; Filter out core Elisp directories, which are already handled by Emacs. + (seq-filter (lambda (dir) + (string-match-p "/share/emacs/site-lisp" dir)) + load-path)) + ;;;###autoload (defun guix-emacs-autoload-packages () "Autoload Emacs packages found in EMACSLOADPATH. @@ -46,18 +53,29 @@ The files in the list do not have extensions (.el, .elc)." 'Autoload' means to load the 'autoloads' files matching `guix-emacs-autoloads-regexp'." (interactive) - (let* ((emacs-non-core-load-path-directories - ;; Filter out core Elisp directories, which are already autoloaded - ;; by Emacs. - (seq-filter (lambda (dir) - (string-match-p "/share/emacs/site-lisp" dir)) - load-path)) - (autoloads (mapcan #'guix-emacs-find-autoloads - emacs-non-core-load-path-directories))) + (let ((autoloads (mapcan #'guix-emacs-find-autoloads + (guix-emacs--non-core-load-path)))) (mapc (lambda (f) (load f 'noerror)) autoloads))) +;;;###autoload +(defun guix-emacs-load-package-descriptors () + "Load descriptors for packages found in EMACSLOADPATH via subdirs.el." + (dolist (dir (guix-emacs--non-core-load-path)) + (let ((subdirs-file (expand-file-name "subdirs.el" dir))) + (when (file-exists-p subdirs-file) + (with-temp-buffer + (insert-file-contents subdirs-file) + (goto-char (point-min)) + (let ((subdirs (read (current-buffer)))) + (and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path) + (equal (car-safe (cadr subdirs)) 'list) + (dolist (subdir (cdadr subdirs)) + (let ((pkg-dir (expand-file-name subdir dir))) + (when (file-directory-p pkg-dir) + (package-load-descriptor pkg-dir))))))))))) + (provide 'guix-emacs) ;;; guix-emacs.el ends here diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index 5316d25151..e4af6ea6a9 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -166,8 +166,11 @@ (with-output-to-file (string-append lisp-dir "/site-start.el") (lambda () (display - (string-append "(when (require 'guix-emacs nil t)\n" - " (guix-emacs-autoload-packages))\n")))) + (string-append + "(when (require 'guix-emacs nil t)\n" + " (guix-emacs-autoload-packages)\n" + " (advice-add 'package-load-all-descriptors" + " :after #'guix-emacs-load-package-descriptors))")))) ;; Remove the extraneous subdirs.el file, as it causes Emacs to ;; add recursively all the the sub-directories of a profile's ;; share/emacs/site-lisp union when added to EMACSLOADPATH, -- 2.31.1