]> git.eshelyaron.com Git - emacs.git/commitdiff
flymake: fall back to margins on text terminals
authorSpencer Baugh <sbaugh@janestreet.com>
Tue, 8 Apr 2025 12:43:37 +0000 (08:43 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sun, 13 Apr 2025 20:51:28 +0000 (22:51 +0200)
Previously, flymake-indicator-type defaulted to either fringes
or margins.  But fringes should be used on graphical frames, and
margins on TTY frames.  So default to fringes instead, and
simply fall back to margins automatically on text frames.

* lisp/progmodes/flymake.el (flymake-indicator-type): Set to
fringes.  (bug#77313)
(flymake-mode): Fallback to margins if there's no fringes.
* doc/misc/flymake.texi (Customizable variables): Mention
fallback behavior.
* etc/NEWS: Announce fallback behavior.

(cherry picked from commit 861e7f8b60e4bf076bf5991d25a22b3a012746bd)

doc/misc/flymake.texi
lisp/progmodes/flymake.el

index 548357679282e99bdce23f7b14d6a906eddb83e9..668a72b4cd1c16851fbf6768a423d37613147b71 100644 (file)
@@ -313,6 +313,9 @@ 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.
 
 @item flymake-error-bitmap
 A bitmap used in the fringe to mark lines for which an error has
index 9cee2365f24aabd46bc199288bbf94b6ed49d882..0359b88218f1091e7d621742ef8c85092919365a 100644 (file)
@@ -176,22 +176,23 @@ See `flymake-error-bitmap' and `flymake-warning-bitmap'."
                 (const right-fringe)
                 (const :tag "No fringe indicators" nil)))
 
-(defcustom flymake-indicator-type (if (display-graphic-p)
-                                      'fringes
-                                    'margins)
+(defcustom flymake-indicator-type 'fringes
   "Indicate which indicator type to use for display errors.
 
 The value can be nil (don't indicate errors but just highlight them),
-fringes (use fringes) or margins (use margins)
+the symbol `fringes' (use fringes) or the symbol `margins' (use
+margins).
 
 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 "30.1"
+  :version "31.1"
   :type '(choice (const :tag "Use Fringes" fringes)
-                 (const :tag "Use Margins "margins)
+                 (const :tag "Use Marginsmargins)
                  (const :tag "No indicators" nil)))
 
 (defcustom flymake-margin-indicators-string
@@ -1492,6 +1493,13 @@ suitable for the current buffer.  The commands
     (add-hook 'after-change-functions 'flymake-after-change-function nil t)
     (add-hook 'dwim-hook 'flymake-dwim-fix nil 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)