Can you please provide a unified cvs diff?

I've not tried this patch but I have some comments (see below).

> Useful for those times you want to use an unbound function, but even
> when the function is bound to something you haven't memorized yet it
> can be faster than lookup up the keybinding in the manual.  Bound to
> CM-/ by default.
>
[...]
>
> +struct func name_to_kbfunc[] = {
>       { "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, {0} },
>       { "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, {0} },
>       { "search", kbfunc_client_search, 0, {0} },
> +     { "funcsearch", kbfunc_func_search, KBFLAG_NEEDCLIENT, {0} },
>       { "menusearch", kbfunc_menu_search, 0, {0} },
>       { "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, {0} },
>       { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} },
> @@ -399,6 +396,7 @@
>           {.i = (CWM_LEFT|CWM_PTRMOVE|CWM_BIGMOVE)} },
>       { "bigptrmoveright", kbfunc_moveresize, 0,
>           {.i = (CWM_RIGHT|CWM_PTRMOVE|CWM_BIGMOVE)} },
> +     { NULL, NULL, 0, {0} }

Why do you insist on adding this?  Why not just use nitems?

> @@ -488,7 +486,8 @@
>               return;
>  
>       for (iter = 0; iter < nitems(name_to_kbfunc); iter++) {
> -             if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
> +             if (name_to_kbfunc[iter].tag == NULL ||
> +                 strcmp(name_to_kbfunc[iter].tag, binding) != 0)
>                       continue;

See?  Now you have to add more code because you broke something.

> Index: cwm/kbfunc.c
> ===================================================================
> --- cwm.orig/kbfunc.c 2012-11-05 10:25:37.577424801 -0600
> +++ cwm/kbfunc.c      2012-11-05 14:17:27.164487245 -0600
> @@ -174,6 +174,35 @@
>  }
>  
>  void
> +kbfunc_func_search(struct client_ctx *cc, union arg *arg)
> +{
> +     struct screen_ctx       *sc = cc->sc;
> +     struct func             *func;
> +     struct menu             *mi;
> +     struct menu_q            menuq;
> +
> +     TAILQ_INIT(&menuq);
> +
> +     for (func = name_to_kbfunc; func->tag != NULL; func++) {

Why not

    for (iter = 0; iter < nitems(name_to_kbfunc); iter++) {
        func = &name_to_kbfunc[iter]; /* if you want to use func */

then you don't need the last NULL entry in the array or add code
to not break existing code.

> +     if ((mi = menu_filter(sc, &menuq, "function", NULL, 0,
> +         search_match_text, NULL)) != NULL) {
> +             func = (struct func *)mi->ctx;
> +             (*func->handler)(cc, &func->argument);

"func->handler(..." is fine but some people prefer the pre-ANSI
C style, "(*func->handler)(..." ... Just a tiny nit.  YMMV.

Reply via email to