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

Re: up-line-or-search question



On Mar 27, 12:59pm, Oliver Kiddle wrote:
} Subject: Re: up-line-or-search question
}
} On Tue, Mar 26, 2002 at 11:51:01AM -0800, Bart Schaefer wrote:
} > 
} > I'd rather have it feep at the end of the history.  Moving down a line
} > when the search fails means I lose my context and have to re-establish
} > it before I can e.g. reverse the direction of the search.
} 
} In the case of this function, re-establishing the context is
} merely a case of pressing the up cursor which I don't think is
} that much of a problem.

The problem I was concerned about was this one:
 
} I did get it slightly wrong in the last function though
} because if the h-b-s-f fails and the subsequent d-l-o-h does a
} down history instead of down line, it is not good. So it
} needs:
}   [[ $RBUFFER = *$'\n'* ]] || return
} before the fi.

So if you've made that change, it shoudl be OK.

} > Don't test [[ $LASTWIDGET = $__searching ]], test [[ -n $__searching ]].
} > And name the cursor-saving variable something less generic, there may be
} > other functions that want to save and restore the cursor ...
} 
} That doesn't help. It also means that the cursor position for
} searches is then fixed forever after for that shell instance.

Not exactly -- __searching will get cleared as soon as a search fails and
a simple up/down motion is done -- but you're right, the test should be
[[ $__searching = *-line-or-search && $LASTWIDGET = *-line-or-search ]]
or something along those lines.

Incidentally, a (possibly better) alternative to saving $CURSOR is to
save $LBUFFER and use it:

	if [[ ... ]]; then
	  __last_search=$LBUFFER
	fi
	zle .history-beginning-search-forward $__last_search

} I think I've got it working now but am not sure why or whether
} there was something peculiar with the history list I had
} yesterday. Do we want to include the cursor movement in
} the examples in the distribution - it is more like up-line-or-
} search? Perhaps we need to use styles to configure it?

Styles are always nice; I'd be inclined to put the cursor movement in
and have a style to turn it off.

-- 
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