in a somewhat hackish way, and it’s still quite different from zsh,
but probably closer to a desired functionality

XXX this makes state by abusing 「modified」 and 「xmp」 (“the mark”).
This commit is contained in:
tg
2008-10-04 23:08:04 +00:00
parent 78a49e8faf
commit 27ee1866fe
4 changed files with 25 additions and 10 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.226 2008/09/30 19:36:15 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.227 2008/10/04 23:08:01 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -7,7 +7,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh # http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R35 2008/09/30 @(#)MIRBSD KSH R35 2008/10/04
description: description:
Check version of shell. Check version of shell.
stdin: stdin:

20
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.135 2008/09/30 19:28:12 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.136 2008/10/04 23:08:03 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -3176,6 +3176,8 @@ x_edit_line(int c __unused)
* command and inserts it into the current edit line. If a * command and inserts it into the current edit line. If a
* numeric arg is supplied then the n'th word from the * numeric arg is supplied then the n'th word from the
* start of the previous command is used. * start of the previous command is used.
* As a side effect, trashes the mark in order to achieve
* being called in a repeatable fashion.
* *
* Bound to M-. * Bound to M-.
* *
@ -3186,11 +3188,20 @@ static int
x_prev_histword(int c __unused) x_prev_histword(int c __unused)
{ {
char *rcp, *cp; char *rcp, *cp;
char **xhp;
int m;
cp = *histptr; if (xmp && modified > 1)
if (!cp) x_kill_region(0);
m = modified ? modified : 1;
xhp = histptr - (m - 1);
if ((xhp < history) || !(cp = *xhp)) {
x_e_putc2(7); x_e_putc2(7);
else if (x_arg_defaulted) { x_modified();
return (KSTD);
}
x_set_mark(0);
if (x_arg_defaulted) {
rcp = &cp[strlen(cp) - 1]; rcp = &cp[strlen(cp) - 1];
/* /*
* ignore white-space after the last word * ignore white-space after the last word
@ -3225,6 +3236,7 @@ x_prev_histword(int c __unused)
x_ins(cp); x_ins(cp);
*rcp = ch; *rcp = ch;
} }
modified = m + 1;
return KSTD; return KSTD;
} }

7
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.138 2008/09/30 18:48:01 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.139 2008/10/04 23:08:03 tg Exp $
.\" $OpenBSD: ksh.1,v 1.122 2008/05/17 23:31:52 sobrado Exp $ .\" $OpenBSD: ksh.1,v 1.122 2008/05/17 23:31:52 sobrado Exp $
.\"- .\"-
.\" Try to make GNU groff and AT&T nroff more compatible .\" Try to make GNU groff and AT&T nroff more compatible
@ -30,7 +30,7 @@
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
.. ..
.\"- .\"-
.Dd $Mdocdate: September 30 2008 $ .Dd $Mdocdate: October 4 2008 $
.Dt MKSH 1 .Dt MKSH 1
.Os MirBSD .Os MirBSD
.Sh NAME .Sh NAME
@ -4804,6 +4804,9 @@ Introduces a 2-character command sequence.
The last The last
.Pq Ar n Ns th .Pq Ar n Ns th
word of the previous command is inserted at the cursor. word of the previous command is inserted at the cursor.
On repeated execution, goes back the history.
Use of this editing command trashes the mark.
If this
.It quote: \*(ha\*(ha , \*(haV .It quote: \*(ha\*(ha , \*(haV
The following character is taken literally rather than as an editing command. The following character is taken literally rather than as an editing command.
.It redraw: \*(haL .It redraw: \*(haL

4
sh.h
View File

@ -100,9 +100,9 @@
#define __SCCSID(x) __IDSTRING(sccsid,x) #define __SCCSID(x) __IDSTRING(sccsid,x)
#ifdef EXTERN #ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.236 2008/09/30 19:25:51 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.237 2008/10/04 23:08:04 tg Exp $");
#endif #endif
#define MKSH_VERSION "R35 2008/09/30" #define MKSH_VERSION "R35 2008/10/04"
#ifndef MKSH_INCLUDES_ONLY #ifndef MKSH_INCLUDES_ONLY