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

Re: psychiatric help





On 2026-04-05 19:24, Bart Schaefer wrote:
Did you even read what I wrote after "Start this way:" in the previous post?

To be honest I'm having trouble figuring it out but I'm still chewing on it.  Learning curve here is vertical.
The place you can access $BUFFER is in the zle-line-finish widget.  At
this point globbing (and other expansion including aliasing) has not
happened yet.
That's where I want to be but I have no idea how to get into the widget.  Never been near a widget yet.
After rewriting to the "nauseating to look at" representation, you can
then put that nauseating thing back into BUFFER, as long as you're
still in the zle-line-finish widget.
Well, writing it to history is no problem, the thing is to be able to insert the unexpanded tail into it at the appropriate place.  No idea what being in the widget means.  This is absolutely new to me.

Let me try demonstrating with your simpler example:

function _tt ()
{
   set -- ${(z)BUFFER}    # Widget doesn't get $@, so create it for clarity
   # Next line replaces alias tt='noglob _tt' but see users/30496
   [[ $1 = tt ]] || return 0  # Don't mess with other commands
   shift                  # This throws away "tt" leaving only the "tail"
   out=( $@ )             # Not really needed, but to keep the example
   out=( '(#i)'$^out )    # Prefix every tail with ignore-case
   BUFFER="ls -AFrGgdt $out"  # Put it back together with "ls" in front
   # All done, no need for _execute
}
zle -N zle-line-finish _tt

Try that and observe the result.
Ok, I can copy that and give it a go.  Probably still want _execute cuz it does some other stuff too, and it's no problem, so long as I have that tail.  Will chew on that tomorrow. Tx. How do we access the users archives?  I should know that.  Any chance of doing this kind of thing in preexec()?  So it's always available? Most of my functions go thru the same trouble, so having general access to that BUFFER would be ideal.








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