branch: elpa/magit
commit 7de0f1335f8c4954d6d07413c5ec19fc8200078c
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    magit-section-mode: Set font-lock-defaults to disable syntactic font-lock
    
    Setting `font-lock-keywords-only' as we did since [1: 9e6791796f]
    (and fixed in [2: 649bc9dc32]) does not work because once some
    third-party minor-mode calls `font-lock-add-keywords', its value
    is set anew (from `font-lock-defaults', which we did not set).
    
    As stated in the manual, such variables should not be set directly,
    one should instead set `font-lock-defaults'.  Failure to follow that
    advice results in issues such as the above.
    
    We avoided setting `font-lock-defaults' ever since [3: 5a2786cc00],
    but that was misguided.  By default `font-look-mode' is enabled for
    all major-modes anyway, so this attempt to not enable font-lock in
    `magit-section-mode' buffers if at all possible was futile.  And
    if it had succeeded that would actually have disabled most if not
    all fontification in Magit buffers (because we use `font-lock-face',
    (not `face') as we are supposed to).
    
    (A more descriptive name for the `font-lock-face' property would be
    `none-font-lock-face-which-font-lock-mode-does-not-discard'.)
    
    Closes #5420.
    
    1: 2025-07-24 9e6791796facd87d6d46abca2628e802edf01ec4
       Set font-lock-keywords-only to disable syntactic fontification
    
    2: 2025-08-13 649bc9dc328b8cb7519292be4f5c9cac13cf3466
       magit-section-mode: Set font-lock-keywords-only locally
    
    3: 2019-08-22 5a2786cc005c1dfb698b6c2fc1dd592c344b0e4a
       magit-mode: Disable syntactic font-lock differently
---
 lisp/magit-section.el | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lisp/magit-section.el b/lisp/magit-section.el
index 7ebfe2140e6..0e7526d3dd2 100644
--- a/lisp/magit-section.el
+++ b/lisp/magit-section.el
@@ -428,11 +428,9 @@ Magit-Section is documented in info node 
`(magit-section)'."
   (buffer-disable-undo)
   (setq truncate-lines t)
   (setq buffer-read-only t)
-  (setq-local line-move-visual t) ; see #1771
-  ;; Turn off syntactic font locking, but not by setting
-  ;; `font-lock-defaults' because that would enable font locking, and
-  ;; not all magit plugins may be ready for that (see #3950).
-  (setq-local font-lock-keywords-only t)
+  (setq-local line-move-visual t) ; See #1771.
+  ;; Turn off syntactic font locking.  See #5420.
+  (setq-local font-lock-defaults '(nil t))
   (setq show-trailing-whitespace nil)
   (setq-local symbol-overlay-inhibit-map t)
   (setq list-buffers-directory (abbreviate-file-name default-directory))

Reply via email to