开发者

How do I modify text while keeping the original fontification?

开发者 https://www.devze.com 2023-01-14 07:21 出处:网络
I\'m writing a mode which is actually a glorified markdown reader. It\'s a read-only mode however, and though I\'d lik开发者_如何学Pythone to change the faces for bold, italics, and links, I\'d love t

I'm writing a mode which is actually a glorified markdown reader. It's a read-only mode however, and though I'd lik开发者_如何学Pythone to change the faces for bold, italics, and links, I'd love to remove the decorations surrounding those faces. However, when I do so, I lose the fontification. Is there anyway to modify fontified-text to something that no longer matches any of the syntax regexes and still keep the fontification?


Org-mode does this for its link markup. I'm not a mode writer (yet), but Org-mode would be the first place I'd look for code that demonstrates how to do this. Oddly, it doesn't do it for any of its fontification: italic, bold, and underline all retain their markup.

Specifically, the code to hide the link markup is on line 4612 of org.el in version 7.01 of org-mode:

(if org-descriptive-links (add-to-invisibility-spec '(org-link)))

where add-to-invisibility-spec is actually supplied by a built in elisp file subr.el, and allows specific types of markup to be hidden. That would be the approach I would take, especially if the buffer is read-only.

0

精彩评论

暂无评论...
验证码 换一张
取 消