aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core-commands.c7
-rw-r--r--src/ring.c12
-rw-r--r--src/ring.h2
3 files changed, 13 insertions, 8 deletions
diff --git a/src/core-commands.c b/src/core-commands.c
index a1d180c..04cdf94 100644
--- a/src/core-commands.c
+++ b/src/core-commands.c
@@ -2581,9 +2581,10 @@ teco_state_ecommand_exit(teco_machine_main_t *ctx, GError **error)
teco_int_t v;
if (!teco_expressions_pop_num_calc(&v, teco_num_sign, error))
return;
- if (teco_is_failure(v) && teco_ring_is_any_dirty()) {
- g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Modified buffers exist");
+ guint id;
+ if (teco_is_failure(v) && (id = teco_ring_get_first_dirty())) {
+ g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Buffer with id %u is dirty", id);
return;
}
}
diff --git a/src/ring.c b/src/ring.c
index 0576545..72aab93 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -233,16 +233,20 @@ teco_ring_dirtify(void)
teco_interface_info_update(teco_ring_current);
}
-gboolean
-teco_ring_is_any_dirty(void)
+/** Get id of first dirty buffer, or otherwise 0 */
+guint
+teco_ring_get_first_dirty(void)
{
+ guint id = 1;
+
for (teco_tailq_entry_t *cur = teco_ring_head.first; cur != NULL; cur = cur->next) {
teco_buffer_t *buffer = (teco_buffer_t *)cur;
if (buffer->dirty)
- return TRUE;
+ return id;
+ id++;
}
- return FALSE;
+ return 0;
}
gboolean
diff --git a/src/ring.h b/src/ring.h
index 6114839..6466a69 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -67,7 +67,7 @@ teco_buffer_t *teco_ring_find_by_id(teco_int_t id);
teco_int_t : teco_ring_find_by_id)(X))
void teco_ring_dirtify(void);
-gboolean teco_ring_is_any_dirty(void);
+guint teco_ring_get_first_dirty(void);
gboolean teco_ring_save_all_dirty_buffers(GError **error);
gboolean teco_ring_edit_by_name(const gchar *filename, GError **error);