From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6220 invoked from network); 5 Dec 1998 02:52:06 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 5 Dec 1998 02:52:06 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id VAA06866; Fri, 4 Dec 1998 21:50:43 -0500 (EST) Resent-Date: Fri, 4 Dec 1998 21:50:43 -0500 (EST) Message-ID: <19981205025521.27213@athenaeum.demon.co.uk> Date: Sat, 5 Dec 1998 02:55:21 +0000 From: Phil Pennock To: Zsh Development Workers Subject: PATCH: WORDCHARS and emulate Mail-Followup-To: Zsh Development Workers Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 Organisation: Organisation? Here? No, over there ----> X-Disclaimer: Any views expressed in this message, where not explicitly attributed otherwise, are mine and mine alone. Such views do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. X-Phase-of-Moon: The Moon is Waning Gibbous (97% of Full) Resent-Message-ID: <"lQ0Te3.0.Ah1.2-9Qs"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/4704 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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?