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

Re: Wishlist for zsh: 3 tcsh features



On Oct 9,  3:25pm, Oliver Kiddle wrote:
}
} Bart Schaefer wrote:
} 
} >     function up-line-or-beginning-search {
} >         if [[ $LASTWIDGET != $WIDGET ]]
} >         then
} >             if [[ $BUFFER == *$'\n'* ]]
} >             then
} >                 __last_up_line=up-line-or-history
} >             else
} >                 __last_up_line=history-beginning-search-backward
} >             fi
} >         fi
} >         zle .${__last_up_line:-beep}
} >     }
} 
} I presume that the LASTWIDGET check and __last_up_line saving is there
} so that if the history search retrieved a multi-line command, it would
} continue to use history-beginning-search-backward.

Yes.

} Unfortunately, this means it won't do a history search from the first
} line of a multi-line buffer

The BUFFER test means that; but what the LASTWIDGET test means is that
if you start somewhere other than at the first line and move upwards,
it won't switch from moving to searching just because you happen to get
to the top line.  I find up-line-or-search a bit strange that way.

} so I changed it to this:
} 
}   if [[ ${BUFFER[1,CURSOR]} == *$'\n'* ]]; then
}     zle up-line-or-history
}   else
}     zle history-beginning-search-backward
}   fi

BUFFER[1,CURSOR] is of course LBUFFER ...

} Please let me know if that has problems which I missed. Next I'll have
} to get it to do something more useful from a PS2 prompt.

The PS2 prompt is a bit of a pain in the neck.  The only way I've found
to tell whether you're at the PS2 prompt is with

	[[ -n ${(%):-%_} ]]

and that only works if you're in a shell construct; if you're just on a
backslash-continuation line, there's no way to detect it.  Is there?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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