summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2024-07-12 19:30:58 +0200
committerChristian Brabandt <cb@256bit.org>2024-07-12 19:36:53 +0200
commit5247b0b92e191a046b034171a3b34031e317735f (patch)
treecedcbae8ce173ce4006262f069d3ce81ed26f877
parent74703f1086e7815f356123736666d9930db8683a (diff)
patch 9.1.0572: cannot specify tab page closing behaviourv9.1.0572
Problem: cannot specify tab page closing behaviour (Gianluca Pacchiella) Solution: Add the 'tabclose' option (LemonBoy). fixes: #5967 closes: #15204 Signed-off-by: LemonBoy <thatlemon@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--runtime/doc/options.txt13
-rw-r--r--runtime/doc/quickref.txt1
-rw-r--r--runtime/doc/tabpage.txt5
-rw-r--r--runtime/doc/tags2
-rw-r--r--runtime/doc/version9.txt3
-rw-r--r--runtime/optwin.vim4
-rw-r--r--runtime/syntax/vim.vim6
-rw-r--r--src/option.h6
-rw-r--r--src/optiondefs.h3
-rw-r--r--src/optionstr.c23
-rw-r--r--src/proto/option.pro1
-rw-r--r--src/proto/optionstr.pro1
-rw-r--r--src/testdir/gen_opt_test.vim1
-rw-r--r--src/testdir/test_options.vim6
-rw-r--r--src/testdir/test_tabpage.vim58
-rw-r--r--src/version.c2
-rw-r--r--src/window.c22
17 files changed, 141 insertions, 16 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 2dc08e2573..5f1a2a074f 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -8100,6 +8100,19 @@ A jump table for the options with a short description can be found at |Q_op|.
'S' flag in 'cpoptions'.
Only normal file name characters can be used, "/\*?[|<>" are illegal.
+ *'tabclose'* *'tcl'*
+'tabclose' 'tcl' string (default "")
+ global
+ This option controls the behavior when closing tab pages (e.g., using
+ |:tabclose|). When empty Vim goes to the next (right) tab page.
+
+ Possible values (comma-separated list):
+ left If included, go to the previous tab page instead of
+ the next one.
+ uselast If included, go to the previously used tab page if
+ possible. This option takes precedence over the
+ others.
+
*'tabline'* *'tal'*
'tabline' 'tal' string (default empty)
global
diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt
index 517fa30426..42b5228a8f 100644
--- a/runtime/doc/quickref.txt
+++ b/runtime/doc/quickref.txt
@@ -935,6 +935,7 @@ Short explanation of each option: *option-list*
'switchbuf' 'swb' sets behavior when switching to another buffer
'synmaxcol' 'smc' maximum column to find syntax items
'syntax' 'syn' syntax to be loaded for current buffer
+'tabclose' 'tcl' which tab page to focus when closing a tab
'tabline' 'tal' custom format for the console tab pages line
'tabpagemax' 'tpm' maximum number of tab pages for |-p| and "tab all"
'tabstop' 'ts' number of spaces that <Tab> in file uses
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index abbc778030..afc2512509 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt* For Vim version 9.1. Last change: 2024 May 15
+*tabpage.txt* For Vim version 9.1. Last change: 2024 Jul 12
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -142,7 +142,8 @@ something else.
:tabclose $ " close the last tab page
:tabclose # " close the last accessed tab page
-When a tab is closed the next tab page will become the current one.
+When a tab is closed the next tab page will become the current one. This
+behaviour can be customized using the 'tabclose' option.
*:tabo* *:tabonly*
:tabo[nly][!] Close all other tab pages.
diff --git a/runtime/doc/tags b/runtime/doc/tags
index b3761e88e2..00c216c847 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -1161,6 +1161,7 @@ $quote eval.txt /*$quote*
't_xo' term.txt /*'t_xo'*
't_xs' term.txt /*'t_xs'*
'ta' options.txt /*'ta'*
+'tabclose' options.txt /*'tabclose'*
'tabline' options.txt /*'tabline'*
'tabpagemax' options.txt /*'tabpagemax'*
'tabstop' options.txt /*'tabstop'*
@@ -1179,6 +1180,7 @@ $quote eval.txt /*$quote*
'tbis' options.txt /*'tbis'*
'tbs' options.txt /*'tbs'*
'tc' options.txt /*'tc'*
+'tcl' options.txt /*'tcl'*
'tcldll' options.txt /*'tcldll'*
'tenc' options.txt /*'tenc'*
'term' options.txt /*'term'*
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 7a2cbe4164..3b719eb9c7 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -1,4 +1,4 @@
-*version9.txt* For Vim version 9.1. Last change: 2024 Jul 11
+*version9.txt* For Vim version 9.1. Last change: 2024 Jul 12
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -41632,6 +41632,7 @@ Commands: ~
Options: ~
'winfixbuf' Keep buffer focused in a window
+'tabclose' Which tab page to focus after closing a tab page
't_xo' Terminal uses XON/XOFF handshaking (e.g. vt420)
't_CF' Support for alternate font highlighting terminal code
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index f218ffba20..8306ed39f5 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
-" Last Change: 2024 Jun 05
+" Last Change: 2024 Jul 12
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If there already is an option window, jump to that one.
@@ -556,6 +556,8 @@ endif
call <SID>Header(gettext("multiple tab pages"))
call <SID>AddOption("showtabline", gettext("0, 1 or 2; when to use a tab pages line"))
call append("$", " \tset stal=" . &stal)
+call <SID>AddOption("tabclose", gettext("behaviour when closing tab pages: left, uselast or empty"))
+call append("$", " \tset tcl=" . &tcl)
call <SID>AddOption("tabpagemax", gettext("maximum number of tab pages to open for -p and \"tab all\""))
call append("$", " \tset tpm=" . &tpm)
call <SID>AddOption("tabline", gettext("custom tab pages line"))
diff --git a/runtime/syntax/vim.vim b/runtime/syntax/vim.vim
index b10531e961..db173815c5 100644
--- a/runtime/syntax/vim.vim
+++ b/runtime/syntax/vim.vim
@@ -3,7 +3,7 @@
" Maintainer: Hirohito Higashi <h.east.727 ATMARK gmail.com>
" Doug Kearns <dougkearns@gmail.com>
" URL: https://github.com/vim-jp/syntax-vim-ex
-" Last Change: 2024 Jul 11
+" Last Change: 2024 Jul 12
" Former Maintainer: Charles E. Campbell
" DO NOT CHANGE DIRECTLY.
@@ -48,8 +48,8 @@ syn keyword vimOption contained ft filetype fcs fillchars fixeol fixendofline fc
syn keyword vimOption contained imst imstyle inc include inex includeexpr is incsearch inde indentexpr indk indentkeys inf infercase im insertmode isf isfname isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw lbr linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm maxmem mmp maxmempattern mmt maxmemtot mis menuitems msm mkspellmem ml modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse mousef mousefocus
syn keyword vimOption contained mh mousehide mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc operatorfunc pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions
syn keyword vimOption contained report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc sft showfulltag sm showmatch smd showmode stal showtabline ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl spelllang
-syn keyword vimOption contained spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tal tabline tpm tabpagemax ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir
-syn keyword vimOption contained udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes
+syn keyword vimOption contained spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype
+syn keyword vimOption contained udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes
" vimOptions: These are the turn-off setting variants {{{2
" GEN_SYN_VIM: vimOption turn-off, START_STR='syn keyword vimOption contained', END_STR=''
diff --git a/src/option.h b/src/option.h
index 630d7bf6b7..e84f7f9add 100644
--- a/src/option.h
+++ b/src/option.h
@@ -955,7 +955,6 @@ EXTERN int p_sol; // 'startofline'
EXTERN char_u *p_su; // 'suffixes'
EXTERN char_u *p_sws; // 'swapsync'
EXTERN char_u *p_swb; // 'switchbuf'
-EXTERN char_u *p_spk; // 'splitkeep'
EXTERN unsigned swb_flags;
// Keep in sync with p_swb_values in optionstr.c
#define SWB_USEOPEN 0x001
@@ -964,9 +963,14 @@ EXTERN unsigned swb_flags;
#define SWB_NEWTAB 0x008
#define SWB_VSPLIT 0x010
#define SWB_USELAST 0x020
+EXTERN char_u *p_spk; // 'splitkeep'
#ifdef FEAT_SYN_HL
EXTERN char_u *p_syn; // 'syntax'
#endif
+EXTERN char_u *p_tcl; // 'tabclose'
+EXTERN unsigned tcl_flags; // flags from 'tabclose'
+#define TCL_LEFT 0x001
+#define TCL_USELAST 0x002
EXTERN long p_ts; // 'tabstop'
EXTERN int p_tbs; // 'tagbsearch'
EXTERN char_u *p_tc; // 'tagcase'
diff --git a/src/optiondefs.h b/src/optiondefs.h
index 617f3cec6b..bf3ed35e0b 100644
--- a/src/optiondefs.h
+++ b/src/optiondefs.h
@@ -2462,6 +2462,9 @@ static struct vimoption options[] =
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
+ {"tabclose", "tcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
+ (char_u *)&p_tcl, PV_NONE, did_set_tabclose, expand_set_tabclose,
+ {(char_u *)"", (char_u *)0L} SCTX_INIT},
{"tabline", "tal", P_STRING|P_VI_DEF|P_RALL|P_MLE,
#ifdef FEAT_STL_OPT
(char_u *)&p_tal, PV_NONE, did_set_tabline, NULL,
diff --git a/src/optionstr.c b/src/optionstr.c
index 417f785907..b6249a2f38 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -81,6 +81,8 @@ static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize",
static char *(p_swb_values[]) = {"useopen", "usetab", "split", "newtab", "vsplit", "uselast", NULL};
static char *(p_spk_values[]) = {"cursor", "screen", "topline", NULL};
static char *(p_tc_values[]) = {"followic", "ignore", "match", "followscs", "smart", NULL};
+// Keep in sync with TCL_ flags in option.h
+static char *(p_tcl_values[]) = {"left", "uselast", NULL};
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
static char *(p_toolbar_values[]) = {"text", "icons", "tooltips", "horiz", NULL};
#endif
@@ -166,6 +168,7 @@ didset_string_options(void)
(void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
#endif
(void)opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE);
+ (void)opt_strings_flags(p_tcl, p_tcl_values, &tcl_flags, TRUE);
}
#if defined(FEAT_EVAL) || defined(PROTO)
@@ -3669,6 +3672,26 @@ expand_set_switchbuf(optexpand_T *args, int *numMatches, char_u ***matches)
matches);
}
+/*
+ * The 'tabclose' option is changed.
+ */
+ char *
+did_set_tabclose(optset_T *args UNUSED)
+{
+ return did_set_opt_flags(p_tcl, p_tcl_values, &tcl_flags, TRUE);
+}
+
+ int
+expand_set_tabclose(optexpand_T *args, int *numMatches, char_u ***matches)
+{
+ return expand_set_opt_string(
+ args,
+ p_tcl_values,
+ ARRAY_LENGTH(p_tcl_values) - 1,
+ numMatches,
+ matches);
+}
+
#if defined(FEAT_STL_OPT) || defined(PROTO)
/*
* The 'tabline' option is changed.
diff --git a/src/proto/option.pro b/src/proto/option.pro
index 69463d44fc..1659131a32 100644
--- a/src/proto/option.pro
+++ b/src/proto/option.pro
@@ -69,6 +69,7 @@ char *did_set_showtabline(optset_T *args);
char *did_set_smoothscroll(optset_T *args);
char *did_set_spell(optset_T *args);
char *did_set_swapfile(optset_T *args);
+char *did_set_tabclose(optset_T *args);
char *did_set_termguicolors(optset_T *args);
char *did_set_terse(optset_T *args);
char *did_set_textauto(optset_T *args);
diff --git a/src/proto/optionstr.pro b/src/proto/optionstr.pro
index 340ffc428a..39c40f39ba 100644
--- a/src/proto/optionstr.pro
+++ b/src/proto/optionstr.pro
@@ -156,6 +156,7 @@ char *did_set_swapsync(optset_T *args);
int expand_set_swapsync(optexpand_T *args, int *numMatches, char_u ***matches);
char *did_set_switchbuf(optset_T *args);
int expand_set_switchbuf(optexpand_T *args, int *numMatches, char_u ***matches);
+int expand_set_tabclose(optexpand_T *args, int *numMatches, char_u ***matches);
char *did_set_tabline(optset_T *args);
char *did_set_tagcase(optset_T *args);
int expand_set_tagcase(optexpand_T *args, int *numMatches, char_u ***matches);
diff --git a/src/testdir/gen_opt_test.vim b/src/testdir/gen_opt_test.vim
index 8cca2b932d..7674714837 100644
--- a/src/testdir/gen_opt_test.vim
+++ b/src/testdir/gen_opt_test.vim
@@ -144,6 +144,7 @@ let test_values = {
\ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
\ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
\ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
+ \ 'tabclose': [['', 'left', 'left,uselast'], ['xxx']],
\ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
\ 'term': [[], []],
\ 'termguicolors': [[], []],
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index fbfbaae14c..02f5d7e900 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -548,6 +548,9 @@ func Test_set_completion_string_values()
call assert_equal('sync', getcompletion('set swapsync=', 'cmdline')[1])
call assert_equal('usetab', getcompletion('set switchbuf=', 'cmdline')[1])
call assert_equal('ignore', getcompletion('set tagcase=', 'cmdline')[1])
+ if exists('+tabclose')
+ call assert_equal('left uselast', join(sort(getcompletion('set tabclose=', 'cmdline'))), ' ')
+ endif
if exists('+termwintype')
call assert_equal('conpty', getcompletion('set termwintype=', 'cmdline')[1])
endif
@@ -1407,7 +1410,8 @@ func Test_write()
set nowrite
call assert_fails('write Xwrfile', 'E142:')
set write
- close!
+ " close swapfile
+ bw!
endfunc
" Test for 'buftype' option
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 3624790e3e..1a40567085 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -965,6 +965,64 @@ func Test_tabpage_alloc_failure()
call assert_equal(1, tabpagenr('$'))
endfunc
+func Test_tabpage_tabclose()
+ " Default behaviour, move to the right.
+ call s:reconstruct_tabpage_for_test(6)
+ norm! 4gt
+ setl tcl=
+ tabclose
+ call assert_equal("n3", bufname())
+
+ " Move to the left.
+ call s:reconstruct_tabpage_for_test(6)
+ norm! 4gt
+ setl tcl=left
+ tabclose
+ call assert_equal("n1", bufname())
+
+ " Move to the last used tab page.
+ call s:reconstruct_tabpage_for_test(6)
+ norm! 5gt
+ norm! 2gt
+ setl tcl=uselast
+ tabclose
+ call assert_equal("n3", bufname())
+
+ " Same, but the last used tab page is invalid. Move to the right.
+ call s:reconstruct_tabpage_for_test(6)
+ norm! 5gt
+ norm! 3gt
+ setl tcl=uselast
+ tabclose 5
+ tabclose!
+ call assert_equal("n2", bufname())
+
+ " Same, but the last used tab page is invalid. Move to the left.
+ call s:reconstruct_tabpage_for_test(6)
+ norm! 5gt
+ norm! 3gt
+ setl tcl=uselast,left
+ tabclose 5
+ tabclose!
+ call assert_equal("n0", bufname())
+
+ " Move left when moving right is not possible.
+ call s:reconstruct_tabpage_for_test(6)
+ setl tcl=
+ norm! 6gt
+ tabclose
+ call assert_equal("n3", bufname())
+
+ " Move right when moving left is not possible.
+ call s:reconstruct_tabpage_for_test(6)
+ setl tcl=left
+ norm! 1gt
+ tabclose
+ call assert_equal("n0", bufname())
+
+ setl tcl&
+endfunc
+
" this was giving ml_get errors
func Test_tabpage_last_line()
enew
diff --git a/src/version.c b/src/version.c
index 194099bbd7..fc1fb24eac 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 572,
+/**/
571,
/**/
570,
diff --git a/src/window.c b/src/window.c
index 73229059ea..c87cce0016 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3782,15 +3782,23 @@ win_altframe(
static tabpage_T *
alt_tabpage(void)
{
- tabpage_T *tp;
+ tabpage_T *tp = NULL;
+ int forward;
- // Use the next tab page if possible.
- if (curtab->tp_next != NULL)
- return curtab->tp_next;
+ // Use the last accessed tab page, if possible.
+ if ((tcl_flags & TCL_USELAST) && valid_tabpage(lastused_tabpage))
+ return lastused_tabpage;
+
+ // Use the previous tab page, if possible.
+ forward = curtab->tp_next != NULL &&
+ ((tcl_flags & TCL_LEFT) == 0 || curtab == first_tabpage);
+
+ if (forward)
+ tp = curtab->tp_next;
+ else
+ for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next)
+ ;
- // Find the last but one tab page.
- for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next)
- ;
return tp;
}