From 1323497fd8ab78870897671938958b7c649c1272 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 11 Dec 2015 11:39:06 +1100 Subject: [PATCH] Use new notifications to support search_again That than the old doc notifer. Signed-off-by: NeilBrown --- core.h | 13 +++++++++++++ emacs-search.c | 19 ++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/core.h b/core.h index fef5cc67..1b326030 100644 --- a/core.h +++ b/core.h @@ -486,6 +486,19 @@ static inline int call3(char *key, struct pane *focus, int numeric, struct mark return key_handle_focus(&ci); } +static inline int call_home(struct pane *home, char *key, struct pane *focus, + int numeric, struct mark *m) +{ + struct cmd_info ci = {0}; + + ci.key = key; + ci.focus = focus; + ci.home = home; + 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) { diff --git a/emacs-search.c b/emacs-search.c index 59fe0efe..b1360338 100644 --- a/emacs-search.c +++ b/emacs-search.c @@ -39,8 +39,6 @@ struct es_info { static struct map *es_map; -DEF_CMD(search_again); - DEF_CMD(search_forward) { struct es_info *esi = ci->home->data; @@ -166,10 +164,10 @@ DEF_CMD(search_close) return 1; } -REDEF_CMD(search_again) +DEF_CMD(search_again) { /* document has changed, retry search */ - struct es_info *esi = container_of(ci->comm, struct es_info, watch); + struct es_info *esi = ci->home->data; struct cmd_info ci2 = {0}; struct pane *p; char *a, *pfx; @@ -177,12 +175,6 @@ REDEF_CMD(search_again) struct mark *m; char *str; - if (strcmp(ci->key, "Release") == 0) { - /* No marks to remove */ - doc_del_view(ci->home, ci->comm); - return 0; - } - /* TEMP HACK - please fix */ doc_set_attr(esi->target, esi->end, "highlight", NULL); ci2.focus = esi->target; @@ -243,6 +235,7 @@ static void emacs_search_init_map(void) key_add(es_map, "C-Chr-R", &search_backward); key_add(es_map, "Close", &search_close); key_add(es_map, "popup:Return", &search_done); + key_add(es_map, "Notify:Replace", &search_again); } DEF_LOOKUP_CMD(search_handle, es_map); @@ -272,13 +265,13 @@ DEF_CMD(emacs_search) esi->matched = 0; esi->wrapped = 0; esi->search = ci->focus; - esi->watch = search_again; - doc_add_view(ci->focus, &esi->watch, 0); p = pane_final_child(ci->focus); p = pane_register(p, 0, &search_handle.c, esi, NULL); - if (p) + if (p) { + call3("Request:Notify:Replace", p, 0, NULL); comm_call(ci->comm2, "callback:attach", p, 0, NULL, NULL, 0); + } return 1; } -- 2.39.5