#StackBounty: #regular-expressions #code-folding Folding custom regular expressions in emacs?

Bounty: 50

Consider a pattern/regular expression I will call reg which matches multiple times in an emacs buffer. I want emacs to recognize all matches for reg and replace (temporarily, like folding) each matching text match with the result of a custom elisp function applied to that particular match, which I call f(match). Furthermore the replaced text should be (customizable) highlighted (other color etc.) and if you move your cursor into an occurrence of f(match), it should display the original match as long as the cursor is inside match (if you move it outside, it just shows f(match) again).

To have a simple example in mind, let reg be say [[!.*?!]] and the elisp function f could just translate all lower case letters in the matched text to upper case and vice versa. So for example [[!HelloWorld1!]] should be folded to [[!hELLOwORLD1!]]

In my particular case I want it to replace in a more complex way results of mathematical python calculations with the results in a latex file using pythontex.

Is there any package which could do this? If there are multiple packages, what would be the “state of the art” for doing something like this?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.