diff -Naur ratpoison/doc/ratpoison.texi ratpoison.lastcolon/doc/ratpoison.texi --- ratpoison/doc/ratpoison.texi Fri Oct 19 08:47:45 2001 +++ ratpoison.lastcolon/doc/ratpoison.texi Thu Nov 8 17:06:54 2001 @@ -260,6 +260,10 @@ @item C-t C-: This allows you to execute a single ratpoison command. address@hidden C-t ; address@hidden C-t C-; +Run the last colon command. + @item C-t ! Run a shell command. @@ -487,6 +491,11 @@ use @command{delete}, but just in case you need to rip the heart out of a misbehaving window this command should do the trick. Also available as @kbd{C-t K}. + address@hidden lastcolon +Run the last colon command. The command is loaded into the input window +first, allowing it to be edited. By default, this is bound to address@hidden ;}. @item lastmsg Display the last message. diff -Naur ratpoison/src/actions.c ratpoison.lastcolon/src/actions.c --- ratpoison/src/actions.c Fri Oct 19 08:47:45 2001 +++ ratpoison.lastcolon/src/actions.c Wed Nov 7 16:07:26 2001 @@ -29,6 +29,7 @@ static rp_action *key_actions; static int key_actions_last; static int key_actions_table_size; +static char *last_colon_command = NULL; static user_command user_commands[] = { {"abort", cmd_abort, arg_VOID}, @@ -78,6 +79,7 @@ {"restart", cmd_restart, arg_VOID}, {"startup_message", cmd_startup_message, arg_STRING}, {"link", cmd_link, arg_STRING}, + {"lastcolon", cmd_last_colon, arg_VOID}, /* Commands to set default behavior. */ {"defbarloc", cmd_defbarloc, arg_STRING}, @@ -291,6 +293,8 @@ add_keybinding (XK_p, RP_CONTROL_MASK, "prev"); add_keybinding (XK_quoteright, 0, "select"); add_keybinding (XK_quoteright, RP_CONTROL_MASK, "select"); + add_keybinding (XK_semicolon, 0, "lastcolon"); + add_keybinding (XK_semicolon, RP_CONTROL_MASK, "lastcolon"); add_keybinding (XK_space, 0, "next"); add_keybinding (XK_space, RP_CONTROL_MASK, "next"); add_keybinding (XK_v, 0, "version"); @@ -878,7 +882,10 @@ if (result) free (result); - free (input); + if (last_colon_command) + free (last_colon_command); + + last_colon_command = input; return NULL; } @@ -1990,5 +1997,12 @@ if (cmd) return command (interactive, cmd); + return NULL; +} + +char * +cmd_last_colon (int interactive, void *data) +{ + cmd_colon (interactive, last_colon_command); return NULL; } diff -Naur ratpoison/src/actions.h ratpoison.lastcolon/src/actions.h --- ratpoison/src/actions.h Fri Oct 19 08:47:45 2001 +++ ratpoison.lastcolon/src/actions.h Tue Nov 6 10:48:57 2001 @@ -103,6 +103,7 @@ char * cmd_startup_message (int interactive, void *data); char * cmd_focuslast (int interactive, void *data); char * cmd_link (int interactive, void *data); +char * cmd_last_colon (int interactive, void *data); /* void cmd_xterm (void *data); */ diff -Naur ratpoison/src/input.c ratpoison.lastcolon/src/input.c --- ratpoison/src/input.c Fri Oct 19 08:47:45 2001 +++ ratpoison.lastcolon/src/input.c Tue Nov 6 11:28:17 2001 @@ -316,7 +316,7 @@ int nbytes; screen_info *s = current_screen (); int cur_len = 0; /* Current length of the string. */ - int allocated_len=100; /* The amount of memory we allocated for str */ + int allocated_len = 100; /* The amount of memory we allocated for str */ KeySym ch; unsigned int modifier; int revert; @@ -324,7 +324,9 @@ char *str; /* Allocate some memory to start with */ - str = (char *) xmalloc ( allocated_len ); + if (preinput != NULL) + allocated_len = strlen (preinput) + 100; + str = (char *) xmalloc (allocated_len); /* load in the preinput */ strcpy (str, preinput);