[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [prettify-symbols-mode] Two consecutive matches don't work?
From: |
Robert Pluim |
Subject: |
Re: [prettify-symbols-mode] Two consecutive matches don't work? |
Date: |
Wed, 18 May 2022 14:28:30 +0200 |
>>>>> On Wed, 18 May 2022 14:56:53 +0300, Eli Zaretskii <eliz@gnu.org> said:
>> Feedback-ID: ie15541ac:Fastmail
>> Date: Wed, 18 May 2022 11:32:07 +0200
>> From: Joost <joostkremers@fastmail.fm>
>>
>> I'm dealing with some `.xml` files that contain data which uses the
>> sequence `<<!` as some sort of operator. Because it's XML, the
>> LESS-THAN sign needs to be encoded as `<`, yielding `<<!`.
>>
>> So I thought this would be the ideal use case for
>> `prettify-symbols-mode`. I added `("<" . ?<)` to
>> `prettify-symbols-alist` and activated the mode.
>>
>> Unfortunately, only the first `<` in each sequence is
>> prettified. This seems to be due to the fact that the second `<`
>> is followed by the exclamation mark: if I insert a space in between,
>> prettification works.
>>
>> Is there any way to remedy this?
Eli> prettify-symbols-mode is not general-purpose enough, its defaults are
Eli> tailored to prettifying keywords of programming languages, not just
Eli> any arbitrary strings of characters.
Yes, it by default does a lot of stuff based on the syntax tables of
the buffer.
Eli> I think you will need to tailor prettify-symbols-default-compose-p or
Eli> roll your own predicate and bind prettify-symbols-compose-predicate to
Eli> that predicate, if you want to support such sequences.
(setq prettify-symbols-alist '(("<" . "<"))
prettify-symbols-compose-predicate
(lambda (s e m)
(string-match-p "<" m)))
seems to do the trick.
You could even generalize it to:
(setq prettify-symbols-alist '(("<" . "<"))
prettify-symbols-compose-predicate
(lambda (s e m)
t))
:-)
Robert
--