* PATCH: WORDCHARS and emulate
@ 1998-12-05 2:55 Phil Pennock
1998-12-05 4:36 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Phil Pennock @ 1998-12-05 2:55 UTC (permalink / raw)
To: Zsh Development Workers
This patch sets wordchars on startup according to emulation mode and
resets it upon an 'emulate' command. Yes, it gets totally clobbered by
emulate.
The alternate WORDCHARS just lacks '/'. It's named for ksh as that is
the only shell of bash, tcsh and pdksh (the ones I have installed) that
handles this similarly.
tcsh handles ^W as ^U (undocumented).
bash has two separate readline functions. In bash 2.01.1(1)-release,
the manual page reads:
backward-kill-rubout (M-rubout)
Kill the word behind the cursor. Word boundaries
are the same as those used by backward-word.
unix-word-rubout (C-w)
Kill the word behind the cursor, using white space
as a word boundary. The word boundaries are dif-
ferent from backward-kill-word.
This patch doesn't modify ZLE to handle these, so I won't be too hurt if
it's rejected. ;^)
*** dDoc/Zsh/builtins.yo Tue Nov 10 09:10:01 1998
--- Doc/Zsh/builtins.yo Sat Dec 5 02:40:40 1998
***************
*** 218,223 ****
--- 218,225 ----
item(tt(emulate) [ tt(-R) ] {tt(zsh)|tt(sh)|tt(ksh)|tt(csh)})(
Set up zsh options to emulate the specified shell as much as possible.
bf(csh) will never be fully emulated.
+ tt(WORDCHARS) is also modified accordingly, but may not provide an exact
+ match for all bindings. This clobbers any changes the user may have made.
If the argument is not one of the shells listed above, tt(zsh)
will be used as a default. If the tt(-R) option is given, all options
are reset to their default value corresponding to the specified emulation
*** dDoc/Zsh/compat.yo Sun Oct 11 22:36:18 1998
--- Doc/Zsh/compat.yo Sat Dec 5 02:02:57 1998
***************
*** 67,69 ****
--- 67,72 ----
and
tt(SINGLE_LINE_ZLE)
options are set if zsh is invoked as tt(ksh).
+ Further, the
+ tt(WORDCHARS)
+ shell variable takes a different value when emulating other shells.
*** dSrc/init.c Sun Oct 11 23:01:03 1998
--- Src/init.c Sat Dec 5 01:05:12 1998
***************
*** 531,537 ****
sprompt = ztrdup("zsh: correct '%R' to '%r' [nyae]? ");
ifs = ztrdup(DEFAULT_IFS);
- wordchars = ztrdup(DEFAULT_WORDCHARS);
postedit = ztrdup("");
underscore = ztrdup("");
--- 531,536 ----
***************
*** 544,557 ****
/* The following variable assignments cause zsh to behave more *
* like Bourne and Korn shells when invoked as "sh" or "ksh". *
! * NULLCMD=":" and READNULLCMD=":" */
if (emulation == EMULATE_KSH || emulation == EMULATE_SH) {
nullcmd = ztrdup(":");
readnullcmd = ztrdup(":");
} else {
nullcmd = ztrdup("cat");
readnullcmd = ztrdup("more");
}
/* We cache the uid so we know when to *
--- 543,558 ----
/* The following variable assignments cause zsh to behave more *
* like Bourne and Korn shells when invoked as "sh" or "ksh". *
! * NULLCMD=":" and READNULLCMD=":", whilst WORDCHARS lacks '/' */
if (emulation == EMULATE_KSH || emulation == EMULATE_SH) {
nullcmd = ztrdup(":");
readnullcmd = ztrdup(":");
+ wordchars = ztrdup(DEFAULT_WORDCHARS_KSH);
} else {
nullcmd = ztrdup("cat");
readnullcmd = ztrdup("more");
+ wordchars = ztrdup(DEFAULT_WORDCHARS);
}
/* We cache the uid so we know when to *
*** dSrc/options.c Wed Apr 29 22:42:50 1998
--- Src/options.c Sat Dec 5 02:38:01 1998
***************
*** 433,438 ****
--- 433,439 ----
emulate(const char *zsh_name, int fully)
{
char ch = *zsh_name;
+ Param wp;
if (ch == 'r')
ch = zsh_name[1];
***************
*** 448,453 ****
--- 449,471 ----
emulation = EMULATE_ZSH;
scanhashtable(optiontab, 0, 0, 0, setemulate, fully);
+
+ /* ksh does not include '/' in WORDCHARS; bash and tcsh use a *
+ * different behaviour. Neither includes '/' for ESC-^H; bash *
+ * uses whitespace as a boundary for ^W whilst tcsh treats ^W *
+ * as synonymous with ^U (undocumented) */
+
+ /* emulate() called from main() before paramtab initialised. *
+ * setupvals() will set wordchars directly, so that's okay. *
+ * Since wp is ignored, we could be lazy and just not bother. */
+ if (paramtab) {
+ wp = (Param) paramtab->getnode(paramtab, "WORDCHARS");
+
+ if (emulation == EMULATE_ZSH)
+ wordcharssetfn(wp, ztrdup(DEFAULT_WORDCHARS));
+ else
+ wordcharssetfn(wp, ztrdup(DEFAULT_WORDCHARS_KSH));
+ }
}
/* setopt, unsetopt */
*** dSrc/params.c Tue Nov 17 12:48:08 1998
--- Src/params.c Sat Dec 5 02:31:46 1998
***************
*** 251,257 ****
/* hash table containing the parameters */
/**/
! HashTable paramtab;
/**/
HashTable
--- 251,257 ----
/* hash table containing the parameters */
/**/
! HashTable paramtab = NULL;
/**/
HashTable
*** dSrc/system.h Fri Oct 30 14:56:15 1998
--- Src/system.h Sat Dec 5 01:05:25 1998
***************
*** 317,322 ****
--- 317,323 ----
#endif
#define DEFAULT_WORDCHARS "*?_-.[]~=/&;!#$%^(){}<>"
+ #define DEFAULT_WORDCHARS_KSH "*?_-.[]~=&;!#$%^(){}<>"
#define DEFAULT_TIMEFMT "%J %U user %S system %P cpu %*E total"
/* Posix getpgrp takes no argument, while the BSD version *
--
--> Phil Pennock ; GAT d- s+:+ a22 C++(++++) UL++++/I+++/S+++/H+ P++@ L+++
E-@ W(+) N>++ o !K w--- O>+ M V !PS PE Y+ PGP+ t-- 5++ X+ R !tv b++>+++ DI+ D+
G+ e+ h* r y?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: WORDCHARS and emulate
1998-12-05 2:55 PATCH: WORDCHARS and emulate Phil Pennock
@ 1998-12-05 4:36 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1998-12-05 4:36 UTC (permalink / raw)
To: Phil Pennock, Zsh Development Workers
On Dec 5, 2:55am, Phil Pennock wrote:
} Subject: PATCH: WORDCHARS and emulate
}
} This patch sets wordchars on startup according to emulation mode and
} resets it upon an 'emulate' command. Yes, it gets totally clobbered by
} emulate.
This is not a reasonable side-effect of "emulate." LOTS of shell functions,
including those in the zsh distribution that are used for completions etc.,
call "emulate". If it's going to change anything like WORDCHARS, it has to
save it and restore it when the emulation mode ceases to be in effect. And
since the only thing that tracks emulation mode is "setopt localoptions",
it's in effect impossible to save and restore anything other than options
during emulation.
So you could conceivably do this by having an option to turn WORDCHARS on
and off, and arrange that "emulate -R" always unsets that option; and then
have values for the internal wordchars array that are independent of the
WORDCHARS variable and which get switched in depending on the emulation.
But you can't stomp WORDCHARS itself.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1998-12-05 4:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-12-05 2:55 PATCH: WORDCHARS and emulate Phil Pennock
1998-12-05 4:36 ` 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).