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

Re: up-line-or-search question



On Wed, Mar 27, 2002 at 04:30:03PM +0000, Bart Schaefer wrote:
> 
> 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.

I'm not quite sure what that is trying to achieve. I also can't
remember how I got it not to work in the first place because it
is now.
 
> 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

Interesting. If I was just planning to put the cursor at the end of
the line in all cases, it would probably be better. It is useful to
think about though because it would allow the resumption of the
search with the same string even if the line had been edited.
 
> } 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.

Okay, I'll probably put the push-line-or-edit in when enabled with
a style too then. Could we maybe agree a common prefix for the
contexts of the styles in Functions/Zle - ':zle:' maybe?

It is probably best to stick with zle .end-of-line in whatever
goes in Functions/Zle but I'm not sure that it is exactly what
I want to happen for the cursor position.

I'm currently experimenting with this:

  if (( HISTNO + 1 == ${(%%):-%h} )) && [[ $BUFFER[1,__savepos] != *$'\n'* ]]
  then
    CURSOR=__savepos
  elif [[ $RBUFFER != *$'\n'* ]]; then
    zle .end-of-line
  fi

as the cursor positioning and using:
  accept-line-and-savepos() {
    __savepos=$CURSOR
    zle .accept-line
  }
instead of accept-line (I probably also need to do others like
accept-line-and-down-history). On the way down, I'm not moving
the cursor at all. It's one of those things where I need to use
it for a while before I decide if it is a good idea or not but
let me know if you see any problems or if this sparks off any
other ideas.

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