Skip to content

Commit

Permalink
patch 8.0.1650: too many #ifdefs
Browse files Browse the repository at this point in the history
Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_LISTCMDS, no reason to leave out buffer commands.
  • Loading branch information
brammool committed Mar 29, 2018
1 parent cd43eff commit 0c72fe4
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 123 deletions.
4 changes: 2 additions & 2 deletions runtime/doc/various.txt
@@ -1,4 +1,4 @@
*various.txt* For Vim version 8.0. Last change: 2018 Mar 10
*various.txt* For Vim version 8.0. Last change: 2018 Mar 29


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -384,7 +384,7 @@ B *+langmap* |'langmap'|
N *+libcall* |libcall()|
N *+linebreak* |'linebreak'|, |'breakat'| and |'showbreak'|
N *+lispindent* |'lisp'|
N *+listcmds* Vim commands for the list of buffers |buffer-hidden|
T *+listcmds* Vim commands for the list of buffers |buffer-hidden|
and argument list |:argdelete|
N *+localmap* Support for mappings local to a buffer |:map-local|
m *+lua* |Lua| interface
Expand Down
45 changes: 10 additions & 35 deletions src/buffer.c
Expand Up @@ -27,13 +27,9 @@

#include "vim.h"

#if defined(FEAT_CMDL_COMPL) || defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL)
static char_u *buflist_match(regmatch_T *rmp, buf_T *buf, int ignore_case);
# define HAVE_BUFLIST_MATCH
static char_u *fname_match(regmatch_T *rmp, char_u *name, int ignore_case);
#endif
static void buflist_setfpos(buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options);
static wininfo_T *find_wininfo(buf_T *buf, int skip_diff_buffer);
#ifdef UNIX
static buf_T *buflist_findname_stat(char_u *ffname, stat_T *st);
static int otherfile_buf(buf_T *buf, char_u *ffname, stat_T *stp);
Expand Down Expand Up @@ -948,7 +944,6 @@ clear_wininfo(buf_T *buf)
}
}

#if defined(FEAT_LISTCMDS) || defined(FEAT_TERMINAL) || defined(PROTO)
/*
* Go to another buffer. Handles the result of the ATTENTION dialog.
*/
Expand All @@ -959,42 +954,41 @@ goto_buffer(
int dir,
int count)
{
# if defined(HAS_SWAP_EXISTS_ACTION)
#if defined(HAS_SWAP_EXISTS_ACTION)
bufref_T old_curbuf;

set_bufref(&old_curbuf, curbuf);

swap_exists_action = SEA_DIALOG;
# endif
#endif
(void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
start, dir, count, eap->forceit);
# if defined(HAS_SWAP_EXISTS_ACTION)
#if defined(HAS_SWAP_EXISTS_ACTION)
if (swap_exists_action == SEA_QUIT && *eap->cmd == 's')
{
# if defined(FEAT_EVAL)
# if defined(FEAT_EVAL)
cleanup_T cs;

/* Reset the error/interrupt/exception state here so that
* aborting() returns FALSE when closing a window. */
enter_cleanup(&cs);
# endif
# endif

/* Quitting means closing the split window, nothing else. */
win_close(curwin, TRUE);
swap_exists_action = SEA_NONE;
swap_exists_did_quit = TRUE;

# if defined(FEAT_EVAL)
# if defined(FEAT_EVAL)
/* Restore the error/interrupt/exception state if not discarded by a
* new aborting error, interrupt, or uncaught exception. */
leave_cleanup(&cs);
# endif
# endif
}
else
handle_swap_exists(&old_curbuf);
# endif
}
#endif
}

#if defined(HAS_SWAP_EXISTS_ACTION) || defined(PROTO)
/*
Expand Down Expand Up @@ -1072,7 +1066,6 @@ handle_swap_exists(bufref_T *old_curbuf)
}
#endif

#if defined(FEAT_LISTCMDS) || defined(PROTO)
/*
* do_bufdel() - delete or unload buffer(s)
*
Expand Down Expand Up @@ -1199,10 +1192,6 @@ do_bufdel(

return errormsg;
}
#endif /* FEAT_LISTCMDS */

#if defined(FEAT_LISTCMDS) || defined(FEAT_PYTHON) \
|| defined(FEAT_PYTHON3) || defined(PROTO)

static int empty_curbuf(int close_others, int forceit, int action);

Expand Down Expand Up @@ -1359,7 +1348,6 @@ do_buffer(
need_mouse_correct = TRUE;
#endif

#ifdef FEAT_LISTCMDS
/*
* delete buffer buf from memory and/or the list
*/
Expand All @@ -1377,7 +1365,7 @@ do_buffer(

if (!forceit && bufIsChanged(buf))
{
# if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
if ((p_confirm || cmdmod.confirm) && p_write)
{
dialog_changed(buf, FALSE);
Expand All @@ -1391,7 +1379,7 @@ do_buffer(
return FAIL;
}
else
# endif
#endif
{
EMSGN(_("E89: No write since last change for buffer %ld (add ! to override)"),
buf->b_fnum);
Expand Down Expand Up @@ -1557,7 +1545,6 @@ do_buffer(
if (win_split(0, 0) == FAIL)
return FAIL;
}
#endif

/* go to current buffer - nothing to do */
if (buf == curbuf)
Expand Down Expand Up @@ -1590,12 +1577,10 @@ do_buffer(
/* Go to the other buffer. */
set_curbuf(buf, action);

#if defined(FEAT_LISTCMDS)
if (action == DOBUF_SPLIT)
{
RESET_BINDING(curwin); /* reset 'scrollbind' and 'cursorbind' */
}
#endif

#if defined(FEAT_EVAL)
if (aborting()) /* autocmds may abort script processing */
Expand All @@ -1604,7 +1589,6 @@ do_buffer(

return OK;
}
#endif

/*
* Set current buffer to "buf". Executes autocommands and closes current
Expand Down Expand Up @@ -2411,8 +2395,6 @@ buflist_findname_stat(
return NULL;
}

#if defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL) \
|| defined(PROTO)
/*
* Find file in buffer list by a regexp pattern.
* Return fnum of the found buffer.
Expand Down Expand Up @@ -2534,7 +2516,6 @@ buflist_findpat(
EMSG2(_("E94: No matching buffer for %s"), pattern);
return match;
}
#endif

#if defined(FEAT_CMDL_COMPL) || defined(PROTO)

Expand Down Expand Up @@ -2644,7 +2625,6 @@ ExpandBufnames(

#endif /* FEAT_CMDL_COMPL */

#ifdef HAVE_BUFLIST_MATCH
/*
* Check for a match on the file name for buffer "buf" with regprog "prog".
*/
Expand Down Expand Up @@ -2695,7 +2675,6 @@ fname_match(

return match;
}
#endif

/*
* Find a file in the buffer list by buffer number.
Expand Down Expand Up @@ -2940,7 +2919,6 @@ buflist_findlnum(buf_T *buf)
return buflist_findfpos(buf)->lnum;
}

#if defined(FEAT_LISTCMDS) || defined(PROTO)
/*
* List all known file names (for :files and :buffers command).
*/
Expand Down Expand Up @@ -3024,7 +3002,6 @@ buflist_list(exarg_T *eap)
ui_breakcheck();
}
}
#endif

/*
* Get file name and line number for file 'fnum'.
Expand Down Expand Up @@ -5095,7 +5072,6 @@ do_arg_all(
vim_free(opened);
}

# if defined(FEAT_LISTCMDS) || defined(PROTO)
/*
* Open a window for a number of buffers.
*/
Expand Down Expand Up @@ -5300,7 +5276,6 @@ ex_buffer_all(exarg_T *eap)
}
}
}
# endif /* FEAT_LISTCMDS */


static int chk_modeline(linenr_T, int);
Expand Down
2 changes: 0 additions & 2 deletions src/charset.c
Expand Up @@ -1787,7 +1787,6 @@ skiptowhite(char_u *p)
return p;
}

#if defined(FEAT_LISTCMDS) || defined(FEAT_SIGNS) || defined(PROTO)
/*
* skiptowhite_esc: Like skiptowhite(), but also skip escaped chars
*/
Expand All @@ -1802,7 +1801,6 @@ skiptowhite_esc(char_u *p)
}
return p;
}
#endif

/*
* Getdigits: Get a number from a string and skip over it.
Expand Down
2 changes: 0 additions & 2 deletions src/evalfunc.c
Expand Up @@ -5980,9 +5980,7 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_LISP
"lispindent",
#endif
#ifdef FEAT_LISTCMDS
"listcmds",
#endif
#ifdef FEAT_LOCALMAP
"localmap",
#endif
Expand Down
12 changes: 1 addition & 11 deletions src/ex_cmds.c
Expand Up @@ -3745,10 +3745,8 @@ do_ecmd(
fname_case(sfname, 0); /* set correct case for sfname */
#endif

#ifdef FEAT_LISTCMDS
if ((flags & ECMD_ADDBUF) && (ffname == NULL || *ffname == NUL))
goto theend;
#endif

if (ffname == NULL)
other_file = TRUE;
Expand Down Expand Up @@ -3830,9 +3828,7 @@ do_ecmd(
*/
if (other_file)
{
#ifdef FEAT_LISTCMDS
if (!(flags & ECMD_ADDBUF))
#endif
{
if (!cmdmod.keepalt)
curwin->w_alt_fnum = curbuf->b_fnum;
Expand All @@ -3844,7 +3840,6 @@ do_ecmd(
buf = buflist_findnr(fnum);
else
{
#ifdef FEAT_LISTCMDS
if (flags & ECMD_ADDBUF)
{
linenr_T tlnum = 1L;
Expand All @@ -3858,7 +3853,6 @@ do_ecmd(
(void)buflist_new(ffname, sfname, tlnum, BLN_LISTED);
goto theend;
}
#endif
buf = buflist_new(ffname, sfname, 0L,
BLN_CURBUF | ((flags & ECMD_SET_HELP) ? 0 : BLN_LISTED));

Expand Down Expand Up @@ -4016,11 +4010,7 @@ do_ecmd(
}
else /* !other_file */
{
if (
#ifdef FEAT_LISTCMDS
(flags & ECMD_ADDBUF) ||
#endif
check_fname() == FAIL)
if ((flags & ECMD_ADDBUF) || check_fname() == FAIL)
goto theend;

oldbuf = (flags & ECMD_OLDBUF);
Expand Down

0 comments on commit 0c72fe4

Please sign in to comment.