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

Re: ZLE Widget: Insert last word (except &)



> I wrote:
> } If we don't accept the shell syntax definition of a "word", how can we
> } choose a single definition of what constitutes a "word" that everyone
> } will agree on?
> 
> The answer is, we don't, we use a style.  Which isn't (presently) ever done
> with the builtin widgets, so you aren't going to see this as the default
> behavior of insert-last-word any time soon.
> 
> ---- 8< ---- cut ---- 8< ----
> # smart-insert-last-word
>
> [...]
>
> Note that this presently doesn't work right when the previous command line
> contains a [[ ... ]] expression that uses one of the (#x) forms of extended
> pattern matching, e.g. (#i) to ignore case.  That's a bug in ${(z)...} (it
> takes the # to be a comment introducer), so it should be fixed soon.  If
> this really bothers you in the meantime, try adding
> 
>   local +h histchars=''
> 
> somewhere before the assignment to lastcmd -- but then it's broken for the
> case of `setopt interactive_comments`, so choose your poison ...

There is another bug in your version of smart-insert-last-word: repeated
calls to it don't go back in the history. Rather than doing the word
splitting yourself, you should always call insert-last-word -- with an
argument of 2 or greater, when necessary.

The solution might be a synthesis of my first version and yours -- a widget
that is smarter than mine when determining the last word, but nevertheless
calls insert-last-word, so that the shell can go back the history on
subsequent calls.

Christoph

-- 
Descartes enters a pub. "Evening, Descartes. Same as usual?"
Descartes says: "No, I think not." -- and disappears.
Christoph Lange, langec@xxxxxx, http://www.cul.de/home/yaph/, ICQ #51191833



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