From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#38694: 26.1; update-*-autoloads fails with local generated-autoload-file Date: Fri, 21 Aug 2020 14:01:53 +0200 Message-ID: <87h7sw6wcu.fsf@gnus.org> References: <2923979.zgHqgAkGFZ@gabor> 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="15343"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 38694@debbugs.gnu.org To: Braun =?UTF-8?Q?G=C3=A1bor?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Aug 21 14:03:09 2020 Return-path: Envelope-to: geb-bug-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 1k95lF-0003ki-Eo for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 14:03:09 +0200 Original-Received: from localhost ([::1]:43508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k95lE-0003Js-Df for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Aug 2020 08:03:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k95l8-0003IP-2q for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 08:03:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33717) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k95l7-0005fR-Pb for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 08:03:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k95l7-0002VS-Ni for bug-gnu-emacs@gnu.org; Fri, 21 Aug 2020 08:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Aug 2020 12:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38694 X-GNU-PR-Package: emacs Original-Received: via spool by 38694-submit@debbugs.gnu.org id=B38694.15980113287866 (code B ref 38694); Fri, 21 Aug 2020 12:03:01 +0000 Original-Received: (at 38694) by debbugs.gnu.org; 21 Aug 2020 12:02:08 +0000 Original-Received: from localhost ([127.0.0.1]:45260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k95kF-00022Q-Vm for submit@debbugs.gnu.org; Fri, 21 Aug 2020 08:02:08 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:41588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k95kE-0001wh-EJ for 38694@debbugs.gnu.org; Fri, 21 Aug 2020 08:02:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=JgLpteNZSUh8usetAk+K3Zd+cfH9qYhesa0QTxK76Go=; b=sEnkKjUtXEoBfTj6UtEWYzA3W0 LzYzQVKlKZ1giOxDCeaAJSUnCcR9LSrYRoUn2MHdrwsALOez8dJhRtJ6MI7EbWvbDppD6SHXltCan 8isQTf1VOs22YOXBeFpHSByACCgMZ6jQLaHyiMnUFnhNXs/K6bO3UZPesTGrwNQnJmkw=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k95k3-0003H4-CD; Fri, 21 Aug 2020 14:01:59 +0200 X-Now-Playing: Move D & Pete Namlook's _Reissued 001_: "Stranger" In-Reply-To: <2923979.zgHqgAkGFZ@gabor> ("Braun =?UTF-8?Q?G=C3=A1bor?="'s message of "Fri, 20 Dec 2019 20:16:29 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:185846 Archived-At: Braun G=C3=A1bor writes: > Let the current directory have only the following two files: [...] > ;; Local Variables: > ;; generated-autoload-file: "foo-autoloads.el" > ;; End: > M-x update-file-autoloads RET > test-bar.el RET > test-autoloads.el RET > > It produces an error message, which I copied from buffer *Messages*: > > autoload-generate-file-autoloads: DIRECTORY/test-bar.el:0:0: error:=20 > wrong-type-argument: (stringp nil) I can confirm this bug. [...] > IMHO, the root of the problem is that update-file-autoloads and > update-directory-autoloads bind generated-autoload-file buffer locally > (as it is a file local variable in test-foo.el) but intend to bind the > default value. Note that the docstrings of both functions > mention the case of generated-autoload-file being buffer-local, so > they ought to support this case. > > As the documented behaviour of these functions do not > depend on the current buffer, I propose to simply switch to a > temporary buffer so that the local settings don't interfere. > This is a preemptive measure of other similar latent problems. > > Admittedly, creating a temporary buffer just to bind variables' > default value seems to be wasteful, and I am very interested in > learning a better, more idiomatic approach. I don't think there is, and that's perhaps unfortunate. What we have here is a pretty unusual situation, though. > + ;; The temporary buffer is only to bind the default value of e.g., > + ;; `generated-autoload-file'. The current buffer is irrelevant. > + (with-temp-buffer > (let* ((generated-autoload-file (or outfile generated-autoload-file)) But I don't think this is the right way to fix this? We want to heed the buffer-local value of generated-autoload-file, and we want to bind the global value of generated-autoload-file, I think? Otherwise, what would be the point of > ;; Local Variables: > ;; generated-autoload-file: "foo-autoloads.el" > ;; End: I'm not very familiar with this code, though, so I may be misreading it. So the patch would be something like + (let ((autoload-file (or outfile generated-autoload-file))) + (with-temp-buffer + (let* ((generated-autoload-file autoload-file) Or more complete (with indentation changes) below. Does that makes sense? diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index 2eef451200..ad39f5642b 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -924,17 +924,20 @@ update-file-autoloads (interactive (list (read-file-name "Update autoloads for file: ") current-prefix-arg (read-file-name "Write autoload definitions to file: "))) - (let* ((generated-autoload-file (or outfile generated-autoload-file)) - (autoload-modified-buffers nil) - ;; We need this only if the output file handles more than one input. - ;; See https://debbugs.gnu.org/22213#38 and subsequent. - (autoload-timestamps t) - (no-autoloads (autoload-generate-file-autoloads file))) - (if autoload-modified-buffers - (if save-after (autoload-save-buffers)) - (if (called-interactively-p 'interactive) - (message "Autoload section for %s is up to date." file))) - (if no-autoloads file))) + (let ((autoload-file (or outfile generated-autoload-file))) + (with-temp-buffer + (let* ((generated-autoload-file autoload-file) + (autoload-modified-buffers nil) + ;; We need this only if the output file handles more than + ;; one input. See https://debbugs.gnu.org/22213#38 and + ;; subsequent. + (autoload-timestamps t) + (no-autoloads (autoload-generate-file-autoloads file))) + (if autoload-modified-buffers + (if save-after (autoload-save-buffers)) + (if (called-interactively-p 'interactive) + (message "Autoload section for %s is up to date." file))) + (if no-autoloads file))))) =20 (defun autoload-find-destination (file load-name) "Find the destination point of the current buffer's autoloads. --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no