* Re: Calling completion function from a non-completion ZLE widget
@ 2000-05-30 7:59 Sven Wischnowsky
2000-05-30 15:38 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-05-30 7:59 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> ...
>
> The best we can do seems to be a bit of defensive programming up front.
> What's a reliable way to determine that the completion system is active?
> (Testing a parameter won't do it, the user could always set another of
> the same name.)
Hm, no parameter? Even if ${(t)compstate} yields `association-local-special'?
We can use the conditions, e.g.:
if [[ -prefix * ]] 2> /dev/null; then
# completion active
fi
Or should we change compadd to return `2' in $? when completion is not
active? Or `1' there, but `2' if no matches are given, so that we
could do
compadd 2> /dev/null
if [[ $? -ne 1 ]]; then
...
fi
? Dunno.
Bye
Sven
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Calling completion function from a non-completion ZLE widget
2000-05-30 7:59 Calling completion function from a non-completion ZLE widget Sven Wischnowsky
@ 2000-05-30 15:38 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-05-30 15:38 UTC (permalink / raw)
To: zsh-workers
On May 30, 9:59am, Sven Wischnowsky wrote:
}
} Bart Schaefer wrote:
}
} > What's a reliable way to determine that the completion system is active?
} > (Testing a parameter won't do it, the user could always set another of
} > the same name.)
}
} Hm, no parameter? Even if ${(t)compstate} yields `association-local-special'?
Ah, I forgot about (t). Yes, that would probably suffice.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 3+ messages in thread
* Calling completion function from a non-completion ZLE widget
@ 2000-05-30 7:20 Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-05-30 7:20 UTC (permalink / raw)
To: zsh-workers
I accidentally ended up with a function bound to an ordinary widget (i.e.
zle -N ...) that called _complete_help. [*] Bad, very bad. Not only did
it complain:
_main_complete:compset:52: can only be called from completion function
_default:compcall:12: can only be called from completion function
_main_complete:266: bad set of key/value pairs for associative array
But now that shell is also in a state where no completion of any kind does
anything other than beep at me and occasionally spit out errors about
bad math expressions, like this:
zstyle:5: bad math expression: operand expected at `:completio...'
Hmm, I suspect _complete_help got aborted in progress by one of the above
errors and left some functions defined. Yup, that's it; probably left
some other garbage state as well. Yow, it even left $compstate in an
inconsistent state! $+compstate is 1, $#compstate is also 1, but trying
`typeset | grep ^compstate` yields nothing.
It'd be best if that sort of thing doesn't happen, but there's no way to
trap on only the sort of error that causes the whole call stack to abort
(as `bad set of ...' seems to have).
The best we can do seems to be a bit of defensive programming up front.
What's a reliable way to determine that the completion system is active?
(Testing a parameter won't do it, the user could always set another of
the same name.)
[*] It should have been calling `zle _complete_help', I forgot the `zle'.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2000-05-30 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-30 7:59 Calling completion function from a non-completion ZLE widget Sven Wischnowsky
2000-05-30 15:38 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2000-05-30 7:20 Bart Schaefer
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).