From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: phillip.lord@russet.org.uk (Phillip Lord) Newsgroups: gmane.emacs.bugs Subject: bug#23203: 25.0.91; some loaddefs files have auto-save remnants after building (and install doesn't ignore them) Date: Mon, 04 Apr 2016 23:12:57 +0100 Message-ID: <87wpodyqdy.fsf@russet.org.uk> References: <87twjjqidp.fsf@Rainer.invalid> <87shz35b8i.fsf@Rainer.invalid> <87lh4v0y1z.fsf@linux-m68k.org> <87egam6hif.fsf@Rainer.invalid> <3bf1141d622845eb4fe66b6dce573551.squirrel@cloud103.planethippo.com> <83fuv2plj5.fsf@gnu.org> <837fgepjm7.fsf@gnu.org> <83oa9po0li.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1459808067 25675 80.91.229.3 (4 Apr 2016 22:14:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 4 Apr 2016 22:14:27 +0000 (UTC) Cc: 23203@debbugs.gnu.org, stromeko@nexgo.de To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 05 00:14:14 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1anCl7-0004Hs-Q9 for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Apr 2016 00:14:10 +0200 Original-Received: from localhost ([::1]:33225 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anCl6-00064o-FC for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Apr 2016 18:14:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anCl1-00064S-Tj for bug-gnu-emacs@gnu.org; Mon, 04 Apr 2016 18:14:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anCl0-0000a5-BV for bug-gnu-emacs@gnu.org; Mon, 04 Apr 2016 18:14:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anCl0-0000a1-8K for bug-gnu-emacs@gnu.org; Mon, 04 Apr 2016 18:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1anCl0-0006rS-25 for bug-gnu-emacs@gnu.org; Mon, 04 Apr 2016 18:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: phillip.lord@russet.org.uk (Phillip Lord) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 04 Apr 2016 22:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23203 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23203-submit@debbugs.gnu.org id=B23203.145980800526314 (code B ref 23203); Mon, 04 Apr 2016 22:14:02 +0000 Original-Received: (at 23203) by debbugs.gnu.org; 4 Apr 2016 22:13:25 +0000 Original-Received: from localhost ([127.0.0.1]:51480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anCkP-0006qM-7a for submit@debbugs.gnu.org; Mon, 04 Apr 2016 18:13:25 -0400 Original-Received: from cloud103.planethippo.com ([31.216.48.48]:42239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1anCkM-0006q7-H7 for 23203@debbugs.gnu.org; Mon, 04 Apr 2016 18:13:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=russet.org.uk; s=default; h=Content-Type:MIME-Version:Message-ID: In-Reply-To:Date:References:Subject:Cc:To:From; bh=87iIms0oH+A52IgzSIg7nOV8OVtnsqldziATRBZByaU=; b=oKuYkCo5eAMPMj0Kxu0dNfbe/W DmTiencsUe/F6Be+YrFKN0SFEUHgYt8UvM585+cjoXcfESasjMFA6OQVu5ukSw8unL4Jm56ThedZ+ yTsuTHgz/xHZ8x7hgppLFiXMf2Da1WHs8whWsiW+lf0FKJQUmP2bboHe3kM0o9GJFjSLIP2RJ10Dk l7UFfHwueW9XfclNkG+hJAx7cFBu+q3XI5XNG1zW37QAhS/BPH9S/tpQMd+iRKjxxt+a+0ReHqPBy lvjnHfyHzJaVDjX/HXz+2btvYvo/IpBjRMXkWfYaVFYcaU2kiKDlz4hxRYU4PmOJpZxQ2xGodYj4n 6nMLUCog==; Original-Received: from cpc1-benw10-2-0-cust373.gate.cable.virginm.net ([77.98.219.118]:38332 helo=russet.org.uk) by cloud103.planethippo.com with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.86_1) (envelope-from ) id 1anCk9-002exU-MI; Mon, 04 Apr 2016 23:13:16 +0100 In-Reply-To: <83oa9po0li.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 04 Apr 2016 18:27:53 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud103.planethippo.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - russet.org.uk X-Get-Message-Sender-Via: cloud103.planethippo.com: authenticated_id: phillip.lord@russet.org.uk X-Authenticated-Sender: cloud103.planethippo.com: phillip.lord@russet.org.uk 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: 208.118.235.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:116043 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Sun, 3 Apr 2016 21:11:34 +0100 >> From: "Phillip Lord" >> Cc: "Phillip Lord" , >> 23203@debbugs.gnu.org, >> stromeko@nexgo.de >> I think that the comment is wrong, as I use this function outside of the >> Emacs build process (and I am sure others do also), so I think we should >> remove that. Alternatively, if it is right, we should move it do the >> docstring. > > Fixing the doc string is always a good thing, but it's orthogonal to > the issue at hand. (I do agree that the comment is wrong.) Yes, it's orthogonal -- will fix that later. >> But, I think having a "no backup files" default is still sensible for a >> function used in batch; if it is always used this way in the Emacs build, >> then it it telling us something. So, I would change it, and update the >> docstring. We could also split the function, so that there is a version >> which does not suppress backup files. > > I don't think I agree that batch mode should behave differently wrt > backups. > > How about this alternative: only disable backing up the initial > (effectively empty) contents of the autoloads file? AFAICT, the > backup files are created during a bootstrap only because we first > write the initial "rubric" into it, using write-region, and only after > that visit it. This defeats the normal mechanism of backing up just > once per session, and leaves a backup file whose contents are not > interesting. That sounds plausible. > > So an alternative would be to modify autoload-ensure-default-file so > that it returns some indication about the fact it created the file, > and then change its caller to set buffer-backed-up after it visits the > file, thus preventing the backup _only_ when the file is first > created. > > This should at least solve Achim's problem, but without affecting > anything else. > > WDYT? Also, it sounds reasonable -- I've attached a patch with a variation on this theme. My concerns is that we will still produce backup files which may end up in a dist build. Consider these commands: make (from bootstrap) rm lisp/loaddefs.el make Removing loaddefs will result in generation of all the associated loaddef files, all of which will now be backups. So, we need to make sure that the packaging system does not copy backup files. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=fix3.diff diff --git a/lisp/Makefile.in b/lisp/Makefile.in index f33dd01..463252a 100644 --- a/lisp/Makefile.in +++ b/lisp/Makefile.in @@ -57,7 +57,7 @@ EMACS = ../src/emacs${EXEEXT} # Command line flags for Emacs. -EMACSOPT = -batch --no-site-file --no-site-lisp +EMACSOPT = -batch --no-site-file --no-site-lisp --debug-init # Extra flags to pass to the byte compiler BYTE_COMPILE_EXTRA_FLAGS = @@ -183,6 +183,7 @@ $(lisp)/loaddefs.el: $(LOADDEFS) --eval '(setq autoload-ensure-writable t)' \ --eval '(setq autoload-builtin-package-versions t)' \ --eval '(setq generated-autoload-file (expand-file-name (unmsys--file-name "$@")))' \ + --eval '(toggle-debug-on-error)' \ -f batch-update-autoloads ${SUBDIRS_ALMOST} # This is required by the bootstrap-emacs target in ../src/Makefile, so @@ -381,7 +382,7 @@ $(MH_E_DIR)/mh-loaddefs.el: $(MH_E_SRC) $(AM_V_GEN)$(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \ --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \ - -f batch-update-autoloads $(MH_E_DIR) + -f batch-update-autoloads $(MH_E_DIR) # Update TRAMP internal autoloads. Maybe we could move tramp*.el into # an own subdirectory. OTOH, it does not hurt to keep them in @@ -418,7 +419,7 @@ $(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC) $(CAL_DIR)/diary-loaddefs.el $(AM_V_GEN)$(emacs) -l autoload \ --eval "(setq generate-autoload-cookie \";;;###holiday-autoload\")" \ --eval "(setq generated-autoload-file (expand-file-name (unmsys--file-name \"$@\")))" \ - -f batch-update-autoloads $(CAL_DIR) + -f batch-update-autoloads $(CAL_DIR) .PHONY: bootstrap-clean distclean maintainer-clean diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el index e688d6b..98bb0d7 100644 --- a/lisp/emacs-lisp/autoload.el +++ b/lisp/emacs-lisp/autoload.el @@ -226,7 +226,6 @@ make-autoload ;; A doc-string-elt property of ELT says that (nth ELT FORM) is ;; the doc-string in FORM. ;; Those properties are now set in lisp-mode.el. - (defun autoload-find-generated-file () "Visit the autoload file for the current buffer, and return its buffer. If a buffer is visiting the desired autoload file, return it." @@ -234,9 +233,20 @@ autoload-find-generated-file (enable-local-eval nil)) ;; We used to use `raw-text' to read this file, but this causes ;; problems when the file contains non-ASCII characters. - (let ((delay-mode-hooks t)) - (find-file-noselect - (autoload-ensure-default-file (autoload-generated-file)))))) + (let* ((delay-mode-hooks t) + (file (autoload-generated-file)) + (file-missing (not (file-exists-p file)))) + (message "File missing %s %s" file file-missing) + (when file-missing + (autoload-ensure-default-file file)) + (with-current-buffer + (find-file-noselect + (autoload-ensure-file-writeable + file)) + (when file-missing + (setq buffer-backed-up t) + (save-buffer)) + (current-buffer))))) (defun autoload-generated-file () (expand-file-name generated-autoload-file @@ -357,21 +367,22 @@ autoload-ensure-writable ;;;###autoload (put 'autoload-ensure-writable 'risky-local-variable t) +(defun autoload-ensure-file-writeable (file) + ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, + ;; which was designed to handle CVSREAD=1 and equivalent. + (and autoload-ensure-writable + (let ((modes (file-modes file))) + (if (zerop (logand modes #o0200)) + ;; Ignore any errors here, and let subsequent attempts + ;; to write the file raise any real error. + (ignore-errors (set-file-modes file (logior modes #o0200)))))) + file) + (defun autoload-ensure-default-file (file) "Make sure that the autoload file FILE exists, creating it if needed. If the file already exists and `autoload-ensure-writable' is non-nil, make it writable." - (if (file-exists-p file) - ;; Probably pointless, but replaces the old AUTOGEN_VCS in lisp/Makefile, - ;; which was designed to handle CVSREAD=1 and equivalent. - (and autoload-ensure-writable - (let ((modes (file-modes file))) - (if (zerop (logand modes #o0200)) - ;; Ignore any errors here, and let subsequent attempts - ;; to write the file raise any real error. - (ignore-errors (set-file-modes file (logior modes #o0200)))))) - (write-region (autoload-rubric file) nil file)) - file) + (write-region (autoload-rubric file) nil file)) (defun autoload-insert-section-header (outbuf autoloads load-name file time) "Insert the section-header line, --=-=-=--