emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* commit e22b4eb7 kills formatting & color
@ 2022-08-01  9:44 Colin Baxter
  2022-08-01 13:02 ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-01  9:44 UTC (permalink / raw)
  To: emacs-orgmode


With the latest org-mode, my org files have lost all syntax coloring and
org-mode formatting. They are essentially dead. If I revert commit
e22b4eb7 then they come back to life with coloring and formatting as
usual. My files have local variables which have worked perfecting ok
before the e22b4eb7 commit. Have other users experienced similar issues?

Best wishes,

Colin Baxter.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01  9:44 commit e22b4eb7 kills formatting & color Colin Baxter
@ 2022-08-01 13:02 ` Ihor Radchenko
  2022-08-01 13:21   ` Colin Baxter
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-01 13:02 UTC (permalink / raw)
  To: m43cap; +Cc: emacs-orgmode

Colin Baxter <m43cap@yandex.com> writes:

> With the latest org-mode, my org files have lost all syntax coloring and
> org-mode formatting. They are essentially dead. If I revert commit
> e22b4eb7 then they come back to life with coloring and formatting as
> usual. My files have local variables which have worked perfecting ok
> before the e22b4eb7 commit. Have other users experienced similar issues?

The commits puts file-local and directory-local variables in effect
_before_ loading Org mode. It means that e.g. setting up initial
visibility can be done using directory-local variables.

Do you have any idea which particular file-local variable is leading to
the breakage?

Best,
Ihor


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01 13:02 ` Ihor Radchenko
@ 2022-08-01 13:21   ` Colin Baxter
  2022-08-01 13:57     ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-01 13:21 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>>>>> Ihor Radchenko <yantar92@gmail.com> writes:

    > Colin Baxter <m43cap@yandex.com> writes:
    >> With the latest org-mode, my org files have lost all syntax
    >> coloring and org-mode formatting. They are essentially dead. If I
    >> revert commit e22b4eb7 then they come back to life with coloring
    >> and formatting as usual. My files have local variables which have
    >> worked perfecting ok before the e22b4eb7 commit. Have other users
    >> experienced similar issues?

    > The commits puts file-local and directory-local variables in
    > effect _before_ loading Org mode. It means that e.g. setting up
    > initial visibility can be done using directory-local variables.

    > Do you have any idea which particular file-local variable is
    > leading to the breakage?

    > Best, Ihor

Dear Ihor,

Well I'm tempted to say all of them because I have local variables in
files and .dir-locals.el in many locations. But for a start:

# Local Variables:
# eval: (setq org-confirm-babel-evaluate nil)
# eval: (setq org-adapt-indentation t)
# eval: (set (make-local-variable 'org-hide-emphasis-markers) t)
# End:

I am obviously missing something because I thought a local variable was
by definition local to a file or directory and was not used until that
file was opened. So why put them in effect before they are needed?

Best wishes.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01 13:21   ` Colin Baxter
@ 2022-08-01 13:57     ` Ihor Radchenko
  2022-08-01 14:34       ` Colin Baxter
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-01 13:57 UTC (permalink / raw)
  To: m43cap; +Cc: emacs-orgmode

Colin Baxter <m43cap@yandex.com> writes:

>     > Do you have any idea which particular file-local variable is
>     > leading to the breakage?
>
> Well I'm tempted to say all of them because I have local variables in
> files and .dir-locals.el in many locations. But for a start:
>
> # Local Variables:
> # eval: (setq org-confirm-babel-evaluate nil)
> # eval: (setq org-adapt-indentation t)
> # eval: (set (make-local-variable 'org-hide-emphasis-markers) t)
> # End:

I am unable to see any issues with fontification starting from emacs -Q
and loading a file containing these variables.

> I am obviously missing something because I thought a local variable was
> by definition local to a file or directory and was not used until that
> file was opened. So why put them in effect before they are needed?

They are put into effect after the file is opened, but Org mode is not
yet loaded. The previous default was applying file-locals _after_ Org
mode is loaded and hence there was no way to set, for example,
org-src-fontify-natively or org-enforce-todo-dependencies via file-local
variables.

Best,
Ihor



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01 13:57     ` Ihor Radchenko
@ 2022-08-01 14:34       ` Colin Baxter
  2022-08-01 14:51         ` Colin Baxter
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-01 14:34 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>>>>> Ihor Radchenko <yantar92@gmail.com> writes:

    > Colin Baxter <m43cap@yandex.com> writes:
    >> > Do you have any idea which particular file-local variable is >
    >> leading to the breakage?
    >> 
    >> Well I'm tempted to say all of them because I have local
    >> variables in files and .dir-locals.el in many locations. But for
    >> a start:
    >> 
    >> # Local Variables: # eval: (setq org-confirm-babel-evaluate nil)
    >> # eval: (setq org-adapt-indentation t) # eval: (set
    >> (make-local-variable 'org-hide-emphasis-markers) t) # End:

    > I am unable to see any issues with fontification starting from
    > emacs -Q and loading a file containing these variables.

I think the solution for me is to delete the .elc files in org-mode. I
am about to do this and will report back.


    >> I am obviously missing something because I thought a local
    >> variable was by definition local to a file or directory and was
    >> not used until that file was opened. So why put them in effect
    >> before they are needed?

    > They are put into effect after the file is opened, but Org mode is
    > not yet loaded. The previous default was applying file-locals
    > _after_ Org mode is loaded and hence there was no way to set, for
    > example, org-src-fontify-natively or org-enforce-todo-dependencies
    > via file-local variables.

Thank you. Now I understand better.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01 14:34       ` Colin Baxter
@ 2022-08-01 14:51         ` Colin Baxter
  2022-08-02 12:49           ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-01 14:51 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>>>>> Colin Baxter <m43cap@yandex.com> writes:

>>>>> Ihor Radchenko <yantar92@gmail.com> writes:
    >> Colin Baxter <m43cap@yandex.com> writes:
    >>> > Do you have any idea which particular file-local variable is >
    >>> leading to the breakage?
    >>> 
    >>> Well I'm tempted to say all of them because I have local
    >>> variables in files and .dir-locals.el in many locations. But for
    >>> a start:
    >>> 
    >>> # Local Variables: # eval: (setq org-confirm-babel-evaluate nil)
    >>> # eval: (setq org-adapt-indentation t) # eval: (set
    >>> (make-local-variable 'org-hide-emphasis-markers) t) # End:

    >> I am unable to see any issues with fontification starting from
    >> emacs -Q and loading a file containing these variables.

    > I think the solution for me is to delete the .elc files in
    > org-mode. I am about to do this and will report back.

No, I spoke too soon. That is not the answer. For me using "emacs -q",
an opened org file will expand the folds using <TAB> but there is still no
synatx coloring. This is probably not relevant but my system is 32bit
not 64.

Best wishes,


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-01 14:51         ` Colin Baxter
@ 2022-08-02 12:49           ` Ihor Radchenko
  2022-08-02 13:29             ` Colin Baxter
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-02 12:49 UTC (permalink / raw)
  To: m43cap; +Cc: emacs-orgmode

Colin Baxter <m43cap@yandex.com> writes:

> No, I spoke too soon. That is not the answer. For me using "emacs -q",
> an opened org file will expand the folds using <TAB> but there is still no
> synatx coloring. This is probably not relevant but my system is 32bit
> not 64.

Hmm. I was able to reproduce the issue using some slightly non-standard
settings. However, only when there is a popup window asking about
non-safe file-local variables. Does it also happen for you after such a
popup? Or do you have the settings marked safe?

Best,
Ihor


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-02 12:49           ` Ihor Radchenko
@ 2022-08-02 13:29             ` Colin Baxter
  2022-08-02 13:55               ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-02 13:29 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>>>>> Ihor Radchenko <yantar92@gmail.com> writes:

    > Colin Baxter <m43cap@yandex.com> writes:
    >> No, I spoke too soon. That is not the answer. For me using "emacs
    >> -q", an opened org file will expand the folds using <TAB> but
    >> there is still no synatx coloring. This is probably not relevant
    >> but my system is 32bit not 64.

    > Hmm. I was able to reproduce the issue using some slightly
    > non-standard settings. However, only when there is a popup window
    > asking about non-safe file-local variables. Does it also happen
    > for you after such a popup? Or do you have the settings marked
    > safe?

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 (*).

Do you want to apply it?  You can type
y  -- to apply the local variables list.
n  -- to ignore the local variables list.
!  -- to apply the local variables list, and permanently mark these
      values (*) as safe (in the future, they will be set automatically.)
i  -- to ignore the local variables list, and permanently mark these
      values (*) as ignored
--8<---------------cut here---------------end--------------->8---

I then enter "y". It's a habit of mine never to use "!" even for files I
use every day. I cannot remember ever entering "n" or "i".

Best wishes,





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-02 13:29             ` Colin Baxter
@ 2022-08-02 13:55               ` Ihor Radchenko
  2022-08-02 14:49                 ` Colin Baxter
  0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-02 13:55 UTC (permalink / raw)
  To: m43cap; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-mode-Prevent-early-fontification.patch --]
[-- Type: text/x-patch, Size: 4620 bytes --]

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 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-02 13:55               ` Ihor Radchenko
@ 2022-08-02 14:49                 ` Colin Baxter
  2022-08-03  9:40                   ` Ihor Radchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Baxter @ 2022-08-02 14:49 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

>>>>> Ihor Radchenko <yantar92@gmail.com> writes:

    > 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?

I've applied your patch and it seems to work me. As far as I can tell
my org files and agenda now look and behave as normal.

Thanks.



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: commit e22b4eb7 kills formatting & color
  2022-08-02 14:49                 ` Colin Baxter
@ 2022-08-03  9:40                   ` Ihor Radchenko
  0 siblings, 0 replies; 11+ messages in thread
From: Ihor Radchenko @ 2022-08-03  9:40 UTC (permalink / raw)
  To: m43cap; +Cc: emacs-orgmode

Colin Baxter <m43cap@yandex.com> writes:

> I've applied your patch and it seems to work me. As far as I can tell
> my org files and agenda now look and behave as normal.

Applied onto main via fde93abb8.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=fde93abb8c490bc2e0a1fe1d7a23127669bbc90e

Best,
Ihor


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-08-03  9:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01  9:44 commit e22b4eb7 kills formatting & color Colin Baxter
2022-08-01 13:02 ` Ihor Radchenko
2022-08-01 13:21   ` Colin Baxter
2022-08-01 13:57     ` Ihor Radchenko
2022-08-01 14:34       ` Colin Baxter
2022-08-01 14:51         ` Colin Baxter
2022-08-02 12:49           ` Ihor Radchenko
2022-08-02 13:29             ` Colin Baxter
2022-08-02 13:55               ` Ihor Radchenko
2022-08-02 14:49                 ` Colin Baxter
2022-08-03  9:40                   ` Ihor Radchenko

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).