nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] [PATCH] possible new feature: allow binding a key to a


From: Brand Huntsman
Subject: Re: [Nano-devel] [PATCH] possible new feature: allow binding a key to a string
Date: Sun, 4 Feb 2018 17:28:17 -0700

On Sun, 4 Feb 2018 16:22:09 -0600
David Ramsey <address@hidden> wrote:

> they'll also lessen the
> ability of such macros to insert text (at least in a simple manner).
> If the sigils are like what Brand came up with, such as "${replace}",
> how would the user insert a literal $, {, or } in a macro without
> making parsing the string much more complex?

Only the $ would need escaping, and only when followed by a {[a-z_]+}. The 
interpolate_string function from my syntax variable patch could be adapted to 
do this. It splits the string into chunks of text and interpolation matches. If 
it sees a \ before a ${...} match it would strip the \ off the end of the 
previous text chunk and begin a new text chunk at the $. It would throw an 
error message instead of converting unknown ${...} sequences to text fragments, 
like the syntax variables patch does. You then escape the $ or correct the 
spelling of the function name inside ${...}.

The strtosc function could be called to lookup function names, but I don't 
think there is anything in nano to map a function name to a key binding. So it 
might be best to store the macro as a list of text fragments and function 
pointers returned from strtosc(). It would add a little more work to the 
execute function but avoid adding the ability to map function names to key 
bindings, unless that is already possible.




reply via email to

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