Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author


On Sep 21, 10:07am, Nikolai Weibull wrote:
} bindkey -a '^D' zle/foreground-or-exit
} zsh: use 'exit' to exit.
} when I press ^D when the following conditions hold (Src/Zle/zle_main.c:1290):
} 1. ^D is bound to a user-defined command
} 2. The command line is empty
} 3. No arguments have been given (unclear exactly what this actually means)
} 4. IGNORE_EOF has been set
} The problem is that I don't want this behavior.

If you are correct, then (1) would be a bug.  The comment in zle_main.c
explicitly says 

     The rule is that "zle -N" widgets suppress EOF warnings.

And the doc says

     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.

So the behavior you want is the one you are supposed to get; we should
not need another option.

However, I can't make a simple case that reproduces your error.  Have
you defined zle/foreground-or-exit with zle -C rather than zle -N ?

Or perhaps the problem is not where you think it is?

} 3. Exiting insert mode in Zle (running in vi mode)

% bindkey -v
% bindkey '^D' vi-cmd-mode
% ^D
zsh: use 'exit' to exit.

You can easily fix that like this:

silent-vi-cmd-mode() { zle vi-cmd-mode }
zle -N silent-vi-cmd-mode
bindkey -v
bindkey ^D silent-vi-cmd-mode

Messages sorted by: Reverse Date, Date, Thread, Author