Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Could this function (zaccu-process-buffer) be added?



Sebastian Gniazdowski wrote on Wed, Sep 07, 2016 at 12:50:03 +0200:
> Hello,
> 
> https://github.com/psprint/accumulator/blob/master/zaccu-process-buffer
> 

Next time please say in the email itself what the function does.  That
would make it easier for your readers to understand your message.

My understanding is that the function presents an API to ${(z)BUFFER}.
(Correct me if that's inaccurate.)

> I use this function in multiple projects, e.g. here it allows to split
> every line in displayed text and preserve spaces:
> 
> https://asciinema.org/a/8k8v5ni5lnnpoc3z5jzl6jgav
> 
> I think it provides with precious data. Allows to keep spaces, to address
> words via indexes, carefully selects active word, and also splits it in
> half. If one would want to use bare (z) flag to obtain some of this he
> would have to write control-rich and careful-indexing-rich code, rather a
> headache.
> 

z-sy-h has code that splits the command-line to words with (z) and
tracks indices.  I know you know that because you helped optimise it
:-).  I don't know which code better solves this problem, z-sy-h's or
zaccu's.  The former has not been spun off into a reusable function but
it could be.

https://github.com/zsh-users/zsh-syntax-highlighting/blob/da60234fb236ccd2b199ffa8a157014dacf4e591/highlighters/main/main-highlighter.zsh#L299-L336

> I would change namespace and send to ml. One thing – it doesn't deal with
> following, but not a problem for current Zsh:
> 
> http://www.zsh.org/mla/workers/2015/msg02570.html
> 

The link describes a bug in ${(z)} that was fixed last year.  Functions
shipped with zsh 5.3 are not required to be compatible with 5.2.

Cheers,

Daniel

P.S. I noticed that the (z) flag parses «a=() b=() c=() d=()» oddly: the
parentheses are parsed alternately as a single token (INOUTPAR) and as
two tokens (ENVARRAY and OUTPAR).

> Best regards,
> Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author