From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: Re: Open bugs and questions?
Date: Wed, 2 Aug 2000 14:08:42 +0200 (MET DST) [thread overview]
Message-ID: <200008021208.OAA11394@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Tue, 1 Aug 2000 15:09:53 +0000
Bart Schaefer wrote:
> ...
>
> } 12054, 12071
> } There is no way to handle ^D at the beginning of the line with a
> } widget, because the zle main loop deals with it directly.
>
> It *is* possible to handle ^D at beginning of line: stty eof undef
> permits it. This is equivalent to having to turn off flow control in
> order to use ^S and ^Q in keybindings.
>
> So maybe the right answer is that `setopt ignoreeof' should affect ZLE
> the same way that `setopt noflowcontrol' does. An actual zero-byte
> read would still be handled as it currently is; only ^D in column zero
> would be different (actually invoke the ^D binding rather than print
> "zsh: use 'logout' to logout.").
>
> THEN we could change delete-char-or-list to print that warning when there
> are no characters in the editor buffer, et voila: the default behavior is
> exactly as now.
I didn't even needed to mess with the tty settings, changing the test
for eofchar was enough.
I've put the message-display into the zle main loop, invoked for every
widget that calls an internally implemented widget. Note that this
includes completion widgets (which call the widget mentioned in the
`zle -C' call). This should make it really independent of the widget
bound to ^D for everyone who hasn't bound a shell-function widget to
it.
But now we can do:
my-eof() {
if [[ -n "$PREBUFFER$BUFFER" ]]; then
zle delete-char-or-list
else
(( ++exit_count == 5 )) && exit
zle -M "$exit_count. time"
fi
}
zle -N my-eof
bindkey '^D' my-eof
Except that there should be a history-write before the exit. And the
counter should probably be reset in precmd or something.
The `use 'exit' to exit' message is displayed slightly differently:
below the prompt without displaying a new prompt. Is that ok?
Hm, because of that and the shell-function widget thing, I'll wait
before committing it.
Bye
Sven
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.10
diff -u -r1.10 options.yo
--- Doc/Zsh/options.yo 2000/07/19 21:37:18 1.10
+++ Doc/Zsh/options.yo 2000/08/02 12:01:30
@@ -573,6 +573,11 @@
of tt(exit) or tt(logout) instead.
However, ten consecutive EOFs will cause the shell to exit anyway,
to avoid the shell hanging if its tty goes away.
+
+Also, if this option is set and the Zsh Line Editor is used, widgets
+implemented by shell functions can be bound to EOF (normally
+Control-D) without printing the normal warning message. This works
+only for normal widgets, not for completion widgets.
)
pindex(INC_APPEND_HISTORY)
cindex(history, incremental appending to a file)
Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.8
diff -u -r1.8 zle_main.c
--- Src/Zle/zle_main.c 2000/07/27 17:48:48 1.8
+++ Src/Zle/zle_main.c 2000/08/02 12:01:31
@@ -76,7 +76,10 @@
/**/
int insmode;
-static int eofchar, eofsent;
+/**/
+mod_export int eofchar;
+
+static int eofsent;
static long keytimeout;
#ifdef HAVE_SELECT
@@ -556,7 +559,7 @@
reselectkeymap();
selectlocalmap(NULL);
bindk = getkeycmd();
- if (!ll && isfirstln && c == eofchar) {
+ if (!ll && isfirstln && unset(IGNOREEOF) && c == eofchar) {
eofsent = 1;
break;
}
@@ -630,26 +633,32 @@
} else if((w = func->widget)->flags & (WIDGET_INT|WIDGET_NCOMP)) {
int wflags = w->flags;
- if(!(wflags & ZLE_KEEPSUFFIX))
- removesuffix();
- if(!(wflags & ZLE_MENUCMP)) {
- fixsuffix();
- invalidatelist();
+ if (keybuf[0] == eofchar && !keybuf[1] &&
+ !ll && isfirstln && isset(IGNOREEOF)) {
+ showmsg((!islogin) ? "use 'exit' to exit." : "use 'logout' to logout.");
+ ret = 1;
+ } else {
+ if(!(wflags & ZLE_KEEPSUFFIX))
+ removesuffix();
+ if(!(wflags & ZLE_MENUCMP)) {
+ fixsuffix();
+ invalidatelist();
+ }
+ if (wflags & ZLE_LINEMOVE)
+ vilinerange = 1;
+ if(!(wflags & ZLE_LASTCOL))
+ lastcol = -1;
+ if (wflags & WIDGET_NCOMP) {
+ int atcurhist = histline == curhist;
+ compwidget = w;
+ ret = completecall(args);
+ if (atcurhist)
+ histline = curhist;
+ } else
+ ret = w->u.fn(args);
+ if (!(wflags & ZLE_NOTCOMMAND))
+ lastcmd = wflags;
}
- if (wflags & ZLE_LINEMOVE)
- vilinerange = 1;
- if(!(wflags & ZLE_LASTCOL))
- lastcol = -1;
- if (wflags & WIDGET_NCOMP) {
- int atcurhist = histline == curhist;
- compwidget = w;
- ret = completecall(args);
- if (atcurhist)
- histline = curhist;
- } else
- ret = w->u.fn(args);
- if (!(wflags & ZLE_NOTCOMMAND))
- lastcmd = wflags;
r = 1;
} else {
Eprog prog = getshfunc(w->u.fnnam);
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next reply other threads:[~2000-08-02 12:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-02 12:08 Sven Wischnowsky [this message]
2000-08-02 16:24 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2000-08-01 10:58 Sven Wischnowsky
2000-08-01 9:00 Sven Wischnowsky
2000-08-01 9:19 ` Peter Stephenson
2000-08-01 9:46 ` Andrej Borsenkow
2000-08-01 15:09 ` Bart Schaefer
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=200008021208.OAA11394@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.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).