* PATCH: functions completion missed -s and -x
@ 2018-05-16 9:55 ` Oliver Kiddle
2018-05-16 10:15 ` Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Kiddle @ 2018-05-16 9:55 UTC (permalink / raw)
To: Zsh workers
Two relatively new options to functions were missing from the completion
function: -x which allows the indentation to be changed and -s which is
for defining math functions with a string parameter.
On the subject of math functions, is it not inconsistent with everything
else that redefining a math function results in a "function already
exists" error rather than being silent. If I re-source my .zshrc, it is
silent apart from these errors.
Oliver
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index 14d5d371b..fb7189c77 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -55,9 +55,13 @@ case ${service} in
;;
float) use="EFHghlprtux";;
functions)
- use="UkmTtuzMW"
+ use="UkmTtuzW"
func=f
- allargs[M]='(-k -t -T -u -U -z -M +M +k +t +z)-+M[define mathematical function]'
+ args=(
+ '(-k -t -T -u -U -W -x -z -M +M +k +t +W +z)-+M[define mathematical function]'
+ '(-k -m -t -T -u -U -W -x -z +M +k +t +W +z)-s[define mathematical function that takes a string argument]'
+ '(-M)-x+[specify spaces to use for indentation]:spaces'
+ )
;;
integer)
use="Hghilprtux"
@@ -89,8 +93,10 @@ if [[ "$state" = vars_eq ]]; then
_wanted functions expl 'math function' compadd -F line - \
${${${(f)"$(functions -M)"}##*-M }%% *}
elif (( $+opt_args[-M] )); then
- _arguments ':new math function:_functions' ':minimum arguments' \
- ':maximum arguments' ':shell function:_functions'
+ _arguments ':new math function:_functions' \
+ ":minimum arguments${(k)opt_args[-s]:+:(1)}" \
+ ":maximum arguments${(k)opt_args[-s]:+:(1)}" \
+ ':shell function:_functions'
elif (( $+opt_args[-w] )); then
_wanted files expl 'zwc file' _files -g '*.zwc(-.)'
elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: functions completion missed -s and -x
2018-05-16 9:55 ` PATCH: functions completion missed -s and -x Oliver Kiddle
@ 2018-05-16 10:15 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2018-05-16 10:15 UTC (permalink / raw)
To: Zsh workers
On Wed, 16 May 2018 11:55:39 +0200
Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> On the subject of math functions, is it not inconsistent with
> everything else that redefining a math function results in a
> "function already exists" error rather than being silent. If I
> re-source my .zshrc, it is silent apart from these errors.
Yes, and this unusual interface doesn't appear to be documented, either.
pws
diff --git a/Src/builtin.c b/Src/builtin.c
index 931605c..1cba97d 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3199,7 +3199,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
pflags |= PRINT_NAMEONLY;
if (OPT_MINUS(ops,'M') || OPT_PLUS(ops,'M')) {
- MathFunc p, q;
+ MathFunc p, q, prev;
/*
* Add/remove/list function as mathematical.
*/
@@ -3331,15 +3331,10 @@ bin_functions(char *name, char **argv, Options ops, int func)
p->maxargs = maxargs;
queue_signals();
- for (q = mathfuncs; q; q = q->next) {
+ for (q = mathfuncs, prev = NULL; q; prev = q, q = q->next) {
if (!strcmp(q->name, funcname)) {
- unqueue_signals();
- zwarnnam(name, "-M %s: function already exists",
- funcname);
- zsfree(p->name);
- zsfree(p->module);
- zfree(p, sizeof(struct mathfunc));
- return 1;
+ removemathfunc(prev, q);
+ break;
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-16 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20180516095641epcas4p240d76877aedbddfc42d29ce1b3945ee5@epcas4p2.samsung.com>
2018-05-16 9:55 ` PATCH: functions completion missed -s and -x Oliver Kiddle
2018-05-16 10:15 ` Peter Stephenson
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).