From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Braun =?UTF-8?Q?G=C3=A1bor?= Newsgroups: gmane.emacs.bugs Subject: bug#38694: 26.1; update-*-autoloads fails with local generated-autoload-file Date: Fri, 20 Dec 2019 20:16:29 +0100 Message-ID: <2923979.zgHqgAkGFZ@gabor> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="169042"; mail-complaints-to="usenet@blaine.gmane.org" To: 38694@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 20 20:17:18 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iiNm2-000hqX-Dz for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Dec 2019 20:17:18 +0100 Original-Received: from localhost ([::1]:60796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiNm1-0004zz-9T for geb-bug-gnu-emacs@m.gmane.org; Fri, 20 Dec 2019 14:17:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33316) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiNlr-0004zr-IE for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:17:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiNlp-0005Vy-Cz for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:17:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiNll-0005UJ-UC for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:17:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iiNll-0005vk-Qf for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:17:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Braun =?UTF-8?Q?G=C3=A1bor?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Dec 2019 19:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38694 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.157686940122765 (code B ref -1); Fri, 20 Dec 2019 19:17:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Dec 2019 19:16:41 +0000 Original-Received: from localhost ([127.0.0.1]:47259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iiNlQ-0005v7-Nl for submit@debbugs.gnu.org; Fri, 20 Dec 2019 14:16:41 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:33200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iiNlO-0005uy-MR for submit@debbugs.gnu.org; Fri, 20 Dec 2019 14:16:39 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58645) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiNlM-0004x7-Sy for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:16:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiNlL-0004Xa-1I for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:16:36 -0500 Original-Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:52342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiNlK-0004UA-PX for bug-gnu-emacs@gnu.org; Fri, 20 Dec 2019 14:16:34 -0500 Original-Received: by mail-wm1-x32d.google.com with SMTP id p9so10027337wmc.2 for ; Fri, 20 Dec 2019 11:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=KS8vHS6d+PfLyasBaryw+U+RcL6oatkaO+zFdRSsNPc=; b=pH8xPQuu4mt5We0Z3KzrX5T2dj7xQZVpj8gXJapkZ1MK8oF6uup4n9RsNiioyLBaod PtJ6Z3VP39xhb4Rk4Ip3CG/SD9+U0GpAAZX+Y0AZ8tKQVw8kCdjj2I5CPGHnpiNswuFv vZ3Oq5uQtMal35OwWXSPZULMC0jLwwN8GMFn76bz4yFHbAWW1lQ1jxO6iNZBLRuA5Bgt 3/yOYtOJBkBCtYoCYDAR7YWbZERUy9Xk9valrY/ivbdQyajF8/iv2sd2IdXhcT68LFQg Tnp62qxiQCNmCYc5/TRVIgmY7ddHGJVc5Y9kJUucM+3cliWD/+kEnM4FXO8cAVsaKdsD JOcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=KS8vHS6d+PfLyasBaryw+U+RcL6oatkaO+zFdRSsNPc=; b=XFmpZJhjG3u7t/jkicCSuwkXHOgUl/dQziJ8uoiPpXz+bhokiuqMmbQsT5dTCqjKvD hTIyrLeDcCN9+Mj9HondiyVD2VcJtyY6S1kSKXGojF2HRhA2f5YNZhFIuGV9JiGOwPSL olkEIxdLAGwt8n9DncORDlF9YPItJb93iQC/f55mbXe9ammIGHb9RoPGOlTGDt0y32DP tLUcWeq6YJmL1HQReM1jA9FLy8Zq0yX1MmNYdAEvYdsO68FqljOzRX7OiDuQ8ceMHT8+ KzgkHBA9coyspcy8Dt/E8xDiWKM68pTGqNZ0pI25JVKLzkgheIVb1z38jtcbXFilJK6v AtuA== X-Gm-Message-State: APjAAAV547zwUo79pz9A2e4Vha+1P2AaYiScDw+hFlcJqG7tnE+7NWVx 4Ki3qrJv6JUdirWPE7YFIz+pMHXmvA0= X-Google-Smtp-Source: APXvYqxagitf0cA6OuGphcUDo3/SufjwSboPvFYJok8RcW4/UAQ196IdThc+dMzvXMBRrFrrwLFCHA== X-Received: by 2002:a1c:3d07:: with SMTP id k7mr19270965wma.79.1576869392642; Fri, 20 Dec 2019 11:16:32 -0800 (PST) Original-Received: from gabor.localnet (254C2B98.nat.pool.telekom.hu. [37.76.43.152]) by smtp.gmail.com with ESMTPSA id t190sm10709023wmt.44.2019.12.20.11.16.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 11:16:32 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173582 Archived-At: Let the current directory have only the following two files: =2D----------------- test-foo.el ------------------------- ;;;###autoload (defun test-foo-fun () "FOO: a function just for testing." t) ;; Local Variables: ;; generated-autoload-file: "foo-autoloads.el" ;; End: =2D------------------------------------------------------- =2D----------------- test-bar.el ------------------------- ;;;###autoload (defun test-bar-fun () "BAR: a noop test function." nil) =2D------------------------------------------------------- 1) Do the following: emacs -Q test-foo.el 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) where in place of DIRECTORY there is the directory the files above reside. 2) Similar as above but try generating autoloads for the whole directory: emacs -Q test-foo.el M-x update-directory-autoloads RET RET test-autoloads.el RET This time the error message is (again from buffer *Messages*): autoload-generate-file-autoloads: test-bar.el:0:0: error: wrong-type- argument: (stringp nil) 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. All in all, the patch is the following, adding wrappers `(with-temp-buffer ...)'. (The code has not been reindented,=20 reformatted solely to keep the patch readable.) =2D-- lisp/emacs-lisp/autoload.el +++ lisp/emacs-lisp/autoload.el @@ -916,6 +916,9 @@ update-file-autoloads (interactive (list (read-file-name "Update autoloads for file: ") current-prefix-arg (read-file-name "Write autoload definitions to=20 file: "))) + ;; 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)) (autoload-modified-buffers nil) ;; We need this only if the output file handles more than one=20 input. @@ -927,6 +930,7 @@ update-file-autoloads (if (called-interactively-p 'interactive) (message "Autoload section for %s is up to date." file))) (if no-autoloads file))) + ) (defun autoload-find-destination (file load-name) "Find the destination point of the current buffer's autoloads. @@ -1028,6 +1032,9 @@ update-directory-autoloads file binds `generated-autoload-file' as a file-local variable, write its autoloads into the specified file instead." (interactive "DUpdate autoloads from directory: ") + ;; The temporary buffer is only to bind default value of e.g., + ;; `generated-autoload-file'. The current buffer is irrelevant. + (with-temp-buffer (let* ((files-re (let ((tmp nil)) (dolist (suf (get-load-suffixes)) ;; We don't use module-file-suffix below because @@ -1142,6 +1149,7 @@ update-directory-autoloads ;; In case autoload entries were added to other files because of ;; file-local autoload-generated-file settings. (autoload-save-buffers)))) + ) (define-obsolete-function-alias 'update-autoloads-from-directories 'update-directory-autoloads "22.1") Best wishes, G=C3=A1bor In GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-09-23, modified by Debian built on x86-grnet-01 Windowing system distributor 'The X.Org Foundation', version=20 11.0.12004000 System Description: Debian GNU/Linux 10 (buster) Recent messages: Generating autoloads for ~/.emacs.d/autoload-test/test-foo.el... (New file) Generating autoloads for ~/.emacs.d/autoload-test/test-foo.el...done Quit Generating autoloads for ~/.emacs.d/autoload-test/test-bar.el... (New file) Generating autoloads for ~/.emacs.d/autoload-test/test-bar.el...done scroll-down-command: Beginning of buffer C-c M-w is undefined scroll-up-command: End of buffer Configured using: 'configure --build x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib --localstatedir=3D/var/lib --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site- lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/ usr/share/emacs/site-lisp --with-sound=3Dalsa --without-gconf --with-mailutils --build x86_64-linux-gnu --prefix=3D/usr --sharedstatedir=3D/var/lib --libexecdir=3D/usr/lib --localstatedir=3D/var/lib --infodir=3D/usr/share/info --mandir=3D/usr/share/man --enable-libsystemd --with-pop=3Dyes --enable-locallisppath=3D/etc/emacs:/usr/local/share/emacs/26.1/site- lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/26.1/site-lisp:/ usr/share/emacs/site-lisp --with-sound=3Dalsa --without-gconf --with-mailutils --with-x=3Dyes --with-x-toolkit=3Dgtk3 --with-toolkit-scroll-bars 'CFLAGS=3D-g -O2 -fdebug-prefix-map=3D/build/emacs-StqULU/emacs-26.1+1=3D. -fstack- protector-strong -Wformat -Werror=3Dformat-security -Wall' 'CPPFLAGS=3D-Wdate-time -D_FORTIFY_SOURCE=3D2' LDFLAGS=3D-Wl,-z,relro' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 THREADS LIBSYSTEMD LCMS2 Important settings: value of $LANG: hu_HU.UTF-8 locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: diff-auto-refine-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: None found. =46eatures: (shadow sort mail-extr emacsbug message rmc puny seq byte-opt bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-macs gv pcase ediff-ptch ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init cl-loaddefs cl-lib ediff-util ediff jka-compr thingatpt find-func autoload radix-tree lisp-mnt vc-git diff-mode easymenu easy-mmode elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 116513 9893) (symbols 48 22483 1) (miscs 40 106 201) (strings 32 34406 1337) (string-bytes 1 943432) (vectors 16 17409) (vector-slots 8 538130 13522) (floats 8 69 226) (intervals 56 380 0) (buffers 992 20))