> Here is a patch to Vim that adds a , register which is basically access to > Vim's > internal 'redo buffer' used when '.' is used. At a quick look, it seems to > work. > You can thus save your '.' commands to another register and replay them later: > > :let @a=@, > @a > > I believe @, will have pretty much the same functionality as . except that it > won't automatically change the count or the register number like . does (nor > will > this happen if you save to another register, of course). > > I wonder what Bram thinks about including this functionality in standard Vim? > I > think it would be useful. What do others think? > > Also, I haven't tested much. Testing and consequent feedback from others > would be > worthwhile. There may be issues with things not being escaped which should > be, etc.
My apologies; that was a poor patch. And I thought I'd tested @, but trying it again showed it didn't work. I have now made sure it doesn't work. The . command is for that purpose, and implementing it isn't trivial! Revised more robust patch attached. Ben. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
Index: runtime/doc/change.txt =================================================================== --- runtime/doc/change.txt (revision 607) +++ runtime/doc/change.txt (working copy) @@ -1013,7 +1013,7 @@ 2. 10 numbered registers "0 to "9 3. The small delete register "- 4. 26 named registers "a to "z or "A to "Z -5. four read-only registers ":, "., "% and "# +5. five read-only registers ":, "., ",, "% and "# 6. the expression register "= 7. The selection and drop registers "*, "+ and "~ 8. The black hole register "_ @@ -1068,6 +1068,9 @@ doesn't work with CTRL-R on the command-line. It works a bit differently, like inserting the text instead of putting it ('textwidth' and other options affect what is inserted). + *quote_,* *quote,* + ", Contains the commands that will be executed if the "." normal + command is used. *quote_%* *quote%* "% Contains the name of the current file. *quote_#* *quote#* Index: src/proto/ops.pro =================================================================== --- src/proto/ops.pro (revision 607) +++ src/proto/ops.pro (working copy) @@ -18,7 +18,7 @@ int yank_register_mline __ARGS((int regname)); int do_record __ARGS((int c)); int do_execreg __ARGS((int regname, int colon, int addcr, int silent)); -int insert_reg __ARGS((int regname, int literally)); +int insert_reg __ARGS((int regname, int literally, int insert_mode)); int get_spec_reg __ARGS((int regname, char_u **argp, int *allocated, int errmsg)); int cmdline_paste_reg __ARGS((int regname, int literally, int remcr)); void adjust_clip_reg __ARGS((int *rp)); Index: src/proto/getchar.pro =================================================================== --- src/proto/getchar.pro (revision 607) +++ src/proto/getchar.pro (working copy) @@ -2,6 +2,7 @@ void free_buff __ARGS((struct buffheader *buf)); char_u *get_recorded __ARGS((void)); char_u *get_inserted __ARGS((void)); +char_u *get_old_inserted __ARGS((void)); int stuff_empty __ARGS((void)); void typeahead_noflush __ARGS((int c)); void flush_buffers __ARGS((int typeahead)); Index: src/getchar.c =================================================================== --- src/getchar.c (revision 607) +++ src/getchar.c (working copy) @@ -225,6 +225,16 @@ } /* + * Return the contents of the old redo buffer as a single string. + * K_SPECIAL and CSI in the returned string are escaped. + */ + char_u * +get_old_inserted() +{ + return(get_buffcont(&old_redobuff, FALSE)); +} + +/* * Add string "s" after the current block of buffer "buf". * K_SPECIAL and CSI should have been escaped already. */ Index: src/edit.c =================================================================== --- src/edit.c (revision 607) +++ src/edit.c (working copy) @@ -7626,7 +7626,7 @@ do_put(regname, BACKWARD, 1L, (literally == Ctrl_P ? PUT_FIXINDENT : 0) | PUT_CURSEND); } - else if (insert_reg(regname, literally) == FAIL) + else if (insert_reg(regname, literally, TRUE) == FAIL) { vim_beep(); need_redraw = TRUE; /* remove the '"' */ Index: src/normal.c =================================================================== --- src/normal.c (revision 607) +++ src/normal.c (working copy) @@ -2427,7 +2427,7 @@ if ((State & INSERT) || !mouse_has(MOUSE_NORMAL)) { if (regname == '.') - insert_reg(regname, TRUE); + insert_reg(regname, TRUE, FALSE); else { #ifdef FEAT_CLIPBOARD @@ -2435,7 +2435,7 @@ regname = '*'; #endif if ((State & REPLACE_FLAG) && !yank_register_mline(regname)) - insert_reg(regname, TRUE); + insert_reg(regname, TRUE, FALSE); else { do_put(regname, BACKWARD, 1L, fixindent | PUT_CURSEND); Index: src/ops.c =================================================================== --- src/ops.c (revision 607) +++ src/ops.c (working copy) @@ -818,9 +818,9 @@ if ( (regname > 0 && ASCII_ISALNUM(regname)) || (!writing && vim_strchr((char_u *) #ifdef FEAT_EVAL - "/.%#:=" + "/.,%#:=" #else - "/.%#:" + "/.,%#:" #endif , regname) != NULL) || regname == '"' @@ -1146,7 +1146,8 @@ regname = lastc; } /* check for valid regname */ - if (regname == '%' || regname == '#' || !valid_yank_reg(regname, FALSE)) + if (regname == '%' || regname == '#' || + regname == ',' || !valid_yank_reg(regname, FALSE)) { emsg_invreg(regname); return FAIL; @@ -1313,9 +1314,10 @@ * return FAIL for failure, OK otherwise */ int -insert_reg(regname, literally) +insert_reg(regname, literally, insert_mode) int regname; int literally; /* insert literally, not as if typed */ + int insert_mode; /* in insert mode; use old redo buffer */ { long i; int retval = OK; @@ -1339,6 +1341,7 @@ regname = may_get_selection(regname); #endif + if (insert_mode && regname == ',') regname = ';'; if (regname == '.') /* insert last inserted text */ retval = stuff_inserted(NUL, 1L, TRUE); else if (get_spec_reg(regname, &arg, &allocated, TRUE)) @@ -1469,6 +1472,15 @@ EMSG(_(e_noinstext)); return TRUE; + case ',': /* redo buffer ('.' command) */ + *argp = get_inserted(); + return TRUE; + + case ';': /* old redo buffer ('.' command), + * internal use only */ + *argp = get_old_inserted(); + return TRUE; + #ifdef FEAT_SEARCHPATH case Ctrl_F: /* Filename under cursor */ case Ctrl_P: /* Path under cursor, expand via "path" */ @@ -5758,6 +5770,7 @@ case ':': /* last command line */ case '/': /* last search-pattern */ case '.': /* last inserted text */ + case ',': /* redo buffer */ #ifdef FEAT_SEARCHPATH case Ctrl_F: /* Filename under cursor */ case Ctrl_P: /* Path under cursor, expand via "path" */