[PATCH] config_files: move counting to source-file

20 views
Skip to first unread message

Thomas Adam

unread,
Aug 13, 2022, 12:19:54 PM8/13/22
to tmux-...@googlegroups.com, Thomas Adam
Currently, the #{config_files} format can only show files started by the
tmux server. Calls to source-file won't update this list.

This patch fixes this by updating the list via source-file.
---
cmd-source-file.c | 8 ++++++++
tmux.c | 3 ---
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/cmd-source-file.c b/cmd-source-file.c
index 255d443e5..2676becc6 100644
--- a/cmd-source-file.c
+++ b/cmd-source-file.c
@@ -196,6 +196,14 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)

if (cdata->nfiles != 0) {
file_read(c, cdata->files[0], cmd_source_file_done, cdata);
+
+ /* Keep a list of the names of the config files which have
+ * been read. This is used for the #{config_files} format.
+ */
+ cfg_files = xreallocarray(cfg_files, cfg_nfiles + 1,
+ sizeof *cfg_files);
+ cfg_files[cfg_nfiles++] = xstrdup(cdata->files[0]);
+
retval = CMD_RETURN_WAIT;
} else
cmd_source_file_complete(c, cdata);
diff --git a/tmux.c b/tmux.c
index b9f2be30b..81b30b224 100644
--- a/tmux.c
+++ b/tmux.c
@@ -385,9 +385,6 @@ main(int argc, char **argv)
free(cfg_files[i]);
cfg_nfiles = 0;
}
- cfg_files = xreallocarray(cfg_files, cfg_nfiles + 1,
- sizeof *cfg_files);
- cfg_files[cfg_nfiles++] = xstrdup(optarg);
cfg_quiet = 0;
break;
case 'V':
--
2.37.1

Nicholas Marriott

unread,
Aug 13, 2022, 12:36:03 PM8/13/22
to Thomas Adam, tmux-users
Hi

I think you need to keep the bit in tmux.c as well so the -f file appears in the list.

Maybe source-file should be a different format though so we can tell which were start-up files and which later?



--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/20220813161939.134819-1-thomas%40xteddy.org.

Thomas Adam

unread,
Aug 19, 2022, 8:41:14 AM8/19/22
to Nicholas Marriott, Thomas Adam, tmux-users
On Sat, Aug 13, 2022 at 05:35:54PM +0100, Nicholas Marriott wrote:
> Maybe source-file should be a different format though so we can tell which
> were start-up files and which later?

Yes indeed. I think we should changet this to a TAILQ list which has a flag
to say if it is used with -f (server) or not (source-file), and let the
current config_file iterate over that, and introduce a config_source_file
format for the rest?

Kindly,
Thomas

Nicholas Marriott

unread,
Aug 19, 2022, 1:40:28 PM8/19/22
to Thomas Adam, tmux-users
That sounds fine to me.
Reply all
Reply to author
Forward
0 new messages