The branch, master has been updated
       via  be13479f099749b2a199e17505797e51090caca0 (commit)
      from  69a8d6471634ebdfa9db70b306e493f47ddd9a5d (commit)

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

    Add a -o option to set-option to prevent setting an option already set, from
    Thiago Padilha.
---
 cmd-set-option.c |   20 +++++++++++++++-----
 tmux.1           |    6 +++++-
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/cmd-set-option.c b/cmd-set-option.c
index 4b351c1..a46460a 100644
--- a/cmd-set-option.c
+++ b/cmd-set-option.c
@@ -30,7 +30,7 @@
 enum cmd_retval        cmd_set_option_exec(struct cmd *, struct cmd_q *);
 
 enum cmd_retval        cmd_set_option_user(struct cmd *, struct cmd_q *,
-                   const char *, const char *);
+           const char *, const char *);
 
 int    cmd_set_option_unset(struct cmd *, struct cmd_q *,
            const struct options_table_entry *, struct options *,
@@ -63,8 +63,8 @@ struct options_entry *cmd_set_option_choice(struct cmd *, 
struct cmd_q *,
 
 const struct cmd_entry cmd_set_option_entry = {
        "set-option", "set",
-       "agqst:uw", 1, 2,
-       "[-agsquw] [-t target-session|target-window] option [value]",
+       "agoqst:uw", 1, 2,
+       "[-agosquw] [-t target-session|target-window] option [value]",
        0,
        NULL,
        NULL,
@@ -73,8 +73,8 @@ const struct cmd_entry cmd_set_option_entry = {
 
 const struct cmd_entry cmd_set_window_option_entry = {
        "set-window-option", "setw",
-       "agqt:u", 1, 2,
-       "[-agqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
+       "agoqt:u", 1, 2,
+       "[-agoqu] " CMD_TARGET_WINDOW_USAGE " option [value]",
        0,
        NULL,
        NULL,
@@ -151,6 +151,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
                if (cmd_set_option_unset(self, cmdq, oe, oo, valstr) != 0)
                        return (CMD_RETURN_ERROR);
        } else {
+               if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
+                       if (!args_has(args, 'q'))
+                               cmdq_print(cmdq, "already set: %s", optstr);
+                       return (CMD_RETURN_NORMAL);
+               }
                if (cmd_set_option_set(self, cmdq, oe, oo, valstr) != 0)
                        return (CMD_RETURN_ERROR);
        }
@@ -227,6 +232,11 @@ cmd_set_option_user(struct cmd *self, struct cmd_q *cmdq, 
const char* optstr,
                        cmdq_error(cmdq, "empty value");
                        return (CMD_RETURN_ERROR);
                }
+               if (args_has(args, 'o') && options_find1(oo, optstr) != NULL) {
+                       if (!args_has(args, 'q'))
+                               cmdq_print(cmdq, "already set: %s", optstr);
+                       return (CMD_RETURN_NORMAL);
+               }
                options_set_string(oo, optstr, "%s", valstr);
                if (!args_has(args, 'q')) {
                        cmdq_info(cmdq, "set option: %s -> %s", optstr,
diff --git a/tmux.1 b/tmux.1
index faa129a..41e76c9 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1996,7 +1996,7 @@ abc123
 Commands which set options are as follows:
 .Bl -tag -width Ds
 .It Xo Ic set-option
-.Op Fl agqsuw
+.Op Fl agoqsuw
 .Op Fl t Ar target-session | Ar target-window
 .Ar option Ar value
 .Xc
@@ -2025,6 +2025,10 @@ options.
 It is not possible to unset a global option.
 .Pp
 The
+.Fl o
+flag prevents setting an option that is already set.
+.Pp
+The
 .Fl q
 flag suppresses the informational message (as if the
 .Ic quiet


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

Summary of changes:
 cmd-set-option.c |   20 +++++++++++++++-----
 tmux.1           |    6 +++++-
 2 files changed, 20 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
tmux

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
tmux-cvs mailing list
tmux-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to