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

Re: up-line-or-search question

On Tue, Mar 26, 2002 at 03:48:50PM +0000, Bart Schaefer wrote:

> That doesn't look quite right to me.  If history-beginning-search-forward
> fails, it may get tried *again* by the final "else" clause.  And that's
> forcing a search with a numeric argument, not a down history?
> Seems like it should be

I didn't realise that the numeric argument would propagate so thought
the second history-beginning-search-backward was harmless. Your
replacement breaks the addition that it goes down a line if at the end
of the history. So, I think it should be:

  down-line-or-beginning-search() {
    if [[ ${+NUMERIC} -eq 0 &&
          ( $LASTWIDGET = $__searching || $RBUFFER != *$'\n'* ) ]]
      zle .history-beginning-search-forward && return
    zle .down-line-or-history

> } I was also hoping to move the cursor to the end of the line after
> } searches but I can't see how I can move it back before the next search
> } without using the mark.
> Stash the value of CURSOR in another global, __searching_pos or some
> such, and re-assign to CURSOR only when [[ -n $__searching ]].

I got confused by the documentation stating that those variables are
read-only and forgot about assigning to CURSOR, thanks.

Changing the zle h-b-s-? commands to:

    [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
    zle .history-beginning-search-backward
    zle .end-of-line
  (and moving the return statement in the down-line function)

It works for going up but breaks when changing to going down.
Basically, it searches down using the whole line instead of up to where
the cursor was. Any ideas?

> Sure it can; I missed 4735 somehow.  You just append the arguments to
> the `zle' command after the name of the widget.  In the case of the
> specific question in 4735, it's the numeric argument, so you have to
> use -n, e.g.:
> 	zle .vi-fetch-history -n $NUMERIC
> I forget whether the default is to propagate $NUMERIC (i.e. if the above
> is redundant and you only need -n to change the value).

Ok. Thanks. It isn't possible to include args (numeric or otherwise)
with a bindkey though is it?


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