diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/error.h | 9 | ||||
-rw-r--r-- | src/qreg-commands.c | 7 | ||||
-rw-r--r-- | src/qreg.c | 6 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/error.h b/src/error.h index b12ec80..03af66c 100644 --- a/src/error.h +++ b/src/error.h @@ -47,6 +47,7 @@ typedef enum { TECO_ERROR_INVALIDQREG, TECO_ERROR_QREGOPUNSUPPORTED, TECO_ERROR_QREGCONTAINSNULL, + TECO_ERROR_EDITINGLOCALQREG, TECO_ERROR_MEMLIMIT, /** Interrupt current operation */ @@ -127,6 +128,14 @@ teco_error_qregcontainsnull_set(GError **error, const gchar *name, gsize len, gb } static inline void +teco_error_editinglocalqreg_set(GError **error, const gchar *name, gsize len) +{ + g_autofree gchar *name_printable = teco_string_echo(name, len); + g_set_error(error, TECO_ERROR, TECO_ERROR_EDITINGLOCALQREG, + "Editing local Q-Register \"%s\" at end of macro call", name_printable); +} + +static inline void teco_error_interrupted_set(GError **error) { g_set_error_literal(error, TECO_ERROR, TECO_ERROR_INTERRUPTED, "Interrupted"); diff --git a/src/qreg-commands.c b/src/qreg-commands.c index 8d28e7d..a96eb5f 100644 --- a/src/qreg-commands.c +++ b/src/qreg-commands.c @@ -652,8 +652,15 @@ teco_state_macro_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg, } else { g_auto(teco_qreg_table_t) table; teco_qreg_table_init(&table, FALSE); + if (!teco_qreg_execute(qreg, &table, error)) return NULL; + if (teco_qreg_current && !teco_qreg_current->must_undo) { + /* currently editing local Q-Register */ + teco_error_editinglocalqreg_set(error, teco_qreg_current->head.name.data, + teco_qreg_current->head.name.len); + return NULL; + } } return &teco_state_start; @@ -1160,6 +1160,12 @@ teco_ed_hook(teco_ed_hook_t type, GError **error) if (!teco_qreg_execute(qreg, &locals, error)) goto error_add_frame; + if (teco_qreg_current && !teco_qreg_current->must_undo) { + /* currently editing local Q-Register */ + teco_error_editinglocalqreg_set(error, teco_qreg_current->head.name.data, + teco_qreg_current->head.name.len); + goto error_add_frame; + } return teco_expressions_discard_args(error) && teco_expressions_brace_close(error); |