To: vim-dev@vim.org Subject: Patch 6.2.485 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.2.485 Problem: A BufWriteCmd autocommand cannot know if "!" was used or not. (Hari Krishna Dara) Solution: Add the v:cmdbang variable. Files: runtime/doc/eval.txt, src/eval.c, src/proto/eval.pro, src/fileio.c, src/vim.h *** ../vim-6.2.484/runtime/doc/eval.txt Sun Apr 4 12:34:29 2004 --- runtime/doc/eval.txt Tue Apr 20 12:41:08 2004 *************** *** 1,4 **** ! *eval.txt* For Vim version 6.2. Last change: 2004 Mar 31 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 6.2. Last change: 2004 Apr 20 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 578,583 **** --- 579,590 ---- the argument for the ":hardcopy" command. This can be used in 'printexpr'. + *v:cmdbang* *cmdbang-variable* + v:cmdbang Set like v:cmdarg for a file read/write command. When a "!" + was used the value is 1, otherwise it is 0. Note that this + can only be used in autocommands. For user commands || + can be used. + *v:count* *count-variable* v:count The count given for the last Normal mode command. Can be used to get the count before a mapping. Read-only. Example: > *** ../vim-6.2.484/src/eval.c Wed Apr 14 21:41:32 2004 --- src/eval.c Tue Apr 20 10:37:31 2004 *************** *** 230,235 **** --- 230,236 ---- {"exception", sizeof("exception") - 1, NULL, VAR_STRING, VV_RO}, {"throwpoint", sizeof("throwpoint") - 1, NULL, VAR_STRING, VV_RO}, {"register", sizeof("register") - 1, NULL, VAR_STRING, VV_RO}, + {"cmdbang", sizeof("cmdbang") - 1, NULL, VAR_NUMBER, VV_RO}, }; static int eval0 __ARGS((char_u *arg, VAR retvar, char_u **nextcmd, int evaluate)); *************** *** 7846,7851 **** --- 7847,7862 ---- } /* + * Get number v: variable value; + */ + long + get_vim_var_nr(idx) + int idx; + { + return (long)vimvars[idx].val; + } + + /* * Set v:count, v:count1 and v:prevcount. */ void *** ../vim-6.2.484/src/proto/eval.pro Sun Oct 12 20:20:38 2003 --- src/proto/eval.pro Tue Apr 20 10:45:33 2004 *************** *** 28,33 **** --- 28,34 ---- char_u *get_function_name __ARGS((expand_T *xp, int idx)); char_u *get_expr_name __ARGS((expand_T *xp, int idx)); void set_vim_var_nr __ARGS((int idx, long val)); + long get_vim_var_nr __ARGS((int idx)); void set_vcount __ARGS((long count, long count1)); void set_vim_var_string __ARGS((int idx, char_u *val, int len)); void set_reg_var __ARGS((int c)); *** ../vim-6.2.484/src/fileio.c Mon Apr 19 20:26:42 2004 --- src/fileio.c Tue Apr 20 10:40:44 2004 *************** *** 7412,7417 **** --- 7425,7431 ---- scid_T save_current_SID; void *save_funccalp; char_u *save_cmdarg; + long save_cmdbang; #endif static int filechangeshell_busy = FALSE; *************** *** 7624,7631 **** --- 7638,7649 ---- { #ifdef FEAT_EVAL /* set v:cmdarg (only when there is a matching pattern) */ + save_cmdbang = get_vim_var_nr(VV_CMDBANG); if (eap != NULL) + { save_cmdarg = set_cmdarg(eap, NULL); + set_vim_var_nr(VV_CMDBANG, (long)eap->forceit); + } else save_cmdarg = NULL; /* avoid gcc warning */ #endif *************** *** 7640,7646 **** --- 7658,7667 ---- DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT); #ifdef FEAT_EVAL if (eap != NULL) + { (void)set_cmdarg(NULL, save_cmdarg); + set_vim_var_nr(VV_CMDBANG, save_cmdbang); + } #endif } *** ../vim-6.2.484/src/vim.h Fri Apr 2 14:07:44 2004 --- src/vim.h Tue Apr 20 10:28:42 2004 *************** *** 1469,1475 **** #define VV_EXCEPTION 29 #define VV_THROWPOINT 30 #define VV_REG 31 ! #define VV_LEN 32 /* number of v: vars */ #ifdef FEAT_CLIPBOARD --- 1469,1476 ---- #define VV_EXCEPTION 29 #define VV_THROWPOINT 30 #define VV_REG 31 ! #define VV_CMDBANG 32 ! #define VV_LEN 33 /* number of v: vars */ #ifdef FEAT_CLIPBOARD *** ../vim-6.2.484/src/version.c Mon Apr 19 23:00:46 2004 --- src/version.c Tue Apr 20 12:49:17 2004 *************** *** 639,640 **** --- 639,642 ---- { /* Add new patch number below this line */ + /**/ + 485, /**/ -- Mynd you, m00se bites Kan be pretty nasti ... "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///