emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] Fontification for inline src blocks


From: Ihor Radchenko
Subject: Re: [PATCH] Fontification for inline src blocks
Date: Mon, 22 Nov 2021 22:35:20 +0800

Timothy <tecosaur@gmail.com> writes:

>> I have some comments. See below.
>
> Thanks for going through this, and for all your help previously.
> I appreciate it :)

Welcome.

>>> (org-inline-src-fontify-max-length): Create a variable to limit the
>>> maximum length of an inline-src block fontified, to protect from lag
>>> spikes (e.g. when typing out src_lang{ and half of the buffer is
>>> fontified).
>>
>> I do not like this. Even with this variable, some part of buffer may be
>> spuriously fontified. Maybe you just verify that you are at actual
>> inline-src block by examining org-element-context?
>
> The description may need updating, as that’s a tad inaccurate. That value
> actually limits how far forwards a paired paren is searched for. There’s no
> spurious fontification.

I can see the purpose. However, it still looks like overcomplication.
org-element-context takes care about this issue simply by narrowing to
current element (inline src block is an object and hence must end within
current element).

>>> +        (font-lock-append-text-property lang-beg lang-end ’face 
>>> ’org-meta-line)
>>> +        (font-lock-append-text-property beg lang-beg ’face ’shadow)
>>> +        (font-lock-append-text-property beg lang-end ’face 
>>> ’org-inline-src-block)
>>
>> Is there some special reason why you apply both ’shadow and
>> ’org-inline-src-block? What about ’org-meta-line face? Maybe
>> ’org-meta-line should not be hard-coded?
>
> I think there’s an argument for more faces that can be made because of element
> like this, but it comes down to the idea that in a 
> `src_lang[options]{content}'
> construct `src_' is effectively visual noise, particularly once fortification
> occurs and it’s obvious that it’s inline code even without it. So, I find it
> nicest if it’s faded, which `shadow' does. Also applying 
> `org-inline-src-block'
> allows for a consistent background colour across the whole construct.

Makes sense. 

>> It looks like you are repeating the job of org-element-context here. Why
>> don’t you just get the proper object?
>
> IIRC `org-element-context' doesn’t separate out the `src_', `lang', 
> `[options]', and
> `{content}' of an inline source code block (which we want).

Sounds like an omission in org-element-context. At least, the parser
could return :contents-begin and :contents-end. Then, you would also not
need to re-implement the parser.

Best,
Ihor



reply via email to

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