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

Re: z-sy-h and z-asug: zle-line-pre-redraw, POSTDISPLAY, coexistence (was: Re: emulate bash key bindings)



On Fri, Jan 10, 2020 at 7:29 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> I assume that a dummy widget that does «{ POSTDISPLAY=foo;
> region_highlight+=( "$#BUFFER $(($#BUFFER + 2)) bold" ) }»
> could be used to mock z-asug for the purposes of the coexistence
> issue?

Yeah, I think so. Perhaps use $#POSTDISPLAY instead of 2 to avoid
mistakes there.

> > I'm trying to finish a couple of large features for p10k (which
> > incidentally includes writing a zsh parser in zsh)
>
> Isn't that basically what z-sy-h's main highlighter does?

Yep.

I wasn't able to find an existing library to do this. z-sy-h's main
highlighter isn't factored out, so I cannot reuse it. I also want
something a bit more precise and performant. On the plus side my goal
is more modest than z-sy-h. I only need to extract "command" words.
For example, given this zsh code:

  () { sudo foo bar && baz }

I want to get "sudo" "foo" and "baz".

I've written some code that works decently well but needs a bit more
polish. It's more precise than z-sy-h but still doesn't handle some
corner cases. For example, given this setup:

  setopt interactive_comments
  alias foo='bar #'

My code incorrectly extracts "bar" and "baz" from "foo; baz". It
should be just "bar" here.

Roman.



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