Update of /cvsroot/tmux/tmux
In directory vz-cvs-2.sog:/tmp/cvs-serv20354
Modified Files:
cmd-attach-session.c cmd-has-session.c cmd-kill-session.c
cmd-list-panes.c cmd-list-windows.c cmd-lock-server.c
cmd-new-session.c cmd-rename-session.c cmd-select-window.c
cmd-set-environment.c cmd-set-option.c cmd-show-buffer.c
cmd-show-environment.c cmd-show-options.c cmd-switch-client.c
cmd.c tmux.1 tmux.h
Log Message:
|PatchSet 882
|Date: 2011/04/05 20:37:01
|Author: nicm
|Branch: HEAD
|Tag: (none)
|Log:
|Add a flag to cmd_find_session so that attach-session can prefer
|unattached sessions when choosing the most recently used (if -t is not
|given). Suggested by claudio@.
Index: cmd-list-panes.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-list-panes.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cmd-list-panes.c 6 Apr 2011 22:20:16 -0000 1.9
+++ cmd-list-panes.c 6 Apr 2011 22:24:00 -0000 1.10
@@ -52,7 +52,7 @@
if (args_has(args, 'a'))
cmd_list_panes_server(ctx);
else if (args_has(args, 's')) {
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
cmd_list_panes_session(s, ctx);
Index: cmd.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -d -r1.150 -r1.151
--- cmd.c 6 Apr 2011 22:16:33 -0000 1.150
+++ cmd.c 6 Apr 2011 22:24:01 -0000 1.151
@@ -111,7 +111,7 @@
};
struct session *cmd_choose_session_list(struct sessionslist *);
-struct session *cmd_choose_session(void);
+struct session *cmd_choose_session(int);
struct client *cmd_choose_client(struct clients *);
struct client *cmd_lookup_client(const char *);
struct session *cmd_lookup_session(const char *, int *);
@@ -315,7 +315,7 @@
* session from all sessions.
*/
struct session *
-cmd_current_session(struct cmd_ctx *ctx)
+cmd_current_session(struct cmd_ctx *ctx, int prefer_unattached)
{
struct msg_command_data *data = ctx->msgdata;
struct client *c = ctx->cmdclient;
@@ -364,19 +364,25 @@
return (s);
}
- return (cmd_choose_session());
+ return (cmd_choose_session(prefer_unattached));
}
-/* Find the most recently used session. */
+/*
+ * Find the most recently used session, preferring unattached if the flag is
+ * set.
+ */
struct session *
-cmd_choose_session(void)
+cmd_choose_session(int prefer_unattached)
{
struct session *s, *sbest;
struct timeval *tv = NULL;
sbest = NULL;
RB_FOREACH(s, sessions, &sessions) {
- if (tv == NULL || timercmp(&s->activity_time, tv, >)) {
+ if (tv == NULL || timercmp(&s->activity_time, tv, >) ||
+ (prefer_unattached &&
+ !(sbest->flags & SESSION_UNATTACHED) &&
+ (s->flags & SESSION_UNATTACHED))) {
sbest = s;
tv = &s->activity_time;
}
@@ -427,7 +433,7 @@
* No current client set. Find the current session and return the
* newest of its clients.
*/
- s = cmd_current_session(ctx);
+ s = cmd_current_session(ctx, 0);
if (s != NULL && !(s->flags & SESSION_UNATTACHED)) {
ARRAY_INIT(&cc);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
@@ -670,7 +676,7 @@
struct winlink *wl;
/* If this pane is in the current session, return that winlink. */
- s = cmd_current_session(ctx);
+ s = cmd_current_session(ctx, 0);
if (s != NULL) {
wl = winlink_find_by_window(&s->windows, wp->window);
if (wl != NULL) {
@@ -695,7 +701,7 @@
/* Find the target session or report an error and return NULL. */
struct session *
-cmd_find_session(struct cmd_ctx *ctx, const char *arg)
+cmd_find_session(struct cmd_ctx *ctx, const char *arg, int prefer_unattached)
{
struct session *s;
struct window_pane *wp;
@@ -706,7 +712,7 @@
/* A NULL argument means the current session. */
if (arg == NULL)
- return (cmd_current_session(ctx));
+ return (cmd_current_session(ctx, prefer_unattached));
tmparg = xstrdup(arg);
/* Lookup as pane id. */
@@ -752,7 +758,7 @@
* Find the current session. There must always be a current session, if
* it can't be found, report an error.
*/
- if ((s = cmd_current_session(ctx)) == NULL) {
+ if ((s = cmd_current_session(ctx, 0)) == NULL) {
ctx->error(ctx, "can't establish current session");
return (NULL);
}
@@ -899,7 +905,7 @@
* Find the current session. There must always be a current session, if
* it can't be found, report an error.
*/
- if ((s = cmd_current_session(ctx)) == NULL) {
+ if ((s = cmd_current_session(ctx, 0)) == NULL) {
ctx->error(ctx, "can't establish current session");
return (-2);
}
@@ -1053,7 +1059,7 @@
u_int idx;
/* Get the current session. */
- if ((s = cmd_current_session(ctx)) == NULL) {
+ if ((s = cmd_current_session(ctx, 0)) == NULL) {
ctx->error(ctx, "can't establish current session");
return (NULL);
}
Index: cmd-show-buffer.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-show-buffer.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- cmd-show-buffer.c 7 Jan 2011 14:45:34 -0000 1.14
+++ cmd-show-buffer.c 6 Apr 2011 22:24:01 -0000 1.15
@@ -47,7 +47,7 @@
size_t size, len;
u_int width;
- if ((s = cmd_find_session(ctx, NULL)) == NULL)
+ if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
return (-1);
if (!args_has(args, 'b')) {
Index: cmd-show-environment.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-show-environment.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cmd-show-environment.c 7 Jan 2011 14:45:34 -0000 1.3
+++ cmd-show-environment.c 6 Apr 2011 22:24:01 -0000 1.4
@@ -50,7 +50,7 @@
if (args_has(self->args, 'g'))
env = &global_environ;
else {
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
return (-1);
env = &s->environ;
}
Index: cmd-show-options.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-show-options.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- cmd-show-options.c 7 Jan 2011 15:02:38 -0000 1.24
+++ cmd-show-options.c 6 Apr 2011 22:24:01 -0000 1.25
@@ -79,7 +79,7 @@
if (args_has(self->args, 'g'))
oo = &global_s_options;
else {
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
oo = &s->options;
Index: cmd-lock-server.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-lock-server.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- cmd-lock-server.c 7 Jan 2011 15:02:38 -0000 1.11
+++ cmd-lock-server.c 6 Apr 2011 22:24:00 -0000 1.12
@@ -71,7 +71,7 @@
if (self->entry == &cmd_lock_server_entry)
server_lock();
else if (self->entry == &cmd_lock_session_entry) {
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
return (-1);
server_lock_session(s);
} else {
Index: tmux.1
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.1,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- tmux.1 6 Apr 2011 22:23:14 -0000 1.301
+++ tmux.1 6 Apr 2011 22:24:01 -0000 1.302
@@ -566,6 +566,17 @@
.Ic attach-session
will attempt to start it; this will fail unless sessions are created in the
configuration file.
+.Pp
+The
+.Ar target-session
+rules for
+.Ic attach-session
+are slightly adjusted: if
+.Nm
+needs to select the most recently used session, it will prefer the most
+recently used
+.Em unattached
+session.
.It Xo Ic detach-client
.Op Fl P
.Op Fl t Ar target-client
Index: cmd-select-window.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-select-window.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- cmd-select-window.c 7 Jan 2011 15:02:38 -0000 1.26
+++ cmd-select-window.c 6 Apr 2011 22:24:01 -0000 1.27
@@ -102,7 +102,7 @@
last = 1;
if (next || previous || last) {
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
Index: cmd-kill-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-kill-session.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cmd-kill-session.c 7 Jan 2011 14:45:34 -0000 1.19
+++ cmd-kill-session.c 6 Apr 2011 22:24:00 -0000 1.20
@@ -45,7 +45,7 @@
struct args *args = self->args;
struct session *s;
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
return (-1);
server_destroy_session(s);
Index: cmd-new-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-new-session.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- cmd-new-session.c 15 Feb 2011 15:25:48 -0000 1.84
+++ cmd-new-session.c 6 Apr 2011 22:24:00 -0000 1.85
@@ -75,7 +75,7 @@
target = args_get(args, 't');
if (target != NULL) {
- groupwith = cmd_find_session(ctx, target);
+ groupwith = cmd_find_session(ctx, target, 0);
if (groupwith == NULL)
return (-1);
} else
Index: cmd-switch-client.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-switch-client.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- cmd-switch-client.c 7 Jan 2011 14:45:34 -0000 1.25
+++ cmd-switch-client.c 6 Apr 2011 22:24:01 -0000 1.26
@@ -86,7 +86,7 @@
return (-1);
}
} else
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
Index: cmd-set-environment.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-set-environment.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cmd-set-environment.c 7 Jan 2011 14:45:34 -0000 1.4
+++ cmd-set-environment.c 6 Apr 2011 22:24:01 -0000 1.5
@@ -65,7 +65,7 @@
if (args_has(self->args, 'g'))
env = &global_environ;
else {
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
return (-1);
env = &s->environ;
}
Index: cmd-has-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-has-session.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- cmd-has-session.c 7 Jan 2011 14:45:34 -0000 1.16
+++ cmd-has-session.c 6 Apr 2011 22:24:00 -0000 1.17
@@ -41,7 +41,7 @@
{
struct args *args = self->args;
- if (cmd_find_session(ctx, args_get(args, 't')) == NULL)
+ if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
return (-1);
return (0);
Index: cmd-set-option.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-set-option.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- cmd-set-option.c 6 Apr 2011 22:22:49 -0000 1.111
+++ cmd-set-option.c 6 Apr 2011 22:24:01 -0000 1.112
@@ -164,7 +164,7 @@
if (args_has(self->args, 'g'))
oo = &global_s_options;
else {
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
oo = &s->options;
Index: cmd-list-windows.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-list-windows.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- cmd-list-windows.c 6 Apr 2011 22:20:16 -0000 1.46
+++ cmd-list-windows.c 6 Apr 2011 22:24:00 -0000 1.47
@@ -50,7 +50,7 @@
if (args_has(args, 'a'))
cmd_list_windows_server(ctx);
else {
- s = cmd_find_session(ctx, args_get(args, 't'));
+ s = cmd_find_session(ctx, args_get(args, 't'), 0);
if (s == NULL)
return (-1);
cmd_list_windows_session(s, ctx);
Index: cmd-rename-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-rename-session.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmd-rename-session.c 7 Jan 2011 14:45:34 -0000 1.22
+++ cmd-rename-session.c 6 Apr 2011 22:24:01 -0000 1.23
@@ -51,7 +51,7 @@
return (-1);
}
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
return (-1);
RB_REMOVE(sessions, &sessions, s);
Index: cmd-attach-session.c
===================================================================
RCS file: /cvsroot/tmux/tmux/cmd-attach-session.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cmd-attach-session.c 7 Jan 2011 14:45:33 -0000 1.39
+++ cmd-attach-session.c 6 Apr 2011 22:24:00 -0000 1.40
@@ -51,7 +51,7 @@
return (-1);
}
- if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL)
+ if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
return (-1);
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
Index: tmux.h
===================================================================
RCS file: /cvsroot/tmux/tmux/tmux.h,v
retrieving revision 1.616
retrieving revision 1.617
diff -u -d -r1.616 -r1.617
--- tmux.h 6 Apr 2011 22:21:02 -0000 1.616
+++ tmux.h 6 Apr 2011 22:24:01 -0000 1.617
@@ -1483,10 +1483,10 @@
int cmd_exec(struct cmd *, struct cmd_ctx *);
void cmd_free(struct cmd *);
size_t cmd_print(struct cmd *, char *, size_t);
-struct session *cmd_current_session(struct cmd_ctx *);
+struct session *cmd_current_session(struct cmd_ctx *, int);
struct client *cmd_current_client(struct cmd_ctx *);
struct client *cmd_find_client(struct cmd_ctx *, const char *);
-struct session *cmd_find_session(struct cmd_ctx *, const char *);
+struct session *cmd_find_session(struct cmd_ctx *, const char *, int);
struct winlink *cmd_find_window(
struct cmd_ctx *, const char *, struct session **);
int cmd_find_index(
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs