diff options
Diffstat (limited to 'src/ring.c')
| -rw-r--r-- | src/ring.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -794,7 +794,7 @@ TECO_DEFINE_STATE_EXPECTFILE(teco_state_read_file, ); /*$ "EF" ":EF" close - * [n]EF -- Remove buffer from ring + * [n]EF -- Remove buffer from ring or free current Q-register * -EF * [n]:EF * @@ -802,6 +802,8 @@ TECO_DEFINE_STATE_EXPECTFILE(teco_state_read_file, * closing it. * The optional argument <n> specifies the id of the buffer * to close -- by default the current buffer will be closed. + * If <n> is omitted and you are currently editing a Q-register, + * this register <q> will be freed as by \fBFQ\fIq\fR. * If the selected buffer is dirty (modified), \fBEF\fP will yield * an error. * If <n> is negative (success boolean), buffer <-n> will be closed @@ -828,6 +830,8 @@ teco_state_ecommand_close(teco_machine_main_t *ctx, GError **error) if (!teco_expressions_eval(FALSE, error)) return; + gboolean colon_modified = teco_machine_main_eval_colon(ctx) > 0; + /* * This is like implying teco_num_sign*teco_ring_get_id(teco_ring_current) * but avoids the O(n) ring iterations. @@ -843,13 +847,7 @@ teco_state_ecommand_close(teco_machine_main_t *ctx, GError **error) } force = id < 0; } else if (teco_qreg_current) { - /* - * TODO: Should perhaps remove the register like FQq. - */ - const teco_string_t *name = &teco_qreg_current->head.name; - g_autofree gchar *name_printable = teco_string_echo(name->data, name->len); - g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED, - "Q-Register \"%s\" currently edited", name_printable); + teco_qreg_table_remove(teco_qreg_table_current, teco_qreg_current, error); return; } else { buffer = teco_ring_current; @@ -857,7 +855,7 @@ teco_state_ecommand_close(teco_machine_main_t *ctx, GError **error) teco_set_num_sign(1); } - if (teco_machine_main_eval_colon(ctx) > 0) { + if (colon_modified) { if (!teco_buffer_save(buffer, NULL, error)) return; } else if (!force && buffer->state > TECO_BUFFER_CLEAN) { |
