emacs-devel
[Top][All Lists]
Advanced

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

Re: Improve `replace-regexp-in-string' ergonomics?


From: Stefan Monnier
Subject: Re: Improve `replace-regexp-in-string' ergonomics?
Date: Wed, 22 Sep 2021 22:15:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> It'd be nice to have a front-end that lets you write a kind of lex-like
>> set of rules, but I think it'd be important for that front-end to allow
>> *computing* the replacement rather than only selecting it based on the
>> matched regexp.  Something like
>>
>>     (foo-replace results
>>       ("\\[" "(")
>>       ("\\]" ")")
>>       ("[[:lower:]]+" (upcase (match-string 0)))
>>       ("siglo \\([0-9]+\\)"
>>        (integer-to-roman (string-to-number (match-string 1))))
>>       ...)
>
> Perfect.  That looks like a really nice function signature to me.
> Perhaps without the parentheses if there's only one replacement to be
> done.

If someone's interested, `syntax-propertize-rules` solves a similar
problem, so some of its code can be reused for that.


        Stefan




reply via email to

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