Re: psychiatric help

Ray Andrews <[email protected]> Mon, 6 Apr 2026 07:14:57 -0700
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <[email protected]>
On 2026-04-05 22:03, Bart Schaefer wrote:
> If you've got "compinit" in your .zshrc, you've been near hundreds of
> widgets.  "Widget" is just the zsh name for a function that is
> executed by ZLE.
Yeah, I know they're all around, I mean actually getting inside one of 
them.  OK, a function executed by ZLE.
> zle-line-finish is a "special" widget that ZLE runs automatically just
> after accept-line (the widget normally bound to Enter/Return).  By
> default it's not defined at all, so you have to create it.
Ah!  Like preexec() -- IF it exists it will be executed.  Yes?
> zle -N zle-line-finish _tt
> Like that.
Not to split hairs, but does that append _tt or cause _tt to be absorbed 
into zle-line-finish? As you say, the latter doesn't exist, so this 
creates it but with the contents of _tt?  But zle-line-finish can't be 
found even after the above is executed.
> The important bit is that you should NOT call "eval" of anything, and
> that the assignment to BUFFER contains the command line you want to
> run.  So if you want to keep using _execute, you would likely replace
> the "eval" by the assignment of BUFFER=.
Yup, that's the goal.
> https://www.zsh.org/mla/ although I believe searching is still broken
> so you need to know an article number or pore over the indexes.
Tx.  Yes, I remember.  I lost track of the site cuz it was hard to 
search anyway.

Ok, I'm starting to understand:

function ttt ()
{
BUFF=${(z)BUFFER} # I just need access, I don't need it actually on the CL.
export BUFF
}
zle -N zle-line-finish ttt

... added to the top of 'l()'

alias l='noglob _l'
function _l ()
{
echo "\nMy name is $BUFF[1]
and my unexpanded tail is: ${BUFF[2,-1]}"

#...
#... and where the monster is created:

#OLD
string=\
"ls --time-style='+[%y-%m-%d--%H:%M]' --group-directories-first\
  -A$cclassify$upsidedown$wwidth$dirnames$sortby$recursive\
$ls_color $ccase\
$filespec 2> /dev/null\  # filespec kept from expansion by using noglob.
$filetype\
$ssed_string\
  | egrep -v '^total'"

#NEW
string=\
"ls --time-style='+[%y-%m-%d--%H:%M]' --group-directories-first\
  -A$cclassify$upsidedown$wwidth$dirnames$sortby$recursive\
$ls_color $ccase
${BUFF[2,-1]}.2> /dev/null\   # Unexpanded filespec anyway, thus no need 
for noglob.
$filetype\
$ssed_string\
  | egrep -v '^total'"

run:

5 /aWorking/Zsh/Source/Wk 1 % l ,v test\ ?

My name is l
and my unexpanded tail is:  ,v test\ ?

  0 [26-04-04--09:00] test a
  0 [26-04-04--09:03] test b

... bingo.  Except :( ...

5 /aWorking/Zsh/Source/Wk 1 % l ,v test\ ?; echo howdy; echo pard

My name is l
and my unexpanded tail is:  ,v test\ ? ; echo howdy ; echo pard

  0 [26-04-04--09:00] test a
  0 [26-04-04--09:03] test b
howdy
pard

... when I first threw myself at this issue, the simple idea was to just 
retrieve the command line from history:

$  history -rn -1

... but the line in history and the above $BUFF method have the exactly 
same problem, namely when there's more than one command on the line.  
The real goal here is to get the unexpanded tail of each command 
separately.  But perhaps zsh expands the whole line in one go rather 
than first break the line into separate commands, and then do the 
expansion?

Anyway one could break the line into separate commands easily enough and 
then take each command and break it into command and tail ... but if 
there's two (say) echo's, or the same function is called twice, which is 
which?  Obviously zsh does all this work internally, but how to get that 
breakdown?

Or is this worth the bother?  My original issue, tiny as it was, is 
repaired.  True, I'd like to cut out the 'noglob's and the 'eval', but 
this is already way more work than I have any right to ask of you.  And 
yet I still feel that this should be done anyway -- basic stuff.  Tho of 
course, nobody else seems to think it's important so ...

Unless ... each command sequentially bit off its own chunk of $BUFF, up 
to the semicolon, leaving the next command unambiguously looking at the 
next: 'command' 'tail' 'semicolon'.  Should be easy?