From 0f255ebb6f23e8cc517b9337bddaa4e326ac4e5a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 14 Jun 2023 20:27:51 +1000 Subject: [PATCH] global-set-attr: support append. Make it easy to append to a global attr. Note the semantics are a bit different to appending to a pane attr. I wonder what is best. Signed-off-by: NeilBrown --- core-editor.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/core-editor.c b/core-editor.c index b17c19fc..c7173531 100644 --- a/core-editor.c +++ b/core-editor.c @@ -34,9 +34,23 @@ DEF_LOOKUP_CMD(ed_handle, ed_map); DEF_CMD(global_set_attr) { + char *v; if (!ci->str) return Enoarg; - attr_set_str(&ci->home->attrs, ci->str, ci->str2); + if (!ci->num) { + attr_set_str(&ci->home->attrs, ci->str, ci->str2); + return 1; + } + /* Append */ + if (!ci->str2) + return 1; + v = attr_find(ci->home->attrs, ci->str); + if (!v) { + attr_set_str(&ci->home->attrs, ci->str, ci->str2); + return 1; + } + v = strconcat(ci->home, v, ci->str2); + attr_set_str(&ci->home->attrs, ci->str, v); return 1; } -- 2.39.5