* org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues
@ 2023-11-12 15:39 JD Smith
2023-11-13 8:37 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: JD Smith @ 2023-11-12 15:39 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
When `org-edit-src-content-indentation’ is non-nil (default: 2), editing SRC blocks preserves this amount of extra indentation space at the beginning of each line of the block, removing and then re-adding it on round trips through `org-edit-src-code’.
But `org-src-font-lock-fontify-block' does not consider this extra space. Instead it simply copies the full block verbatim into e.g. *org-src-fontification:python-mode*, as if the extra indent space were a legitimate part of the source. Normally this wouldn’t be a problem, as faces are attached to keywords. But for any fontification that depends explicitly on indentation, this leads to incorrect results. For example, my indent-bars package adds indentation bars via text properties based on absolute column position. These bars are then offset in the displayed org src block by 2 columns from their correct locations, due to the extra space org has put there.
A sensible solution might be for fontify-block to strip `org-edit-src-content-indentation’ worth of space from the beginning of each line, just as is done for src block editing, then perform the fontification, then add that space back to the fontified text for display.
Thanks for all your work on org.
[-- Attachment #2: Type: text/html, Size: 1902 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues
2023-11-12 15:39 org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues JD Smith
@ 2023-11-13 8:37 ` Ihor Radchenko
2023-11-13 12:25 ` JD Smith
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2023-11-13 8:37 UTC (permalink / raw)
To: JD Smith; +Cc: emacs-orgmode
JD Smith <jdtsmith@gmail.com> writes:
> When `org-edit-src-content-indentation’ is non-nil (default: 2), editing SRC blocks preserves this amount of extra indentation space at the beginning of each line of the block, removing and then re-adding it on round trips through `org-edit-src-code’.
>
> But `org-src-font-lock-fontify-block' does not consider this extra space. Instead it simply copies the full block verbatim into e.g. *org-src-fontification:python-mode*, as if the extra indent space were a legitimate part of the source. Normally this wouldn’t be a problem, as faces are attached to keywords. But for any fontification that depends explicitly on indentation, this leads to incorrect results. For example, my indent-bars package adds indentation bars via text properties based on absolute column position. These bars are then offset in the displayed org src block by 2 columns from their correct locations, due to the extra space org has put there.
Duplicate of
https://list.orgmode.org/orgmode/CAOn=hbevUMGS0-qMTy8kB4-db65s1Tmn0cQJcw8b++PZZ=vULA@mail.gmail.com/
Handled.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues
2023-11-13 8:37 ` Ihor Radchenko
@ 2023-11-13 12:25 ` JD Smith
2023-11-13 12:30 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: JD Smith @ 2023-11-13 12:25 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
> On Nov 13, 2023, at 3:37 AM, Ihor Radchenko <yantar92@posteo.net> wrote:
>
> JD Smith <jdtsmith@gmail.com> writes:
>
>> When `org-edit-src-content-indentation’ is non-nil (default: 2), editing SRC blocks preserves this amount of extra indentation space at the beginning of each line of the block, removing and then re-adding it on round trips through `org-edit-src-code’.
>>
>> But `org-src-font-lock-fontify-block' does not consider this extra space. Instead it simply copies the full block verbatim into e.g. *org-src-fontification:python-mode*, as if the extra indent space were a legitimate part of the source. Normally this wouldn’t be a problem, as faces are attached to keywords. But for any fontification that depends explicitly on indentation, this leads to incorrect results. For example, my indent-bars package adds indentation bars via text properties based on absolute column position. These bars are then offset in the displayed org src block by 2 columns from their correct locations, due to the extra space org has put there.
>
> Duplicate of
> https://list.orgmode.org/orgmode/CAOn=hbevUMGS0-qMTy8kB4-db65s1Tmn0cQJcw8b++PZZ=vULA@mail.gmail.com/
> Handled.
Great. In Org 9.7?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues
2023-11-13 12:25 ` JD Smith
@ 2023-11-13 12:30 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2023-11-13 12:30 UTC (permalink / raw)
To: JD Smith; +Cc: emacs-orgmode
JD Smith <jdtsmith@gmail.com> writes:
>> Duplicate of
>> https://list.orgmode.org/orgmode/CAOn=hbevUMGS0-qMTy8kB4-db65s1Tmn0cQJcw8b++PZZ=vULA@mail.gmail.com/
>> Handled.
>
> Great. In Org 9.7?
No. It is not fixed yet.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-13 12:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-12 15:39 org-src-font-lock-fontify-block is unaware of org-edit-src-content-indentation, leading to fontification issues JD Smith
2023-11-13 8:37 ` Ihor Radchenko
2023-11-13 12:25 ` JD Smith
2023-11-13 12:30 ` Ihor Radchenko
Code repositories for project(s) associated with this public 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).