Subject: Re: bug#79244: [PATCH] flymake: stop trying to automatically fall back to margins

From: Spencer Baugh <[email-masked]>
Date: Fri, 15 Aug 2025 13:52:31 -0400

Eli Zaretskii <[email-masked]> writes:

>> Date: Fri, 15 Aug 2025 10:13:49 -0400
>> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <[email-masked]>
>> 
>> The code to automatically fallback to margins is not correct: it
>> relies implicitly on the buffer being displayed in a window
>> while flymake-mode is running.  If the buffer is created while
>> not displayed, we will always automatically fallback to margins,
>> which is incorrect.
>> 
>> Avoid the regression by simply disabling this code.  I'll try
>> again to fall back automatically in the future.
>
> Thanks.
>
>> --- a/doc/misc/flymake.texi
>> +++ b/doc/misc/flymake.texi
>> @@ -317,9 +317,6 @@ Customizable variables
>>  errors or warnings.
>>  Depending on your preference, this can either use @code{fringes} or
>>  @code{margins} for indicating errors.
>> -If set to @code{fringes} (the default), it will automatically fall back
>> -to using margins in windows or frames without fringes, such as text
>> -terminals.
>
> Text-mode terminals default to margins, so I think the above text
> should mention that.
>
> Otherwise, no comments.

Sure, fixed.

>From 8abc91b5f7ae3eeb675f3f041d20fce943184f34 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <[email-masked]>
Date: Fri, 15 Aug 2025 10:13:16 -0400
Subject: [PATCH] flymake: stop trying to automatically fall back to margins

The code to automatically fallback to margins is not correct: it
relies implicitly on the buffer being displayed in a window
while flymake-mode is running.  If the buffer is created while
not displayed, we will always automatically fallback to margins,
which is incorrect.

Avoid the regression by simply disabling this code.  I'll try
again to fall back automatically in the future.

* doc/misc/flymake.texi (Customizable variables): Remove section
about automatic fallback to margins.
* etc/NEWS: Un-announce removed feature.
* lisp/progmodes/flymake.el (flymake-indicator-type)
(flymake-mode): Stop automatically falling back to
margins. (bug#77313)
---
 doc/misc/flymake.texi     | 6 ++----
 etc/NEWS                  | 5 -----
 lisp/progmodes/flymake.el | 9 ---------
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index d6c8778d785..cc364813f8b 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -316,10 +316,8 @@ Customizable variables
 The indicator type which Flymake should use to indicate lines with
 errors or warnings.
 Depending on your preference, this can either use @code{fringes} or
-@code{margins} for indicating errors.
-If set to @code{fringes} (the default), it will automatically fall back
-to using margins in windows or frames without fringes, such as text
-terminals.
+@code{margins} for indicating errors.  On text terminals, only
+@code{margins} is available.
 
 @item flymake-error-bitmap
 A bitmap used in the fringe to mark lines for which an error has
diff --git a/etc/NEWS b/etc/NEWS
index 374fee4b770..881f4f4f09a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2481,11 +2481,6 @@ file names in above buffers.  The default is nil.
 ---
 ** Flymake
 
-*** Windows without fringes now automatically use margin indicators.
-When 'flymake-indicator-type' is set to 'fringes', as is now the default,
-flymake will automatically fall back to using margin indicators in
-windows without fringes, including any window on a text terminal.
-
 *** Enhanced 'flymake-show-diagnostics-at-end-of-line'
 The new value 'fancy' allowed for this user option will attempt to
 layout diagnostics below the affected line using unicode graphics to
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index e911faf603d..95d5c0f5624 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -195,8 +195,6 @@ flymake-indicator-type
 Difference between fringes and margin is that fringes support displaying
 bitmaps on graphical displays and margins display text in a blank area
 from current buffer that works in both graphical and text displays.
-Thus, even when `fringes' is selected, margins will still be used on
-text displays and also when fringes are disabled.
 
 See Info node `Fringes' and Info node `(elisp)Display Margins'."
   :version "31.1"
@@ -1485,13 +1483,6 @@ flymake-mode
     (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
     (add-hook 'eldoc-documentation-functions 'flymake-eldoc-function t t)
 
-    (when (and (eq flymake-indicator-type 'fringes)
-               (not (cl-case flymake-fringe-indicator-position
-                      (left-fringe (< 0 (nth 0 (window-fringes))))
-                      (right-fringe (< 0 (nth 1 (window-fringes)))))))
-      ;; There are no fringes in the buffer, fallback to margins.
-      (setq-local flymake-indicator-type 'margins))
-
     ;; AutoResize margins.
     (flymake--resize-margins)
 
-- 
2.39.3