]> git.neil.brown.name Git - edlib.git/commitdiff
history: drop second string arg to attach-history
authorNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 11:54:01 +0000 (21:54 +1000)
committerNeilBrown <neil@brown.name>
Fri, 8 Sep 2023 11:54:01 +0000 (21:54 +1000)
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 <neil@brown.name>
emacs-search.c
lib-history.c
mode-emacs.c
python/lib-compose-email.py
python/lib-make.py
python/module-notmuch.py

index 54bd057238c8d4fd0b2050099895619b0fea1f00..ff7ab0d9fa6f442e736fed8ea4ae557872dda26f 100644 (file)
@@ -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");
index 74bb019e2aa59043d0c15da587440ff616d00eb3..fc839f34bae94b0ebc843f41f8340d6ba73ff4af 100644 (file)
@@ -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);
 }
index d344fda32460560436580ccc18204d1baff724a3..90f12f6826882579fcbc7d3071f07addeedbce7a 100644 (file)
@@ -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;
index 157e2279ec2246a8c69f789498be7f9a8ea9ee65..17eef8bfaea93cb23916e5ec7d909836bad5cd3b 100644 (file)
@@ -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
index 0c0115f510f7584a02c4871280c730f188275d4f..222e47895fe1e266c3affd2e1f181dea5266cdc6 100644 (file)
@@ -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']
index 5039bd2eb1d92647db7d494d69bcf1b7d8d23609..2377e7e88deca16ea2a3af40c637415a8b80eb78 100644 (file)
@@ -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)