From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: funcstack parameter
Date: Tue, 2 Nov 1999 10:04:56 +0100 (MET) [thread overview]
Message-ID: <199911020904.KAA30028@beta.informatik.hu-berlin.de> (raw)
I'm currently playing with the grouping/priority stuff for completion
and I think for that it might be nice/useful to have a way to get at
the names of the function currently being executed.
So this add the `funcstack' parameter to the parameter module which is
an array containing these names.
Maybe it's useful in other places, too.
Bye
Sven
diff -u -r oldsrc/Modules/parameter.c Src/Modules/parameter.c
--- oldsrc/Modules/parameter.c Mon Nov 1 20:43:22 1999
+++ Src/Modules/parameter.c Mon Nov 1 21:06:03 1999
@@ -555,6 +555,44 @@
scanfunctions(ht, func, flags, DISABLED);
}
+/* Functions for the funcstack special parameter. */
+
+static LinkList funcstack;
+
+/**/
+static char **
+funcstackgetfn(Param pm)
+{
+ char **ret, **p;
+ LinkNode node;
+
+ ret = (char **) zhalloc((countlinknodes(funcstack) + 1) * sizeof(char *));
+
+ for (node = firstnode(funcstack), p = ret; node; incnode(node), p++)
+ *p = (char *) getdata(node);
+ *p = NULL;
+
+ return ret;
+}
+
+/**/
+static int
+func_wrapper(List list, FuncWrap w, char *name)
+{
+ PERMALLOC {
+ pushnode(funcstack, ztrdup(name));
+ } LASTALLOC;
+
+ runshfunc(list, w, name);
+
+ DPUTS(strcmp(name, (char *) getdata(firstnode(funcstack))),
+ "funcstack wrapper with wrong function");
+
+ zsfree((char *) remnode(funcstack, firstnode(funcstack)));
+
+ return 0;
+}
+
/* Functions for the builtins special parameter. */
/**/
@@ -1775,6 +1813,9 @@
{ "disfunctions", 0,
getpmdisfunction, scanpmdisfunctions, setpmdisfunctions,
NULL, NULL, stdunsetfn, NULL },
+ { "funcstack", PM_ARRAY|PM_SPECIAL|PM_READONLY,
+ NULL, NULL, NULL,
+ arrsetfn, funcstackgetfn, stdunsetfn, NULL },
{ "builtins", PM_READONLY,
getpmbuiltin, scanpmbuiltins, hashsetfn,
NULL, NULL, stdunsetfn, NULL },
@@ -1829,6 +1870,10 @@
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
+static struct funcwrap wrapper[] = {
+ WRAPDEF(func_wrapper),
+};
+
/**/
int
setup_parameter(Module m)
@@ -1867,6 +1912,12 @@
def->pm->unsetfn = def->unsetfn;
}
}
+ PERMALLOC {
+ funcstack = newlinklist();
+ } LASTALLOC;
+
+ addwrapper(m, wrapper);
+
return 0;
}
@@ -1888,6 +1939,9 @@
unsetparam_pm(pm, 0, 1);
}
}
+ deletewrapper(m, wrapper);
+ freelinklist(funcstack, freestr);
+
return 0;
}
diff -u -r oldsrc/Modules/parameter.mdd Src/Modules/parameter.mdd
--- oldsrc/Modules/parameter.mdd Mon Nov 1 20:43:22 1999
+++ Src/Modules/parameter.mdd Mon Nov 1 21:10:00 1999
@@ -1,3 +1,3 @@
-autoparams="parameters commands functions disfunctions builtins disbuiltins reswords disreswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases disraliases galiases disgaliases"
+autoparams="parameters commands functions disfunctions funcstack builtins disbuiltins reswords disreswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases disraliases galiases disgaliases"
objects="parameter.o"
diff -u olddoc/Zsh/mod_parameter.yo Doc/Zsh/mod_parameter.yo
--- olddoc/Zsh/mod_parameter.yo Fri Oct 29 21:18:25 1999
+++ Doc/Zsh/mod_parameter.yo Mon Nov 1 21:13:50 1999
@@ -137,4 +137,10 @@
This association maps user names to the pathnames of their home
directories.
)
+vindex(funcstack)
+item(tt(funcstack))(
+This array contains the names of the functions currently being
+executed. The first element is the name of the function using the
+parameter.
+)
enditem()
--- oldcompletion/Core/compinit Fri Oct 29 21:15:45 1999
+++ Completion/Core/compinit Mon Nov 1 21:11:08 1999
@@ -113,6 +113,10 @@
comppostfuncs=()
+# Loading it now ensures that the `funcstack' parameter is always correct.
+
+zmodload -i parameter
+
# This function is used to register or delete completion functions. For
# registering completion functions, it is invoked with the name of the
# function as it's first argument (after the options). The other
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~1999-11-02 9:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=199911020904.KAA30028@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).