[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ksh: set +o emacs-usemeta



On Sat, 14 Jun 2003, Christian Weisgerber wrote:

> Currently, our system ksh always interprets the 8th bit as meta
> (^[) prefix in emacs command-line editing mode.  This means that
> you cannot enter 8-bit characters for filenames etc.
> 
> The small patch below makes this behavior configurable by way of a
> new emacs-usemeta shell option. "set +o emacs-usemeta" and type
> away characters with the 8th bit set.
> 
> Do we want this?  Does anybody care?  Comments?

I want it. I care. This way I don't have to patch ksh to get the
old behaviour. I don't need it every day, but often enough to find
the current behaviour annoying.

-moj
 
> Index: emacs.c
> ===================================================================
> RCS file: /cvs/src/bin/ksh/emacs.c,v
> retrieving revision 1.19
> diff -u -r1.19 emacs.c
> --- emacs.c	16 Apr 2003 23:11:52 -0000	1.19
> +++ emacs.c	14 Jun 2003 00:41:06 -0000
> @@ -25,7 +25,7 @@
>  #define	CTRL(x)		((x) == '?' ? 0x7F : (x) & 0x1F)	/* ASCII */
>  #define	UNCTRL(x)	((x) == 0x7F ? '?' : (x) | 0x40)	/* ASCII */
>  #define	META(x)		((x) & 0x7f)
> -#define	ISMETA(x)	(x_usemeta && ((x) & 0x80))
> +#define	ISMETA(x)	(Flag(FEMACSUSEMETA) && ((x) & 0x80))
>  
>  
>  /* values returned by keyboard functions */
> @@ -101,7 +101,6 @@
>  static int	x_displen;
>  static int	x_arg;		/* general purpose arg */
>  static int	x_arg_defaulted;/* x_arg not explicitly set; defaulted to 1 */
> -static int	x_usemeta;	/* no 8-bit ascii, meta = ESC */
>  
>  static int	xlp_valid;
>  /* end from 4.9 edit.h } */
> @@ -1530,7 +1529,7 @@
>  	 */
>  	locale = setlocale(LC_CTYPE, NULL);
>  	if (locale == NULL || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
> -		x_usemeta = 1;
> +		Flag(FEMACSUSEMETA) = 1;
>  }
>  
>  static void
> Index: ksh.1tbl
> ===================================================================
> RCS file: /cvs/src/bin/ksh/ksh.1tbl,v
> retrieving revision 1.53
> diff -u -r1.53 ksh.1tbl
> --- ksh.1tbl	6 Jun 2003 10:05:52 -0000	1.53
> +++ ksh.1tbl	14 Jun 2003 19:36:17 -0000
> @@ -3352,6 +3352,9 @@
>  .It Ic emacs
>  Enable BRL emacs-like command-line editing (interactive shells only); see
>  .Sx Emacs editing mode .
> +.It Ic emacs-usemeta
> +In emacs command-line editing, use the 8th bit as meta (^[) prefix.
> +This is the default.
>  .It Ic gmacs
>  Enable gmacs-like command-line editing (interactive shells only).
>  Currently identical to emacs editing except that transpose (^T) acts slightly
> @@ -4307,8 +4310,7 @@
>  .Ic emacs
>  option is set, interactive input line editing is enabled.
>  Warning: This mode is
> -slightly different from the emacs mode in the original Korn shell and the 8th
> -bit is stripped in emacs mode.
> +slightly different from the emacs mode in the original Korn shell.
>  In this mode, various editing commands
>  (typically bound to one or more control characters) cause immediate actions
>  without waiting for a newline.
> Index: misc.c
> ===================================================================
> RCS file: /cvs/src/bin/ksh/misc.c,v
> retrieving revision 1.16
> diff -u -r1.16 misc.c
> --- misc.c	16 Apr 2003 23:11:52 -0000	1.16
> +++ misc.c	14 Jun 2003 00:30:44 -0000
> @@ -143,6 +143,7 @@
>  	{ (char *) 0, 	'c',	    OF_CMDLINE },
>  #ifdef EMACS
>  	{ "emacs",	  0,		OF_ANY },
> +	{ "emacs-usemeta",  0,		OF_ANY }, /* non-standard */
>  #endif
>  	{ "errexit",	'e',		OF_ANY },
>  #ifdef EMACS
> Index: sh.h
> ===================================================================
> RCS file: /cvs/src/bin/ksh/sh.h,v
> retrieving revision 1.13
> diff -u -r1.13 sh.h
> --- sh.h	16 May 2003 19:58:57 -0000	1.13
> +++ sh.h	14 Jun 2003 00:41:47 -0000
> @@ -474,6 +474,7 @@
>  	FCOMMAND,	/* -c: (invocation) execute specified command */
>  #ifdef EMACS
>  	FEMACS,		/* emacs command editing */
> +	FEMACSUSEMETA,	/* use 8th bit as meta */
>  #endif
>  	FERREXIT,	/* -e: quit on error */
>  #ifdef EMACS
> -- 
> Christian "naddy" Weisgerber                          naddy@mips.inka.de