jkunstle / rpms / vim

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