Subject: bug#40573: closed (Re: bug#40573: 27.0.90; flymake-mode broken in scratch buffer)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 01 May 2020 11:11:02 +0000

Your bug report

#40573: 27.0.90; flymake-mode broken in scratch buffer

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
40573: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=40573
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#40573: 27.0.90; flymake-mode broken in scratch buffer
From: João Távora <[email-masked]>
To: Eli Zaretskii <[email-masked]>, [email-masked]
Cc: "Basil L. Contovounesios" <[email-masked]>, Dmitry Gutov <[email-masked]>, Stefan Monnier <[email-masked]>, Juri Linkov <[email-masked]>
Date: Fri, 1 May 2020 12:10:19 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

On Mon, Apr 20, 2020 at 5:05 PM Eli Zaretskii <[email-masked]> wrote:
>
> > From: João Távora <[email-masked]>
> > Date: Mon, 20 Apr 2020 15:02:47 +0100
> > Cc: "Basil L. Contovounesios" <[email-masked]>, Stefan Monnier <[email-masked]>,
> >       Juri Linkov <[email-masked]>, [email-masked], Dmitry Gutov <[email-masked]>
> >
> > Shall I squash the commits and push to master?
>
> If there's nothing left to take care of, sure.

Done.  Also marking this bug "done".

Subject: 27.0.90; flymake-mode broken in scratch buffer
From: João Távora <[email-masked]>
To: [email-masked]
Date: Sun, 12 Apr 2020 14:18:50 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Eli, remember when you added this commit?

commit 61fb5214816ef3d57e676d900e499ffcd079a1f9
Author: Eli Zaretskii <[email-masked]>
Date:   Mon Oct 21 14:29:13 2019 +0300

    Avoid false indications from Flymake in .dir-locals.el files

This seems to have the unintended effect of also disabling flymake-mode
in fileless elisp buffers, like *scratch*.  Was it intended? It seems like
a
regression in relation to 26.3. The repro is simple:

Emacs -Q
M-x flymake-mode

Works in Emacs 26.3, doesn't in Emacs-27.

Again, without wanting to rehash a long and difficult discussion, I
think the best way to fix the original problem is to make an
emacs-lisp-data-mode and use that mode for .dir-locals.el.

  emacs-lisp-data-mode   ; things related to
           ^             ; emacs-lisp-data, like sexp navigation,
           |             ; comments, etc.  Use for .dir-locals.el
           |
           |
     emacs-lisp-mode     ; things related to data which happens
           ^             ; to also be code. Setup xref, flymake, imenu,
           |             ; etc
           |
           |
  lisp-interaction-mode  ; no change, basically this just has an
                         ; enhanced keymap for for the advanced
                         ; interaction possibilities.

That said, whatever fix we can come up with for this regression is
probably safer for Emacs 27.  I propose this slight convolution of the
condition you added.

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 2617a6e4cc..f39ecf9b7b 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -264,9 +264,9 @@ emacs-lisp-mode
   (unless
       (let* ((bfname (buffer-file-name))
              (fname (and (stringp bfname) (file-name-nondirectory
bfname))))
-        (or (not (stringp fname))
-            (string-match "\\`\\.#" fname)
-            (string-equal dir-locals-file fname)))
+        (and (stringp fname)
+             (or (string-match "\\`\\.#" fname)
+                 (string-equal dir-locals-file fname))))
     (add-hook 'flymake-diagnostic-functions #'elisp-flymake-checkdoc nil t)
     (add-hook 'flymake-diagnostic-functions
               #'elisp-flymake-byte-compile nil t)))