From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: PATCH: Re: vi editting troubles
Date: Tue, 29 May 2001 13:57:31 +0200 (MET DST) [thread overview]
Message-ID: <200105291157.NAA09013@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <200105290659.IAA08490@beta.informatik.hu-berlin.de>
I wrote:
> Bart Schaefer wrote:
>
> > On May 23, 11:18am, Wayne Davison wrote:
> > >
> > > An off-the-cuff suggestion: Would it be possible to have the C code
> > > call a "set completion defaults" shell function
> >
> > The problem with any shell-function-based solution is that it requires a
> > special case for the `localoptions' setting.
> >
> > Better, perhaps, would be to augment the _comp_options variable with a
> > _comp_setup variable, which would look something like this:
> >
> > _comp_setup='setopt ${_comp_options[@]} localtraps;
> > exec </dev/null;
> > trap - ZERR'
> >
> > and then `eval' that variable in any function that is an entry point into
> > the completion system.
>
> Hm, not one reply so far (unless I've missed something).
>
> This is of course better than what I suggested in 14449 because I always
> forget about eval. I'd even volunteer to make that change... or is
> anyone really against it?
Here it is. There are still some functions in Base/Widget that don't
eval $_comp_setup but they either call _main_complete later or something
entirely different anyway (and use emulate -L or some such), so I wasn't
sure if we should use it there, too. Some part of my brain says yes,
other parts say no or `for some...'.
Bye
Sven
Index: Completion/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/compinit,v
retrieving revision 1.4
diff -u -r1.4 compinit
--- Completion/compinit 2001/04/29 19:12:14 1.4
+++ Completion/compinit 2001/05/29 11:54:54
@@ -139,7 +139,18 @@
NO_cshnullglob
NO_allexport
NO_aliases
+ NO_errexit
)
+
+# And this one should be `eval'ed at the beginning of every entry point
+# to the completion system. It sets up what we currently consider a
+# sane environment. That means we set the options above, make sure we
+# have a valid stdin descriptor (zle closes it before calling widgets)
+# and don't get confused by user's ZERR trap handlers.
+
+_comp_setup='setopt localoptions localtraps ${_comp_options[@]};
+ exec </dev/null;
+ trap - ZERR'
# These can hold names of functions that are to be called before/after all
# matches have been generated.
Index: Completion/Base/Completer/_expand_alias
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_expand_alias,v
retrieving revision 1.1
diff -u -r1.1 _expand_alias
--- Completion/Base/Completer/_expand_alias 2001/04/02 11:06:52 1.1
+++ Completion/Base/Completer/_expand_alias 2001/05/29 11:54:54
@@ -2,7 +2,7 @@
local word expl tmp pre sel what
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
if [[ -n $funcstack[2] ]]; then
if [[ "$funcstack[2]" = _prefix ]]; then
Index: Completion/Base/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_main_complete,v
retrieving revision 1.1
diff -u -r1.1 _main_complete
--- Completion/Base/Core/_main_complete 2001/04/02 11:03:18 1.1
+++ Completion/Base/Core/_main_complete 2001/05/29 11:54:54
@@ -16,12 +16,7 @@
# which makes the output of setopt and unsetopt reflect a different
# state than the global one for which you are completing.
-setopt localoptions ${_comp_options[@]}
-
-exec </dev/null # ZLE closes stdin, which can cause errors
-
-# Failed returns from this code are not real errors
-setopt localtraps noerrexit ; trap - ZERR
+eval "$_comp_setup"
local func funcs ret=1 tmp _compskip format nm call match min max i num\
_completers _completer _completer_num curtag _comp_force_list \
Index: Completion/Base/Widget/_bash_completions
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_bash_completions,v
retrieving revision 1.1
diff -u -r1.1 _bash_completions
--- Completion/Base/Widget/_bash_completions 2001/04/02 11:14:07 1.1
+++ Completion/Base/Widget/_bash_completions 2001/05/29 11:54:54
@@ -25,7 +25,7 @@
# that will not have been overridden, so you should add '~' to the
# list of keys at the top of the for-loop.
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
local key=$KEYS[-1] expl
Index: Completion/Base/Widget/_complete_debug
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_complete_debug,v
retrieving revision 1.1
diff -u -r1.1 _complete_debug
--- Completion/Base/Widget/_complete_debug 2001/04/02 11:14:23 1.1
+++ Completion/Base/Widget/_complete_debug 2001/05/29 11:54:54
@@ -1,8 +1,6 @@
#compdef -k complete-word \C-x?
-setopt localoptions ${_comp_options[@]}
-
-setopt localtraps noerrexit ; trap - ZERR
+eval "$_comp_setup"
(( $+_debug_count )) || integer -g _debug_count
local tmp=${TMPPREFIX}${$}${words[1]:t}$[++_debug_count]
Index: Completion/Base/Widget/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_complete_help,v
retrieving revision 1.1
diff -u -r1.1 _complete_help
--- Completion/Base/Widget/_complete_help 2001/04/02 11:14:40 1.1
+++ Completion/Base/Widget/_complete_help 2001/05/29 11:54:54
@@ -1,9 +1,7 @@
#compdef -k complete-word \C-xh
_complete_help() {
- setopt localoptions ${_comp_options[@]}
-
- exec </dev/null # ZLE closes stdin, which can cause errors
+ eval "$_comp_setup"
local _sort_tags=_help_sort_tags text i j k tmp
typeset -A help_funcs help_tags help_sfuncs help_styles
Index: Completion/Base/Widget/_correct_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_correct_word,v
retrieving revision 1.1
diff -u -r1.1 _correct_word
--- Completion/Base/Widget/_correct_word 2001/04/02 11:15:29 1.1
+++ Completion/Base/Widget/_correct_word 2001/05/29 11:54:54
@@ -7,7 +7,7 @@
# If configurations keys with the prefix `correctword_' are
# given they override those starting with `correct_'.
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
local curcontext="$curcontext"
Index: Completion/Base/Widget/_expand_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_expand_word,v
retrieving revision 1.1
diff -u -r1.1 _expand_word
--- Completion/Base/Widget/_expand_word 2001/04/02 11:15:46 1.1
+++ Completion/Base/Widget/_expand_word 2001/05/29 11:54:54
@@ -2,7 +2,7 @@
# Simple completion front-end implementing expansion.
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
local curcontext="$curcontext"
Index: Completion/Base/Widget/_history_complete_word
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_history_complete_word,v
retrieving revision 1.1
diff -u -r1.1 _history_complete_word
--- Completion/Base/Widget/_history_complete_word 2001/04/02 11:16:19 1.1
+++ Completion/Base/Widget/_history_complete_word 2001/05/29 11:54:54
@@ -15,7 +15,7 @@
# range -- range of history words to complete
_history_complete_word () {
- setopt localoptions ${_comp_options[@]}
+ eval "$_comp_setup"
local expl direction stop curcontext="$curcontext"
Index: Completion/Base/Widget/_next_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_next_tags,v
retrieving revision 1.1
diff -u -r1.1 _next_tags
--- Completion/Base/Widget/_next_tags 2001/04/02 11:16:51 1.1
+++ Completion/Base/Widget/_next_tags 2001/05/29 11:54:54
@@ -3,7 +3,7 @@
# Main widget.
_next_tags() {
- setopt localoptions ${_comp_options[@]}
+ eval "$_comp_setup"
local ins ops="$PREFIX$SUFFIX"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
next prev parent reply other threads:[~2001-05-29 11:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-23 3:04 Paul Ackersviller
2001-05-23 4:41 ` 64-bit sparc instructions Bart Schaefer
2001-05-23 9:38 ` Andrej Borsenkow
2001-05-23 16:42 ` Clint Adams
2001-05-23 12:29 ` Clint Adams
2001-05-23 6:28 ` vi editting troubles Bart Schaefer
2001-05-23 7:08 ` Sven Wischnowsky
2001-05-23 9:42 ` Peter Stephenson
2001-05-23 18:18 ` Wayne Davison
2001-05-23 19:31 ` Bart Schaefer
2001-05-29 6:59 ` Sven Wischnowsky
2001-05-29 11:57 ` Sven Wischnowsky [this message]
2001-05-29 14:58 ` Bart Schaefer
2001-05-30 7:19 ` Sven Wischnowsky
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=200105291157.NAA09013@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.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).