From: NeilBrown Date: Fri, 8 Sep 2023 11:54:01 +0000 (+1000) Subject: history: drop second string arg to attach-history X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=46213e20fefa69dd056959c57750da069693d100;p=edlib.git history: drop second string arg to attach-history All callers pass popup:close as second arg to attach-history. This is a command that history catches so as to save the new entry into this history. Handling it requires complexity that I would rather avoid. So for now - just assume it is always popup:close. If a need appears, I can come up with some other way to achieve the same effect. Signed-off-by: NeilBrown --- diff --git a/emacs-search.c b/emacs-search.c index 54bd0572..ff7ab0d9 100644 --- a/emacs-search.c +++ b/emacs-search.c @@ -480,8 +480,7 @@ DEF_CMD(search_replace) p = pane_register(p, 0, &replace_handle.c, ci->focus); if (!p) return Efail; - p = call_ret(pane, "attach-history", p, 0, NULL, "*Replace History*", - 0, NULL, "popup:close"); + p = call_ret(pane, "attach-history", p, 0, NULL, "*Replace History*"); esi->replace_pane = p; if (p) { pane_add_notify(ci->home, p, "Notify:Close"); diff --git a/lib-history.c b/lib-history.c index 74bb019e..fc839f34 100644 --- a/lib-history.c +++ b/lib-history.c @@ -53,8 +53,6 @@ struct history_info { struct mark *line; } *prev; int changed; - struct map *done_map; - struct lookup_cmd handle; }; static struct map *history_map; @@ -258,15 +256,10 @@ DEF_CMD(history_attach) struct history_info *hi; struct pane *p; - if (!ci->str || !ci->str2) + if (!ci->str) return Enoarg; alloc(hi, pane); - hi->done_map = key_alloc(); - hi->handle = history_handle; - hi->handle.m = &hi->done_map; - key_add_chain(hi->done_map, history_map); - key_add(hi->done_map, ci->str2, &history_done); p = call_ret(pane, "docs:byname", ci->focus, 0, NULL, ci->str); if (!p) p = call_ret(pane, "doc:from-text", ci->focus, 0, NULL, ci->str); @@ -281,7 +274,7 @@ DEF_CMD(history_attach) call("doc:file", hi->history, 1); buf_init(&hi->search); buf_concat(&hi->search, "?0"); /* remaining chars are searched verbatim */ - p = pane_register(ci->focus, 0, &hi->handle.c, hi); + p = pane_register(ci->focus, 0, &history_handle.c, hi); if (!p) return Efail; pane_add_notify(p, hi->history, "Notify:Close"); @@ -567,4 +560,5 @@ void edlib_init(struct pane *ed safe) &history_search_cancel); key_add(history_map, "history:save", &history_save); key_add(history_map, "history:get-last", &history_hlast); + key_add(history_map, "popup:close", &history_done); } diff --git a/mode-emacs.c b/mode-emacs.c index d344fda3..90f12f68 100644 --- a/mode-emacs.c +++ b/mode-emacs.c @@ -1242,8 +1242,7 @@ DEF_CMD(emacs_findfile) if (!p) return Efail; attr_set_str(&p->attrs, "initial_path", path); - call("attach-history", p, 0, NULL, "*File History*", - 0, NULL, "popup:close"); + call("attach-history", p, 0, NULL, "*File History*"); return 1; } if (!ci->str) @@ -1341,8 +1340,7 @@ DEF_CMD(emacs_writefile) if (!p) return Efail; attr_set_str(&p->attrs, "initial_path", path); - call("attach-history", p, 0, NULL, "*File History*", - 0, NULL, "popup:close"); + call("attach-history", p, 0, NULL, "*File History*"); return 1; } @@ -1415,8 +1413,7 @@ DEF_CMD(emacs_insertfile) if (!p) return Efail; attr_set_str(&p->attrs, "initial_path", path); - call("attach-history", p, 0, NULL, "*File History*", - 0, NULL, "popup:close"); + call("attach-history", p, 0, NULL, "*File History*"); return 1; } @@ -1803,8 +1800,7 @@ DEF_CMD(emacs_shell) attr_set_str(&p->attrs, "popup-aux", aux); attr_set_str(&p->attrs, "done-key", "Shell Command"); call("doc:set-name", p, 0, NULL, "Shell Command", -1); - p = call_ret(pane, "attach-history", p, 0, NULL, "*Shell History*", - 0, NULL, "popup:close"); + p = call_ret(pane, "attach-history", p, 0, NULL, "*Shell History*"); if (p) p = pane_register(p, 0, &find_handle.c, "shellcmd"); if (!p) @@ -2019,8 +2015,7 @@ DEF_CMD(emacs_start_search) attr_set_str(&p->attrs, "prompt", "Search"); attr_set_str(&p->attrs, "done-key", "Search String"); - hp = call_ret(pane, "attach-history", p, 0, NULL, "*Search History*", - 0, NULL, "popup:close"); + hp = call_ret(pane, "attach-history", p, 0, NULL, "*Search History*"); if (hp) p = hp; @@ -2044,8 +2039,7 @@ DEF_CMD(emacs_command) attr_set_str(&p->attrs, "prompt", "Cmd"); attr_set_str(&p->attrs, "done-key", "emacs:command"); call("doc:set-name", p, 0, NULL, "K:Ax command", -1); - p = call_ret(pane, "attach-history", p, 0, NULL, "*Command History*", - 0, NULL, "popup:close"); + p = call_ret(pane, "attach-history", p, 0, NULL, "*Command History*"); if (p) pane_register(p, 0, &find_handle.c, "cmd"); return 1; diff --git a/python/lib-compose-email.py b/python/lib-compose-email.py index 157e2279..17eef8bf 100644 --- a/python/lib-compose-email.py +++ b/python/lib-compose-email.py @@ -723,7 +723,7 @@ class compose_email(edlib.Pane): p['done-key'] = "compose-email:attach" p.call('doc:set-name', "Attachment File") p['pane-title'] = "Attachment File" - p = p.call("attach-history", "*Attachment History*", "popup:close", + p = p.call("attach-history", "*Attachment History*", ret='pane') p.call("attach-file-entry", "file") return 1 diff --git a/python/lib-make.py b/python/lib-make.py index 0c0115f5..222e4789 100644 --- a/python/lib-make.py +++ b/python/lib-make.py @@ -920,7 +920,7 @@ def make_request(key, focus, num, num2, str1, mark, **a): p['cmd'] = cmd p['mode'] = mode if history: - p = p.call("attach-history", history, "popup:close", ret='pane') + p = p.call("attach-history", history, ret='pane') if dir: p["dirname"] = dir p['orig-dirname'] = focus['dirname'] diff --git a/python/module-notmuch.py b/python/module-notmuch.py index 5039bd2e..2377e7e8 100644 --- a/python/module-notmuch.py +++ b/python/module-notmuch.py @@ -1962,7 +1962,7 @@ class notmuch_master_view(edlib.Pane): pup['prompt'] = "Ad hoc query" pup.call("doc:set-name", "Ad hoc query") p = pup.call("attach-history", "*Notmuch Query History*", - "popup:close", ret='pane') + ret='pane') if p: pup = p query_popup(pup) @@ -2009,7 +2009,7 @@ class notmuch_master_view(edlib.Pane): pup['prompt'] = "Query filter" pup.call("doc:set-name", "*Query filter for %s*" % focus['qname']) p = pup.call("attach-history", "*Notmuch Filter History*", - "popup:close", ret='pane') + ret='pane') if p: pup = p query_popup(pup)