From 983776685722eff62b6dc2f249003f58c4b3ec26 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Mon, 14 Sep 2026 05:35:00 +0100 Subject: [PATCH] Allow callers to override editor command --- spawn.c | 6 +++--- tmux.h | 2 +- window-buffer.c | 3 ++- window-customize.c | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spawn.c b/spawn.c index 361d207e5..8df5e63a6 100644 --- a/spawn.c +++ b/spawn.c @@ -701,7 +701,7 @@ spawn_editor_finish(struct window_pane *wp) struct spawn_editor_state * spawn_editor(struct client *c, const char *buf, size_t len, - spawn_finish_edit_cb cb, void *arg) + const char *editor, spawn_finish_edit_cb cb, void *arg) { struct spawn_editor_state *es; struct spawn_context sc = { 0 }; @@ -715,13 +715,13 @@ spawn_editor(struct client *c, const char *buf, size_t len, FILE *f; char *cmd, *cause = NULL; char path[] = _PATH_TMP "tmux.XXXXXXXX"; - const char *editor; int fd; if (w->modal != NULL) return (NULL); - editor = options_get_string(global_options, "editor"); + if (editor == NULL) + editor = options_get_string(global_options, "editor"); fd = mkstemp(path); if (fd == -1) return (NULL); diff --git a/tmux.h b/tmux.h index 6635280e9..ebffe3fcb 100644 --- a/tmux.h +++ b/tmux.h @@ -4227,7 +4227,7 @@ struct winlink *spawn_window(struct spawn_context *, char **); struct window_pane *spawn_pane(struct spawn_context *, char **); typedef void (*spawn_finish_edit_cb)(char *, size_t, void *); struct spawn_editor_state *spawn_editor(struct client *, const char *, size_t, - spawn_finish_edit_cb, void *); + const char *, spawn_finish_edit_cb, void *); void spawn_cancel_editor(struct spawn_editor_state *); pid_t spawn_get_editor_pid(struct spawn_editor_state *); void spawn_editor_finish(struct window_pane *); diff --git a/window-buffer.c b/window-buffer.c index bc25de66e..7c9cf6037 100644 --- a/window-buffer.c +++ b/window-buffer.c @@ -606,7 +606,8 @@ window_buffer_start_edit(struct window_buffer_modedata *data, ed->name = xstrdup(paste_buffer_name(pb)); ed->pb = pb; - ed->editor = spawn_editor(c, buf, len, window_buffer_edit_close_cb, ed); + ed->editor = spawn_editor(c, buf, len, NULL, window_buffer_edit_close_cb, + ed); if (ed->editor == NULL) window_buffer_finish_edit(ed); else { diff --git a/window-customize.c b/window-customize.c index 1bf311ff2..7c3b42795 100644 --- a/window-customize.c +++ b/window-customize.c @@ -2104,8 +2104,8 @@ window_customize_start_edit(struct window_customize_modedata *data, buf = "\n"; len = 1; } - ed->editor = spawn_editor(c, buf, len, window_customize_edit_close_cb, - ed); + ed->editor = spawn_editor(c, buf, len, NULL, + window_customize_edit_close_cb, ed); free(value); if (ed->editor == NULL) window_customize_finish_edit(ed);