aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.7.template8
-rw-r--r--src/cmdline.c29
-rw-r--r--src/core-commands.c2
-rw-r--r--src/core-commands.h3
4 files changed, 31 insertions, 11 deletions
diff --git a/doc/sciteco.7.template b/doc/sciteco.7.template
index 30f53ba..3560973 100644
--- a/doc/sciteco.7.template
+++ b/doc/sciteco.7.template
@@ -514,8 +514,7 @@ Miscelleaneous
.br
(modifier \fIdisabled\fP)
T};T{
-Rub out last command, i.e. rub out at least one character until
-a new command could begin.
+Rub out until the beginning of the last command, which is not a no-op (whitespace).
T}
T{
Re-insert word/command
@@ -541,9 +540,8 @@ Miscelleaneous
.br
(modifier \fIenabled\fP)
T};T{
-Re-insert next command from the rubbed-out command line,
-i.e. insert at least one character and repeat until
-a new command could begin.
+Re-insert next command from the rubbed-out command line
+including all subsequent no-ops (whitespace).
T}
T{
.SCITECO_TOPIC ^U
diff --git a/src/cmdline.c b/src/cmdline.c
index b3da887..25b7b98 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -449,6 +449,11 @@ teco_state_process_edit_cmd(teco_machine_t *ctx, teco_machine_t *parent_ctx, gun
case TECO_CTL_KEY('W'): /* rubout/reinsert command */
teco_interface_popup_clear();
+ /*
+ * This mimics the behavior of the `Y` command,
+ * so it also rubs out no-op commands.
+ * See also teco_find_words().
+ */
if (teco_cmdline.modifier_enabled) {
/* reinsert command */
do {
@@ -456,12 +461,26 @@ teco_state_process_edit_cmd(teco_machine_t *ctx, teco_machine_t *parent_ctx, gun
return FALSE;
} while (!ctx->current->is_start &&
teco_cmdline.effective_len < teco_cmdline.str.len);
- } else {
- /* rubout command */
- do
- teco_cmdline_rubout();
- while (!ctx->current->is_start);
+
+ while (ctx->current->is_start &&
+ teco_cmdline.effective_len < teco_cmdline.str.len &&
+ strchr(TECO_NOOPS, teco_cmdline.str.data[teco_cmdline.effective_len]))
+ if (!teco_cmdline_rubin(error))
+ return FALSE;
+
+ return TRUE;
}
+
+ /* rubout command */
+ while (ctx->current->is_start &&
+ teco_cmdline.effective_len > 0 &&
+ strchr(TECO_NOOPS, teco_cmdline.str.data[teco_cmdline.effective_len-1]))
+ teco_cmdline_rubout();
+
+ do
+ teco_cmdline_rubout();
+ while (!ctx->current->is_start);
+
return TRUE;
#if !defined(INTERFACE_GTK) && defined(SIGTSTP)
diff --git a/src/core-commands.c b/src/core-commands.c
index 4abf38b..950127a 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -671,7 +671,7 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
switch (chr) {
/*
- * No-ops:
+ * No-ops (same as TECO_NOOPS):
* These are explicitly not handled in teco_state_control,
* so that we can potentially reuse the upcaret notations like ^J.
*/
diff --git a/src/core-commands.h b/src/core-commands.h
index 8ce7be7..523ba28 100644
--- a/src/core-commands.h
+++ b/src/core-commands.h
@@ -22,6 +22,9 @@
#include "parser.h"
#include "string-utils.h"
+/** non-operational characters in teco_state_start */
+#define TECO_NOOPS " \f\r\n\v"
+
/*
* FIXME: Most of these states can probably be private/static
* as they are only referenced from teco_state_start.