Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Difficulties with _oldlist
- X-seq: zsh-workers 20332
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Difficulties with _oldlist
- Date: Wed, 08 Sep 2004 17:56:07 +0100
- In-reply-to: <Pine.LNX.4.61.0408230821370.5997@xxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <Pine.LNX.4.61.0408230821370.5997@xxxxxxxxxxxxxxxxxx>
Bart Schaefer wrote:
> A better solution would be
> if $WIDGET could be replaced by a different variable, say $WIDGETSTYLE for
> example, which is set corresponding to the second argument of "zle -C".
> I.e. if the widget were defined with
>
> zle -C blather list-choices blather
>
> then at time of call $WIDGETSTYLE would be "list-choices", and _oldlist
> could examine that instead of $WIDGET.
This is the internal implementation. For a "zle -N" widget $WIDGETSTYLE
gives the name of the function that implements the widget. Altering the
completion system is left as an exercise to the reader.
Index: Src/Zle/zle_params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_params.c,v
retrieving revision 1.16
diff -u -r1.16 zle_params.c
--- Src/Zle/zle_params.c 29 Jul 2004 14:22:22 -0000 1.16
+++ Src/Zle/zle_params.c 8 Sep 2004 16:52:53 -0000
@@ -55,43 +55,45 @@
} zleparams[] = {
{ "BUFFER", PM_SCALAR, FN(set_buffer), FN(get_buffer),
zleunsetfn, NULL },
- { "CURSOR", PM_INTEGER, FN(set_cursor), FN(get_cursor),
- zleunsetfn, NULL },
- { "MARK", PM_INTEGER, FN(set_mark), FN(get_mark),
- zleunsetfn, NULL },
- { "LBUFFER", PM_SCALAR, FN(set_lbuffer), FN(get_lbuffer),
- zleunsetfn, NULL },
- { "RBUFFER", PM_SCALAR, FN(set_rbuffer), FN(get_rbuffer),
+ { "BUFFERLINES", PM_INTEGER | PM_READONLY, NULL, FN(get_bufferlines),
+ zleunsetfn, NULL },
+ { "CONTEXT", PM_SCALAR | PM_READONLY, NULL, FN(get_context),
zleunsetfn, NULL },
- { "PREBUFFER", PM_SCALAR | PM_READONLY, NULL, FN(get_prebuffer),
+ { "CURSOR", PM_INTEGER, FN(set_cursor), FN(get_cursor),
zleunsetfn, NULL },
- { "WIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_widget),
- zleunsetfn, NULL },
- { "LASTWIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_lwidget),
+ { "CUTBUFFER", PM_SCALAR, FN(set_cutbuffer), FN(get_cutbuffer),
+ unset_cutbuffer, NULL },
+ { "HISTNO", PM_INTEGER, FN(set_histno), FN(get_histno),
zleunsetfn, NULL },
{ "KEYMAP", PM_SCALAR | PM_READONLY, NULL, FN(get_keymap),
zleunsetfn, NULL },
{ "KEYS", PM_SCALAR | PM_READONLY, NULL, FN(get_keys),
zleunsetfn, NULL },
- { "NUMERIC", PM_INTEGER | PM_UNSET, FN(set_numeric), FN(get_numeric),
- unset_numeric, NULL },
- { "HISTNO", PM_INTEGER, FN(set_histno), FN(get_histno),
+ { "killring", PM_ARRAY, FN(set_killring), FN(get_killring),
+ unset_killring, NULL },
+ { "LASTSEARCH", PM_SCALAR | PM_READONLY, NULL, FN(get_lsearch),
zleunsetfn, NULL },
- { "BUFFERLINES", PM_INTEGER | PM_READONLY, NULL, FN(get_bufferlines),
+ { "LASTWIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_lwidget),
zleunsetfn, NULL },
+ { "LBUFFER", PM_SCALAR, FN(set_lbuffer), FN(get_lbuffer),
+ zleunsetfn, NULL },
+ { "MARK", PM_INTEGER, FN(set_mark), FN(get_mark),
+ zleunsetfn, NULL },
+ { "NUMERIC", PM_INTEGER | PM_UNSET, FN(set_numeric), FN(get_numeric),
+ unset_numeric, NULL },
{ "PENDING", PM_INTEGER | PM_READONLY, NULL, FN(get_pending),
zleunsetfn, NULL },
- { "CUTBUFFER", PM_SCALAR, FN(set_cutbuffer), FN(get_cutbuffer),
- unset_cutbuffer, NULL },
- { "killring", PM_ARRAY, FN(set_killring), FN(get_killring),
- unset_killring, NULL },
+ { "POSTDISPLAY", PM_SCALAR, FN(set_postdisplay), FN(get_postdisplay),
+ zleunsetfn, NULL },
+ { "PREBUFFER", PM_SCALAR | PM_READONLY, NULL, FN(get_prebuffer),
+ zleunsetfn, NULL },
{ "PREDISPLAY", PM_SCALAR, FN(set_predisplay), FN(get_predisplay),
zleunsetfn, NULL },
- { "POSTDISPLAY", PM_SCALAR, FN(set_postdisplay), FN(get_postdisplay),
+ { "RBUFFER", PM_SCALAR, FN(set_rbuffer), FN(get_rbuffer),
zleunsetfn, NULL },
- { "LASTSEARCH", PM_SCALAR | PM_READONLY, NULL, FN(get_lsearch),
+ { "WIDGET", PM_SCALAR | PM_READONLY, NULL, FN(get_widget),
zleunsetfn, NULL },
- { "CONTEXT", PM_SCALAR | PM_READONLY, NULL, FN(get_context),
+ { "WIDGETSTYLE", PM_SCALAR | PM_READONLY, NULL, FN(get_widgetstyle),
zleunsetfn, NULL },
{ NULL, 0, NULL, NULL, NULL, NULL }
};
@@ -280,6 +282,21 @@
/**/
static char *
+get_widgetstyle(UNUSED(Param pm))
+{
+ Widget widget = bindk->widget;
+ int flags = widget->flags;
+
+ if (flags & WIDGET_INT)
+ return ".internal"; /* Don't see how this can ever be returned... */
+ else if (flags & WIDGET_NCOMP)
+ return widget->u.comp.wid;
+ else
+ return widget->u.fnnam;
+}
+
+/**/
+static char *
get_lwidget(UNUSED(Param pm))
{
return (lbindk ? lbindk->nam : "");
Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.41
diff -u -r1.41 zle.yo
--- Doc/Zsh/zle.yo 8 Sep 2004 15:24:08 -0000 1.41
+++ Doc/Zsh/zle.yo 8 Sep 2004 16:52:55 -0000
@@ -732,6 +732,16 @@
item(tt(WIDGET) (scalar))(
The name of the widget currently being executed; read-only.
)
+vindex(WIDGETSTYLE)
+item(tt(WIDGET) (scalar))(
+Describes the implementation behind the widget currently being executed;
+the second argument that followed tt(zle -C) or tt(zle -N) when the widget
+was defined, if any. If the widget was defined with tt(zle -N) and there was
+no second argument this is the same as the first argument. Hence for
+tt(zle -N) this gives the name of the function that implements the widget,
+and for tt(zle -C) this gives the internal completion widget that defines
+the type of completion. Read-only.
+)
enditem()
subsect(Special Widget)
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author