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

Re: up-line-or-search question



On Thu, Mar 28, 2002 at 11:01:33AM +0100, Sven Wischnowsky wrote:
> 
> I don't really like this double testing and personally would vote to
> put everything under the :zle top-level context.  I'd like to know how
> many users are out there who have styles for any of the (currently
> only three) zle functions.  Maybe we should ask on zsh-users?

I think I'd also vote for just changing it.

> But first we should probably try to come up with a context format like
> the one we have for the completion system, with a fixed number of
> parts (some of which may be blank most of the time), which allows us
> to extend it to future uses.  And that's hard to predict, I fear.

What else might we want in the context? Most of the things used for
completion wouldn't make sense because we don't dispatch based on
such things as the command and we don't have any tags. The full name
of the widget function is certainly useful (abbreviating it is perhaps
unwise). What else? The key combination used is the only other thing I
can think of.

> I had collected some ideas for that (and the suffix stuff etc.) but on
> saturday my hard disk was killed.  Sigh.

Oh dear. On the subject of suffix stuff, I recently had problems with
a completion widget which did compset -P '*,' and then a compadd -Q -U -qS,
If the comma taken off by compset was added as an autoremovable suffix
earlier then it gets removed when the next part is inserted. I can send
you the functions if you don't understand.

Patch below is those up/down search widgets in the form that I'll
commit for now before I lose them.

Oliver

Index: Functions/Zle/down-line-or-beginning-search
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/down-line-or-beginning-search,v
retrieving revision 1.1
diff -u -r1.1 down-line-or-beginning-search
--- Functions/Zle/down-line-or-beginning-search	21 Mar 2002 23:03:14 -0000	1.1
+++ Functions/Zle/down-line-or-beginning-search	4 Apr 2002 11:15:51 -0000
@@ -1,13 +1,19 @@
 # Like down-line-or-search, but uses the whole line prefix up to the
 # cursor position for searching forwards.
 
-if [[ $LASTWIDGET != $WIDGET ]]
+if [[ ${+NUMERIC} -eq 0 &&
+    ( $LASTWIDGET = $__searching || $RBUFFER != *$'\n'* ) ]]
 then
-    if [[ $LBUFFER == *$'\n'* ]]
-    then
-        __last_down_line=down-line-or-history
-    else
-        __last_down_line=history-beginning-search-forward
-    fi
+  [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
+  __searching=$WIDGET
+  __savecursor=$CURSOR
+  if zle .history-beginning-search-forward; then
+    [[ $RBUFFER = *$'\n'* ]] || 
+	zstyle -T ':zle:down-line-or-beginning-search' leave-cursor &&
+	zle .end-of-line
+    return
+  fi
+  [[ $RBUFFER = *$'\n'* ]] || return
 fi
-zle .${__last_down_line:-beep}
+__searching=''
+zle .down-line-or-history
Index: Functions/Zle/up-line-or-beginning-search
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/up-line-or-beginning-search,v
retrieving revision 1.1
diff -u -r1.1 up-line-or-beginning-search
--- Functions/Zle/up-line-or-beginning-search	21 Mar 2002 23:03:14 -0000	1.1
+++ Functions/Zle/up-line-or-beginning-search	4 Apr 2002 11:15:51 -0000
@@ -1,13 +1,18 @@
 # Like up-line-or-search, but uses the whole line prefix up to the
 # cursor position for searching backwards.
 
-if [[ $LASTWIDGET != $WIDGET ]]
+if [[ $LBUFFER == *$'\n'* ]]; then
+  zle .up-line-or-history
+  __searching=''
+elif [[ -n $PREBUFFER ]] && 
+    zstyle -t ':zle:up-line-or-beginning-search' edit-buffer
 then
-    if [[ $LBUFFER == *$'\n'* ]]
-    then
-        __last_up_line=up-line-or-history
-    else
-        __last_up_line=history-beginning-search-backward
-    fi
+  zle .push-line-or-edit
+else
+  [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
+  __savecursor=$CURSOR
+  __searching=$WIDGET
+  zle .history-beginning-search-backward
+  zstyle -T ':zle:up-line-or-beginning-search' leave-cursor &&
+      zle .end-of-line
 fi
-zle .${__last_up_line:-beep}

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