emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: commit e22b4eb7 kills formatting & color


From: Ihor Radchenko
Subject: Re: commit e22b4eb7 kills formatting & color
Date: Tue, 02 Aug 2022 21:55:32 +0800

Colin Baxter <m43cap@yandex.com> writes:

> I disable popups so I always receive a buffer with:
>
> --8<---------------cut here---------------start------------->8---
> The local variables list in test.org
> or .dir-locals.el contains values that may not be safe (*).

Thanks!

Can you try the attached patch?

Best,
Ihor

>From 8348c62250d2ef92da92416ae13d91289b2abe01 Mon Sep 17 00:00:00 2001
Message-Id: 
<8348c62250d2ef92da92416ae13d91289b2abe01.1659448323.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 2 Aug 2022 21:50:20 +0800
Subject: [PATCH] org-mode: Prevent early fontification

* lisp/org.el (org-mode): Avoid triggering fontification when
`hack-local-variables' popup window is displayed.  Font-lock settings
are not configured yet at this point.

Fixes 87r120kodw.fsf@yandex.com">https://orgmode.org/list/87r120kodw.fsf@yandex.com
---
 lisp/org.el | 68 +++++++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 31 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 214652364..f8977bba5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -4708,37 +4708,43 @@ (define-derived-mode org-mode outline-mode "Org"
 
 \\{org-mode-map}"
   (setq-local org-mode-loading t)
-  ;; Apply file-local and directory-local variables, so that Org
-  ;; startup respects them.  See
-  ;; 
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
-  (hack-local-variables 'ignore-mode-settings)
-  (org-load-modules-maybe)
-  (org-install-agenda-files-menu)
-  (when (and org-link-descriptive
-             (eq org-fold-core-style 'overlays))
-    (add-to-invisibility-spec '(org-link)))
-  (org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" 
org-ellipsis)) org-ellipsis)
-                        "..."))
-  (make-local-variable 'org-link-descriptive)
-  (when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec 
'(org-hide-block . t)))
-  (if org-link-descriptive
-      (org-fold-core-set-folding-spec-property (car 
org-link--link-folding-spec) :visible nil)
-    (org-fold-core-set-folding-spec-property (car org-link--link-folding-spec) 
:visible t))
-  (setq-local outline-regexp org-outline-regexp)
-  (setq-local outline-level 'org-outline-level)
-  (when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
-    (unless org-display-table
-      (setq org-display-table (make-display-table)))
-    (set-display-table-slot
-     org-display-table 4
-     (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis))
-                     org-ellipsis)))
-    (setq buffer-display-table org-display-table))
-  (org-set-regexps-and-options)
-  (org-set-font-lock-defaults)
-  (when (and org-tag-faces (not org-tags-special-faces-re))
-    ;; tag faces set outside customize.... force initialization.
-    (org-set-tag-faces 'org-tag-faces org-tag-faces))
+  ;; Disable `font-lock-mode' temporarily to delay fontification in case if
+  ;; `hack-local-variables' shows a popup window.  Such a popup causes
+  ;; redisplay and triggers fontification too early.
+  (let ((org-font-lock-enabled-p font-lock-mode))
+    (font-lock-mode -1)
+    ;; Apply file-local and directory-local variables, so that Org
+    ;; startup respects them.  See
+    ;; 
https://list.orgmode.org/587be554-906c-5370-2cf2-f08b14fa58ff@gmail.com/T/#u
+    (hack-local-variables 'ignore-mode-settings)
+    (org-load-modules-maybe)
+    (org-install-agenda-files-menu)
+    (when (and org-link-descriptive
+               (eq org-fold-core-style 'overlays))
+      (add-to-invisibility-spec '(org-link)))
+    (org-fold-initialize (or (and (stringp org-ellipsis) (not (equal "" 
org-ellipsis)) org-ellipsis)
+                          "..."))
+    (make-local-variable 'org-link-descriptive)
+    (when (eq org-fold-core-style 'overlays) (add-to-invisibility-spec 
'(org-hide-block . t)))
+    (if org-link-descriptive
+        (org-fold-core-set-folding-spec-property (car 
org-link--link-folding-spec) :visible nil)
+      (org-fold-core-set-folding-spec-property (car 
org-link--link-folding-spec) :visible t))
+    (setq-local outline-regexp org-outline-regexp)
+    (setq-local outline-level 'org-outline-level)
+    (when (and (stringp org-ellipsis) (not (equal "" org-ellipsis)))
+      (unless org-display-table
+        (setq org-display-table (make-display-table)))
+      (set-display-table-slot
+       org-display-table 4
+       (vconcat (mapcar (lambda (c) (make-glyph-code c 'org-ellipsis))
+                       org-ellipsis)))
+      (setq buffer-display-table org-display-table))
+    (org-set-regexps-and-options)
+    (org-set-font-lock-defaults)
+    (when (and org-tag-faces (not org-tags-special-faces-re))
+      ;; tag faces set outside customize.... force initialization.
+      (org-set-tag-faces 'org-tag-faces org-tag-faces))
+    (font-lock-mode org-font-lock-enabled-p))
   ;; Calc embedded
   (setq-local calc-embedded-open-mode "# ")
   ;; Modify a few syntax entries
-- 
2.35.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]