emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Timothy <tecosaur@gmail.com>
Cc: Tom Gillespie <tgbugs@gmail.com>, org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fontification for inline src blocks
Date: Thu, 13 May 2021 13:31:03 +0800	[thread overview]
Message-ID: <87wns3p5d4.fsf@localhost> (raw)
In-Reply-To: <87cztv29ff.fsf@gmail.com>

Timothy <tecosaur@gmail.com> writes:

>>>> I do not like abusing prettify-symbols-mode. What if it is not enabled?
> If you know of another way of accomplishing text-replacement which
> changes back when the cursor enters the region, please let me know.


>>> Ah, it does it anyway at the moment.
>> Hmm. You are right. You are calling compose-region directly. Note, that
>> you do not add 'decompose-region function for automatic region
>> destruction (see help:pretty-symbol-pattern-to-keyword).
> Isn't the same effect achieved by the remove-list-of-text-properties call?

It is. Though only while font-lock is active. Now, looking at
prettify-symbols-mode code, it does not seem to be necessary when
font-locking is set correctly.

>> If I understand correctly (I did not really install your patch), if you have
>> composed region, disable font-lock, and try to edit the region, edits
>> will be invisible. Or imagine setting org-inline-src-prettify-results to
>> nil in already fontified buffer.
> I just tried "setting org-inline-src-prettify-results to nil in already
> fontified buffer." and the region just decomposed and stayed that way.

Did you also have prettify-symbols-mode disabled?

>> Also, you may find help:font-lock-extra-managed-props useful. That way,
>> you will not have to manually remove composition and other non-standard
>> properties during fontification
> Hmmm, from a look I can't tell exactly how these are "managed". Are they
> just removed when a region is processed?

They are removed just before the region is processed and they are
removed when font-lock-mode is disabled. On the other hand, it will not
be possible to set the managed properties directly (try setting font
using a direct M-: command in a buffer with font-lock enabled).

>> P.S. Nitpick: You do not need to run fontification in while loops. Just
>> fontifying next match before limit should be enough. Font-lock will call
>> the function again if needed.
> I'm guessing for this to work I'd need to return the final char
> fortified? Or is the moving of point enough?
> Maybe related - I've noticed this doesn't seem to work with multiple
> src_ blocks per line, might you have any insight here?

As I understand, the fontificatoin function must behave like
re-search-forward. From font-lock-keywords docstring:

>>> ... MATCHER can be either the regexp to search for, or the function
>>> name to call to make the search (called with one argument, the limit
>>> of the search; it should return non-nil, move point, and set
>>> `match-data' appropriately if it succeeds; like `re-search-forward'
>>> would).


  parent reply	other threads:[~2021-05-13  5:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31 15:00 Timothy
2021-04-28  7:14 ` Timothy
2021-05-02 20:17   ` Timothy
2021-05-02 20:57     ` Tom Gillespie
2021-05-02 21:03       ` Timothy
2021-05-02 21:13         ` Tom Gillespie
2021-05-02 23:54           ` Tom Gillespie
2021-05-03  3:29       ` Timothy
2021-05-12 11:15         ` Timothy
2021-05-12 14:24           ` Ihor Radchenko
2021-05-12 14:47             ` Timothy
2021-05-12 15:53               ` Ihor Radchenko
2021-05-12 16:39                 ` Timothy
2021-05-13  2:38                   ` Tim Cross
2021-05-13  5:31                   ` Ihor Radchenko [this message]
2021-05-18 12:06                   ` Sébastien Miquel
2021-05-18 13:34                     ` Timothy
2021-05-18 14:36                       ` Sébastien Miquel
2021-04-29 22:59 ` TRS-80
2021-10-03  7:14 ` Ihor Radchenko
2021-10-03  7:16   ` Timothy
2021-10-03  9:09     ` Ihor Radchenko
2021-10-03  9:22       ` Timothy
2021-10-04 20:02       ` Protesilaos Stavrou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wns3p5d4.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tecosaur@gmail.com \
    --cc=tgbugs@gmail.com \
    --subject='Re: [PATCH] Fontification for inline src blocks' \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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


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 NNTP newsgroup(s).