Hi Bram, attached is a patch, that makes 'undolevels' a buffer-local option. I think, this is useful if you are editing a large file you might want to disable undo completely, without loosing the undo information for other buffers.
regards, Christian -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
# HG changeset patch # User Christian Brabandt <[email protected]> # Date 1292102968 -3600 # Node ID fd48b71df593c3b81b9d470560b6895ce0412a69 # Parent c92c7970ecda2b7b0e7283d493e78e7bcdf4f7f4 [mq]: undolevels_bufferlocal diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -7401,7 +7401,7 @@ *'undolevels'* *'ul'* 'undolevels' 'ul' number (default 100, 1000 for Unix, VMS, Win32 and OS/2) - global + local to buffer {not in Vi} Maximum number of changes that can be undone. Since undo information is kept in memory, higher numbers will cause more memory to be used diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -180,6 +180,7 @@ #ifdef FEAT_PERSISTENT_UNDO # define PV_UDF OPT_BUF(BV_UDF) #endif +#define PV_UL OPT_BUF(BV_UL) #define PV_WM OPT_BUF(BV_WM) /* @@ -2654,7 +2655,7 @@ #endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, {"undolevels", "ul", P_NUM|P_VI_DEF, - (char_u *)&p_ul, PV_NONE, + (char_u *)&p_ul, PV_UL, { #if (defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)) \ && defined(FEAT_PERSISTENT_UNDO) @@ -8338,12 +8339,12 @@ #endif /* sync undo before 'undolevels' changes */ - else if (pp == &p_ul) + else if (pp == &curbuf->b_p_ul) { /* use the old value, otherwise u_sync() may not work properly */ - p_ul = old_value; + curbuf->b_p_ul = old_value; u_sync(TRUE); - p_ul = value; + curbuf->b_p_ul = value; } @@ -9709,6 +9710,7 @@ #ifdef FEAT_PERSISTENT_UNDO case PV_UDF: return (char_u *)&(curbuf->b_p_udf); #endif + case PV_UL: return (char_u *)&(curbuf->b_p_ul); case PV_WM: return (char_u *)&(curbuf->b_p_wm); #ifdef FEAT_KEYMAP case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); @@ -9977,6 +9979,7 @@ buf->b_p_ai_nopaste = p_ai_nopaste; buf->b_p_sw = p_sw; buf->b_p_tw = p_tw; + buf->b_p_ul = p_ul; buf->b_p_tw_nopaste = p_tw_nopaste; buf->b_p_tw_nobin = p_tw_nobin; buf->b_p_wm = p_wm; diff --git a/src/option.h b/src/option.h --- a/src/option.h +++ b/src/option.h @@ -1019,6 +1019,7 @@ , BV_TW , BV_TX , BV_UDF + , BV_UL , BV_WM , BV_COUNT /* must be the last one */ }; diff --git a/src/structs.h b/src/structs.h --- a/src/structs.h +++ b/src/structs.h @@ -1537,6 +1537,7 @@ long b_p_tw; /* 'textwidth' */ long b_p_tw_nobin; /* b_p_tw saved for binary mode */ long b_p_tw_nopaste; /* b_p_tw saved for paste mode */ + long b_p_ul; /* 'undolevels' */ long b_p_wm; /* 'wrapmargin' */ long b_p_wm_nobin; /* b_p_wm saved for binary mode */ long b_p_wm_nopaste; /* b_p_wm saved for paste mode */ diff --git a/src/undo.c b/src/undo.c --- a/src/undo.c +++ b/src/undo.c @@ -421,7 +421,7 @@ curbuf->b_new_change = TRUE; #endif - if (p_ul >= 0) + if (curbuf->b_p_ul >= 0) { /* * Make a new header entry. Do this first so that we don't mess @@ -451,7 +451,7 @@ /* * free headers to keep the size right */ - while (curbuf->b_u_numhead > p_ul && curbuf->b_u_oldhead != NULL) + while (curbuf->b_u_numhead > curbuf->b_p_ul && curbuf->b_u_oldhead != NULL) { u_header_T *uhfree = curbuf->b_u_oldhead; @@ -532,7 +532,7 @@ } else { - if (p_ul < 0) /* no undo at all */ + if (curbuf->b_p_ul < 0) /* no undo at all */ return OK; /* @@ -1970,7 +1970,7 @@ { if (curbuf->b_u_curhead == NULL) /* first undo */ curbuf->b_u_curhead = curbuf->b_u_newhead; - else if (p_ul > 0) /* multi level undo */ + else if (curbuf->b_p_ul > 0) /* multi level undo */ /* get next undo */ curbuf->b_u_curhead = curbuf->b_u_curhead->uh_next.ptr; /* nothing to undo */ @@ -1991,7 +1991,7 @@ } else { - if (curbuf->b_u_curhead == NULL || p_ul <= 0) + if (curbuf->b_u_curhead == NULL || curbuf->b_p_ul <= 0) { beep_flush(); /* nothing to redo */ if (count == startcount - 1) @@ -2749,7 +2749,7 @@ if (im_is_preediting()) return; /* XIM is busy, don't break an undo sequence */ #endif - if (p_ul < 0) + if (curbuf->b_p_ul < 0) curbuf->b_u_synced = TRUE; /* no entries, nothing to do */ else { @@ -2912,7 +2912,7 @@ } if (!curbuf->b_u_synced) return; /* already unsynced */ - if (p_ul < 0) + if (curbuf->b_p_ul < 0) return; /* no entries, nothing to do */ else {
