Delete-previous-char and delete-next-char without an argument are not supposed
to modify the yank buffer in Emacs. Make it so.
This commit is contained in:
parent
b151590832
commit
6360c4b0f8
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chared.c,v 1.21 2003/11/02 20:08:41 christos Exp $ */
|
||||
/* $NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: chared.c,v 1.21 2003/11/02 20:08:41 christos Exp $");
|
||||
__RCSID("$NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -135,6 +135,21 @@ c_delafter(EditLine *el, int num)
|
||||
}
|
||||
|
||||
|
||||
/* c_delafter1():
|
||||
* Delete the character after the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delafter1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore():
|
||||
* Delete num characters before the cursor
|
||||
*/
|
||||
@ -163,6 +178,21 @@ c_delbefore(EditLine *el, int num)
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore1():
|
||||
* Delete the character before the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delbefore1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* ce__isword():
|
||||
* Return if p is part of a word according to emacs
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: chared.h,v 1.13 2003/10/18 23:48:42 christos Exp $ */
|
||||
/* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -154,7 +154,9 @@ protected char *c__next_word(char *, char *, int, int (*)(int));
|
||||
protected char *c__prev_word(char *, char *, int, int (*)(int));
|
||||
protected void c_insert(EditLine *, int);
|
||||
protected void c_delbefore(EditLine *, int);
|
||||
protected void c_delbefore1(EditLine *);
|
||||
protected void c_delafter(EditLine *, int);
|
||||
protected void c_delafter1(EditLine *);
|
||||
protected int c_gets(EditLine *, char *, const char *);
|
||||
protected int c_hpos(EditLine *);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: emacs.c,v 1.16 2003/11/02 20:07:58 christos Exp $ */
|
||||
/* $NetBSD: emacs.c,v 1.17 2004/08/13 12:10:39 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: emacs.c,v 1.16 2003/11/02 20:07:58 christos Exp $");
|
||||
__RCSID("$NetBSD: emacs.c,v 1.17 2004/08/13 12:10:39 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -71,7 +71,10 @@ em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
|
||||
return (CC_ERROR);
|
||||
}
|
||||
} else {
|
||||
c_delafter(el, el->el_state.argument); /* delete after dot */
|
||||
if (el->el_state.doingarg)
|
||||
c_delafter(el, el->el_state.argument);
|
||||
else
|
||||
c_delafter1(el);
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
/* bounds check */
|
||||
@ -480,3 +483,26 @@ em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
|
||||
el->el_search.patlen = 0;
|
||||
return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
|
||||
}
|
||||
|
||||
|
||||
/* em_delete_prev_char():
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg)
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
else
|
||||
c_delbefore1(el);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: map.c,v 1.19 2003/08/07 16:44:32 agc Exp $ */
|
||||
/* $NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: map.c,v 1.19 2003/08/07 16:44:32 agc Exp $");
|
||||
__RCSID("$NetBSD: map.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -67,7 +67,7 @@ private const el_action_t el_map_emacs[] = {
|
||||
/* 5 */ ED_MOVE_TO_END, /* ^E */
|
||||
/* 6 */ ED_NEXT_CHAR, /* ^F */
|
||||
/* 7 */ ED_UNASSIGNED, /* ^G */
|
||||
/* 8 */ ED_DELETE_PREV_CHAR, /* ^H */
|
||||
/* 8 */ EM_DELETE_PREV_CHAR, /* ^H */
|
||||
/* 9 */ ED_UNASSIGNED, /* ^I */
|
||||
/* 10 */ ED_NEWLINE, /* ^J */
|
||||
/* 11 */ ED_KILL_LINE, /* ^K */
|
||||
@ -186,7 +186,7 @@ private const el_action_t el_map_emacs[] = {
|
||||
/* 124 */ ED_INSERT, /* | */
|
||||
/* 125 */ ED_INSERT, /* } */
|
||||
/* 126 */ ED_INSERT, /* ~ */
|
||||
/* 127 */ ED_DELETE_PREV_CHAR, /* ^? */
|
||||
/* 127 */ EM_DELETE_PREV_CHAR, /* ^? */
|
||||
/* 128 */ ED_UNASSIGNED, /* M-^@ */
|
||||
/* 129 */ ED_UNASSIGNED, /* M-^A */
|
||||
/* 130 */ ED_UNASSIGNED, /* M-^B */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tty.c,v 1.20 2003/10/18 22:37:24 christos Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -37,7 +37,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: tty.c,v 1.20 2003/10/18 22:37:24 christos Exp $");
|
||||
__RCSID("$NetBSD: tty.c,v 1.21 2004/08/13 12:10:39 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -121,11 +121,11 @@ private const ttychar_t ttychar = {
|
||||
private const ttymap_t tty_map[] = {
|
||||
#ifdef VERASE
|
||||
{C_ERASE, VERASE,
|
||||
{ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
|
||||
{EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
|
||||
#endif /* VERASE */
|
||||
#ifdef VERASE2
|
||||
{C_ERASE2, VERASE2,
|
||||
{ED_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
|
||||
{EM_DELETE_PREV_CHAR, VI_DELETE_PREV_CHAR, ED_PREV_CHAR}},
|
||||
#endif /* VERASE2 */
|
||||
#ifdef VKILL
|
||||
{C_KILL, VKILL,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vi.c,v 1.19 2003/08/07 16:44:35 agc Exp $ */
|
||||
/* $NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -41,7 +41,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: vi.c,v 1.19 2003/08/07 16:44:35 agc Exp $");
|
||||
__RCSID("$NetBSD: vi.c,v 1.20 2004/08/13 12:10:39 mycroft Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
@ -583,18 +583,12 @@ protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
vi_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
if (cp <= el->el_line.buffer)
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
/* do the delete here so we dont mess up the undo and paste buffers */
|
||||
el->el_line.cursor = --cp;
|
||||
for (; cp < el->el_line.lastchar; cp++)
|
||||
cp[0] = cp[1];
|
||||
el->el_line.lastchar = cp - 1;
|
||||
|
||||
c_delbefore1(el);
|
||||
el->el_line.cursor--;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user