]> git.neil.brown.name Git - edlib.git/commitdiff
Introduce some 'call*' functions to call command.
authorNeilBrown <neil@brown.name>
Tue, 1 Dec 2015 22:11:32 +0000 (09:11 +1100)
committerNeilBrown <neil@brown.name>
Tue, 1 Dec 2015 22:32:23 +0000 (09:32 +1100)
This simplifies lots of code.

Signed-off-by: NeilBrown <neil@brown.name>
core-doc.c
core-mark.c
core.h
doc-dir.c
edlib.c
emacs-search.c
lib-popup.c
lib-view.c
mode-emacs.c
render-complete.c

index bd5a16ddf6de126d0ee3fd40fb3d61dadaa60098..966233f2d4ef4f8ca9ffef633b1c58e67126db33 100644 (file)
@@ -563,7 +563,6 @@ struct pane *doc_from_text(struct pane *parent, char *name, char *text)
        bool first = 1;
        struct pane *p;
        struct doc *d;
-       struct cmd_info ci = {0};
 
        d = doc_new(pane2ed(parent), "text");
        if (!d)
@@ -575,10 +574,7 @@ struct pane *doc_from_text(struct pane *parent, char *name, char *text)
                return p;
        }
        doc_replace(p, NULL, text, &first);
-       ci.key = "Move-File";
-       ci.numeric = -1;
-       ci.focus = p;
-       key_handle_focus(&ci);
+       call3("Move-File", p, -1, NULL);
        return p;
 }
 
@@ -754,11 +750,9 @@ DEF_CMD(docs_open)
                renderer = "hex";
 
        if (strcmp(ci->key, "Chr-o") == 0) {
-               struct cmd_info ci2 = {0};
-               ci2.key = "OtherPane";
-               ci2.focus = ci->focus;
-               if (key_handle_focus(&ci2)) {
-                       par = ci2.focus;
+               struct pane *p2 = call_pane("OtherPane", ci->focus, 0, NULL, 0);
+               if (p2) {
+                       par = p2;
                        p = pane_child(par);
                }
        }
@@ -859,7 +853,6 @@ int  doc_destroy(struct doc *d)
         * the documents list and destroy it.
         */
        int i;
-       struct cmd_info ci2 = {0};
 
        d->deleting = 1;
        if (d == d->ed->docs)
@@ -877,9 +870,7 @@ int  doc_destroy(struct doc *d)
 
        docs_release(d);
 
-       ci2.key = "doc:destroy";
-       ci2.focus = d->home;
-       key_handle_focus(&ci2);
+       call3("doc:destroy", d->home, 0, 0);
        pane_close(d->home);
 
        free(d->views);
index 3601b679724f6c4a03450ab350b067e321cf3f07..09ddc77a296fdb302deb98949bfc0b4be927f584 100644 (file)
@@ -161,14 +161,7 @@ struct mark *do_mark_at_point(struct doc *d, struct mark *pt, int view)
 
 struct mark *mark_at_point(struct pane *p, struct mark *pm, int view)
 {
-       struct cmd_info ci = {0};
-       ci.key = "doc:dup-point";
-       ci.extra = view;
-       ci.mark = pm;
-       ci.focus = p;
-       if (key_handle_focus(&ci) == 0)
-               return NULL;
-       return ci.mark;
+       return call_mark("doc:dup-point", p, 0, pm, view);
 }
 
 struct mark *point_dup(struct mark *p)
@@ -259,7 +252,6 @@ struct mark *mark_dup(struct mark *m, int notype)
 void __mark_reset(struct doc *d, struct mark *m, int new, int end)
 {
        int i;
-       struct cmd_info ci = {0};
        int seq = 0;
        struct point_links *lnk;
 
@@ -281,11 +273,7 @@ void __mark_reset(struct doc *d, struct mark *m, int new, int end)
                hlist_add_head(&m->all, &d->marks);
        assign_seq(m, seq);
 
-       ci.key = "doc:set-ref";
-       ci.mark = m;
-       ci.numeric = !end; /* start */
-       ci.focus = d->home;
-       key_handle_focus(&ci);
+       call3("doc:set-ref", d->home, !end, m);
 
        if (m->viewnum == MARK_UNGROUPED)
                return;
@@ -508,13 +496,7 @@ void mark_backward_over(struct mark *m, struct mark *mp)
 
 wint_t mark_step(struct doc *d, struct mark *m, int forward, int move, struct cmd_info *ci)
 {
-       ci->key = "doc:step";
-       ci->focus = d->home;
-       ci->mark = m;
-       ci->numeric = forward;
-       ci->extra = move;
-       key_handle_focus(ci);
-       return ci->extra;
+       return call_extra("doc:step", d->home, forward, m, move);
 }
 
 wint_t mark_step2(struct doc *d, struct mark *m, int forward, int move)
diff --git a/core.h b/core.h
index d349e22f1d23dcf7f23ee17ebfe3ce7277e40432..4e0b9723db18ee662a73d065f56bd3d05990ae96 100644 (file)
--- a/core.h
+++ b/core.h
@@ -470,3 +470,87 @@ static inline struct doc *doc_from_pane(struct pane *p)
        return ci.misc;
 }
 
+static inline int call3(char *key, struct pane *focus, int numeric, struct mark *m)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.mark = m;
+       return key_handle_focus(&ci);
+}
+
+static inline int call5(char *key, struct pane *focus, int numeric, struct mark *m,
+                        char *str, int extra)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.mark = m;
+       ci.str = str;
+       ci.extra = extra;
+       return key_handle_focus(&ci);
+}
+
+static inline struct mark *call_mark(char *key, struct pane *focus, int numeric,
+                                    struct mark *m, int extra)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.extra = extra;
+       ci.mark = m;
+       if (!key_handle_focus(&ci))
+               return NULL;
+       return ci.mark;
+}
+
+static inline struct pane *call_pane(char *key, struct pane *focus, int numeric,
+                                    struct mark *m, int extra)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.extra = extra;
+       ci.mark = m;
+       if (!key_handle_focus(&ci))
+               return NULL;
+       return ci.focus;
+}
+
+static inline int call_extra(char *key, struct pane *focus, int numeric, struct mark *m,
+                            int extra)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.extra = extra;
+       ci.mark = m;
+       if (!key_handle_focus(&ci))
+               return 0;
+       return ci.extra;
+}
+
+static inline char *call_str(char *key, struct pane *focus, int numeric, struct mark *m,
+                            char *str)
+{
+       struct cmd_info ci = {0};
+
+       ci.key = key;
+       ci.focus = focus;
+       ci.numeric = numeric;
+       ci.str = str;
+       ci.mark = m;
+       if (!key_handle_focus(&ci))
+               return NULL;
+       return ci.str;
+}
index 34cd12b9fd3b92a3994736d27bf1876512d2055d..31ea8855b538d67fcf2bf6008d3fdda3d87ce092 100644 (file)
--- a/doc-dir.c
+++ b/doc-dir.c
@@ -518,11 +518,9 @@ DEF_CMD(dir_open)
        asprintf(&fname, "%s/%s", dr->fname, de->name);
        fd = open(fname, O_RDONLY);
        if (strcmp(ci->key, "Chr-o") == 0) {
-               struct cmd_info ci2 = {0};
-               ci2.key = "OtherPane";
-               ci2.focus = ci->focus;
-               if (key_handle_focus(&ci2)) {
-                       par = ci2.focus;
+               struct pane *p2 = call_pane("OtherPane", ci->focus, 0, NULL, 0);
+               if (p2) {
+                       par = p2;
                        p = pane_child(par);
                }
        }
diff --git a/edlib.c b/edlib.c
index cc1f76bb729978317cfc79b4f12693b4e48d4d8b..6a872d037a20c1affe0fdefe78da31349586c853 100644 (file)
--- a/edlib.c
+++ b/edlib.c
@@ -70,10 +70,8 @@ int main(int argc, char *argv[])
        global = pane_attach(root, "global-keymap", NULL, NULL);
 
        editor_load_module(ed, "mode-emacs");
-       ci.focus = global;
-       ci.key = "global-set-keymap";
-       ci.str = "mode-emacs";
-       key_handle_focus(&ci);
+       call5("global-set-keymap", global, 0, NULL, "mode-emacs", 0);
+
        b = pane_attach(global, "tile", NULL, NULL);
        if (b)
                p = doc_from_text(b, "*Welcome*", WelcomeText);
index 4ecef74778ef3679062784cc406329b1aef652d4..afd08a1e793584eedec7cafc50783fa80b6059c3 100644 (file)
@@ -104,7 +104,6 @@ DEF_CMD(search_add)
        char b[5];
        mbstate_t ps = {0};
        int l;
-       struct cmd_info ci2 = {0};
 
        if (!d)
                return -1;
@@ -129,12 +128,7 @@ DEF_CMD(search_add)
                } else
                        l = wcrtomb(b, wch, &ps);
                b[l] = 0;
-               ci2.key = "Replace";
-               ci2.str = b;
-               ci2.numeric = 1;
-               ci2.mark = NULL;
-               ci2.focus = ci->focus;
-               key_handle_focus(&ci2);
+               call5("Replace", ci->focus, 1, NULL, b, 0);
        } while (strcmp(ci->key, "C-Chr-C") != 0 && wch != ' ');
        return 1;
 }
@@ -198,10 +192,7 @@ REDEF_CMD(search_again)
                point_to_mark(esi->end, m);
                /* TEMP HACK - please fix */
                doc_set_attr(esi->target, esi->end, "highlight","fg:red,inverse");
-               ci2.key = "Move-View-Pos";
-               ci2.focus = esi->target;
-               ci2.mark = esi->end;
-               key_handle_focus(&ci2);
+               call3("Move-View-Pos", esi->target, 0, esi->end);
                esi->matched = 1;
                pfx = "Search: ";
        } else {
@@ -238,28 +229,23 @@ DEF_CMD(emacs_search)
 {
        struct pane *p;
        struct es_info *esi;
-       struct cmd_info ci2 = {0};
+       struct mark *m;
 
        if (!es_map)
                emacs_search_init_map();
-       ci2.key = "popup:get-target";
-       ci2.focus = ci->focus;
-       if (key_handle_focus(&ci2) == 0)
-               return 0;
+       p = call_pane("popup:get-target", ci->focus, 0, 0, 0);
+       if (!p)
+               return -1;
        esi = malloc(sizeof(*esi));
-       esi->target = ci2.focus;
-       memset(&ci2, 0, sizeof(ci2));
-       ci2.key = "doc:dup-point";
-       ci2.extra = MARK_POINT;
-       ci2.focus = esi->target;
-       key_handle_focus(&ci2);
-       if (!ci2.mark) {
+       esi->target = p;
+       m = call_mark("doc:dup-point", p, 0, NULL, MARK_POINT);
+       if (!m) {
                free(esi);
                return -1;
        }
-       esi->end = ci2.mark;
+       esi->end = m;
 
-       esi->start = mark_dup(ci2.mark, 1);
+       esi->start = mark_dup(m, 1);
        esi->s = NULL;
        esi->matched = 0;
        esi->search = ci->focus;
index 4ea0d7189b3275bfde825482fc89e0fb65ca51b2..40d018c8543d7eb326ce3ffcae6775fc3a5a8cf1 100644 (file)
@@ -140,14 +140,11 @@ DEF_CMD(popup_attach)
        if (strchr(style, 'D')) {
                int x = 0, y = 0;
                pane_to_root(ci->focus, &x, &y, &z, NULL, NULL);
-               ci2.key = "global-key-root";
+               root = call_pane("global-key-root", ci->focus, 0, NULL, 0);
        } else
-               ci2.key = "ThisPane";
-       ci2.focus = ci->focus;
-
-       if (!key_handle_focus(&ci2))
+               root = call_pane("ThisPane", ci->focus, 0, NULL, 0);
+       if (!root)
                return 0;
-       root = ci2.focus;
 
        ppi->target = ci->focus;
        ppi->popup = pane_register(root, z, &popup_handle, ppi, NULL);
@@ -172,7 +169,7 @@ DEF_CMD(popup_attach)
                p = doc_attach_view(ppi->popup, d->home, NULL);
        }
        pane_focus(p);
-       memset(&ci2, 0, sizeof(ci2));
+
        ci2.key = "local-set-key";
        ci2.focus = p;
        ci2.str = "popup:quote";
index 8735d54eac8aa4249194b9eeeee091f1891adb43..11970399381747b17e73421b8ed660187ed5987e 100644 (file)
@@ -251,7 +251,8 @@ DEF_CMD(view_click)
        struct pane *p = ci->home;
        struct view_data *vd = p->data;
        int mid = vd->scroll_bar_y;
-       struct cmd_info ci2 = {0};
+       char *key;
+       int num;
 
        if (ci->hx != 0)
                return 0;
@@ -259,25 +260,24 @@ DEF_CMD(view_click)
                return 0;
 
        p = pane_child(p);
-       ci2.focus = p;
-       ci2.key = "Move-View-Small";
-       ci2.numeric = RPT_NUM(ci);
-       ci2.mark = ci->mark;
+
+       key = "Move-View-Small";
+       num = RPT_NUM(ci);
 
        if (ci->hy == mid-1) {
                /* scroll up */
-               ci2.numeric = -ci2.numeric;
+               num = -num;
        } else if (ci->hy < mid-1) {
                /* big scroll up */
-               ci2.numeric = -ci2.numeric;
-               ci2.key = "Move-View-Large";
+               num = -num;
+               key = "Move-View-Large";
        } else if (ci->hy == mid+1) {
                /* scroll down */
        } else if (ci->hy > mid+1 && ci->hy < p->h-1) {
-               ci2.key = "Move-View-Large";
+               key = "Move-View-Large";
        } else
                return 0;
-       return key_handle_focus(&ci2);
+       return call3(key, p, num, NULL);
 }
 
 void edlib_init(struct editor *ed)
index a1b7e6e0f41af7d0b55a613d2cead2689d56b66b..61a7ff86650ba6df95674bf28e13d06ad7802084 100644 (file)
@@ -78,12 +78,7 @@ REDEF_CMD(emacs_move)
                return 0;
        old_x = cursor_pane->cx;
 
-       ci2.focus = ci->focus;
-       ci2.key = mv->type;
-       ci2.numeric = mv->direction * RPT_NUM(ci);
-       ci2.mark = ci->mark;
-       ret = key_handle_focus(&ci2);
-
+       ret = call3(mv->type, ci->focus, mv->direction * RPT_NUM(ci), ci->mark);
        if (!ret)
                return 0;
 
@@ -95,6 +90,7 @@ REDEF_CMD(emacs_move)
                ci2.key = "Move-CursorXY";
                ci2.numeric = 1;
                ci2.x = old_x;
+               ci2.mark = ci->mark;
                if (mv->direction == 1)
                        ci2.y = 0;
                else
@@ -110,31 +106,24 @@ REDEF_CMD(emacs_move)
 REDEF_CMD(emacs_delete)
 {
        struct move_command *mv = container_of(ci->comm, struct move_command, cmd);
-       struct cmd_info ci2 = {0};
        int ret = 0;
        struct mark *m;
        struct doc *d = doc_from_pane(ci->home);
 
        m = mark_dup(ci->mark, 1);
-       ci2.focus = ci->focus;
-       ci2.key = mv->type;
-       ci2.numeric = mv->direction * RPT_NUM(ci);
-       if (strcmp(mv->type, "Move-EOL") == 0 && ci2.numeric == 1 &&
+
+       if (strcmp(mv->type, "Move-EOL") == 0 &&
+           mv->direction == 1 && RPT_NUM(ci) == 1 &&
            doc_following(d, m) == '\n')
-               ci2.key = "Move-Char";
-       ci2.mark = m;
-       ret = key_handle_focus(&ci2);
+               ret = call3("Move-Char", ci->focus, mv->direction * RPT_NUM(ci), m);
+       else
+               ret = call3(mv->type, ci->focus, mv->direction * RPT_NUM(ci), m);
+
        if (!ret) {
                mark_free(m);
                return 0;
        }
-       ci2.focus = ci->focus;
-       ci2.key = "Replace";
-       ci2.numeric = 1;
-       ci2.extra = ci->extra;
-       ci2.mark = m;
-       ci2.str = NULL;
-       ret = key_handle_focus(&ci2);
+       ret = call5("Replace", ci->focus, 1, m, NULL, ci->extra);
        mark_free(m);
        pane_set_extra(ci->home, 1);
 
@@ -179,19 +168,12 @@ REDEF_CMD(emacs_str)
 
 DEF_CMD(emacs_insert)
 {
-       char str[5];
-       struct cmd_info ci2 = {0};
        int ret;
+       char *str;
 
-       ci2.focus = ci->focus;
-       ci2.key = "Replace";
-       ci2.numeric = 1;
-       ci2.extra = ci->extra;
-       ci2.mark = ci->mark;
-       strncpy(str,ci->key+4, sizeof(str));
-       str[4] = 0;
-       ci2.str = str;
-       ret = key_handle_focus(&ci2);
+       /* Key is "Chr-X" - skip 4 bytes to get X */
+       str = ci->key + 4;
+       ret = call5("Replace", ci->focus, 1, ci->mark, str, ci->extra);
        pane_set_extra(ci->home, 1);
 
        return ret;
@@ -209,25 +191,18 @@ static struct {
 
 DEF_CMD(emacs_insert_other)
 {
-       struct pane *p = ci->home;
-       struct cmd_info ci2 = {0};
        int ret;
        int i;
 
-       ci2.focus = ci->focus;
-       ci2.key = "Replace";
-       ci2.numeric = 1;
-       ci2.extra = ci->extra;
-       ci2.mark = ci->mark;
        for (i = 0; other_inserts[i].key; i++)
                if (strcmp(other_inserts[i].key, ci->key) == 0)
                        break;
        if (other_inserts[i].key == NULL)
                return 0;
 
-       ci2.str = other_inserts[i].insert;
-       ret = key_handle_focus(&ci2);
-       pane_set_extra(p, 0); /* A newline starts a new undo */
+       ret = call5("Replace", ci->focus, 1, ci->mark, other_inserts[i].insert,
+                   ci->extra);
+       pane_set_extra(ci->home, 0); /* A newline starts a new undo */
        return ret;
 }
 
@@ -279,18 +254,10 @@ DEF_CMD(emacs_findfile)
                        attr_set_str(&p->attrs, "prefix", "Find File: ", -1);
                        attr_set_str(&p->attrs, "done-key", "File Found", -1);
                }
-               ci2.key = "doc:set-name";
-               ci2.focus = p;
-               ci2.str = "Find File";
-               key_handle_focus(&ci2);
-               if (path) {
-                       memset(&ci2, 0, sizeof(ci2));
-                       ci2.key = "Replace";
-                       ci2.focus = p;
-                       ci2.str = path;
-                       key_handle_focus(&ci2);
-               }
-               memset(&ci2, 0, sizeof(ci2));
+               call5("doc:set-name", p, 0, NULL, "Find File", 0);
+               if (path)
+                       call5("Replace", p, 0, NULL, path, 0);
+
                ci2.key = "local-set-key";
                ci2.focus = p;
                ci2.str = "emacs:file-complete";
@@ -300,13 +267,12 @@ DEF_CMD(emacs_findfile)
        }
 
        if (strcmp(ci->key, "File Found Other Window") == 0)
-               ci2.key = "OtherPane";
+               p = call_pane("OtherPane", ci->focus, 0, NULL, 0);
        else
-               ci2.key = "ThisPane";
-       ci2.focus = ci->focus;
-       if (key_handle_focus(&ci2) == 0)
+               p = call_pane("ThisPane", ci->focus, 0, NULL, 0);
+
+       if (!p)
                return -1;
-       p = ci2.focus;
 
        par = p;
        /* par is the tile */
@@ -379,13 +345,8 @@ DEF_CMD(emacs_file_complete)
        if (ci2.str) {
                /* add the extra chars from ci2.str */
                char *c = ci2.str + strlen(b);
-               struct cmd_info ci3 = {0};
-               ci3.key = "Replace";
-               ci3.mark = ci->mark;
-               ci3.numeric = 1;
-               ci3.focus = ci->focus;
-               ci3.str = c;
-               key_handle_focus(&ci3);
+
+               call5("Replace", ci->focus, 1, ci->mark, c, 0);
        }
        /* Now need to close the popup */
        pane_close(pop);
@@ -412,12 +373,8 @@ DEF_CMD(emacs_finddoc)
                        attr_set_str(&p->attrs, "prefix", "Find Document: ", -1);
                        attr_set_str(&p->attrs, "done-key", "Doc Found", -1);
                }
-               ci2.key = "doc:set-name";
-               ci2.focus = p;
-               ci2.str = "Find Document";
-               key_handle_focus(&ci2);
+               call5("doc:set-name", p, 0, NULL, "Find Document", 0);
 
-               memset(&ci2, 0, sizeof(ci2));
                ci2.key = "local-set-key";
                ci2.focus = p;
                ci2.str = "emacs:doc-complete";
@@ -427,13 +384,11 @@ DEF_CMD(emacs_finddoc)
        }
 
        if (strcmp(ci->key, "Doc Found Other Window") == 0)
-               ci2.key = "OtherPane";
+               p = call_pane("OtherPane", ci->focus, 0, NULL, 0);
        else
-               ci2.key = "ThisPane";
-       ci2.focus = ci->focus;
-       if (key_handle_focus(&ci2) == 0)
+               p = call_pane("ThisPane", ci->focus, 0, NULL, 0);
+       if (!p)
                return -1;
-       p = ci2.focus;
 
        par = p;
        /* par is the tile */
@@ -477,13 +432,8 @@ DEF_CMD(emacs_doc_complete)
        if (ci2.str) {
                /* add the extra chars from ci2.str */
                char *c = ci2.str + strlen(str);
-               struct cmd_info ci3 = {0};
-               ci3.key = "Replace";
-               ci3.mark = ci->mark;
-               ci3.numeric = 1;
-               ci3.focus = ci->focus;
-               ci3.str = c;
-               key_handle_focus(&ci3);
+
+               call5("Replace", ci->focus, 1, ci->mark, c, 0);
        }
        /* Now need to close the popup */
        pane_close(pop);
@@ -494,13 +444,10 @@ DEF_CMD(emacs_viewdocs)
 {
        struct pane *p, *par;
        struct doc *d;
-       struct cmd_info ci2 = {0};
 
-       ci2.key = "ThisPane";
-       ci2.focus = ci->focus;
-       if (key_handle_focus(&ci2) == 0)
+       par = call_pane("ThisPane", ci->focus, 0, NULL, 0);
+       if (!par)
                return -1;
-       par = ci2.focus;
        /* par is the tile */
 
        d = pane2ed(par)->docs;
@@ -557,10 +504,7 @@ DEF_CMD(emacs_search)
                attr_set_str(&p->attrs, "prefix", "Search: ", -1);
                attr_set_str(&p->attrs, "done-key", "Search String", -1);
 
-               ci2.key = "doc:set-name";
-               ci2.focus = p;
-               ci2.str = "Search";
-               key_handle_focus(&ci2);
+               call5("doc:set-name", p, 0, NULL, "Search", 0);
 
                p = pane_final_child(p);
                pane_attach(p, "emacs-search", NULL, NULL);
@@ -570,11 +514,7 @@ DEF_CMD(emacs_search)
        if (!ci->str || !ci->str[0])
                return -1;
 
-       ci2.key = "doc:dup-point";
-       ci2.focus = ci->home;
-       ci2.extra = MARK_UNGROUPED;
-       key_handle_focus(&ci2);
-       m = ci2.mark;
+       m = call_mark("doc:dup-point", ci->home, 0, NULL, MARK_UNGROUPED);
 
        memset(&ci2, 0, sizeof(ci2));
        ci2.focus = ci->home;
@@ -583,13 +523,9 @@ DEF_CMD(emacs_search)
        ci2.key = "text-search";
        if (!key_lookup(pane2ed(ci->focus)->commands, &ci2))
                ci2.extra = -1;
-       if (ci2.extra > 0) {
-               memset(&ci2, 0, sizeof(ci2));
-               ci2.key = "Move-to";
-               ci2.mark = m;
-               ci2.focus = ci->focus;
-               key_handle_focus(&ci2);
-       }
+       if (ci2.extra > 0)
+               call3("Move-to", ci->focus, 0, m);
+
        mark_free(m);
        return 1;
 }
index fb2aba5412841ce16cfa1cc1a30e8d771450c2a0..c27c206893a559e72ce6a57969a598f7e5acd0b1 100644 (file)
@@ -216,21 +216,9 @@ DEF_CMD(complete_set_prefix)
        free(cd->prefix);
        cd->prefix = strdup(ci->str);
 
-       ci2.key = "doc:dup-point";
-       ci2.focus = ci->home;
-       ci2.extra = MARK_UNGROUPED;
-       key_handle_focus(&ci2);
-       m = ci2.mark;
-
-       memset(&ci2, 0, sizeof(ci2));
-
-       ci2.key = "Move-File";
-       ci2.focus = ci->home;
-       ci2.numeric = 1;
-       ci2.mark = m;
-       key_handle_focus(&ci2);
+       m = call_mark("doc:dup-point", ci->home, 0, NULL, MARK_UNGROUPED);
+       call3("Move-File", ci->home, 1, m);
 
-       memset(&ci2, 0, sizeof(ci2));
        ci2.key = "render-line-prev";
        ci2.numeric = 1;
        ci2.mark = m;
@@ -250,16 +238,9 @@ DEF_CMD(complete_set_prefix)
        }
        ci->extra = cnt;
        ci->str = common;
-       memset(&ci2, 0, sizeof(ci2));
-       ci2.key = "Move-to";
-       ci2.mark = m;
-       ci2.focus = ci->home;
-       key_handle_focus(&ci2);
+       call3("Move-to", ci->home, 0, m);
        mark_free(m);
-       memset(&ci2, 0, sizeof(ci2));
-       ci2.key = "render-lines:redraw";
-       ci2.focus = ci->focus;
-       key_handle_focus(&ci2);
+       call3("render-lines:redraw", ci->focus, 0, NULL);
        return 1;
 }