comparison src/option.c @ 5446:d0595545e98a v7.4.073

updated for version 7.4.073 Problem: Setting undolevels for one buffer changes undo in another. Solution: Make 'undolevels' a global-local option. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 06 Nov 2013 05:26:15 +0100
parents 878ed73c7070
children 6ae816249627
comparison
equal deleted inserted replaced
5445:75c7eef1de70 5446:d0595545e98a
232 # define PV_CC OPT_WIN(WV_CC) 232 # define PV_CC OPT_WIN(WV_CC)
233 #endif 233 #endif
234 #ifdef FEAT_STL_OPT 234 #ifdef FEAT_STL_OPT
235 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL)) 235 # define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
236 #endif 236 #endif
237 #define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
237 #ifdef FEAT_WINDOWS 238 #ifdef FEAT_WINDOWS
238 # define PV_WFH OPT_WIN(WV_WFH) 239 # define PV_WFH OPT_WIN(WV_WFH)
239 #endif 240 #endif
240 #ifdef FEAT_VERTSPLIT 241 #ifdef FEAT_VERTSPLIT
241 # define PV_WFW OPT_WIN(WV_WFW) 242 # define PV_WFW OPT_WIN(WV_WFW)
2681 #else 2682 #else
2682 (char_u *)NULL, PV_NONE, 2683 (char_u *)NULL, PV_NONE,
2683 #endif 2684 #endif
2684 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, 2685 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
2685 {"undolevels", "ul", P_NUM|P_VI_DEF, 2686 {"undolevels", "ul", P_NUM|P_VI_DEF,
2686 (char_u *)&p_ul, PV_NONE, 2687 (char_u *)&p_ul, PV_UL,
2687 { 2688 {
2688 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS) 2689 #if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2689 (char_u *)1000L, 2690 (char_u *)1000L,
2690 #else 2691 #else
2691 (char_u *)100L, 2692 (char_u *)100L,
3311 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0); 3312 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3312 #endif 3313 #endif
3313 3314
3314 curbuf->b_p_initialized = TRUE; 3315 curbuf->b_p_initialized = TRUE;
3315 curbuf->b_p_ar = -1; /* no local 'autoread' value */ 3316 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3317 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
3316 check_buf_options(curbuf); 3318 check_buf_options(curbuf);
3317 check_win_options(curwin); 3319 check_win_options(curwin);
3318 check_options(); 3320 check_options();
3319 3321
3320 /* Must be before option_expand(), because that one needs vim_isIDc() */ 3322 /* Must be before option_expand(), because that one needs vim_isIDc() */
4510 if (nextchar == '&') 4512 if (nextchar == '&')
4511 value = (long)(long_i)options[opt_idx].def_val[ 4513 value = (long)(long_i)options[opt_idx].def_val[
4512 ((flags & P_VI_DEF) || cp_val) 4514 ((flags & P_VI_DEF) || cp_val)
4513 ? VI_DEFAULT : VIM_DEFAULT]; 4515 ? VI_DEFAULT : VIM_DEFAULT];
4514 else if (nextchar == '<') 4516 else if (nextchar == '<')
4515 value = *(long *)get_varp_scope(&(options[opt_idx]), 4517 {
4516 OPT_GLOBAL); 4518 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4519 * use the global value. */
4520 if ((long *)varp == &curbuf->b_p_ul
4521 && opt_flags == OPT_LOCAL)
4522 value = NO_LOCAL_UNDOLEVEL;
4523 else
4524 value = *(long *)get_varp_scope(
4525 &(options[opt_idx]), OPT_GLOBAL);
4526 }
4517 else if (((long *)varp == &p_wc 4527 else if (((long *)varp == &p_wc
4518 || (long *)varp == &p_wcm) 4528 || (long *)varp == &p_wcm)
4519 && (*arg == '<' 4529 && (*arg == '<'
4520 || *arg == '^' 4530 || *arg == '^'
4521 || ((!arg[1] || vim_iswhite(arg[1])) 4531 || ((!arg[1] || vim_iswhite(arg[1]))
8485 /* use the old value, otherwise u_sync() may not work properly */ 8495 /* use the old value, otherwise u_sync() may not work properly */
8486 p_ul = old_value; 8496 p_ul = old_value;
8487 u_sync(TRUE); 8497 u_sync(TRUE);
8488 p_ul = value; 8498 p_ul = value;
8489 } 8499 }
8500 else if (pp == &curbuf->b_p_ul)
8501 {
8502 /* use the old value, otherwise u_sync() may not work properly */
8503 curbuf->b_p_ul = old_value;
8504 u_sync(TRUE);
8505 curbuf->b_p_ul = value;
8506 }
8490 8507
8491 #ifdef FEAT_LINEBREAK 8508 #ifdef FEAT_LINEBREAK
8492 /* 'numberwidth' must be positive */ 8509 /* 'numberwidth' must be positive */
8493 else if (pp == &curwin->w_p_nuw) 8510 else if (pp == &curwin->w_p_nuw)
8494 { 8511 {
9718 } 9735 }
9719 9736
9720 /* 9737 /*
9721 * Unset local option value, similar to ":set opt<". 9738 * Unset local option value, similar to ":set opt<".
9722 */ 9739 */
9723
9724 void 9740 void
9725 unset_global_local_option(name, from) 9741 unset_global_local_option(name, from)
9726 char_u *name; 9742 char_u *name;
9727 void *from; 9743 void *from;
9728 { 9744 {
9791 #ifdef FEAT_STL_OPT 9807 #ifdef FEAT_STL_OPT
9792 case PV_STL: 9808 case PV_STL:
9793 clear_string_option(&((win_T *)from)->w_p_stl); 9809 clear_string_option(&((win_T *)from)->w_p_stl);
9794 break; 9810 break;
9795 #endif 9811 #endif
9812 case PV_UL:
9813 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
9814 break;
9796 } 9815 }
9797 } 9816 }
9798 9817
9799 /* 9818 /*
9800 * Get pointer to option variable, depending on local or global scope. 9819 * Get pointer to option variable, depending on local or global scope.
9839 case PV_CM: return (char_u *)&(curbuf->b_p_cm); 9858 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
9840 #endif 9859 #endif
9841 #ifdef FEAT_STL_OPT 9860 #ifdef FEAT_STL_OPT
9842 case PV_STL: return (char_u *)&(curwin->w_p_stl); 9861 case PV_STL: return (char_u *)&(curwin->w_p_stl);
9843 #endif 9862 #endif
9863 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
9844 } 9864 }
9845 return NULL; /* "cannot happen" */ 9865 return NULL; /* "cannot happen" */
9846 } 9866 }
9847 return get_varp(p); 9867 return get_varp(p);
9848 } 9868 }
9903 #endif 9923 #endif
9904 #ifdef FEAT_STL_OPT 9924 #ifdef FEAT_STL_OPT
9905 case PV_STL: return *curwin->w_p_stl != NUL 9925 case PV_STL: return *curwin->w_p_stl != NUL
9906 ? (char_u *)&(curwin->w_p_stl) : p->var; 9926 ? (char_u *)&(curwin->w_p_stl) : p->var;
9907 #endif 9927 #endif
9928 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
9929 ? (char_u *)&(curbuf->b_p_ul) : p->var;
9908 9930
9909 #ifdef FEAT_ARABIC 9931 #ifdef FEAT_ARABIC
9910 case PV_ARAB: return (char_u *)&(curwin->w_p_arab); 9932 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9911 #endif 9933 #endif
9912 case PV_LIST: return (char_u *)&(curwin->w_p_list); 9934 case PV_LIST: return (char_u *)&(curwin->w_p_list);
10443 buf->b_p_imsearch = p_imsearch; 10465 buf->b_p_imsearch = p_imsearch;
10444 10466
10445 /* options that are normally global but also have a local value 10467 /* options that are normally global but also have a local value
10446 * are not copied, start using the global value */ 10468 * are not copied, start using the global value */
10447 buf->b_p_ar = -1; 10469 buf->b_p_ar = -1;
10470 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10448 #ifdef FEAT_QUICKFIX 10471 #ifdef FEAT_QUICKFIX
10449 buf->b_p_gp = empty_option; 10472 buf->b_p_gp = empty_option;
10450 buf->b_p_mp = empty_option; 10473 buf->b_p_mp = empty_option;
10451 buf->b_p_efm = empty_option; 10474 buf->b_p_efm = empty_option;
10452 #endif 10475 #endif