zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Sven Wischnowsky <wischnow@berkom.de>
Cc: zsh-workers@sunsite.dk
Subject: Re: up-line-or-search question
Date: Thu, 4 Apr 2002 12:46:18 +0100	[thread overview]
Message-ID: <20020404114618.GA25369@logica.com> (raw)
In-Reply-To: <15522.59901.788124.9741@wischnow.berkom.de>

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.


  reply	other threads:[~2002-04-04 11:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1020227161622.ZM10705@candle.brasslantern.com>
2002-02-27 16:29 ` Peter Stephenson
2002-02-27 16:56   ` Bart Schaefer
2002-02-27 17:07   ` Oliver Kiddle
2002-02-27 17:29     ` Peter Stephenson
2002-02-27 18:03       ` Bart Schaefer
2002-03-21 22:56   ` Peter Stephenson
2002-03-26 14:30     ` Oliver Kiddle
2002-03-26 15:48       ` Bart Schaefer
2002-03-26 19:23         ` Oliver Kiddle
2002-03-26 19:51           ` Bart Schaefer
2002-03-27 12:59             ` Oliver Kiddle
2002-03-27 16:30               ` Bart Schaefer
2002-03-27 18:00                 ` Oliver Kiddle
2002-03-27 18:19                   ` Bart Schaefer
2002-03-27 19:35                     ` Oliver Kiddle
2002-03-28 10:01                       ` Sven Wischnowsky
2002-04-04 11:46                         ` Oliver Kiddle [this message]
2002-04-09  9:51                           ` Sven Wischnowsky
2002-04-16  7:47                           ` Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020404114618.GA25369@logica.com \
    --to=okiddle@yahoo.co.uk \
    --cc=wischnow@berkom.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).