Switch the callback of this command to use the centralised window_choose_ctx
function.
---
 trunk/cmd-choose-buffer.c |   37 ++++++-------------------------------
 1 file changed, 6 insertions(+), 31 deletions(-)

diff --git a/trunk/cmd-choose-buffer.c b/trunk/cmd-choose-buffer.c
index 29535a2..535765e 100644
--- a/trunk/cmd-choose-buffer.c
+++ b/trunk/cmd-choose-buffer.c
@@ -50,7 +50,7 @@ int
 cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
 {
        struct args                     *args = self->args;
-       struct cmd_choose_buffer_data   *cdata;
+       struct window_choose_data       *cdata;
        struct winlink                  *wl;
        struct paste_buffer             *pb;
        struct format_tree              *ft;
@@ -105,49 +105,24 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx 
*ctx)
 void
 cmd_choose_buffer_callback(void *data, int idx)
 {
-       struct cmd_choose_buffer_data   *cdata = data;
-       struct cmd_list                 *cmdlist;
-       struct cmd_ctx                   ctx;
-       char                            *template, *cause, tmp[16];
+       struct window_choose_data       *cdata = data;
 
        if (idx == -1)
                return;
        if (cdata->client->flags & CLIENT_DEAD)
                return;
 
-       xsnprintf(tmp, sizeof tmp, "%u", idx);
-       template = cmd_template_replace(cdata->template, tmp, 1);
-
-       if (cmd_string_parse(template, &cmdlist, &cause) != 0) {
-               if (cause != NULL) {
-                       *cause = toupper((u_char) *cause);
-                       status_message_set(cdata->client, "%s", cause);
-                       xfree(cause);
-               }
-               xfree(template);
-               return;
-       }
-       xfree(template);
-
-       ctx.msgdata = NULL;
-       ctx.curclient = cdata->client;
-
-       ctx.error = key_bindings_error;
-       ctx.print = key_bindings_print;
-       ctx.info = key_bindings_info;
-
-       ctx.cmdclient = NULL;
-
-       cmd_list_exec(cmdlist, &ctx);
-       cmd_list_free(cmdlist);
+       xasprintf(&cdata->raw_format, "%u", idx);
+       window_choose_ctx(cdata);
 }
 
 void
 cmd_choose_buffer_free(void *data)
 {
-       struct cmd_choose_buffer_data   *cdata = data;
+       struct window_choose_data       *cdata = data;
 
        cdata->client->references--;
        xfree(cdata->template);
+       xfree(cdata->raw_format);
        xfree(cdata);
 }
-- 
1.7.10


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to