unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Paul Pogonyshev <pogonyshev@gmail.com>
Cc: 38072@debbugs.gnu.org
Subject: bug#38072: when `byte-compile-file' finds out that a file is `no-byte-compile', it ignores `load' parameter
Date: Sat, 5 Sep 2020 00:30:38 +0000	[thread overview]
Message-ID: <CADwFkmnXBW5i5WNAtvLWRDG=gwujNRW9JwLXVZ+7Y+QZ=Yae+Q@mail.gmail.com> (raw)
In-Reply-To: <CAG7BpapSZSV8hLpaDQg6uyR05tVWKCpO+hgPEuy4cQktf7w+Bg@mail.gmail.com> (Paul Pogonyshev's message of "Tue, 5 Nov 2019 21:58:55 +0100")

[-- Attachment #1: Type: text/plain, Size: 1516 bytes --]

tags 38072 + patch
thanks

Paul Pogonyshev <pogonyshev@gmail.com> writes:

> After (byte-compile-file "..." t) one normally expects that the file
> is loaded, all its functions and variables are visible etc.  However,
> if file contains local variable `no-byte-compile', not only
> compilation is cancelled, `byte-compile-file' also doesn't load the
> file.
>
> Expected: if `byte-compile-file' cancels byte-compilation and `load'
> is non-nil, it should load the uncompiled source instead.

The fix is pretty simple (see attached), but I'm not sure what the
correct behavior is here.

The doc string of `byte-compile-file' says:

    Compile a file of Lisp code named FILENAME into a file of byte code.
    The output file’s name is generated by passing FILENAME to the
    function ‘byte-compile-dest-file’ (which see).
    With prefix arg (noninteractively: 2nd arg), LOAD the file after compiling.
                                                               ^^^^^^^^^^^^^^^

So should we load the file if we did not compile the file?  I'm thinking
yes, and I don't see what it could hurt to change it to load the file.
If the user uses a prefix arg or the LOAD argument from Lisp, surely
that was the intention.

But on the other hand the text above seems deliberate, somehow?  (And
AFAICT the behavior has been not to load the file since pretty much
forever, possibly since byte-compilation was first added.)

Any other opinions here?

Best regards,
Stefan Kangas

[-- Attachment #2: 0001-Ensure-byte-compile-file-loads-file-with-non-nil-loa.patch --]
[-- Type: text/x-diff, Size: 1089 bytes --]

From f48c2a446e5343f8ad104eb5523e834bb127825d Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefankangas@gmail.com>
Date: Sat, 5 Sep 2020 02:14:54 +0200
Subject: [PATCH] Ensure byte-compile-file loads file with non-nil load arg

* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Load file when
argument 'load' is non-nil, even if 'no-byte-compile' is also
non-nil.  (Bug#38072)
---
 lisp/emacs-lisp/bytecomp.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 966990bac9..d6db318e65 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1970,6 +1970,9 @@ byte-compile-file
 		     (byte-compile-abbreviate-file target-file)
 		     (buffer-local-value 'no-byte-compile input-buffer))
 	    (condition-case nil (delete-file target-file) (error nil)))
+          ;; Load the file even when not byte-compiling.  (Bug#38072)
+          (when load
+            (load target-file))
 	  ;; We successfully didn't compile this file.
 	  'no-byte-compile)
       (when byte-compile-verbose
-- 
2.28.0


  reply	other threads:[~2020-09-05  0:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 20:58 bug#38072: when `byte-compile-file' finds out that a file is `no-byte-compile', it ignores `load' parameter Paul Pogonyshev
2020-09-05  0:30 ` Stefan Kangas [this message]
2020-09-05  6:21   ` Eli Zaretskii
2020-09-05 15:26     ` Stefan Monnier
2020-09-07 16:37       ` Stefan Kangas
2020-09-07 16:44         ` Andrea Corallo via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-13 13:06           ` Stefan Kangas
2020-09-13 14:52             ` Eli Zaretskii
2020-09-21 22:30               ` Stefan Kangas
2020-09-22  2:28                 ` Eli Zaretskii
2020-10-20 16:56                   ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmnXBW5i5WNAtvLWRDG=gwujNRW9JwLXVZ+7Y+QZ=Yae+Q@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=38072@debbugs.gnu.org \
    --cc=pogonyshev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).