3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.082
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.082
3ef2ca
Problem:    Using "gf" in a changed buffer suggests adding "!", which is not
3ef2ca
            possible. (Tim Chase)
3ef2ca
Solution:   Pass a flag to check_changed() wether adding ! make sense.
3ef2ca
Files:      src/vim.h, src/ex_cmds2.c, src/proto/ex_cmds2.pro, src/globals.h,
3ef2ca
            src/ex_cmds.c, src/ex_docmd.c
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.081/src/vim.h	2013-11-08 04:30:06.000000000 +0100
3ef2ca
--- src/vim.h	2013-11-09 03:00:00.000000000 +0100
3ef2ca
***************
3ef2ca
*** 1176,1181 ****
3ef2ca
--- 1176,1190 ----
3ef2ca
  #define RESIZE_BOTH	15	/* resize in both directions */
3ef2ca
  
3ef2ca
  /*
3ef2ca
+  * flags for check_changed()
3ef2ca
+  */
3ef2ca
+ #define CCGD_AW		1	/* do autowrite if buffer was changed */
3ef2ca
+ #define CCGD_MULTWIN	2	/* check also when several wins for the buf */
3ef2ca
+ #define CCGD_FORCEIT	4	/* ! used */
3ef2ca
+ #define CCGD_ALLBUF	8	/* may write all buffers */
3ef2ca
+ #define CCGD_EXCMD	16	/* may suggest using ! */
3ef2ca
+ 
3ef2ca
+ /*
3ef2ca
   * "flags" values for option-setting functions.
3ef2ca
   * When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
3ef2ca
   * values, get local value.
3ef2ca
*** ../vim-7.4.081/src/ex_cmds2.c	2013-06-28 20:14:53.000000000 +0200
3ef2ca
--- src/ex_cmds2.c	2013-11-09 03:14:44.000000000 +0100
3ef2ca
***************
3ef2ca
*** 1436,1455 ****
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * return TRUE if buffer was changed and cannot be abandoned.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! check_changed(buf, checkaw, mult_win, forceit, allbuf)
3ef2ca
      buf_T	*buf;
3ef2ca
!     int		checkaw;	/* do autowrite if buffer was changed */
3ef2ca
!     int		mult_win;	/* check also when several wins for the buf */
3ef2ca
!     int		forceit;
3ef2ca
!     int		allbuf UNUSED;	/* may write all buffers */
3ef2ca
  {
3ef2ca
      if (       !forceit
3ef2ca
  	    && bufIsChanged(buf)
3ef2ca
! 	    && (mult_win || buf->b_nwindows <= 1)
3ef2ca
! 	    && (!checkaw || autowrite(buf, forceit) == FAIL))
3ef2ca
      {
3ef2ca
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3ef2ca
  	if ((p_confirm || cmdmod.confirm) && p_write)
3ef2ca
--- 1436,1455 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Return TRUE if buffer was changed and cannot be abandoned.
3ef2ca
!  * For flags use the CCGD_ values.
3ef2ca
   */
3ef2ca
      int
3ef2ca
! check_changed(buf, flags)
3ef2ca
      buf_T	*buf;
3ef2ca
!     int		flags;
3ef2ca
  {
3ef2ca
+     int forceit = (flags & CCGD_FORCEIT);
3ef2ca
+ 
3ef2ca
      if (       !forceit
3ef2ca
  	    && bufIsChanged(buf)
3ef2ca
! 	    && ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1)
3ef2ca
! 	    && (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL))
3ef2ca
      {
3ef2ca
  #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
3ef2ca
  	if ((p_confirm || cmdmod.confirm) && p_write)
3ef2ca
***************
3ef2ca
*** 1457,1463 ****
3ef2ca
  	    buf_T	*buf2;
3ef2ca
  	    int		count = 0;
3ef2ca
  
3ef2ca
! 	    if (allbuf)
3ef2ca
  		for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next)
3ef2ca
  		    if (bufIsChanged(buf2)
3ef2ca
  				     && (buf2->b_ffname != NULL
3ef2ca
--- 1457,1463 ----
3ef2ca
  	    buf_T	*buf2;
3ef2ca
  	    int		count = 0;
3ef2ca
  
3ef2ca
! 	    if (flags & CCGD_ALLBUF)
3ef2ca
  		for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next)
3ef2ca
  		    if (bufIsChanged(buf2)
3ef2ca
  				     && (buf2->b_ffname != NULL
3ef2ca
***************
3ef2ca
*** 1480,1486 ****
3ef2ca
  	    return bufIsChanged(buf);
3ef2ca
  	}
3ef2ca
  #endif
3ef2ca
! 	EMSG(_(e_nowrtmsg));
3ef2ca
  	return TRUE;
3ef2ca
      }
3ef2ca
      return FALSE;
3ef2ca
--- 1480,1489 ----
3ef2ca
  	    return bufIsChanged(buf);
3ef2ca
  	}
3ef2ca
  #endif
3ef2ca
! 	if (flags & CCGD_EXCMD)
3ef2ca
! 	    EMSG(_(e_nowrtmsg));
3ef2ca
! 	else
3ef2ca
! 	    EMSG(_(e_nowrtmsg_nobang));
3ef2ca
  	return TRUE;
3ef2ca
      }
3ef2ca
      return FALSE;
3ef2ca
***************
3ef2ca
*** 1690,1696 ****
3ef2ca
  	{
3ef2ca
  	    /* Try auto-writing the buffer.  If this fails but the buffer no
3ef2ca
  	    * longer exists it's not changed, that's OK. */
3ef2ca
! 	    if (check_changed(buf, p_awa, TRUE, FALSE, TRUE) && buf_valid(buf))
3ef2ca
  		break;	    /* didn't save - still changes */
3ef2ca
  	}
3ef2ca
      }
3ef2ca
--- 1693,1701 ----
3ef2ca
  	{
3ef2ca
  	    /* Try auto-writing the buffer.  If this fails but the buffer no
3ef2ca
  	    * longer exists it's not changed, that's OK. */
3ef2ca
! 	    if (check_changed(buf, (p_awa ? CCGD_AW : 0)
3ef2ca
! 				 | CCGD_MULTWIN
3ef2ca
! 				 | CCGD_ALLBUF) && buf_valid(buf))
3ef2ca
  		break;	    /* didn't save - still changes */
3ef2ca
  	}
3ef2ca
      }
3ef2ca
***************
3ef2ca
*** 2274,2280 ****
3ef2ca
  		vim_free(p);
3ef2ca
  	    }
3ef2ca
  	    if ((!P_HID(curbuf) || !other)
3ef2ca
! 		  && check_changed(curbuf, TRUE, !other, eap->forceit, FALSE))
3ef2ca
  		return;
3ef2ca
  	}
3ef2ca
  
3ef2ca
--- 2279,2288 ----
3ef2ca
  		vim_free(p);
3ef2ca
  	    }
3ef2ca
  	    if ((!P_HID(curbuf) || !other)
3ef2ca
! 		  && check_changed(curbuf, CCGD_AW
3ef2ca
! 					 | (other ? 0 : CCGD_MULTWIN)
3ef2ca
! 					 | (eap->forceit ? CCGD_FORCEIT : 0)
3ef2ca
! 					 | CCGD_EXCMD))
3ef2ca
  		return;
3ef2ca
  	}
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 2315,2321 ****
3ef2ca
       */
3ef2ca
      if (       P_HID(curbuf)
3ef2ca
  	    || eap->cmdidx == CMD_snext
3ef2ca
! 	    || !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE))
3ef2ca
      {
3ef2ca
  	if (*eap->arg != NUL)		    /* redefine file list */
3ef2ca
  	{
3ef2ca
--- 2323,2331 ----
3ef2ca
       */
3ef2ca
      if (       P_HID(curbuf)
3ef2ca
  	    || eap->cmdidx == CMD_snext
3ef2ca
! 	    || !check_changed(curbuf, CCGD_AW
3ef2ca
! 				    | (eap->forceit ? CCGD_FORCEIT : 0)
3ef2ca
! 				    | CCGD_EXCMD))
3ef2ca
      {
3ef2ca
  	if (*eap->arg != NUL)		    /* redefine file list */
3ef2ca
  	{
3ef2ca
***************
3ef2ca
*** 2458,2464 ****
3ef2ca
      if (eap->cmdidx == CMD_windo
3ef2ca
  	    || eap->cmdidx == CMD_tabdo
3ef2ca
  	    || P_HID(curbuf)
3ef2ca
! 	    || !check_changed(curbuf, TRUE, FALSE, eap->forceit, FALSE))
3ef2ca
      {
3ef2ca
  	/* start at the first argument/window/buffer */
3ef2ca
  	i = 0;
3ef2ca
--- 2468,2476 ----
3ef2ca
      if (eap->cmdidx == CMD_windo
3ef2ca
  	    || eap->cmdidx == CMD_tabdo
3ef2ca
  	    || P_HID(curbuf)
3ef2ca
! 	    || !check_changed(curbuf, CCGD_AW
3ef2ca
! 				    | (eap->forceit ? CCGD_FORCEIT : 0)
3ef2ca
! 				    | CCGD_EXCMD))
3ef2ca
      {
3ef2ca
  	/* start at the first argument/window/buffer */
3ef2ca
  	i = 0;
3ef2ca
*** ../vim-7.4.081/src/proto/ex_cmds2.pro	2013-08-10 13:37:10.000000000 +0200
3ef2ca
--- src/proto/ex_cmds2.pro	2013-11-09 03:18:02.000000000 +0100
3ef2ca
***************
3ef2ca
*** 35,41 ****
3ef2ca
  int prof_def_func __ARGS((void));
3ef2ca
  int autowrite __ARGS((buf_T *buf, int forceit));
3ef2ca
  void autowrite_all __ARGS((void));
3ef2ca
! int check_changed __ARGS((buf_T *buf, int checkaw, int mult_win, int forceit, int allbuf));
3ef2ca
  void browse_save_fname __ARGS((buf_T *buf));
3ef2ca
  void dialog_changed __ARGS((buf_T *buf, int checkall));
3ef2ca
  int can_abandon __ARGS((buf_T *buf, int forceit));
3ef2ca
--- 35,41 ----
3ef2ca
  int prof_def_func __ARGS((void));
3ef2ca
  int autowrite __ARGS((buf_T *buf, int forceit));
3ef2ca
  void autowrite_all __ARGS((void));
3ef2ca
! int check_changed __ARGS((buf_T *buf, int flags));
3ef2ca
  void browse_save_fname __ARGS((buf_T *buf));
3ef2ca
  void dialog_changed __ARGS((buf_T *buf, int checkall));
3ef2ca
  int can_abandon __ARGS((buf_T *buf, int forceit));
3ef2ca
*** ../vim-7.4.081/src/globals.h	2013-07-04 19:53:44.000000000 +0200
3ef2ca
--- src/globals.h	2013-11-09 03:05:54.000000000 +0100
3ef2ca
***************
3ef2ca
*** 1490,1495 ****
3ef2ca
--- 1490,1496 ----
3ef2ca
  EXTERN char_u e_notopen[]	INIT(= N_("E484: Can't open file %s"));
3ef2ca
  EXTERN char_u e_notread[]	INIT(= N_("E485: Can't read file %s"));
3ef2ca
  EXTERN char_u e_nowrtmsg[]	INIT(= N_("E37: No write since last change (add ! to override)"));
3ef2ca
+ EXTERN char_u e_nowrtmsg_nobang[]   INIT(= N_("E37: No write since last change"));
3ef2ca
  EXTERN char_u e_null[]		INIT(= N_("E38: Null argument"));
3ef2ca
  #ifdef FEAT_DIGRAPHS
3ef2ca
  EXTERN char_u e_number_exp[]	INIT(= N_("E39: Number expected"));
3ef2ca
*** ../vim-7.4.081/src/ex_cmds.c	2013-10-02 18:43:00.000000000 +0200
3ef2ca
--- src/ex_cmds.c	2013-11-09 03:19:25.000000000 +0100
3ef2ca
***************
3ef2ca
*** 3253,3260 ****
3ef2ca
      if (  ((!other_file && !(flags & ECMD_OLDBUF))
3ef2ca
  	    || (curbuf->b_nwindows == 1
3ef2ca
  		&& !(flags & (ECMD_HIDE | ECMD_ADDBUF))))
3ef2ca
! 	&& check_changed(curbuf, p_awa, !other_file,
3ef2ca
! 					(flags & ECMD_FORCEIT), FALSE))
3ef2ca
      {
3ef2ca
  	if (fnum == 0 && other_file && ffname != NULL)
3ef2ca
  	    (void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
3ef2ca
--- 3253,3262 ----
3ef2ca
      if (  ((!other_file && !(flags & ECMD_OLDBUF))
3ef2ca
  	    || (curbuf->b_nwindows == 1
3ef2ca
  		&& !(flags & (ECMD_HIDE | ECMD_ADDBUF))))
3ef2ca
! 	&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
3ef2ca
! 			       | (other_file ? 0 : CCGD_MULTWIN)
3ef2ca
! 			       | ((flags & ECMD_FORCEIT) ? CCGD_FORCEIT : 0)
3ef2ca
! 			       | (eap == NULL ? 0 : CCGD_EXCMD)))
3ef2ca
      {
3ef2ca
  	if (fnum == 0 && other_file && ffname != NULL)
3ef2ca
  	    (void)setaltfname(ffname, sfname, newlnum < 0 ? 0 : newlnum);
3ef2ca
***************
3ef2ca
*** 7664,7670 ****
3ef2ca
  # ifdef FEAT_WINDOWS
3ef2ca
  	    ++emsg_off;
3ef2ca
  # endif
3ef2ca
! 	    split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE);
3ef2ca
  # ifdef FEAT_WINDOWS
3ef2ca
  	    --emsg_off;
3ef2ca
  # else
3ef2ca
--- 7666,7672 ----
3ef2ca
  # ifdef FEAT_WINDOWS
3ef2ca
  	    ++emsg_off;
3ef2ca
  # endif
3ef2ca
! 	    split = check_changed(curbuf, CCGD_AW | CCGD_EXCMD);
3ef2ca
  # ifdef FEAT_WINDOWS
3ef2ca
  	    --emsg_off;
3ef2ca
  # else
3ef2ca
*** ../vim-7.4.081/src/ex_docmd.c	2013-11-08 04:30:06.000000000 +0100
3ef2ca
--- src/ex_docmd.c	2013-11-09 03:30:10.000000000 +0100
3ef2ca
***************
3ef2ca
*** 6565,6571 ****
3ef2ca
      if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3ef2ca
  	exiting = TRUE;
3ef2ca
      if ((!P_HID(curbuf)
3ef2ca
! 		&& check_changed(curbuf, p_awa, FALSE, eap->forceit, FALSE))
3ef2ca
  	    || check_more(TRUE, eap->forceit) == FAIL
3ef2ca
  	    || (only_one_window() && check_changed_any(eap->forceit)))
3ef2ca
      {
3ef2ca
--- 6565,6573 ----
3ef2ca
      if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3ef2ca
  	exiting = TRUE;
3ef2ca
      if ((!P_HID(curbuf)
3ef2ca
! 		&& check_changed(curbuf, (p_awa ? CCGD_AW : 0)
3ef2ca
! 				       | (eap->forceit ? CCGD_FORCEIT : 0)
3ef2ca
! 				       | CCGD_EXCMD))
3ef2ca
  	    || check_more(TRUE, eap->forceit) == FAIL
3ef2ca
  	    || (only_one_window() && check_changed_any(eap->forceit)))
3ef2ca
      {
3ef2ca
***************
3ef2ca
*** 7099,7105 ****
3ef2ca
      if (!P_HID(curbuf) && !split)
3ef2ca
      {
3ef2ca
  	++emsg_off;
3ef2ca
! 	split = check_changed(curbuf, TRUE, FALSE, FALSE, FALSE);
3ef2ca
  	--emsg_off;
3ef2ca
      }
3ef2ca
      if (split)
3ef2ca
--- 7101,7107 ----
3ef2ca
      if (!P_HID(curbuf) && !split)
3ef2ca
      {
3ef2ca
  	++emsg_off;
3ef2ca
! 	split = check_changed(curbuf, CCGD_AW);
3ef2ca
  	--emsg_off;
3ef2ca
      }
3ef2ca
      if (split)
3ef2ca
***************
3ef2ca
*** 7361,7367 ****
3ef2ca
  {
3ef2ca
      /* Set recoverymode right away to avoid the ATTENTION prompt. */
3ef2ca
      recoverymode = TRUE;
3ef2ca
!     if (!check_changed(curbuf, p_awa, TRUE, eap->forceit, FALSE)
3ef2ca
  	    && (*eap->arg == NUL
3ef2ca
  			     || setfname(curbuf, eap->arg, NULL, TRUE) == OK))
3ef2ca
  	ml_recover();
3ef2ca
--- 7363,7373 ----
3ef2ca
  {
3ef2ca
      /* Set recoverymode right away to avoid the ATTENTION prompt. */
3ef2ca
      recoverymode = TRUE;
3ef2ca
!     if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0)
3ef2ca
! 			     | CCGD_MULTWIN
3ef2ca
! 			     | (eap->forceit ? CCGD_FORCEIT : 0)
3ef2ca
! 			     | CCGD_EXCMD)
3ef2ca
! 
3ef2ca
  	    && (*eap->arg == NUL
3ef2ca
  			     || setfname(curbuf, eap->arg, NULL, TRUE) == OK))
3ef2ca
  	ml_recover();
3ef2ca
*** ../vim-7.4.081/src/version.c	2013-11-09 02:32:15.000000000 +0100
3ef2ca
--- src/version.c	2013-11-09 03:26:06.000000000 +0100
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     82,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
People who want to share their religious views with you
3ef2ca
almost never want you to share yours with them.
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///