Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Handling for ZLE modules



I'm so impressed with the dynamic library code I couldn't resist
implementing a way of allowing you to load new ZLE functions from
modules.

My thinking was this: there are 162 builtin functions and you're
presumably never going to add more than a half dozen or so new ones
(very likely none).  Thus it didn't seem sensible to reorganize the
existing function table into malloc'd memory.  Instead, I've made a
new table for any functions that are loaded and modified the zle code
via a #define, ZLEGETCMD, to choose between the arrays based on
number.  I don't think this should be too inefficient; the worst case
is in executenamedcommand() when looping through looking for a prefix.
If it ever seems a good idea to allow overloading of builtin functions
this may well need changing.  That's the only major change to zle
itself; note that for non-dynamic zsh's it will work quite happily
without the functions (add|delete)zlefunction() defined in
module.c. I'd be glad to hear of better ways of doing it.

The other question is how to handle unloading.  One has to be careful
when bindings remain which point to the function; also, the functions
are in a linear array like the builtin functions and you may not be
deleting at the end.  I have arranged it so that the function is
marked as deleted with name "<deleted>" (which should only be used for
output), but the table entry is kept. Executing the binding performs a
feep().  That's probably fine, the only problem arises when you load
another module which then inherits the slot in the table and hence the
binding will point to that.  This seems to me a problem to be fixed in
any script code associated with the (z?)modload -u, in particular via
    bindkey | grep '<deleted>' | while read -A line; do
        eval bindkey -r $line[0]
    done
-- I don't think it's worthwhile adding that code to the shell, though
it wouldn't be hard.

The sample module mod_deltochar implements Emacs' zap-to-char (except
it's here called delete-to-char) which reads a key and deletes up to
and including the next occurrence of that character on the command
line.  Multipliers work as expected.  (I've always wanted
zap-to-char.)  Just do `make mod_deltochar.so'.

All this code is as up-in-the-air as Zoltan's, of course.

begin 644 zle_mod.dif.gz
M'XL("*9/@S(``WIL95]M;V0N9&EF`.4[:W/;N+6?M;\"]FW7DDPYHB0_),?9
M\2;>U%/'R:R][=YZ/1Z*A"Q6%,D2H!UI-_^]YQP`)"A1;K)U.M.IQI%(/`[.
M^P$@[7:;767^BWD2W`4\DHD_];(]?P_>&S]D(;M,'A@[8NY@U'='[I"YP^'!
M-YU.IV[2RH3]WJCGJ@GMZ@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ZKMZ4*7>`S6Y^KWIAA<Y>
MS.PR8RX=+TV@xxxx+-J<W92J6<"TS4D_@O$$20[.4!W;"D?=!O;H%+,?#/[N
MT`$D<C&D&[D.R^,(SV8?^4Z&MX]2[M%M?'W8X`X&P(1!Y9#J7S-A-6.9]10Q
M]?G*9J;HJPUUS#`POC83:C5C.'1ZW>)H:'WYRP2/1O$>'5[T_0XL^S)QV"+)
M\<K4CL2K8XM`1Q?C"#<KS;OW?SE[=P8N6GO(-1^B>:_PH$C9=0'!0_LL[ED0
M7!'<ER%6FRCU`-%R0Q`_CTD6D%\_88\3,YL\`M95J10WWY^=?;@M>HH6DV[C
M9Y-!K2W1K853=4`8I03N!4BZBZNN5/8![Z'-X.?"NZ+SSX%O+=\'!TZO]&WT
M:=.=>HG_WR56ZJ]J&_HO-U`D2_M_/I!C=?0-1&K`BX((I01G;I#,<R'+BX3V
M#9!H@5<NI+H3ER;HZA\Y^SN.I^L4%7`0_N?>C)?+0\#`7,`#P\7_KY%QN@LM
MGKI345'H3?9V<7YYAJJMM1JQ`D[XHAHR<.<!FU2ZW:`T&[NYZB8M&1P!ERL7
4;_\'N;SB-)Z%N_\$F6-O9?XV``#X
`
end

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.



Messages sorted by: Reverse Date, Date, Thread, Author