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

Re: PATCH: Re: insert-last-word/copy-prev-word/... question



On Wed, Mar 06, 2002 at 06:21:11PM +0000, Bart Schaefer wrote:
> On Mar 5,  2:48pm, Peter Stephenson wrote:
> }
> } +     * If we have two arguments, the second is the position of
> } +     * the word to extract, 1..N.  The default is to use the
> } +     * numeric argument, or the last word if that is not set.
> 
> Doesn't this conflict with what the numeric argument used to mean?
> 
> I think this whole thing could have been written as a shell widget
> without resorting to modifying insert-last-word.  I just haven't had
> a lot of time to think about it yet.

Sorry for being very slow here. I was busy and only skim read the
thread before.

If we just want a shell widget, I've been using this for years:

copy-last-word() {
  setopt localoptions noksharrays
  local words
  words=( "${=LBUFFER}" )
  if [[ $LASTWIDGET = copy-last-word ]] && (( clwcount > -$#words )); then
    (( clwcount-- ))
  else
    (( clwcount=-2 ))
  fi
  LBUFFER="${LBUFFER%$words[-1]}$words[clwcount]"
}

It doesn't duplicate the current word at the first invocation like
copy-prev-word does - I find that useless. I suspect that Peter's
patch does a better job of using WORDCHARS or whatever. This just
worked for me. I'm sure it could be better.

What I've been meaning to do in ages is combine this with 
insert-last-word so you can use insert-last-word to go up a few
lines and then go back along the words of that previous line.

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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