Handle bad session/client properly.

This commit is contained in:
Nicholas Marriott 2008-06-27 17:10:01 +00:00
parent 6bc6e97da5
commit 571935c823
3 changed files with 25 additions and 19 deletions

View File

@ -1,3 +1,7 @@
27 June 2008
* Handle nonexistent session or client to -t properly.
25 June 2008 25 June 2008
* select-prompt command to allow a window to be selected at a prompt. Only * select-prompt command to allow a window to be selected at a prompt. Only
@ -573,4 +577,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.144 2008-06-25 20:43:13 nicm Exp $ $Id: CHANGES,v 1.145 2008-06-27 17:10:01 nicm Exp $

6
TODO
View File

@ -53,8 +53,7 @@
- document buffer stuff - document buffer stuff
- document next/prev word - document next/prev word
- fix prompt scrolling when line exceeds space **** - fix prompt scrolling when line exceeds space ****
- commands: - commands: save-buffer -b number filename
save-buffer -b number filename
load-buffer -b number filename load-buffer -b number filename
copy-buffer -s src-session -t dst-session -a src-index -b dst-index copy-buffer -s src-session -t dst-session -a src-index -b dst-index
(from other session) (from other session)
@ -74,4 +73,5 @@
- next prev word etc in command prompt - next prev word etc in command prompt
- split keys in command prompt/scroll mode/copy mode into vi and emacs and - split keys in command prompt/scroll mode/copy mode into vi and emacs and
have a "edit-mode" option select which keymap have a "edit-mode" option select which keymap
- zombie windows: don't disappear when the command dies. new command
respawn-window [command] to restart; ommitting commands uses previous

16
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.58 2008-06-25 20:43:14 nicm Exp $ */ /* $Id: cmd.c,v 1.59 2008-06-27 17:10:01 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -338,14 +338,16 @@ cmd_find_client(struct cmd_ctx *ctx, const char *arg)
{ {
struct client *c; struct client *c;
if ((c = arg_parse_client(arg)) == NULL) if (arg == NULL)
c = ctx->curclient; c = ctx->curclient;
if (c == NULL) { else {
if ((c = arg_parse_client(arg)) == NULL) {
if (arg != NULL) if (arg != NULL)
ctx->error(ctx, "client not found: %s", arg); ctx->error(ctx, "client not found: %s", arg);
else else
ctx->error(ctx, "no client found"); ctx->error(ctx, "no client found");
} }
}
return (c); return (c);
} }
@ -354,16 +356,16 @@ cmd_find_session(struct cmd_ctx *ctx, const char *arg)
{ {
struct session *s; struct session *s;
if ((s = arg_parse_session(arg)) == NULL) if (arg == NULL)
s = ctx->cursession;
if (s == NULL)
s = cmd_current_session(ctx); s = cmd_current_session(ctx);
if (s == NULL) { else {
if ((s = arg_parse_session(arg)) == NULL) {
if (arg != NULL) if (arg != NULL)
ctx->error(ctx, "session not found: %s", arg); ctx->error(ctx, "session not found: %s", arg);
else else
ctx->error(ctx, "no session found"); ctx->error(ctx, "no session found");
} }
}
return (s); return (s);
} }