zsh-users
 help / color / mirror / code / Atom feed
* up-line-or-search question
@ 2002-02-27  8:14 Dominik Vogt
  2002-02-27  9:24 ` Goran Koruga
  2002-02-27 13:36 ` Dominik Vogt
  0 siblings, 2 replies; 9+ messages in thread
From: Dominik Vogt @ 2002-02-27  8:14 UTC (permalink / raw)
  To: zsh-users

When I use the up-line-or-search function to complete a partially
typed command, the matching history lines are only matched to the
first word.  Is is possible to match by comparing to everything I
have typed?  Example:

In the history:

  cd /foo
  cd /bar

When I type (up-line-or-search bound to the <Up> key):

  $ cd /f<Up>

I get

  $ cd /bar

But I want to get

  $ cd /foo

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27  8:14 up-line-or-search question Dominik Vogt
@ 2002-02-27  9:24 ` Goran Koruga
  2002-02-27 13:36 ` Dominik Vogt
  1 sibling, 0 replies; 9+ messages in thread
From: Goran Koruga @ 2002-02-27  9:24 UTC (permalink / raw)
  To: zsh-users

On Wed, Feb 27 2002, Dominik Vogt wrote:

> When I use the up-line-or-search function to complete a partially
> typed command, the matching history lines are only matched to the
> first word.  Is is possible to match by comparing to everything I
> have typed?  Example:
> 
> In the history:
> 
>   cd /foo
>   cd /bar
> 
> When I type (up-line-or-search bound to the <Up> key):
> 
>   $ cd /f<Up>
> 
> I get
> 
>   $ cd /bar
> 
> But I want to get
> 
>   $ cd /foo

Yeah this was already discussed here :

bindkey "^[p" history-beginning-search-backward
bindkey "^[P" history-beginning-search-backward
bindkey "^[r" history-beginning-search-forward
bindkey "^[R" history-beginning-search-forward

Bind it to whatever else you want.

Goran

> 
> Bye
> 
> Dominik ^_^  ^_^
> 
> -- 
> Dominik Vogt, email: d.vogt@lifebits.de
> LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
> fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20

Cheers,
Goran

--

Writing about music is like dancing about architecture.
    -- Frank Zappa 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27  8:14 up-line-or-search question Dominik Vogt
  2002-02-27  9:24 ` Goran Koruga
@ 2002-02-27 13:36 ` Dominik Vogt
       [not found]   ` <3C7CED18.mail4KQ11CK3F@viadomus.com>
  2002-02-27 16:08   ` Oliver Kiddle
  1 sibling, 2 replies; 9+ messages in thread
From: Dominik Vogt @ 2002-02-27 13:36 UTC (permalink / raw)
  To: zsh-users

> Goran Koruga wrote:
> On Wed, Feb 27 2002, Dominik Vogt wrote:
> 
> > When I use the up-line-or-search function to complete a partially
> > typed command, the matching history lines are only matched to the
> > first word.  Is is possible to match by comparing to everything I
> > have typed?  Example:
> > > In the history:
> > > cd /foo
> > cd /bar
> > > When I type (up-line-or-search bound to the <Up> key):
> > > $ cd /f<Up>
> > > I get
> > > $ cd /bar
> > > But I want to get
> > > $ cd /foo
> 
> Yeah this was already discussed here :
> 
> bindkey "^[p" history-beginning-search-backward
> bindkey "^[P" history-beginning-search-backward
> bindkey "^[r" history-beginning-search-forward
> bindkey "^[R" history-beginning-search-forward
> 
> Bind it to whatever else you want.

Actually, that does not do what I want.  I'd need

  up-line-or-history-beginning-search-backward
  up-line-or-history-beginning-search-forward

Since I still want to be able to navigate through the lines in the
ZLE.

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
       [not found]   ` <3C7CED18.mail4KQ11CK3F@viadomus.com>
@ 2002-02-27 14:44     ` Dominik Vogt
  2002-02-27 15:00       ` Anthony R Iano-Fletcher
  0 siblings, 1 reply; 9+ messages in thread
From: Dominik Vogt @ 2002-02-27 14:44 UTC (permalink / raw)
  To: zsh-users

On Wed, Feb 27, 2002 at 03:28:40PM +0100, DervishD wrote:
>     Hi Dominik :)
> 
> >> bindkey "^[p" history-beginning-search-backward
> >> bindkey "^[r" history-beginning-search-forward
> >Actually, that does not do what I want.  I'd need
> >  up-line-or-history-beginning-search-backward
> >  up-line-or-history-beginning-search-forward
> >Since I still want to be able to navigate through the lines in the
> >ZLE.
> 
>     With that keybindings you can. The history...search widgets
> navigate just like up and down when the prompt is empty.

Nope.  I tried it, but it doesn't work.  When I hit Up/Down in a
multi line command, a history search is performed.

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27 14:44     ` Dominik Vogt
@ 2002-02-27 15:00       ` Anthony R Iano-Fletcher
  2002-02-27 16:16         ` Bart Schaefer
  0 siblings, 1 reply; 9+ messages in thread
From: Anthony R Iano-Fletcher @ 2002-02-27 15:00 UTC (permalink / raw)
  To: zsh-users

Dominik does seem to be correct.

> >     With that keybindings you can. The history...search widgets
> > navigate just like up and down when the prompt is empty.
> 
> Nope.  I tried it, but it doesn't work.  When I hit Up/Down in a
> multi line command, a history search is performed.

I have
	"^N" history-beginning-search-forward
	"^P" history-beginning-search-backward
	"^[OA" up-line-or-history
	"^[OB" down-line-or-history
	"^[[A" up-line-or-history
	"^[[B" down-line-or-history

ie ^P and ^N bound to the history-begining-search-* versions and the
arrow keys on my keyboard bound to *-line-or-history.

When I'm in a multi-line command ^P does try to search back in the history
which is what Dominik is seeing.

This doesn't worry me because after using ^P to get the multiline command
I wanted I naturally swap to using the arrow keys to edit it.

I'm using zsh version 4.0.4.

Is there an easy way for Dominik to add this 'up/down-line'
functionallity using the widget stuff?


			Anthony.

-- 
Anthony R Iano-Fletcher        Anthony.Iano-Fletcher@nih.gov
                               http://cbel.cit.nih.gov/~arif
                               CBEL, CIT, NIH, Bethesda, MD, USA.
                               Phone: (+1) 301 402 1741.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27 13:36 ` Dominik Vogt
       [not found]   ` <3C7CED18.mail4KQ11CK3F@viadomus.com>
@ 2002-02-27 16:08   ` Oliver Kiddle
  2002-02-28  6:41     ` Dominik Vogt
  1 sibling, 1 reply; 9+ messages in thread
From: Oliver Kiddle @ 2002-02-27 16:08 UTC (permalink / raw)
  To: dominik.vogt, zsh-users

 --- Dominik Vogt <dominik.vogt@gmx.de> wrote: 
> 
> Actually, that does not do what I want.  I'd need
> 
>   up-line-or-history-beginning-search-backward
>   up-line-or-history-beginning-search-forward
> 
> Since I still want to be able to navigate through the lines in the
> ZLE.

Is this closer to what you want:

up-line-or-beginning-search-backward() {
  if [[ $LBUFFER == *$'\n'* ]]; then
    zle up-line-or-history
  else
    zle history-beginning-search-backward
  fi
}

zle -N up-line-or-beginning-search-backward

If it is, this was discussed some time around about last November. A
few variations on the idea were posted including a similar function for
forward.

Oliver


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27 15:00       ` Anthony R Iano-Fletcher
@ 2002-02-27 16:16         ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2002-02-27 16:16 UTC (permalink / raw)
  To: zsh-users, Anthony R Iano-Fletcher, d.vogt, dominik.vogt

On Feb 27,  2:36pm, Dominik Vogt wrote:
}
} Actually, that does not do what I want.  I'd need
} 
}   up-line-or-history-beginning-search-backward
}   up-line-or-history-beginning-search-forward

On Feb 27, 10:00am, Anthony R Iano-Fletcher wrote:
}
} Is there an easy way for Dominik to add this 'up/down-line'
} functionallity using the widget stuff?

Search the zsh-users archive for the string: up-line-or-beginning

And please remember that the zsh lists are now at sunsite.dk, not at
sunsite.auc.dk.  Automatic forwarding may not work forever.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-27 16:08   ` Oliver Kiddle
@ 2002-02-28  6:41     ` Dominik Vogt
  2002-02-28  7:52       ` Dominik Vogt
  0 siblings, 1 reply; 9+ messages in thread
From: Dominik Vogt @ 2002-02-28  6:41 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

On Wed, Feb 27, 2002 at 04:08:06PM +0000, Oliver Kiddle wrote:
>  --- Dominik Vogt <dominik.vogt@gmx.de> wrote: 
> > 
> > Actually, that does not do what I want.  I'd need
> > 
> >   up-line-or-history-beginning-search-backward
> >   up-line-or-history-beginning-search-forward
> > 
> > Since I still want to be able to navigate through the lines in the
> > ZLE.
> 
> Is this closer to what you want:
> 
> up-line-or-beginning-search-backward() {
>   if [[ $LBUFFER == *$'\n'* ]]; then
>     zle up-line-or-history
>   else
>     zle history-beginning-search-backward
>   fi
> }
> 
> zle -N up-line-or-beginning-search-backward
> 
> If it is, this was discussed some time around about last November. A
> few variations on the idea were posted including a similar function for
> forward.

It's close, but not exactly what I need.  For reference, I have
attached my final solution including documentation.  Since it
contains tabs, don't simply copy-and-paste it.

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20

[-- Attachment #2: zle_updown_funcs --]
[-- Type: text/plain, Size: 1788 bytes --]

###################################################################
# ZLE functions:
#   up-line-or-beginning-search-backward
#   down-line-or-beginning-search-forward
#
# If these functions are invoked if the cursor is at the beginning
# of the first line of the buffer (ignoring leading whitespace) or
# in any line except the first, they work exactly like
# up-line-or-history and down-line-or-history.  However, the
# cursor is moved to the beginning of the line afterwards. # If
# invoked when the cursor is in the first line, but not at the
# beginning of the line (leading whitespace are ignored), they
# work like history-beginning-search-backward and
# history-beginning-search-forward
###################################################################

# needed later; why doesn't zle have beginning_of_buffer and
# end-of-buffer functions?
beginning-of-buffer() {
  while [[ ! $LBUFFER == "" ]]; do
    zle beginning-of-line
  done
}
zle -N beginning-of-buffer

up-line-or-beginning-search-backward() {
  if [[ ${LBUFFER/#[ 	]#/} == "" ]]; then
    zle up-history
    zle beginning-of-line
  elif [[ $LBUFFER == *$'\n'* ]]; then
    zle up-line-or-history
  else
    zle history-beginning-search-backward
  fi
}
down-line-or-beginning-search-forward() {
  if [[ ${LBUFFER/#[ 	]#/} == "" || $LBUFFER == *$'\n'* ]]; then
    local DO_MOVE_TO_BOB=""
    if [[ ! $RBUFFER == *$'\n'* ]]; then
      DO_MOVE_TO_BOB=1
    fi
    zle down-line-or-history
    if [[ $DO_MOVE_TO_BOB == 1 ]]; then
      zle beginning-of-buffer
    fi
  else
    zle history-beginning-search-forward
  fi
}
zle -N up-line-or-beginning-search-backward
zle -N down-line-or-beginning-search-forward

#bindkey "\e[A" up-line-or-beginning-search-backward
#bindkey "\e[B" down-line-or-beginning-search-forward

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: up-line-or-search question
  2002-02-28  6:41     ` Dominik Vogt
@ 2002-02-28  7:52       ` Dominik Vogt
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Vogt @ 2002-02-28  7:52 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]

On Thu, Feb 28, 2002 at 07:41:36AM +0100, Dominik Vogt wrote:
> On Wed, Feb 27, 2002 at 04:08:06PM +0000, Oliver Kiddle wrote:
> >  --- Dominik Vogt <dominik.vogt@gmx.de> wrote: 
> > > 
> > > Actually, that does not do what I want.  I'd need
> > > 
> > >   up-line-or-history-beginning-search-backward
> > >   up-line-or-history-beginning-search-forward
> > > 
> > > Since I still want to be able to navigate through the lines in the
> > > ZLE.
> > 
> > Is this closer to what you want:
> > 
> > up-line-or-beginning-search-backward() {
> >   if [[ $LBUFFER == *$'\n'* ]]; then
> >     zle up-line-or-history
> >   else
> >     zle history-beginning-search-backward
> >   fi
> > }
> > 
> > zle -N up-line-or-beginning-search-backward
> > 
> > If it is, this was discussed some time around about last November. A
> > few variations on the idea were posted including a similar function for
> > forward.
> 
> It's close, but not exactly what I need.  For reference, I have
> attached my final solution including documentation.  Since it
> contains tabs, don't simply copy-and-paste it.

I've tinkered a bit mor with it and used the function Bart posted
as the base and came up with a new version that works a tad more
like up-line-or-search.  The history-beginning-search-...
functions are only used when one actually typed more than the
first word, i.e.

  $ cd /f<Up>

uses history-beginning-search-backward and

  $ cd <Up>

uses up-line-or-search

Bye

Dominik ^_^  ^_^

-- 
Dominik Vogt, email: d.vogt@lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20

[-- Attachment #2: zle_updown_funcs.sh --]
[-- Type: application/x-sh, Size: 1110 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-02-28  8:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-27  8:14 up-line-or-search question Dominik Vogt
2002-02-27  9:24 ` Goran Koruga
2002-02-27 13:36 ` Dominik Vogt
     [not found]   ` <3C7CED18.mail4KQ11CK3F@viadomus.com>
2002-02-27 14:44     ` Dominik Vogt
2002-02-27 15:00       ` Anthony R Iano-Fletcher
2002-02-27 16:16         ` Bart Schaefer
2002-02-27 16:08   ` Oliver Kiddle
2002-02-28  6:41     ` Dominik Vogt
2002-02-28  7:52       ` Dominik Vogt

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