zsh-users
 help / color / mirror / code / Atom feed
* History key bindings
@ 1997-11-26 17:10 Christopher Croughton
  1997-11-27 17:55 ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Christopher Croughton @ 1997-11-26 17:10 UTC (permalink / raw)
  To: zsh-users

I'm using zsh version 3.0.0, with the up and down cursor keys being bound
(at the moment) to history-beginning-search-backward and history-beginning-
search-forward.  These almost do what I want (i.e. they match on the start
of the line) except that they put the cursor at the start (or rather leave
it where it is) rather than putting it at the end of the line.

The equivalent tcsh functions (and 4DOS on MSDOS) match on wherever you are
when you first start the search but put the cursor at the end.

For instance, with history:

  vi fred
  chmod +x fred
  vi bill
  vi fred.c
  
typing 

  $vi f_

and searching backwards will find 'vi fred.c' and put the cursor at the end 
of the line, whereas under zsh it will put the cursor after 'f'.

Is there some way to cause zsh to remember the buffer up to where it was
when the search started and use that, while putting the cursor at the end 
still?  From the documentation it seems that up until version 3 something
like this was normal, and then the history-search-backward etc. was
changed to only match on the first word.

Apart from this one (annoying, to me) problem, zsh is wonderful.  If this is
fixed in the latest release or the beta version then I'll try that...

Thanks,
    Chris C


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

* Re: History key bindings
  1997-11-26 17:10 History key bindings Christopher Croughton
@ 1997-11-27 17:55 ` Bart Schaefer
  1997-11-27 18:21   ` Christopher Croughton
  1997-11-28 12:30   ` Christopher Croughton
  0 siblings, 2 replies; 8+ messages in thread
From: Bart Schaefer @ 1997-11-27 17:55 UTC (permalink / raw)
  To: Christopher Croughton, zsh-users

On Nov 26,  6:10pm, Christopher Croughton wrote:
} Subject: History key bindings
}
} Is there some way to cause zsh to remember the buffer up to where it was
} when the search started and use that, while putting the cursor at the end 
} still?

That shouldn't be terribly difficult to code as a zle module, if you have
3.1.2.  The code for vi-repeat-search might be a good starting point.

However, this does a pretty good job:

bindkey '^X^P' history-beginning-search-backward
bindkey -s '^[[A' '^X^X^X^P^@^E'

That binds up-arrow to:
 exchange-point-and-mark		^X^X
 history-beginning-search-backward	^X^P
 set-mark-command			^@
 end-of-line				^E

When you first press up-arrow, there (normally) won't be any mark on
the line, so ^X^X does nothing.  Then ^X^P finds the previous history
item with the prefix, ^@ sets the mark at the end of the prefix, and
^E moves the cursor to end of line.

Next time you press up-arrow, ^X^X puts the cursor back at the prefix
again, so ^X^P finds the further previous history with the same prefix.
Then the mark is set and the cursor moved to end of line again.

} From the documentation it seems that up until version 3 something
} like this was normal, and then the history-search-backward etc. was
} changed to only match on the first word.

Yeah, I was never satisfied with the explanations for why that changed.
The new behavior doesn't seem as useful to me.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: History key bindings
  1997-11-27 17:55 ` Bart Schaefer
@ 1997-11-27 18:21   ` Christopher Croughton
  1997-11-27 18:43     ` Bart Schaefer
  1997-11-28 12:30   ` Christopher Croughton
  1 sibling, 1 reply; 8+ messages in thread
From: Christopher Croughton @ 1997-11-27 18:21 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: crough45, zsh-users

Bart Schaefer wrote:
> 
> That shouldn't be terribly difficult to code as a zle module, if you have
> 3.1.2.  The code for vi-repeat-search might be a good starting point.

I don't, yet, I'm using 3.0.  I'll have to look for it...

(And then work out how to program modules - sounds fun...)

> When you first press up-arrow, there (normally) won't be any mark on
> the line, so ^X^X does nothing.  

Er, on 3.0 it seems that the mark is initially set to the start of the line,
so if I do:

  $bind^X^X

then the cursor goes to the start of the line.  Not exactly useful.
Otherwise it looks like the sort of thing I wanted...

> Yeah, I was never satisfied with the explanations for why that changed.
> The new behavior doesn't seem as useful to me.

Definitely not to me.  Although having it as Yet Another Option(tm) is
probably a good thing for those who do want it.  Perhaps a request to put
the tcsh behaviour in as another option?

Thanks,
    Chris


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

* Re: History key bindings
  1997-11-27 18:21   ` Christopher Croughton
@ 1997-11-27 18:43     ` Bart Schaefer
  1997-11-28  8:57       ` Christopher Croughton
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 1997-11-27 18:43 UTC (permalink / raw)
  To: Christopher Croughton; +Cc: zsh-users

On Nov 27,  7:21pm, Christopher Croughton wrote:
} Subject: Re: History key bindings
}
} Bart Schaefer wrote:
} > When you first press up-arrow, there (normally) won't be any mark on
} > the line, so ^X^X does nothing.  
} 
} Er, on 3.0 it seems that the mark is initially set to the start of the line,

I thought I was seeing that behavior at one point, but now I can't get it
to happen again (... some fooling about occurs ...)

Aha!  Whenever you use a history operation like ^P, the mark gets set at
the beginning of the line before the new history line is inserted.  So
you can't mix that bindkey -s with other history motions unless you set
the mark yourself in between.  If all you do is type the prefix and then
press up-arrow, it works fine.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: History key bindings
  1997-11-27 18:43     ` Bart Schaefer
@ 1997-11-28  8:57       ` Christopher Croughton
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Croughton @ 1997-11-28  8:57 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: crough45, zsh-users

Bart Schaefer wrote:
> 
> On Nov 27,  7:21pm, Christopher Croughton wrote:
> } Subject: Re: History key bindings
> }
> } Bart Schaefer wrote:
> } > When you first press up-arrow, there (normally) won't be any mark on
> } > the line, so ^X^X does nothing.  
> } 
> } Er, on 3.0 it seems that the mark is initially set to the start of the line,
> 
> I thought I was seeing that behavior at one point, but now I can't get it
> to happen again (... some fooling about occurs ...)
> 
> Aha!  Whenever you use a history operation like ^P, the mark gets set at
> the beginning of the line before the new history line is inserted.  So
> you can't mix that bindkey -s with other history motions unless you set
> the mark yourself in between.  If all you do is type the prefix and then
> press up-arrow, it works fine.

The only way I can get it to work is if I do an initial ^X^X after typing 
the prefix.  If I do <CR>fred<UP> then it just scans through the history 
matching on nothing at all.  If I do <CR>fred^X^X<UP> then it works fine, 
and I can even delete everything on the line or modify it in any other way
and it will search for the new string.  I'm not doing any other history
motions on the line, just the bound up-arrow key.

Strange, ne?  Perhaps a different version of zsh will help?

Chris C


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

* Re: History key bindings
  1997-11-27 17:55 ` Bart Schaefer
  1997-11-27 18:21   ` Christopher Croughton
@ 1997-11-28 12:30   ` Christopher Croughton
  1997-11-28 17:18     ` Bart Schaefer
  1 sibling, 1 reply; 8+ messages in thread
From: Christopher Croughton @ 1997-11-28 12:30 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: crough45, zsh-users

Bart Schaefer wrote:
> 
> When you first press up-arrow, there (normally) won't be any mark on
> the line, so ^X^X does nothing.  

Confirmed - this works with (beta) version 3.1.2, not with (released)
version 3.0 (which seems to put the mark at the start of the line when
it is first edited or something).

BTW, it was not very easy to compile on the Dec Alpha under OSF/1 
version 3.2.  In Src/Zle/zle_tricky.c line 1551 the parameters to
yp_all() are not the same (the third parameter is the callback structure
on OSF1, not a pointer to it as in the code.  As a diff -c:

*** Src/Zle/zle_tricky.c.old    Fri Nov 28 13:06:33 1997
--- Src/Zle/zle_tricky.c        Fri Nov 28 12:44:51 1997
***************
*** 1548,1554 ****
      if (getdomainname(domain, YPMAXDOMAIN) == 0) {
        cb.foreach = (int ((*) _((void)))) match_username;
        cb.data = (char *)&data;
!       yp_all(domain, PASSWD_MAP, &cb);
  /*    for (n = firstnode(matches); n; incnode(n))
            if (getpwnam(getdata(n)) == NULL)
                uremnode(matches, n);*/
--- 1548,1554 ----
      if (getdomainname(domain, YPMAXDOMAIN) == 0) {
        cb.foreach = (int ((*) _((void)))) match_username;
        cb.data = (char *)&data;
!       yp_all(domain, PASSWD_MAP, cb);
  /*    for (n = firstnode(matches); n; incnode(n))
            if (getpwnam(getdata(n)) == NULL)
                uremnode(matches, n);*/

It also required GNU make (missing .SUFFIXES in several of the makefiles)
not the OSF1 version.  But lots of GNU and GNU-is stuff needs that...

Thanks,
    Chris C


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

* Re: History key bindings
  1997-11-28 12:30   ` Christopher Croughton
@ 1997-11-28 17:18     ` Bart Schaefer
  1997-11-29 13:49       ` Christopher Croughton
  0 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 1997-11-28 17:18 UTC (permalink / raw)
  To: Christopher Croughton, zsh-users

On Nov 28,  9:57am, Christopher Croughton wrote:
} Subject: Re: History key bindings
}
} Bart Schaefer wrote:
} > 
} > } on 3.0 it seems that the mark is initially set to the start of the line,
} > 
} > Aha!  Whenever you use a history operation like ^P, the mark gets set at
} > the beginning of the line before the new history line is inserted.
} 
} The only way I can get it to work is if I do an initial ^X^X after typing 
} the prefix.  If I do <CR>fred<UP> then it just scans through the history 
} matching on nothing at all.

On Nov 28,  1:30pm, Christopher Croughton wrote:
} Subject: Re: History key bindings
}
} Confirmed - this works with (beta) version 3.1.2, not with (released)
} version 3.0 (which seems to put the mark at the start of the line when
} it is first edited or something).

Hrm.  I get the behavior Christopher describes with 3.0.0 and 3.0.1; but
it stops for me as of 3.0.3 (I don't have a 3.0.2 around to try), and I
don't see it in 3.0.4 or 3.0.5.

I believe this ChangeLog entry is relevant:

Mon Jan 20 21:11:22 1997  Zoltan Hidvegi  <hzoli@cs.elte.hu>

        * Src/zle_utils.c: move the mark when characters are
          inserted/deleted.  From Peter (2807)

} BTW, it was not very easy to compile on the Dec Alpha under OSF/1 
} version 3.2.  In Src/Zle/zle_tricky.c line 1551 the parameters to
} yp_all() are not the same (the third parameter is the callback structure
} on OSF1, not a pointer to it as in the code.

Actually, it's the parameter in the prototype in the header that is wrong,
not the pointer in the zsh code.  There's a discussion of this somewhere
in Etc/MACHINES.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

* Re: History key bindings
  1997-11-28 17:18     ` Bart Schaefer
@ 1997-11-29 13:49       ` Christopher Croughton
  0 siblings, 0 replies; 8+ messages in thread
From: Christopher Croughton @ 1997-11-29 13:49 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: crough45, zsh-users

Bart Schaefer wrote:
> 
> Hrm.  I get the behavior Christopher describes with 3.0.0 and 3.0.1; but
> it stops for me as of 3.0.3 (I don't have a 3.0.2 around to try), and I
> don't see it in 3.0.4 or 3.0.5.

3.0.0 is in fact what I had, so that sounds like the problem.  I've now
compiled 3.1.2 which is working beautifully and I'm very happy.  Thanks, 
y'all!

(Literally, that was the only thing I've found in zsh which I didn't like.
That, for any piece of software more complex than "Hello World", is very
unusual...)

> } BTW, it was not very easy to compile on the Dec Alpha under OSF/1 
> } version 3.2.  In Src/Zle/zle_tricky.c line 1551 the parameters to
> } yp_all() are not the same (the third parameter is the callback structure
> } on OSF1, not a pointer to it as in the code.
> 
> Actually, it's the parameter in the prototype in the header that is wrong,
> not the pointer in the zsh code.  There's a discussion of this somewhere
> in Etc/MACHINES.

Indeed there is.  However I was uncertain as to which was correct since the
man page for ypall on OSF is also incorrect, it gives the prototype without
the *.  And to think I used to like DEC <sigh>...

(Now what would make me really deliriously happy would be to find a port
of zsh for MSDOS (not Windows or OS/2, straight DOS)...)

Chris C


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

end of thread, other threads:[~1997-11-29 13:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-26 17:10 History key bindings Christopher Croughton
1997-11-27 17:55 ` Bart Schaefer
1997-11-27 18:21   ` Christopher Croughton
1997-11-27 18:43     ` Bart Schaefer
1997-11-28  8:57       ` Christopher Croughton
1997-11-28 12:30   ` Christopher Croughton
1997-11-28 17:18     ` Bart Schaefer
1997-11-29 13:49       ` Christopher Croughton

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