jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.073

dcaee6
To: vim_dev@googlegroups.com
dcaee6
Subject: Patch 7.4.073
dcaee6
Fcc: outbox
dcaee6
From: Bram Moolenaar <Bram@moolenaar.net>
dcaee6
Mime-Version: 1.0
dcaee6
Content-Type: text/plain; charset=UTF-8
dcaee6
Content-Transfer-Encoding: 8bit
dcaee6
------------
dcaee6
dcaee6
Patch 7.4.073
dcaee6
Problem:    Setting undolevels for one buffer changes undo in another.
dcaee6
Solution:   Make 'undolevels' a global-local option. (Christian Brabandt)
dcaee6
Files:      runtime/doc/options.txt, src/buffer.c, src/option.c, src/option.h
dcaee6
            src/structs.h, src/undo.c
dcaee6
dcaee6
dcaee6
*** ../vim-7.4.072/runtime/doc/options.txt	2013-08-10 13:24:57.000000000 +0200
dcaee6
--- runtime/doc/options.txt	2013-11-06 04:18:43.000000000 +0100
dcaee6
***************
dcaee6
*** 7594,7600 ****
dcaee6
  						*'undolevels'* *'ul'*
dcaee6
  'undolevels' 'ul'	number	(default 100, 1000 for Unix, VMS,
dcaee6
  						Win32 and OS/2)
dcaee6
! 			global
dcaee6
  			{not in Vi}
dcaee6
  	Maximum number of changes that can be undone.  Since undo information
dcaee6
  	is kept in memory, higher numbers will cause more memory to be used
dcaee6
--- 7594,7600 ----
dcaee6
  						*'undolevels'* *'ul'*
dcaee6
  'undolevels' 'ul'	number	(default 100, 1000 for Unix, VMS,
dcaee6
  						Win32 and OS/2)
dcaee6
! 			global or local to buffer |global-local|
dcaee6
  			{not in Vi}
dcaee6
  	Maximum number of changes that can be undone.  Since undo information
dcaee6
  	is kept in memory, higher numbers will cause more memory to be used
dcaee6
***************
dcaee6
*** 7605,7612 ****
dcaee6
  <	But you can also get Vi compatibility by including the 'u' flag in
dcaee6
  	'cpoptions', and still be able to use CTRL-R to repeat undo.
dcaee6
  	Also see |undo-two-ways|.
dcaee6
! 	Set to a negative number for no undo at all: >
dcaee6
! 		set ul=-1
dcaee6
  <	This helps when you run out of memory for a single change.
dcaee6
  	Also see |clear-undo|.
dcaee6
  
dcaee6
--- 7605,7613 ----
dcaee6
  <	But you can also get Vi compatibility by including the 'u' flag in
dcaee6
  	'cpoptions', and still be able to use CTRL-R to repeat undo.
dcaee6
  	Also see |undo-two-ways|.
dcaee6
! 	Set to -1 for no undo at all.  You might want to do this only for the
dcaee6
! 	current buffer: >
dcaee6
! 		setlocal ul=-1
dcaee6
  <	This helps when you run out of memory for a single change.
dcaee6
  	Also see |clear-undo|.
dcaee6
  
dcaee6
*** ../vim-7.4.072/src/buffer.c	2013-11-05 17:40:47.000000000 +0100
dcaee6
--- src/buffer.c	2013-11-06 04:25:27.000000000 +0100
dcaee6
***************
dcaee6
*** 1949,1954 ****
dcaee6
--- 1949,1955 ----
dcaee6
      clear_string_option(&buf->b_p_qe);
dcaee6
  #endif
dcaee6
      buf->b_p_ar = -1;
dcaee6
+     buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
dcaee6
  }
dcaee6
  
dcaee6
  /*
dcaee6
*** ../vim-7.4.072/src/option.c	2013-11-05 07:12:59.000000000 +0100
dcaee6
--- src/option.c	2013-11-06 04:34:23.000000000 +0100
dcaee6
***************
dcaee6
*** 234,239 ****
dcaee6
--- 234,240 ----
dcaee6
  #ifdef FEAT_STL_OPT
dcaee6
  # define PV_STL		OPT_BOTH(OPT_WIN(WV_STL))
dcaee6
  #endif
dcaee6
+ #define PV_UL		OPT_BOTH(OPT_BUF(BV_UL))
dcaee6
  #ifdef FEAT_WINDOWS
dcaee6
  # define PV_WFH		OPT_WIN(WV_WFH)
dcaee6
  #endif
dcaee6
***************
dcaee6
*** 2683,2689 ****
dcaee6
  #endif
dcaee6
  			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
dcaee6
      {"undolevels",  "ul",   P_NUM|P_VI_DEF,
dcaee6
! 			    (char_u *)&p_ul, PV_NONE,
dcaee6
  			    {
dcaee6
  #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
dcaee6
  			    (char_u *)1000L,
dcaee6
--- 2684,2690 ----
dcaee6
  #endif
dcaee6
  			    {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
dcaee6
      {"undolevels",  "ul",   P_NUM|P_VI_DEF,
dcaee6
! 			    (char_u *)&p_ul, PV_UL,
dcaee6
  			    {
dcaee6
  #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
dcaee6
  			    (char_u *)1000L,
dcaee6
***************
dcaee6
*** 3313,3318 ****
dcaee6
--- 3314,3320 ----
dcaee6
  
dcaee6
      curbuf->b_p_initialized = TRUE;
dcaee6
      curbuf->b_p_ar = -1;	/* no local 'autoread' value */
dcaee6
+     curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
dcaee6
      check_buf_options(curbuf);
dcaee6
      check_win_options(curwin);
dcaee6
      check_options();
dcaee6
***************
dcaee6
*** 4512,4519 ****
dcaee6
  						((flags & P_VI_DEF) || cp_val)
dcaee6
  						 ?  VI_DEFAULT : VIM_DEFAULT];
dcaee6
  			else if (nextchar == '<')
dcaee6
! 			    value = *(long *)get_varp_scope(&(options[opt_idx]),
dcaee6
! 								  OPT_GLOBAL);
dcaee6
  			else if (((long *)varp == &p_wc
dcaee6
  				    || (long *)varp == &p_wcm)
dcaee6
  				&& (*arg == '<'
dcaee6
--- 4514,4529 ----
dcaee6
  						((flags & P_VI_DEF) || cp_val)
dcaee6
  						 ?  VI_DEFAULT : VIM_DEFAULT];
dcaee6
  			else if (nextchar == '<')
dcaee6
! 			{
dcaee6
! 			    /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
dcaee6
! 			     * use the global value. */
dcaee6
! 			    if ((long *)varp == &curbuf->b_p_ul
dcaee6
! 						    && opt_flags == OPT_LOCAL)
dcaee6
! 				value = NO_LOCAL_UNDOLEVEL;
dcaee6
! 			    else
dcaee6
! 				value = *(long *)get_varp_scope(
dcaee6
! 					     &(options[opt_idx]), OPT_GLOBAL);
dcaee6
! 			}
dcaee6
  			else if (((long *)varp == &p_wc
dcaee6
  				    || (long *)varp == &p_wcm)
dcaee6
  				&& (*arg == '<'
dcaee6
***************
dcaee6
*** 8487,8492 ****
dcaee6
--- 8497,8509 ----
dcaee6
  	u_sync(TRUE);
dcaee6
  	p_ul = value;
dcaee6
      }
dcaee6
+     else if (pp == &curbuf->b_p_ul)
dcaee6
+     {
dcaee6
+ 	/* use the old value, otherwise u_sync() may not work properly */
dcaee6
+ 	curbuf->b_p_ul = old_value;
dcaee6
+ 	u_sync(TRUE);
dcaee6
+ 	curbuf->b_p_ul = value;
dcaee6
+     }
dcaee6
  
dcaee6
  #ifdef FEAT_LINEBREAK
dcaee6
      /* 'numberwidth' must be positive */
dcaee6
***************
dcaee6
*** 9720,9726 ****
dcaee6
  /*
dcaee6
   * Unset local option value, similar to ":set opt<".
dcaee6
   */
dcaee6
- 
dcaee6
      void
dcaee6
  unset_global_local_option(name, from)
dcaee6
      char_u	*name;
dcaee6
--- 9737,9742 ----
dcaee6
***************
dcaee6
*** 9793,9798 ****
dcaee6
--- 9809,9817 ----
dcaee6
  	    clear_string_option(&((win_T *)from)->w_p_stl);
dcaee6
  	    break;
dcaee6
  #endif
dcaee6
+ 	case PV_UL:
dcaee6
+ 	    buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
dcaee6
+ 	    break;
dcaee6
      }
dcaee6
  }
dcaee6
  
dcaee6
***************
dcaee6
*** 9841,9846 ****
dcaee6
--- 9860,9866 ----
dcaee6
  #ifdef FEAT_STL_OPT
dcaee6
  	    case PV_STL:  return (char_u *)&(curwin->w_p_stl);
dcaee6
  #endif
dcaee6
+ 	    case PV_UL:   return (char_u *)&(curbuf->b_p_ul);
dcaee6
  	}
dcaee6
  	return NULL; /* "cannot happen" */
dcaee6
      }
dcaee6
***************
dcaee6
*** 9905,9910 ****
dcaee6
--- 9925,9932 ----
dcaee6
  	case PV_STL:	return *curwin->w_p_stl != NUL
dcaee6
  				    ? (char_u *)&(curwin->w_p_stl) : p->var;
dcaee6
  #endif
dcaee6
+ 	case PV_UL:	return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
dcaee6
+ 				    ? (char_u *)&(curbuf->b_p_ul) : p->var;
dcaee6
  
dcaee6
  #ifdef FEAT_ARABIC
dcaee6
  	case PV_ARAB:	return (char_u *)&(curwin->w_p_arab);
dcaee6
***************
dcaee6
*** 10445,10450 ****
dcaee6
--- 10467,10473 ----
dcaee6
  	    /* options that are normally global but also have a local value
dcaee6
  	     * are not copied, start using the global value */
dcaee6
  	    buf->b_p_ar = -1;
dcaee6
+ 	    buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
dcaee6
  #ifdef FEAT_QUICKFIX
dcaee6
  	    buf->b_p_gp = empty_option;
dcaee6
  	    buf->b_p_mp = empty_option;
dcaee6
*** ../vim-7.4.072/src/option.h	2013-06-26 18:41:39.000000000 +0200
dcaee6
--- src/option.h	2013-11-06 04:17:40.000000000 +0100
dcaee6
***************
dcaee6
*** 1031,1036 ****
dcaee6
--- 1031,1037 ----
dcaee6
      , BV_TW
dcaee6
      , BV_TX
dcaee6
      , BV_UDF
dcaee6
+     , BV_UL
dcaee6
      , BV_WM
dcaee6
      , BV_COUNT	    /* must be the last one */
dcaee6
  };
dcaee6
***************
dcaee6
*** 1109,1111 ****
dcaee6
--- 1110,1115 ----
dcaee6
      , WV_WRAP
dcaee6
      , WV_COUNT	    /* must be the last one */
dcaee6
  };
dcaee6
+ 
dcaee6
+ /* Value for b_p_ul indicating the global value must be used. */
dcaee6
+ #define NO_LOCAL_UNDOLEVEL -123456
dcaee6
*** ../vim-7.4.072/src/structs.h	2013-11-05 07:12:59.000000000 +0100
dcaee6
--- src/structs.h	2013-11-06 04:26:17.000000000 +0100
dcaee6
***************
dcaee6
*** 1627,1632 ****
dcaee6
--- 1627,1633 ----
dcaee6
      char_u	*b_p_dict;	/* 'dictionary' local value */
dcaee6
      char_u	*b_p_tsr;	/* 'thesaurus' local value */
dcaee6
  #endif
dcaee6
+     long	b_p_ul;		/* 'undolevels' local value */
dcaee6
  #ifdef FEAT_PERSISTENT_UNDO
dcaee6
      int		b_p_udf;	/* 'undofile' */
dcaee6
  #endif
dcaee6
*** ../vim-7.4.072/src/undo.c	2013-09-08 15:40:45.000000000 +0200
dcaee6
--- src/undo.c	2013-11-06 04:33:12.000000000 +0100
dcaee6
***************
dcaee6
*** 83,88 ****
dcaee6
--- 83,89 ----
dcaee6
  
dcaee6
  #include "vim.h"
dcaee6
  
dcaee6
+ static long get_undolevel __ARGS((void));
dcaee6
  static void u_unch_branch __ARGS((u_header_T *uhp));
dcaee6
  static u_entry_T *u_get_headentry __ARGS((void));
dcaee6
  static void u_getbot __ARGS((void));
dcaee6
***************
dcaee6
*** 336,341 ****
dcaee6
--- 337,353 ----
dcaee6
  }
dcaee6
  
dcaee6
  /*
dcaee6
+  * Get the undolevle value for the current buffer.
dcaee6
+  */
dcaee6
+     static long
dcaee6
+ get_undolevel()
dcaee6
+ {
dcaee6
+     if (curbuf->b_p_ul == NO_LOCAL_UNDOLEVEL)
dcaee6
+ 	return p_ul;
dcaee6
+     return curbuf->b_p_ul;
dcaee6
+ }
dcaee6
+ 
dcaee6
+ /*
dcaee6
   * Common code for various ways to save text before a change.
dcaee6
   * "top" is the line above the first changed line.
dcaee6
   * "bot" is the line below the last changed line.
dcaee6
***************
dcaee6
*** 419,425 ****
dcaee6
  	curbuf->b_new_change = TRUE;
dcaee6
  #endif
dcaee6
  
dcaee6
! 	if (p_ul >= 0)
dcaee6
  	{
dcaee6
  	    /*
dcaee6
  	     * Make a new header entry.  Do this first so that we don't mess
dcaee6
--- 431,437 ----
dcaee6
  	curbuf->b_new_change = TRUE;
dcaee6
  #endif
dcaee6
  
dcaee6
! 	if (get_undolevel() >= 0)
dcaee6
  	{
dcaee6
  	    /*
dcaee6
  	     * Make a new header entry.  Do this first so that we don't mess
dcaee6
***************
dcaee6
*** 449,455 ****
dcaee6
  	/*
dcaee6
  	 * free headers to keep the size right
dcaee6
  	 */
dcaee6
! 	while (curbuf->b_u_numhead > p_ul && curbuf->b_u_oldhead != NULL)
dcaee6
  	{
dcaee6
  	    u_header_T	    *uhfree = curbuf->b_u_oldhead;
dcaee6
  
dcaee6
--- 461,468 ----
dcaee6
  	/*
dcaee6
  	 * free headers to keep the size right
dcaee6
  	 */
dcaee6
! 	while (curbuf->b_u_numhead > get_undolevel()
dcaee6
! 					       && curbuf->b_u_oldhead != NULL)
dcaee6
  	{
dcaee6
  	    u_header_T	    *uhfree = curbuf->b_u_oldhead;
dcaee6
  
dcaee6
***************
dcaee6
*** 530,536 ****
dcaee6
      }
dcaee6
      else
dcaee6
      {
dcaee6
! 	if (p_ul < 0)		/* no undo at all */
dcaee6
  	    return OK;
dcaee6
  
dcaee6
  	/*
dcaee6
--- 543,549 ----
dcaee6
      }
dcaee6
      else
dcaee6
      {
dcaee6
! 	if (get_undolevel() < 0)	/* no undo at all */
dcaee6
  	    return OK;
dcaee6
  
dcaee6
  	/*
dcaee6
***************
dcaee6
*** 1972,1978 ****
dcaee6
  	{
dcaee6
  	    if (curbuf->b_u_curhead == NULL)		/* first undo */
dcaee6
  		curbuf->b_u_curhead = curbuf->b_u_newhead;
dcaee6
! 	    else if (p_ul > 0)				/* multi level undo */
dcaee6
  		/* get next undo */
dcaee6
  		curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr;
dcaee6
  	    /* nothing to undo */
dcaee6
--- 1985,1991 ----
dcaee6
  	{
dcaee6
  	    if (curbuf->b_u_curhead == NULL)		/* first undo */
dcaee6
  		curbuf->b_u_curhead = curbuf->b_u_newhead;
dcaee6
! 	    else if (get_undolevel() > 0)		/* multi level undo */
dcaee6
  		/* get next undo */
dcaee6
  		curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr;
dcaee6
  	    /* nothing to undo */
dcaee6
***************
dcaee6
*** 1993,1999 ****
dcaee6
  	}
dcaee6
  	else
dcaee6
  	{
dcaee6
! 	    if (curbuf->b_u_curhead == NULL || p_ul <= 0)
dcaee6
  	    {
dcaee6
  		beep_flush();	/* nothing to redo */
dcaee6
  		if (count == startcount - 1)
dcaee6
--- 2006,2012 ----
dcaee6
  	}
dcaee6
  	else
dcaee6
  	{
dcaee6
! 	    if (curbuf->b_u_curhead == NULL || get_undolevel() <= 0)
dcaee6
  	    {
dcaee6
  		beep_flush();	/* nothing to redo */
dcaee6
  		if (count == startcount - 1)
dcaee6
***************
dcaee6
*** 2751,2757 ****
dcaee6
      if (im_is_preediting())
dcaee6
  	return;		    /* XIM is busy, don't break an undo sequence */
dcaee6
  #endif
dcaee6
!     if (p_ul < 0)
dcaee6
  	curbuf->b_u_synced = TRUE;  /* no entries, nothing to do */
dcaee6
      else
dcaee6
      {
dcaee6
--- 2764,2770 ----
dcaee6
      if (im_is_preediting())
dcaee6
  	return;		    /* XIM is busy, don't break an undo sequence */
dcaee6
  #endif
dcaee6
!     if (get_undolevel() < 0)
dcaee6
  	curbuf->b_u_synced = TRUE;  /* no entries, nothing to do */
dcaee6
      else
dcaee6
      {
dcaee6
***************
dcaee6
*** 2911,2917 ****
dcaee6
      }
dcaee6
      if (!curbuf->b_u_synced)
dcaee6
  	return;		    /* already unsynced */
dcaee6
!     if (p_ul < 0)
dcaee6
  	return;		    /* no entries, nothing to do */
dcaee6
      else
dcaee6
      {
dcaee6
--- 2924,2930 ----
dcaee6
      }
dcaee6
      if (!curbuf->b_u_synced)
dcaee6
  	return;		    /* already unsynced */
dcaee6
!     if (get_undolevel() < 0)
dcaee6
  	return;		    /* no entries, nothing to do */
dcaee6
      else
dcaee6
      {
dcaee6
*** ../vim-7.4.072/src/version.c	2013-11-06 04:04:29.000000000 +0100
dcaee6
--- src/version.c	2013-11-06 05:21:43.000000000 +0100
dcaee6
***************
dcaee6
*** 740,741 ****
dcaee6
--- 740,743 ----
dcaee6
  {   /* Add new patch number below this line */
dcaee6
+ /**/
dcaee6
+     73,
dcaee6
  /**/
dcaee6
dcaee6
-- 
dcaee6
Living on Earth includes an annual free trip around the Sun.
dcaee6
dcaee6
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
dcaee6
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
dcaee6
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
dcaee6
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///