zsh-workers
 help / color / mirror / code / Atom feed
From: Phil Pennock <phil@athenaeum.demon.co.uk>
To: Zsh Development Workers <zsh-workers@math.gatech.edu>
Subject: PATCH: WORDCHARS and emulate
Date: Sat, 5 Dec 1998 02:55:21 +0000	[thread overview]
Message-ID: <19981205025521.27213@athenaeum.demon.co.uk> (raw)

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?


             reply	other threads:[~1998-12-05  2:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-05  2:55 Phil Pennock [this message]
1998-12-05  4:36 ` Bart Schaefer

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=19981205025521.27213@athenaeum.demon.co.uk \
    --to=phil@athenaeum.demon.co.uk \
    --cc=zsh-workers@math.gatech.edu \
    /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).