From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id SJbeFROmwWZAwgAAe85BDQ:P1 (envelope-from ) for ; Sun, 18 Aug 2024 07:43:15 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id SJbeFROmwWZAwgAAe85BDQ (envelope-from ) for ; Sun, 18 Aug 2024 09:43:15 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=pengjiz.com header.s=fm1 header.b=eih2fjpC; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=I37RXAna; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1723966995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=KPhF2nkcQ8wXkj1P9oWxySHjVvE7qhwVjpO1aMG++ao=; b=qMQpN/RhWYYyrgdbF3FqBGrgvp5LC4Lci0Bw+h/eJrNzCjDmGEoWFWtwA13MzEzreMywlN LEWzTfv/Q9VKEpqXxWArKDifKQhAXelB0FKSPs4zG2zx55Txr1RlcBzt7pRd6G6CKvEBZg 9BA1soEwkeEAee88ZgaHjbe8rkjxRDLLPfKikY22Lp9/Wn39iOt2WCwh1MQs0rQ44huJB7 9gP4MKhrc2oftUP/Yusd2m1KgJ8BrkMJffLHpbCcywYMIBbtT/MhA7P00Djf6dhBBbbXn5 QW02OQfFAKcXKUSWhJ4YbTmMq9rTGEFXEYVGR62T0zyAt/fdZl0iE7Ki6UwHjw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=pengjiz.com header.s=fm1 header.b=eih2fjpC; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=I37RXAna; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1723966995; a=rsa-sha256; cv=none; b=N9fGolGSBibh2bGF+vsnPON3M9ktYxAxV8uwkxqp+NHnEO2lewNaoW7R4VYekdYsubQnFk kOPJ266s36csvd4dWPfNSlzZNC1VEsGeDkdeyx57YHmkrCh10JWoaSRm+YNAxhlosdfv7l 2lcD9UTEDnqqOsXgx7pN6nIxUBNFO/CFpM6Ukle0uW8r4GPLOxxGsLK/NXfQgmFweK1uLH jhsaZ918grs6EGvtpsLYZshzFnPGu3CrRljjuEnS7yG1N/JoL37T1YHd+y0Ye4zPohQIIF 3YneoxP0t7NekHjjwGEdZ+sA1eQrUiK0ZGjdS6FlG5Yuh6b2ezBaJ69SBLUQWg== Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B1ACA74341 for ; Sun, 18 Aug 2024 09:43:14 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 457055E296; Sun, 18 Aug 2024 07:43:11 +0000 (UTC) Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) by mail.notmuchmail.org (Postfix) with ESMTPS id 8ACAA5E292 for ; Sun, 18 Aug 2024 07:43:08 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 33EB5138FFD0 for ; Sun, 18 Aug 2024 03:43:07 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Sun, 18 Aug 2024 03:43:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengjiz.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm1; t=1723966987; x=1724053387; bh=EJCkqnenuWC1VGZNalaXT toSZwPkGfFgDPORx8g9Ni4=; b=eih2fjpCrnh/Lgv38PfQdoCQScXqBKWgrUop4 1450jqE2MNKyIHYEEllqmMSK1NgUMip7PIs0hBoKZ20dsXL/oTxsjFFUYoRowjQU DQim+2tkitOrmuAFOE7aKn9bshpcPyn7vRKD6X36lgSReCYuejAjmv7rFhjlrhrm C1ixR0rXjWa70qd38fQKsRe7KXVbW05+LSYCl1mXVe11gF5UDNHzykR2hfgjFviZ k98jah0GRhz0iJAWLqXE2mgh/FAfnXyERJIg7HIlC/EAU3OQ8uWWbqVBuXdfBaw3 4ZAlxLD1BPv1yjCRaffo6po7NRcq9if+sMVPkp4Hk4F/s8G/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1723966987; x=1724053387; bh=EJCkqnenuWC1VGZNalaXTtoSZwPk GfFgDPORx8g9Ni4=; b=I37RXAnaQd85llwgFP12N5KTrBz1dnZD/7pfy/wt0pjq dFqO3HrOyH39OirCaBKo8Zb6zb+vpS0LgMcDUbmTwZ1mWXu7t1MMByQ+G4/9e8hR Q3qleaLXcEBwkbNrbJuedKfH/WiPj4e+fOHjsljiP+od1VGas3lZgmawqeqp8gQ5 sS7AivovGCyrgogp7ofdfP7pzsXDxCqO7wUmFE7DP6ySsjfTmblBhodnoXpqnjqQ LTreOF7T7VV7OyXUx+ulTKYElhnYxStjft9UVuzSLuHsH5bFmhVvG1AY/HiqMdYG KuWRltR3QehSCqXGeEvtidy+YdSpzv6yMVoDcEp/Fw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudduuddguddvfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhephffvuf ffkffoggfgsedtkeertdertddtnecuhfhrohhmpefrvghnghhjihcukghhrghnghcuoehm vgesphgvnhhgjhhiiidrtghomheqnecuggftrfgrthhtvghrnhepheffudeigeduueduvd duteeludffffejiefhudduvedvjeduffegffekvdelgfelnecuffhomhgrihhnpehgnhhu rdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgvsehpvghnghhjihiirdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhm thhpohhuthdprhgtphhtthhopehnohhtmhhutghhsehnohhtmhhutghhmhgrihhlrdhorh hg X-ME-Proxy: Feedback-ID: i16614472:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 18 Aug 2024 03:43:06 -0400 (EDT) From: Pengji Zhang To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Generate and install autoloads Date: Sun, 18 Aug 2024 15:42:55 +0800 Message-ID: <20240818074255.49829-1-me@pengjiz.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Message-ID-Hash: U42E6CUCLUQPCTRMBU6XYHLIOBGQOGTA X-Message-ID-Hash: U42E6CUCLUQPCTRMBU6XYHLIOBGQOGTA X-MailFrom: me@pengjiz.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Country: DE X-Migadu-Flow: FLOW_IN X-Spam-Score: 1.25 X-Migadu-Queue-Id: B1ACA74341 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: 1.25 X-TUID: TuGja2dbzROz Previously when installed with 'make install', autoloads in sources were not scraped. So users still had to load the full library beforehand in order to use Notmuch. Now we generate and install such a file for 'make install-emacs'. With this change, users can replace in their Emacs configuration: (require 'notmuch) with a much cheaper: (require 'notmuch-autoloads) but are still able to use 'M-x notmuch'. Note that this new file is not included in the 'make elpa' package, so it does not break for those users, who have already been enjoying autoloads generated by 'package.el'. Besides, this should not break packaging for most distros. Even if they have generated and maintained such a file using their package managers, Emacs does not choke on an existing output file when scraping autoloads. Re: thread starting at id:87o75yl4u5.fsf@pengjiz.com --- PS I am not familiar with Debian packaging but I have the impression that its system for Emacs packages is sophisticated. Do we need to do anything here in the Notmuch repository? Thanks! Pengji --- emacs/.gitignore | 1 + emacs/Makefile.local | 13 ++++++- emacs/autoloads-gen.el | 79 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 emacs/autoloads-gen.el diff --git a/emacs/.gitignore b/emacs/.gitignore index b9873b0a..c1af442b 100644 --- a/emacs/.gitignore +++ b/emacs/.gitignore @@ -3,3 +3,4 @@ /*.rsti /notmuch-version.el /notmuch-pkg.el +/notmuch-autoloads.el diff --git a/emacs/Makefile.local b/emacs/Makefile.local index 0f1f0eb2..7991a859 100644 --- a/emacs/Makefile.local +++ b/emacs/Makefile.local @@ -38,6 +38,16 @@ $(dir)/notmuch-pkg.el: $(srcdir)/$(dir)/notmuch-pkg.el.tmpl all: $(dir)/notmuch-pkg.el install-emacs: $(dir)/notmuch-pkg.el +emacs_autoloads := $(dir)/notmuch-autoloads.el +ifeq ($(WITH_EMACS),1) +$(emacs_autoloads): $(emacs_sources) $(dir)/autoloads-gen.el + $(call quiet,EMACS) -batch -L emacs -l autoloads-gen.el \ + -f autoloads-gen-batch $@ $(emacs_sources) + +all: $(emacs_autoloads) +install-emacs: $(emacs_autoloads) +endif + emacs_mua := $(dir)/notmuch-emacs-mua emacs_mua_desktop := $(dir)/notmuch-emacs-mua.desktop @@ -115,6 +125,7 @@ install-emacs: $(emacs_sources) $(emacs_images) install -m0644 $(emacs_sources) "$(DESTDIR)$(emacslispdir)" ifeq ($(WITH_EMACS),1) install -m0644 $(emacs_bytecode) "$(DESTDIR)$(emacslispdir)" + install -m0644 $(emacs_autoloads) "$(DESTDIR)$(emacslispdir)" endif mkdir -p "$(DESTDIR)$(emacsetcdir)" install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)" @@ -130,4 +141,4 @@ ifeq ($(WITH_DESKTOP),1) endif CLEAN := $(CLEAN) $(emacs_bytecode) $(dir)/notmuch-version.el $(dir)/notmuch-pkg.el \ - $(emacs_docstrings) docstring.stamp + $(emacs_autoloads) $(emacs_docstrings) docstring.stamp diff --git a/emacs/autoloads-gen.el b/emacs/autoloads-gen.el new file mode 100644 index 00000000..9a1a7254 --- /dev/null +++ b/emacs/autoloads-gen.el @@ -0,0 +1,79 @@ +;;; autoloads-gen.el --- help generate autoloads -*- lexical-binding: t -*- +;; +;; Copyright (C) 2024 Pengji Zhang +;; +;; This file is part of Notmuch. +;; +;; Notmuch is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; Notmuch is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with Notmuch. If not, see . + +;;; Commentary: +;; +;; Helpers for generating a `notmuch-autoloads.el' file. +;; +;; This file is written specifically for the Notmuch project. Some +;; design choices here perhaps only make sense for Notmuch. +;; +;; An alternative way is to directly call `package-generate-autoloads' +;; on our source directory. It was not chosen because we could not +;; easily exclude files. Besides, that function is for packages, so +;; using it on a non-package directory feels a bit hacky. + +;;; Code: + +(require 'seq) ; `seq-uniq', `seq-difference' (both in Emacs >= 25) + +(defvar generated-autoload-file) +(defvar autoload-excludes) + +(defun autoloads-gen-batch () + "Generate autoloads on the command line. +First argument is the output file, and the rest are source files." + (let ((output-file (car command-line-args-left)) + (sources (cdr command-line-args-left))) + (setq command-line-args-left nil) + (autoloads-gen (expand-file-name output-file) + (mapcar #'expand-file-name sources)))) + +(defun autoloads-gen (output-file sources) + "Generate autoloads for SOURCES and write them to OUTPUT-FILE. +All filenames should be absolute. + +Note that this function always generate OUTPUT-FILE anew, instead +of just updating added or changed autoloads." + ;; Here we always generate a new file to avoid potential troubles + ;; when switching Emacs versions, and also to update the timestamp + ;; of the output file reliably. + (let* ((dirs (seq-uniq (mapcar #'file-name-directory sources))) + (excludes (mapcan (lambda (dir) + (seq-difference (directory-files dir t) + sources)) + dirs))) + ;; NOTE: The generated file does not contain the additional + ;; expression to modify `load-path', as is done by `package.el', + ;; because it is tedious to do for Emacs <= 29. Besides, this file + ;; is intended to be installed to some directory that is already + ;; in `load-path'. + (if (fboundp 'loaddefs-generate) + (loaddefs-generate dirs output-file excludes nil nil t) + ;; In Emacs >= 29, we have the new `loaddefs-gen' library, used + ;; above, and that superseded the now obsolete `autoload' + ;; library, used below. + (when (file-exists-p output-file) + (delete-file output-file)) + (let ((generated-autoload-file output-file) + (autoload-excludes excludes) + (backup-inhibited t)) + (mapc #'update-directory-autoloads dirs))))) + +;;; autoloads-gen.el ends here -- 2.46.0