The branch, master has been updated
       via  f1ce95915c612ef3b429dc7d2f635b5758b27669 (commit)
      from  aadc87f5a79865f404f4b6cb0f4892daa17e7365 (commit)

- Log -----------------------------------------------------------------
commit f1ce95915c612ef3b429dc7d2f635b5758b27669
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Allow choose commands to be used outside tmux, so long as at least one 
client
    is attached.
---
 cmd-choose-buffer.c |    5 ++---
 cmd-choose-client.c |    5 ++---
 cmd-choose-list.c   |    7 ++++---
 cmd-choose-tree.c   |   12 +++++++-----
 cmd-find-window.c   |    5 ++---
 tmux.1              |   21 +++++++--------------
 tmux.h              |    6 +++---
 window-choose.c     |    9 +++------
 8 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c
index c002196..a7fc52a 100644
--- a/cmd-choose-buffer.c
+++ b/cmd-choose-buffer.c
@@ -51,11 +51,10 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx 
*ctx)
        const char                      *template;
        u_int                            idx;
 
-       if (ctx->curclient == NULL) {
-               ctx->error(ctx, "must be run interactively");
+       if ((c = cmd_current_client(ctx)) == NULL) {
+               ctx->error(ctx, "no client available");
                return (CMD_RETURN_ERROR);
        }
-       c = ctx->curclient;
 
        if ((template = args_get(args, 'F')) == NULL)
                template = CHOOSE_BUFFER_TEMPLATE;
diff --git a/cmd-choose-client.c b/cmd-choose-client.c
index 0c1eb07..7f26452 100644
--- a/cmd-choose-client.c
+++ b/cmd-choose-client.c
@@ -57,11 +57,10 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx 
*ctx)
        char                            *action;
        u_int                            i, idx, cur;
 
-       if (ctx->curclient == NULL) {
-               ctx->error(ctx, "must be run interactively");
+       if ((c = cmd_current_client(ctx)) == NULL) {
+               ctx->error(ctx, "no client available");
                return (CMD_RETURN_ERROR);
        }
-       c = ctx->curclient;
 
        if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
                return (CMD_RETURN_ERROR);
diff --git a/cmd-choose-list.c b/cmd-choose-list.c
index 136cd4c..9634fef 100644
--- a/cmd-choose-list.c
+++ b/cmd-choose-list.c
@@ -47,13 +47,14 @@ enum cmd_retval
 cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
 {
        struct args                     *args = self->args;
+       struct client                   *c;
        struct winlink                  *wl;
        const char                      *list1;
        char                            *template, *item, *copy, *list;
        u_int                            idx;
 
-       if (ctx->curclient == NULL) {
-               ctx->error(ctx, "must be run interactively");
+       if ((c = cmd_current_client(ctx)) == NULL) {
+               ctx->error(ctx, "no client available");
                return (CMD_RETURN_ERROR);
        }
 
@@ -77,7 +78,7 @@ cmd_choose_list_exec(struct cmd *self, struct cmd_ctx *ctx)
        {
                if (*item == '\0') /* no empty entries */
                        continue;
-               window_choose_add_item(wl->window->active, ctx, wl, item,
+               window_choose_add_item(wl->window->active, c, wl, item,
                    template, idx);
                idx++;
        }
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index 77eda5d..d1f106e 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -71,6 +71,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
        struct args                     *args = self->args;
        struct winlink                  *wl, *wm;
        struct session                  *s, *s2;
+       struct client                   *c;
        struct window_choose_data       *wcd = NULL;
        const char                      *ses_template, *win_template;
        char                            *final_win_action, *cur_win_template;
@@ -83,12 +84,13 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
        ses_template = win_template = NULL;
        ses_action = win_action = NULL;
 
-       if (ctx->curclient == NULL) {
-               ctx->error(ctx, "must be run interactively");
+       if ((c = cmd_current_client(ctx)) == NULL) {
+               ctx->error(ctx, "no client available");
                return (CMD_RETURN_ERROR);
        }
 
-       s = ctx->curclient->session;
+       if ((s = c->session) == NULL)
+               return (CMD_RETURN_ERROR);
 
        if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
                return (CMD_RETURN_ERROR);
@@ -172,7 +174,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
                }
 
                wcd = window_choose_add_session(wl->window->active,
-                   ctx, s2, ses_template, (char *)ses_action, idx_ses);
+                   c, s2, ses_template, (char *)ses_action, idx_ses);
 
                /* If we're just choosing sessions, skip choosing windows. */
                if (sflag && !wflag) {
@@ -210,7 +212,7 @@ windows_only:
                                cur_win_template = final_win_template_last;
 
                        window_choose_add_window(wl->window->active,
-                           ctx, s2, wm, cur_win_template,
+                           c, s2, wm, cur_win_template,
                            final_win_action,
                            (wflag && !sflag) ? win_ses : idx_ses);
 
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 29ac284..8d34e60 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -139,11 +139,10 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx 
*ctx)
        const char                      *template;
        u_int                            i, match_flags;
 
-       if (ctx->curclient == NULL) {
-               ctx->error(ctx, "must be run interactively");
+       if ((c = cmd_current_client(ctx)) == NULL) {
+               ctx->error(ctx, "no client available");
                return (CMD_RETURN_ERROR);
        }
-       c = ctx->curclient;
        s = c->session;
 
        if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
diff --git a/tmux.1 b/tmux.1
index 3e85be7..c360be7 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1078,8 +1078,7 @@ For the meaning of the
 flag, see the
 .Sx FORMATS
 section.
-This command works only from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Xo
 .Ic choose-list
 .Op Fl l Ar items
@@ -1105,8 +1104,7 @@ also accepts format specifiers.
 For the meaning of this see the
 .Sx FORMATS
 section.
-This command works only from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Xo
 .Ic choose-session
 .Op Fl F Ar format
@@ -1128,8 +1126,7 @@ For the meaning of the
 flag, see the
 .Sx FORMATS
 section.
-This command works only from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Xo
 .Ic choose-tree
 .Op Fl s
@@ -1193,8 +1190,7 @@ and
 options, see the
 .Sx FORMATS
 section.
-This command only works from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Xo
 .Ic choose-window
 .Op Fl F Ar format
@@ -1216,8 +1212,7 @@ For the meaning of the
 flag, see the
 .Sx FORMATS
 section.
-This command works only from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Ic display-panes Op Fl t Ar target-client
 .D1 (alias: Ic displayp)
 Display a visible indicator of each pane shown by
@@ -1261,8 +1256,7 @@ For the meaning of the
 flag, see the
 .Sx FORMATS
 section.
-This command only works from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Xo Ic join-pane
 .Op Fl bdhv
 .Oo Fl l
@@ -3310,8 +3304,7 @@ For the meaning of the
 flag, see the
 .Sx FORMATS
 section.
-This command works only from inside
-.Nm .
+This command works only if at least one client is attached.
 .It Ic clear-history Op Fl t Ar target-pane
 .D1 (alias: Ic clearhist )
 Remove and free the history for the specified pane.
diff --git a/tmux.h b/tmux.h
index e401cd7..4a18ecc 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2204,13 +2204,13 @@ struct window_choose_data       
*window_choose_data_create (int,
 void   window_choose_data_free(struct window_choose_data *);
 void   window_choose_data_run(struct window_choose_data *);
 struct window_choose_data      *window_choose_add_window(struct window_pane *,
-                       struct cmd_ctx *, struct session *, struct winlink *,
+                       struct client *, struct session *, struct winlink *,
                        const char *, char *, u_int);
 struct window_choose_data      *window_choose_add_session(struct window_pane *,
-                       struct cmd_ctx *, struct session *, const char *,
+                       struct client *, struct session *, const char *,
                        char *, u_int);
 struct window_choose_data      *window_choose_add_item(struct window_pane *,
-                       struct cmd_ctx *, struct winlink *, const char *,
+                       struct client *, struct winlink *, const char *,
                        char *, u_int);
 void   window_choose_expand_all(struct window_pane *);
 
diff --git a/window-choose.c b/window-choose.c
index 21d6aec..d461887 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -863,11 +863,10 @@ window_choose_scroll_down(struct window_pane *wp)
 }
 
 struct window_choose_data *
-window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx,
+window_choose_add_session(struct window_pane *wp, struct client *c,
     struct session *s, const char *template, char *action, u_int idx)
 {
        struct window_choose_data       *wcd;
-       struct client                   *c = ctx->curclient;
 
        wcd = window_choose_data_create(TREE_SESSION, c, c->session);
        wcd->idx = s->idx;
@@ -887,11 +886,10 @@ window_choose_add_session(struct window_pane *wp, struct 
cmd_ctx *ctx,
 }
 
 struct window_choose_data *
-window_choose_add_item(struct window_pane *wp, struct cmd_ctx *ctx,
+window_choose_add_item(struct window_pane *wp, struct client *c,
     struct winlink *wl, const char *template, char *action, u_int idx)
 {
        struct window_choose_data       *wcd;
-       struct client                   *c = ctx->curclient;
        char                            *expanded;
 
        wcd = window_choose_data_create(TREE_OTHER, c, c->session);
@@ -918,12 +916,11 @@ window_choose_add_item(struct window_pane *wp, struct 
cmd_ctx *ctx,
 }
 
 struct window_choose_data *
-window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx,
+window_choose_add_window(struct window_pane *wp, struct client *c,
     struct session *s, struct winlink *wl, const char *template,
     char *action, u_int idx)
 {
        struct window_choose_data       *wcd;
-       struct client                   *c = ctx->curclient;
        char                            *expanded;
 
        wcd = window_choose_data_create(TREE_WINDOW, c, c->session);


-----------------------------------------------------------------------

Summary of changes:
 cmd-choose-buffer.c |    5 ++---
 cmd-choose-client.c |    5 ++---
 cmd-choose-list.c   |    7 ++++---
 cmd-choose-tree.c   |   12 +++++++-----
 cmd-find-window.c   |    5 ++---
 tmux.1              |   21 +++++++--------------
 tmux.h              |    6 +++---
 window-choose.c     |    9 +++------
 8 files changed, 30 insertions(+), 40 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to