new non-standard mode: -o emacs-usemeta (on by default)

from naddy@, thanks
This commit is contained in:
tg 2003-06-26 18:26:21 +00:00
parent 1d75ca6305
commit f31bf084e3
4 changed files with 20 additions and 8 deletions

View File

@ -1,3 +1,4 @@
/* $MirBSD: emacs.c,v 1.2 2003/06/26 18:26:21 tg Exp $ */
/* $OpenBSD: emacs.c,v 1.19 2003/04/16 23:11:52 tdeval Exp $ */
/*
@ -25,7 +26,7 @@ static Area aedit;
#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 +102,6 @@ static int x_col;
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 +1530,7 @@ x_init_emacs()
*/
locale = setlocale(LC_CTYPE, NULL);
if (locale == NULL || !strcmp(locale, "C") || !strcmp(locale, "POSIX"))
x_usemeta = 1;
Flag(FEMACSUSEMETA) = 1;
}
static void

View File

@ -1,4 +1,4 @@
.\" $MirBSD: ksh.1tbl,v 1.6 2003/06/14 11:51:40 tg Exp $
.\" $MirBSD: ksh.1tbl,v 1.7 2003/06/26 18:26:21 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.53 2003/06/06 10:05:52 jmc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@ -3353,6 +3353,9 @@ Enable brace expansion (a.k.a., alternation).
.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
@ -4313,9 +4316,15 @@ When the
.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.
In this mode, various editing commands
slightly different from the emacs mode in the original Korn shell.
By default, the eight bit is used as Meta, but this can be turned
off by entering
.Ic set +o emacs-usemeta ,
which is default in the
.Mx 6
.Pa /etc/profile
file.
In the emacs mode, various editing commands
(typically bound to one or more control characters) cause immediate actions
without waiting for a newline.
Several editing commands are bound to particular

2
misc.c
View File

@ -1,3 +1,4 @@
/* $MirBSD: misc.c,v 1.2 2003/06/26 18:26:21 tg Exp $ */
/* $OpenBSD: misc.c,v 1.16 2003/04/16 23:11:52 tdeval Exp $ */
/*
@ -143,6 +144,7 @@ const struct option options[] = {
{ (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

3
sh.h
View File

@ -1,4 +1,4 @@
/* $MirBSD: sh.h,v 1.3 2003/05/22 14:06:07 tg Exp $ */
/* $MirBSD: sh.h,v 1.4 2003/06/26 18:26:21 tg Exp $ */
/* $OpenBSD: sh.h,v 1.13 2003/05/16 19:58:57 jsyn Exp $ */
/*
@ -475,6 +475,7 @@ enum sh_flag {
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