The branch, hooks has been updated
       via  ad037b7ea361ecbabf7df015e701e12db702978e (commit)
       via  333fd2d1655d4b6a4982b7599709d9c84dd28c4e (commit)
      from  3bcacea265ee98296fcda9f00b514fb4e0a3640d (commit)

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

    Use prepare flags for set-option and show-options.
---
 cmd-set-option.c   |   50 ++++++++++++--------------------------------------
 cmd-show-options.c |   20 ++++++--------------
 2 files changed, 18 insertions(+), 52 deletions(-)

diff --git a/cmd-set-option.c b/cmd-set-option.c
index 01d691d..bda6876 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -68,7 +68,7 @@ const struct cmd_entry cmd_set_option_entry = {
        "set-option", "set",
        "agoqst:uw", 1, 2,
        "[-agosquw] [-t target-session|target-window] option [value]",
-       0,
+       CMD_PREP_WINDOW_T,
        cmd_set_option_exec
 };
 
@@ -76,7 +76,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
        "set-window-option", "setw",
        "agoqt:u", 1, 2,
        "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
-       0,
+       CMD_PREP_WINDOW_T,
        cmd_set_option_exec
 };
 
@@ -84,12 +84,12 @@ enum cmd_retval
 cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args                             *args = self->args;
-       const struct options_table_entry        *table, *oe;
-       struct session                          *s;
-       struct winlink                          *wl;
+       struct session                          *s = cmdq->state.tflag.s;
+       struct winlink                          *wl = cmdq->state.tflag.wl;
        struct client                           *c;
-       struct options                          *oo;
        struct window                           *w;
+       const struct options_table_entry        *table, *oe;
+       struct options                          *oo;
        const char                              *optstr, *valstr;
        u_int                                    i;
 
@@ -128,31 +128,13 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
        else if (table == window_options_table) {
                if (args_has(self->args, 'g'))
                        oo = &global_w_options;
-               else {
-                       wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
-                       if (wl == NULL) {
-                               cmdq_error(cmdq,
-                                   "couldn't set '%s'%s", optstr,
-                                   (!args_has(args, 't') && !args_has(args,
-                                   'g')) ? " need target window or -g" : "");
-                               return (CMD_RETURN_ERROR);
-                       }
+               else
                        oo = &wl->window->options;
-               }
        } else if (table == session_options_table) {
                if (args_has(self->args, 'g'))
                        oo = &global_s_options;
-               else {
-                       s = cmd_find_session(cmdq, args_get(args, 't'), 0);
-                       if (s == NULL) {
-                               cmdq_error(cmdq,
-                                   "couldn't set '%s'%s", optstr,
-                                   (!args_has(args, 't') && !args_has(args,
-                                   'g')) ? " need target session or -g" : "");
-                               return (CMD_RETURN_ERROR);
-                       }
+               else
                        oo = &s->options;
-               }
        } else {
                cmdq_error(cmdq, "unknown table");
                return (CMD_RETURN_ERROR);
@@ -203,8 +185,8 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, 
const char *optstr,
     const char *valstr)
 {
        struct args     *args = self->args;
-       struct session  *s;
-       struct winlink  *wl;
+       struct session  *s = cmdq->state.tflag.s;
+       struct winlink  *wl = cmdq->state.tflag.wl;
        struct options  *oo;
 
        if (args_has(args, 's'))
@@ -213,21 +195,13 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, 
const char *optstr,
            self->entry == &cmd_set_window_option_entry) {
                if (args_has(self->args, 'g'))
                        oo = &global_w_options;
-               else {
-                       wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
-                       if (wl == NULL)
-                               return (CMD_RETURN_ERROR);
+               else
                        oo = &wl->window->options;
-               }
        } else {
                if (args_has(self->args, 'g'))
                        oo = &global_s_options;
-               else {
-                       s = cmd_find_session(cmdq, args_get(args, 't'), 0);
-                       if (s == NULL)
-                               return (CMD_RETURN_ERROR);
+               else
                        oo = &s->options;
-               }
        }
 
        if (args_has(args, 'u')) {
diff --git a/cmd-show-options.c b/cmd-show-options.c
index a5011e7..03f269c 100644
--- a/cmd-show-options.c
+++ b/cmd-show-options.c
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_show_options_entry = {
        "show-options", "show",
        "gqst:vw", 0, 1,
        "[-gqsvw] [-t target-session|target-window] [option]",
-       0,
+       CMD_PREP_WINDOW_T,
        cmd_show_options_exec
 };
 
@@ -46,7 +46,7 @@ const struct cmd_entry cmd_show_window_options_entry = {
        "show-window-options", "showw",
        "gvt:", 0, 1,
        "[-gv] " CMD_TARGET_WINDOW_USAGE " [option]",
-       0,
+       CMD_PREP_WINDOW_T,
        cmd_show_options_exec
 };
 
@@ -54,8 +54,8 @@ enum cmd_retval
 cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args                             *args = self->args;
-       struct session                          *s;
-       struct winlink                          *wl;
+       struct session                          *s = cmdq->state.tflag.s;
+       struct winlink                          *wl = cmdq->state.tflag.wl;
        const struct options_table_entry        *table;
        struct options                          *oo;
        int                                      quiet;
@@ -68,22 +68,14 @@ cmd_show_options_exec(struct cmd *self, struct cmd_q *cmdq)
                table = window_options_table;
                if (args_has(self->args, 'g'))
                        oo = &global_w_options;
-               else {
-                       wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
-                       if (wl == NULL)
-                               return (CMD_RETURN_ERROR);
+               else
                        oo = &wl->window->options;
-               }
        } else {
                table = session_options_table;
                if (args_has(self->args, 'g'))
                        oo = &global_s_options;
-               else {
-                       s = cmd_find_session(cmdq, args_get(args, 't'), 0);
-                       if (s == NULL)
-                               return (CMD_RETURN_ERROR);
+               else
                        oo = &s->options;
-               }
        }
 
        quiet = args_has(self->args, 'q');


commit 333fd2d1655d4b6a4982b7599709d9c84dd28c4e
Author: Nicholas Marriott <nicholas.marri...@gmail.com>
Commit: Nicholas Marriott <nicholas.marri...@gmail.com>

    Use prepare flags for select-pane.
---
 cmd-select-pane.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index 5810eea..90850f6 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -30,7 +30,7 @@ const struct cmd_entry cmd_select_pane_entry = {
        "select-pane", "selectp",
        "DdeLlRt:U", 0, 0,
        "[-DdeLlRU] " CMD_TARGET_PANE_USAGE,
-       0,
+       CMD_PREP_PANE_T,
        cmd_select_pane_exec
 };
 
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_last_pane_entry = {
        "last-pane", "lastp",
        "det:", 0, 0,
        "[-de] " CMD_TARGET_WINDOW_USAGE,
-       0,
+       CMD_PREP_WINDOW_T,
        cmd_select_pane_exec
 };
 
@@ -46,14 +46,10 @@ enum cmd_retval
 cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
 {
        struct args             *args = self->args;
-       struct winlink          *wl;
-       struct window_pane      *wp;
+       struct winlink          *wl = cmdq->state.tflag.wl;
+       struct window_pane      *wp = cmdq->state.tflag.wp;
 
        if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
-               wl = cmd_find_window(cmdq, args_get(args, 't'), NULL);
-               if (wl == NULL)
-                       return (CMD_RETURN_ERROR);
-
                if (wl->window->last == NULL) {
                        cmdq_error(cmdq, "no last pane");
                        return (CMD_RETURN_ERROR);
@@ -73,9 +69,6 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
                return (CMD_RETURN_NORMAL);
        }
 
-       if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
-               return (CMD_RETURN_ERROR);
-
        server_unzoom_window(wp->window);
        if (!window_pane_visible(wp)) {
                cmdq_error(cmdq, "pane not visible");


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

Summary of changes:
 cmd-select-pane.c  |   15 ++++-----------
 cmd-set-option.c   |   50 ++++++++++++--------------------------------------
 cmd-show-options.c |   20 ++++++--------------
 3 files changed, 22 insertions(+), 63 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to