zsh-users
 help / color / mirror / code / Atom feed
* How to kill string but leave it in history?
@ 1997-01-16 10:59 Andrej Borsenkow
  1997-01-16 12:15 ` Peter Stephenson
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Andrej Borsenkow @ 1997-01-16 10:59 UTC (permalink / raw)
  To: Zsh users mailing list

Suppose, I type in long command and realize, I made some mistake (or I
need to look for additional info). If I cancel line with DEL (or ^C) the
line gets lost and I have to retype it - nor very handy.

I understand, that I can push it on stack, but it then pops up
automatically after next command - not what I want.

So - is there any way to cancel current command line but leave it in
history?

thanks in advance

Oh, yes - zsh 3.1.0 (without dynamic support)

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



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

* Re: How to kill string but leave it in history?
  1997-01-16 10:59 How to kill string but leave it in history? Andrej Borsenkow
@ 1997-01-16 12:15 ` Peter Stephenson
  1997-01-16 13:36   ` Andrej Borsenkow
  1997-01-16 14:02 ` Juergen Christoffel
  1997-01-16 14:40 ` Zefram
  2 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 1997-01-16 12:15 UTC (permalink / raw)
  To: Zsh users mailing list

Andrej Borsenkow wrote:
> So - is there any way to cancel current command line but leave it in
> history?

how about

bindkey -s "^X^H" "^['^A print -s ^M"       

works best with histignorespace set.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: How to kill string but leave it in history?
  1997-01-16 12:15 ` Peter Stephenson
@ 1997-01-16 13:36   ` Andrej Borsenkow
  1997-01-16 13:54     ` Peter Stephenson
  0 siblings, 1 reply; 13+ messages in thread
From: Andrej Borsenkow @ 1997-01-16 13:36 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh users mailing list

On Thu, 16 Jan 1997, Peter Stephenson wrote:

> Andrej Borsenkow wrote:
> > So - is there any way to cancel current command line but leave it in
> > history?
> 
> how about
> 
> bindkey -s "^X^H" "^['^A print -s ^M"       
> 
> works best with histignorespace set.
> 

Not exactly.

1. It doesn't work with multiline command (sorry, I had to be more precise
on this). E.g.
if .... then
if> kkldsfkl; ^X^H

Doesn't push the whole in history.

2. It echows the whole command (well, rather cosmetic).

Actually standard 'push-line' would suite just fine - _if_ it wouldn't pop
line again after next command. 

thanks

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
-------------------------------------------------------------------------



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

* Re: How to kill string but leave it in history?
  1997-01-16 13:36   ` Andrej Borsenkow
@ 1997-01-16 13:54     ` Peter Stephenson
  0 siblings, 0 replies; 13+ messages in thread
From: Peter Stephenson @ 1997-01-16 13:54 UTC (permalink / raw)
  To: Zsh users mailing list

Andrej Borsenkow wrote:
> 1. It doesn't work with multiline command (sorry, I had to be more precise
> on this). E.g.

This gets tricky, because there's currently no reliable way of going to the
beginning/end of the buffer or even of the line:  if you're there already,
the corresponding commands take you somewhere else.  So I've just set it
to go to 100 end/beginning of lines to get to the end/beginning of the
buffer.  That's not very nice.  Perhaps Zefram has some plans for this.

bindkey -s '\C-X\C-H' '\M-1\M-0\M-0\C-e\C-@\M-1\M-0\M-0\C-a print -s \M-"\C-M'

> 2. It echows the whole command (well, rather cosmetic).

There's no builtin command you can use, so you have to trick it somehow.
I can't see any way of avoiding this.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

* Re: How to kill string but leave it in history?
  1997-01-16 10:59 How to kill string but leave it in history? Andrej Borsenkow
  1997-01-16 12:15 ` Peter Stephenson
@ 1997-01-16 14:02 ` Juergen Christoffel
  1997-01-16 14:40 ` Zefram
  2 siblings, 0 replies; 13+ messages in thread
From: Juergen Christoffel @ 1997-01-16 14:02 UTC (permalink / raw)
  To: borsenkow.msk; +Cc: zsh-users

   Date: Thu, 16 Jan 1997 13:59:45 +0300 (MSK)
   From: Andrej Borsenkow <borsenkow.msk@sni.de>

   So - is there any way to cancel current command line but leave it in
   history?

Using emacs-mode I simple go to the beginning of the line (c-A), then
quote the line (ESC-') and write echo before it and execute it. Thus
it isn't executed but in the history and it's easy to retrieve.
Nothing fancy but works for me.

	--jc

-- 
   E-Mail: christoffel@gmd.de or one of {ftp,news,web}master@gmd.de
   GMD - German National Research Center for Information Technology

GMD pays for my technical expertise. My opinions probably scare them...


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

* Re: How to kill string but leave it in history?
  1997-01-16 10:59 How to kill string but leave it in history? Andrej Borsenkow
  1997-01-16 12:15 ` Peter Stephenson
  1997-01-16 14:02 ` Juergen Christoffel
@ 1997-01-16 14:40 ` Zefram
  1997-01-16 16:27   ` Roderick Schertler
  2 siblings, 1 reply; 13+ messages in thread
From: Zefram @ 1997-01-16 14:40 UTC (permalink / raw)
  To: borsenkow.msk; +Cc: zsh-users

Andrej Borsenkow wrote:
>So - is there any way to cancel current command line but leave it in
>history?

This is exactly what pound-insert is for.  I use it often.

-zefram


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

* Re: How to kill string but leave it in history?
  1997-01-16 14:40 ` Zefram
@ 1997-01-16 16:27   ` Roderick Schertler
  1997-01-16 16:37     ` Zefram
  0 siblings, 1 reply; 13+ messages in thread
From: Roderick Schertler @ 1997-01-16 16:27 UTC (permalink / raw)
  To: Zefram; +Cc: borsenkow.msk, zsh-users

On Thu, 16 Jan 1997 14:40:54 +0000 (GMT), Zefram <zefram@dcs.warwick.ac.uk> said:
> Andrej Borsenkow wrote:
>>
>> So - is there any way to cancel current command line but leave it in
>> history?
> 
> This is exactly what pound-insert is for.  I use it often.

It doesn't work for multiline commands, though.  Here's a binding (set
up for vi mode) which works if none of the editing lines were zsh-forced
continuations (which I don't understand, seems like a bug):

    bindkey -a -s q '\M-xpush-input\C-maread -z _buf; print -s $_buf\C-m'

Which reminds me, it has always bugged me that if zsh creates a
continuation line (like

    $ print "foo<return>
    dquote> _

) I can't go from the dquote> line back up to the first line (my
workaround is to get onto a blank line and interrupt, then pull up the
history).  Is it just me?  Is there a way not to have this happen?

-- 
Roderick Schertler
roderick@gate.net


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

* Re: How to kill string but leave it in history?
  1997-01-16 16:27   ` Roderick Schertler
@ 1997-01-16 16:37     ` Zefram
  1997-01-16 17:41       ` Roderick Schertler
       [not found]       ` <pws@ifh.de>
  0 siblings, 2 replies; 13+ messages in thread
From: Zefram @ 1997-01-16 16:37 UTC (permalink / raw)
  To: Roderick Schertler; +Cc: zefram, borsenkow.msk, zsh-users

Roderick Schertler wrote:
>> This is exactly what pound-insert is for.  I use it often.
>
>It doesn't work for multiline commands, though.

Yes it does.  It adds a # at the beginning of each line.  Or do you
mean continuation lines?  push-input may help here.

>Which reminds me, it has always bugged me that if zsh creates a
>continuation line (like
>
>    $ print "foo<return>
>    dquote> _
>
>) I can't go from the dquote> line back up to the first line

Yes, this is what push-input is for.

-zefram


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

* Re: How to kill string but leave it in history?
  1997-01-16 16:37     ` Zefram
@ 1997-01-16 17:41       ` Roderick Schertler
       [not found]       ` <pws@ifh.de>
  1 sibling, 0 replies; 13+ messages in thread
From: Roderick Schertler @ 1997-01-16 17:41 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-users

On Thu, 16 Jan 1997 16:37:52 +0000 (GMT), Zefram <zefram@dcs.warwick.ac.uk> said:
> Roderick Schertler wrote:
>>>
>>> This is exactly what pound-insert is for.  I use it often.
>>
>> It doesn't work for multiline commands, though.
>
> Yes it does.  It adds a # at the beginning of each line.  Or do you
> mean continuation lines?  push-input may help here.

Right, I hadn't clued to the fact that it was continuation lines which
were the problem.  I also hadn't thought of using push-input to edit
back before a continuation, and I even regularly use push-input.
Thanks.  Here's a hint for the documentation which might save others
this trouble.

--- Doc/zshzle.man.~1~	Tue Dec 17 15:14:11 1996
+++ Doc/zshzle.man	Thu Jan 16 12:34:30 1997
@@ -653,6 +653,8 @@
 Next time the editor starts up or is popped with \fBget-line\fP, the
 construct will be popped off the top of the buffer stack and loaded
 into the editing buffer.
+This is currently the best way to edit text above a zsh-forced line
+continuation.
 .TP
 \fBpush-line\fP (^Q ESC-Q ESC-q) (unbound) (unbound)
 Push the current buffer onto the buffer stack and clear
--- Doc/zshparam.man.~1~	Tue Aug 13 16:24:13 1996
+++ Doc/zshparam.man	Thu Jan 16 12:35:52 1997
@@ -685,6 +685,8 @@
 Recognizes the same escape sequences as \fB$PS1\fP.
 The default is "%_> ", which displays any shell constructs or quotation
 marks which are currently being processed.
+The best way to edit the continuation text along with the initial part
+of the command is to use the \fBpush-input\fP editor command.
 .TP
 .B PS3
 Selection prompt used within a \fBselect\fP loop.

-- 
Roderick Schertler
roderick@gate.net


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

* Re: How to kill string but leave it in history?
       [not found]           ` <zefram@dcs.warwick.ac.uk>
@ 1997-01-16 18:21             ` Bart Schaefer
  1997-01-16 18:39               ` Zefram
  1997-01-16 19:21               ` Roderick Schertler
  0 siblings, 2 replies; 13+ messages in thread
From: Bart Schaefer @ 1997-01-16 18:21 UTC (permalink / raw)
  To: Zsh users mailing list

On Jan 16,  4:37pm, Zefram wrote:
} Subject: Re: How to kill string but leave it in history?
}
} Roderick Schertler wrote:
} >Which reminds me, it has always bugged me that if zsh creates a
} >continuation line (like
} >
} >    $ print "foo<return>
} >    dquote> _
} >
} >) I can't go from the dquote> line back up to the first line
} 
} Yes, this is what push-input is for.

Or push-line-or-edit, which acts like push-line at the PS1 prompt, but
at the PS2 prompt acts like push-input followed by get-line.  (Saves
some vertical space and one or two keystrokes.)

In answer to the original query, this *ought* to work, and does if you
type the keystrokes by hand:

bindkey '\eq' push-line-or-edit
bindkey -s '^X^H' '\eq\e< print -s ^@\e>\e"^M'

For some reason, though, the right-hand-side of the ^X^H binding stops
as soon as either of push-input or push-line-or-edit is executed.  I.e.,
the binding above acts like "bindkey -s '^X^H' '\eq'" -- all the trailing
stuff is dropped.  I presume that's a bug in push-input ....

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: How to kill string but leave it in history?
  1997-01-16 18:21             ` Bart Schaefer
@ 1997-01-16 18:39               ` Zefram
  1997-01-17  9:05                 ` Bart Schaefer
  1997-01-16 19:21               ` Roderick Schertler
  1 sibling, 1 reply; 13+ messages in thread
From: Zefram @ 1997-01-16 18:39 UTC (permalink / raw)
  To: schaefer; +Cc: zsh-users

Bart Schaefer wrote:
>For some reason, though, the right-hand-side of the ^X^H binding stops
>as soon as either of push-input or push-line-or-edit is executed.  I.e.,
>the binding above acts like "bindkey -s '^X^H' '\eq'" -- all the trailing
>stuff is dropped.  I presume that's a bug in push-input ....

Isn't it just that the unget buffer is cleared when zleread() starts?

-zefram


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

* Re: How to kill string but leave it in history?
  1997-01-16 18:21             ` Bart Schaefer
  1997-01-16 18:39               ` Zefram
@ 1997-01-16 19:21               ` Roderick Schertler
  1 sibling, 0 replies; 13+ messages in thread
From: Roderick Schertler @ 1997-01-16 19:21 UTC (permalink / raw)
  To: schaefer; +Cc: Zsh users mailing list

On Thu, 16 Jan 1997 10:21:41 -0800, "Bart Schaefer" <schaefer@candle.brasslantern.com> said:
> 
> Or push-line-or-edit, which acts like push-line at the PS1 prompt, but
> at the PS2 prompt acts like push-input followed by get-line.

Jeez, how did I miss when that one got added?  (Or, cough, how did I
miss it two entries under push-input this morning?)  I'd suggest this
doc change over the other one.

--- Doc/zshparam.man.~1~	Tue Aug 13 16:24:13 1996
+++ Doc/zshparam.man	Thu Jan 16 14:15:05 1997
@@ -685,6 +685,8 @@
 Recognizes the same escape sequences as \fB$PS1\fP.
 The default is "%_> ", which displays any shell constructs or quotation
 marks which are currently being processed.
+The best way to edit the continuation text along with the initial part
+of the command is to use the \fBpush-line-or-edit\fP editor command.
 .TP
 .B PS3
 Selection prompt used within a \fBselect\fP loop.

-- 
Roderick Schertler
roderick@gate.net


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

* Re: How to kill string but leave it in history?
  1997-01-16 18:39               ` Zefram
@ 1997-01-17  9:05                 ` Bart Schaefer
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Schaefer @ 1997-01-17  9:05 UTC (permalink / raw)
  To: Zefram; +Cc: zsh-users

On Jan 16,  6:39pm, Zefram wrote:
} Subject: Re: How to kill string but leave it in history?
}
} Bart Schaefer wrote:
} >For some reason, though, the right-hand-side of the ^X^H binding stops
} >as soon as either of push-input or push-line-or-edit is executed.
} 
} Isn't it just that the unget buffer is cleared when zleread() starts?

That would explain it, but it doesn't make it correct ...

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

end of thread, other threads:[~1997-01-17  9:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-16 10:59 How to kill string but leave it in history? Andrej Borsenkow
1997-01-16 12:15 ` Peter Stephenson
1997-01-16 13:36   ` Andrej Borsenkow
1997-01-16 13:54     ` Peter Stephenson
1997-01-16 14:02 ` Juergen Christoffel
1997-01-16 14:40 ` Zefram
1997-01-16 16:27   ` Roderick Schertler
1997-01-16 16:37     ` Zefram
1997-01-16 17:41       ` Roderick Schertler
     [not found]       ` <pws@ifh.de>
     [not found]         ` <roderick@gate.net>
     [not found]           ` <zefram@dcs.warwick.ac.uk>
1997-01-16 18:21             ` Bart Schaefer
1997-01-16 18:39               ` Zefram
1997-01-17  9:05                 ` Bart Schaefer
1997-01-16 19:21               ` Roderick Schertler

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