diff options
Diffstat (limited to 'dist/emacs.c')
-rw-r--r-- | dist/emacs.c | 109 |
1 files changed, 64 insertions, 45 deletions
diff --git a/dist/emacs.c b/dist/emacs.c index cc18411..895bc3e 100644 --- a/dist/emacs.c +++ b/dist/emacs.c @@ -1,4 +1,4 @@ -/* $NetBSD: emacs.c,v 1.9 2001/01/10 07:45:41 jdolecek Exp $ */ +/* $NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -15,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,19 +32,18 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> +#include "config.h" #if !defined(lint) && !defined(SCCSID) #if 0 static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: emacs.c,v 1.9 2001/01/10 07:45:41 jdolecek Exp $"); +__RCSID("$NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp $"); #endif #endif /* not lint && not SCCSID */ /* * emacs.c: Emacs functions */ -#include "sys.h" #include "el.h" /* em_delete_or_list(): @@ -57,7 +52,7 @@ __RCSID("$NetBSD: emacs.c,v 1.9 2001/01/10 07:45:41 jdolecek Exp $"); */ protected el_action_t /*ARGSUSED*/ -em_delete_or_list(EditLine *el, int c) +em_delete_or_list(EditLine *el, int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.lastchar) { @@ -76,7 +71,10 @@ em_delete_or_list(EditLine *el, int c) 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 */ @@ -91,7 +89,7 @@ em_delete_or_list(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_delete_next_word(EditLine *el, int c) +em_delete_next_word(EditLine *el, int c __attribute__((__unused__))) { char *cp, *p, *kp; @@ -120,14 +118,12 @@ em_delete_next_word(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_yank(EditLine *el, int c) +em_yank(EditLine *el, int c __attribute__((__unused__))) { char *kp, *cp; - if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) { - if (!ch_enlargebufs(el, 1)) - return (CC_ERROR); - } + if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) + return (CC_NORM); if (el->el_line.lastchar + (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >= @@ -157,7 +153,7 @@ em_yank(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_kill_line(EditLine *el, int c) +em_kill_line(EditLine *el, int c __attribute__((__unused__))) { char *kp, *cp; @@ -179,7 +175,7 @@ em_kill_line(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_kill_region(EditLine *el, int c) +em_kill_region(EditLine *el, int c __attribute__((__unused__))) { char *kp, *cp; @@ -212,11 +208,11 @@ em_kill_region(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_copy_region(EditLine *el, int c) +em_copy_region(EditLine *el, int c __attribute__((__unused__))) { char *kp, *cp; - if (el->el_chared.c_kill.mark) + if (!el->el_chared.c_kill.mark) return (CC_ERROR); if (el->el_chared.c_kill.mark > el->el_line.cursor) { @@ -236,12 +232,12 @@ em_copy_region(EditLine *el, int c) } -/* em_gosmacs_traspose(): +/* em_gosmacs_transpose(): * Exchange the two characters before the cursor * Gosling emacs transpose chars [^T] */ protected el_action_t -em_gosmacs_traspose(EditLine *el, int c) +em_gosmacs_transpose(EditLine *el, int c) { if (el->el_line.cursor > &el->el_line.buffer[1]) { @@ -261,7 +257,7 @@ em_gosmacs_traspose(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_next_word(EditLine *el, int c) +em_next_word(EditLine *el, int c __attribute__((__unused__))) { if (el->el_line.cursor == el->el_line.lastchar) return (CC_ERROR); @@ -272,7 +268,7 @@ em_next_word(EditLine *el, int c) ce__isword); if (el->el_map.type == MAP_VI) - if (el->el_chared.c_vcmd.action & DELETE) { + if (el->el_chared.c_vcmd.action != NOP) { cv_delfini(el); return (CC_REFRESH); } @@ -286,7 +282,7 @@ em_next_word(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_upper_case(EditLine *el, int c) +em_upper_case(EditLine *el, int c __attribute__((__unused__))) { char *cp, *ep; @@ -294,8 +290,8 @@ em_upper_case(EditLine *el, int c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) - if (islower((unsigned char) *cp)) - *cp = toupper(*cp); + if (islower((unsigned char)*cp)) + *cp = toupper((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) @@ -310,7 +306,7 @@ em_upper_case(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_capitol_case(EditLine *el, int c) +em_capitol_case(EditLine *el, int c __attribute__((__unused__))) { char *cp, *ep; @@ -318,16 +314,16 @@ em_capitol_case(EditLine *el, int c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) { - if (isalpha((unsigned char) *cp)) { - if (islower((unsigned char) *cp)) - *cp = toupper(*cp); + if (isalpha((unsigned char)*cp)) { + if (islower((unsigned char)*cp)) + *cp = toupper((unsigned char)*cp); cp++; break; } } for (; cp < ep; cp++) - if (isupper((unsigned char) *cp)) - *cp = tolower(*cp); + if (isupper((unsigned char)*cp)) + *cp = tolower((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) @@ -342,7 +338,7 @@ em_capitol_case(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_lower_case(EditLine *el, int c) +em_lower_case(EditLine *el, int c __attribute__((__unused__))) { char *cp, *ep; @@ -350,8 +346,8 @@ em_lower_case(EditLine *el, int c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) - if (isupper((unsigned char) *cp)) - *cp = tolower(*cp); + if (isupper((unsigned char)*cp)) + *cp = tolower((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) @@ -366,7 +362,7 @@ em_lower_case(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_set_mark(EditLine *el, int c) +em_set_mark(EditLine *el, int c __attribute__((__unused__))) { el->el_chared.c_kill.mark = el->el_line.cursor; @@ -380,7 +376,7 @@ em_set_mark(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_exchange_mark(EditLine *el, int c) +em_exchange_mark(EditLine *el, int c __attribute__((__unused__))) { char *cp; @@ -397,7 +393,7 @@ em_exchange_mark(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_universal_argument(EditLine *el, int c) +em_universal_argument(EditLine *el, int c __attribute__((__unused__))) { /* multiply current argument by 4 */ if (el->el_state.argument > 1000000) @@ -414,7 +410,7 @@ em_universal_argument(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_meta_next(EditLine *el, int c) +em_meta_next(EditLine *el, int c __attribute__((__unused__))) { el->el_state.metanext = 1; @@ -427,7 +423,7 @@ em_meta_next(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_toggle_overwrite(EditLine *el, int c) +em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__))) { el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ? @@ -441,7 +437,7 @@ em_toggle_overwrite(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_copy_prev_word(EditLine *el, int c) +em_copy_prev_word(EditLine *el, int c __attribute__((__unused__))) { char *cp, *oldc, *dp; @@ -468,7 +464,7 @@ em_copy_prev_word(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_inc_search_next(EditLine *el, int c) +em_inc_search_next(EditLine *el, int c __attribute__((__unused__))) { el->el_search.patlen = 0; @@ -481,9 +477,32 @@ em_inc_search_next(EditLine *el, int c) */ protected el_action_t /*ARGSUSED*/ -em_inc_search_prev(EditLine *el, int c) +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); +} |