zsh-workers
 help / color / mirror / code / Atom feed
* Could this function (zaccu-process-buffer) be added?
@ 2016-09-07 10:50 Sebastian Gniazdowski
  2016-09-08 12:17 ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-07 10:50 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 788 bytes --]

Hello,

https://github.com/psprint/accumulator/blob/master/zaccu-process-buffer

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.

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

Best regards,
Sebastian Gniazdowski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Could this function (zaccu-process-buffer) be added?
  2016-09-07 10:50 Could this function (zaccu-process-buffer) be added? Sebastian Gniazdowski
@ 2016-09-08 12:17 ` Daniel Shahaf
  2016-09-08 15:27   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2016-09-08 12:17 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Could this function (zaccu-process-buffer) be added?
  2016-09-08 12:17 ` Daniel Shahaf
@ 2016-09-08 15:27   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-08 15:27 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh hackers list

On 8 September 2016 at 14:17, Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> 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.)

Yes. I included the link as first thing in message, thinking that
anyone would just take a look rather than read my message.

>
> 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

My function is more basic, too bad no one has time to interpret code,
even when it's plain simple. The whole thing is around this line:

# Remove white spaces
buf="${buf##(#m)[^$word[1]]#}"

Which removes white spaces also storing them. Rest is careful indexing
and decisions whether a word is selected or not, things that make a
headache when writing, from what is the value of the function.

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-08 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-07 10:50 Could this function (zaccu-process-buffer) be added? Sebastian Gniazdowski
2016-09-08 12:17 ` Daniel Shahaf
2016-09-08 15:27   ` Sebastian Gniazdowski

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).