summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Filelist2
-rw-r--r--runtime/doc/eval.txt4
-rw-r--r--runtime/doc/various.txt3
-rw-r--r--src/Make_bc5.mak1
-rw-r--r--src/Make_cyg_ming.mak1
-rw-r--r--src/Make_dice.mak4
-rw-r--r--src/Make_ivc.mak5
-rw-r--r--src/Make_manx.mak6
-rw-r--r--src/Make_morph.mak1
-rw-r--r--src/Make_mvc.mak4
-rw-r--r--src/Make_sas.mak5
-rw-r--r--src/Make_vms.mms14
-rw-r--r--src/Makefile10
-rw-r--r--src/README.md7
-rw-r--r--src/buffer.c6
-rw-r--r--src/eval.c4
-rw-r--r--src/evalfunc.c2
-rw-r--r--src/ex_cmds.h6
-rw-r--r--src/ex_docmd.c1705
-rw-r--r--src/ex_getln.c16
-rw-r--r--src/feature.h4
-rw-r--r--src/macros.h3
-rw-r--r--src/misc2.c6
-rw-r--r--src/proto.h1
-rw-r--r--src/proto/ex_docmd.pro10
-rw-r--r--src/proto/usercmd.pro18
-rw-r--r--src/structs.h6
-rw-r--r--src/usercmd.c1656
-rw-r--r--src/version.c6
29 files changed, 1778 insertions, 1738 deletions
diff --git a/Filelist b/Filelist
index fc6374bacb..a6cc76c9f1 100644
--- a/Filelist
+++ b/Filelist
@@ -98,6 +98,7 @@ SRC_ALL = \
src/textprop.c \
src/ui.c \
src/undo.c \
+ src/usercmd.c \
src/userfunc.c \
src/version.c \
src/version.h \
@@ -212,6 +213,7 @@ SRC_ALL = \
src/proto/textprop.pro \
src/proto/ui.pro \
src/proto/undo.pro \
+ src/proto/usercmd.pro \
src/proto/userfunc.pro \
src/proto/version.pro \
src/proto/winclip.pro \
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 261457128e..ceaa0e0645 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 8.1. Last change: 2019 Apr 21
+*eval.txt* For Vim version 8.1. Last change: 2019 Apr 27
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -10550,7 +10550,7 @@ ttyin input is a terminal (tty)
ttyout output is a terminal (tty)
unix Unix version of Vim. *+unix*
unnamedplus Compiled with support for "unnamedplus" in 'clipboard'
-user_commands User-defined commands.
+user_commands User-defined commands. (always true)
vcon Win32: Virtual console support is working, can use
'termguicolors'. Also see |+vtp|.
vertsplit Compiled with vertically split windows |:vsplit|.
diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt
index 428a7348e7..923ac240f1 100644
--- a/runtime/doc/various.txt
+++ b/runtime/doc/various.txt
@@ -456,7 +456,8 @@ N *+textprop* |text-properties|
N *+timers* the |timer_start()| function
N *+title* Setting the window 'title' and 'icon'
N *+toolbar* |gui-toolbar|
-N *+user_commands* User-defined commands. |user-commands|
+T *+user_commands* User-defined commands. |user-commands|
+ Always enabled since 8.1.1210.
B *+vartabs* Variable-width tabstops. |'vartabstop'|
N *+viminfo* |'viminfo'|
*+vertsplit* Vertically split windows |:vsplit|; Always enabled
diff --git a/src/Make_bc5.mak b/src/Make_bc5.mak
index 62d03972e8..a6b4bc96e9 100644
--- a/src/Make_bc5.mak
+++ b/src/Make_bc5.mak
@@ -565,6 +565,7 @@ vimobj = \
$(OBJDIR)\term.obj \
$(OBJDIR)\ui.obj \
$(OBJDIR)\undo.obj \
+ $(OBJDIR)\usercmd.obj \
$(OBJDIR)\userfunc.obj \
$(OBJDIR)\version.obj \
$(OBJDIR)\window.obj \
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index 3c01e63fe0..599b9eeb4c 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -757,6 +757,7 @@ OBJ = \
$(OUTDIR)/textprop.o \
$(OUTDIR)/ui.o \
$(OUTDIR)/undo.o \
+ $(OUTDIR)/usercmd.o \
$(OUTDIR)/userfunc.o \
$(OUTDIR)/version.o \
$(OUTDIR)/vimrc.o \
diff --git a/src/Make_dice.mak b/src/Make_dice.mak
index 93e960a8db..89fa589459 100644
--- a/src/Make_dice.mak
+++ b/src/Make_dice.mak
@@ -83,6 +83,7 @@ SRC = \
term.c \
ui.c \
undo.c \
+ usercmd.c \
userfunc.c \
window.c \
version.c
@@ -144,6 +145,7 @@ OBJ = o/arabic.o \
o/term.o \
o/ui.o \
o/undo.o \
+ o/usercmd.o \
o/userfunc.o \
o/window.o \
$(TERMLIB)
@@ -288,6 +290,8 @@ o/ui.o: ui.c $(SYMS)
o/undo.o: undo.c $(SYMS)
+o/usercmd.o: usercmd.c $(SYMS)
+
o/userfunc.o: userfunc.c $(SYMS)
o/window.o: window.c $(SYMS)
diff --git a/src/Make_ivc.mak b/src/Make_ivc.mak
index 08bd87451f..a8b9dffd7b 100644
--- a/src/Make_ivc.mak
+++ b/src/Make_ivc.mak
@@ -269,6 +269,7 @@ LINK32_OBJS= \
"$(INTDIR)/term.obj" \
"$(INTDIR)/ui.obj" \
"$(INTDIR)/undo.obj" \
+ "$(INTDIR)/usercmd.obj" \
"$(INTDIR)/userfunc.obj" \
"$(INTDIR)/version.obj" \
"$(INTDIR)/window.obj"
@@ -728,6 +729,10 @@ SOURCE=.\undo.c
# End Source File
# Begin Source File
+SOURCE=.\usercmd.c
+# End Source File
+# Begin Source File
+
SOURCE=.\userfunc.c
# End Source File
# Begin Source File
diff --git a/src/Make_manx.mak b/src/Make_manx.mak
index 6eb7bfa684..e53522f06e 100644
--- a/src/Make_manx.mak
+++ b/src/Make_manx.mak
@@ -93,6 +93,7 @@ SRC = arabic.c \
term.c \
ui.c \
undo.c \
+ usercmd.c \
userfunc.c \
window.c \
version.c
@@ -156,6 +157,7 @@ OBJ = obj/arabic.o \
obj/term.o \
obj/ui.o \
obj/undo.o \
+ obj/usercmd.o \
obj/userfunc.o \
obj/window.o \
$(TERMLIB)
@@ -218,6 +220,7 @@ PRO = proto/arabic.pro \
proto/termlib.pro \
proto/ui.pro \
proto/undo.pro \
+ proto/usercmd.pro \
proto/userfunc.pro \
proto/window.pro
@@ -443,6 +446,9 @@ obj/ui.o: ui.c
obj/undo.o: undo.c
$(CCSYM) $@ undo.c
+obj/usercmd.o: usercmd.c
+ $(CCSYM) $@ usercmd.c
+
obj/userfunc.o: userfunc.c
$(CCSYM) $@ userfunc.c
diff --git a/src/Make_morph.mak b/src/Make_morph.mak
index 65cf8447be..a5ce62b8c6 100644
--- a/src/Make_morph.mak
+++ b/src/Make_morph.mak
@@ -81,6 +81,7 @@ SRC = arabic.c \
term.c \
ui.c \
undo.c \
+ usercmd.c \
userfunc.c \
version.c \
window.c \
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index 7da56bc2d8..ef2b7f3f9d 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -765,6 +765,7 @@ OBJ = \
$(OUTDIR)\textprop.obj \
$(OUTDIR)\ui.obj \
$(OUTDIR)\undo.obj \
+ $(OUTDIR)\usercmd.obj \
$(OUTDIR)\userfunc.obj \
$(OUTDIR)\winclip.obj \
$(OUTDIR)\window.obj \
@@ -1550,6 +1551,8 @@ $(OUTDIR)/ui.obj: $(OUTDIR) ui.c $(INCL)
$(OUTDIR)/undo.obj: $(OUTDIR) undo.c $(INCL)
+$(OUTDIR)/usercmd.obj: $(OUTDIR) usercmd.c $(INCL)
+
$(OUTDIR)/userfunc.obj: $(OUTDIR) userfunc.c $(INCL)
$(OUTDIR)/window.obj: $(OUTDIR) window.c $(INCL)
@@ -1693,6 +1696,7 @@ proto.h: \
proto/textprop.pro \
proto/ui.pro \
proto/undo.pro \
+ proto/usercmd.pro \
proto/userfunc.pro \
proto/window.pro \
$(NETBEANS_PRO) \
diff --git a/src/Make_sas.mak b/src/Make_sas.mak
index 78d6d2a93f..0d8eb3d9ec 100644
--- a/src/Make_sas.mak
+++ b/src/Make_sas.mak
@@ -146,6 +146,7 @@ SRC = \
term.c \
ui.c \
undo.c \
+ usercmd.c \
userfunc.c \
window.c \
version.c
@@ -208,6 +209,7 @@ OBJ = \
term.o \
ui.o \
undo.o \
+ usercmd.o \
userfunc.o \
window.o \
$(TERMLIB)
@@ -271,6 +273,7 @@ PRO = \
proto/termlib.pro \
proto/ui.pro \
proto/undo.pro \
+ proto/usercmd.pro \
proto/userfunc.pro \
proto/window.pro
@@ -445,6 +448,8 @@ ui.o: ui.c
proto/ui.pro: ui.c
undo.o: undo.c
proto/undo.pro: undo.c
+usercmd.o: usercmd.c
+proto/usercmd.pro: usercmd.c
userfunc.o: userfunc.c
proto/userfunc.pro: userfunc.c
window.o: window.c
diff --git a/src/Make_vms.mms b/src/Make_vms.mms
index edf77cb6bd..e25e426fd5 100644
--- a/src/Make_vms.mms
+++ b/src/Make_vms.mms
@@ -2,7 +2,7 @@
# Makefile for Vim on OpenVMS
#
# Maintainer: Zoltan Arpadffy <arpadffy@polarhome.com>
-# Last change: 2019 Mar 22
+# Last change: 2019 Apr 26
#
# This has script been tested on VMS 6.2 to 8.2 on DEC Alpha, VAX and IA64
# with MMS and MMK
@@ -315,8 +315,8 @@ SRC = arabic.c autocmd.c beval.c blob.c blowfish.c buffer.c charset.c \
menu.c mbyte.c memfile.c memline.c message.c misc1.c misc2.c move.c \
normal.c ops.c option.c popupmnu.c quickfix.c regexp.c search.c \
sha256.c sign.c spell.c spellfile.c syntax.c tag.c term.c termlib.c \
- textprop.c ui.c undo.c userfunc.c version.c screen.c window.c \
- os_unix.c os_vms.c pathdef.c \
+ textprop.c ui.c undo.c usercmd.c userfunc.c version.c screen.c \
+ window.c os_unix.c os_vms.c pathdef.c \
$(GUI_SRC) $(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) \
$(RUBY_SRC) $(HANGULIN_SRC) $(MZSCH_SRC) $(XDIFF_SRC)
@@ -330,7 +330,7 @@ OBJ = arabic.obj autocmd.obj beval.obj blob.obj blowfish.obj buffer.obj \
move.obj mbyte.obj normal.obj ops.obj option.obj popupmnu.obj \
quickfix.obj regexp.obj search.obj sha256.obj sign.obj spell.obj \
spellfile.obj syntax.obj tag.obj term.obj termlib.obj textprop.obj \
- ui.obj undo.obj userfunc.obj screen.obj version.obj \
+ ui.obj undo.obj usercmd.obj userfunc.obj screen.obj version.obj \
window.obj os_unix.obj os_vms.obj pathdef.obj if_mzsch.obj \
$(GUI_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(TCL_OBJ) \
$(RUBY_OBJ) $(HANGULIN_OBJ) $(MZSCH_OBJ) $(XDIFF_OBJ)
@@ -744,10 +744,16 @@ undo.obj : undo.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h gui.h beval.h \
[.proto]gui_beval.pro option.h ex_cmds.h proto.h globals.h \
+usercmd.obj : usercmd.c vim.h [.auto]config.h feature.h os_unix.h \
+ ascii.h keymap.h term.h macros.h option.h structs.h \
+ regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
+ proto.h globals.h
+
userfunc.obj : userfunc.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h beval.h [.proto]gui_beval.pro alloc.h ex_cmds.h spell.h \
proto.h globals.h
+
version.obj : version.c vim.h [.auto]config.h feature.h os_unix.h \
ascii.h keymap.h term.h macros.h structs.h regexp.h \
gui.h beval.h [.proto]gui_beval.pro option.h ex_cmds.h proto.h \
diff --git a/src/Makefile b/src/Makefile
index 40f4b1b90d..0e719ea12f 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1635,6 +1635,7 @@ BASIC_SRC = \
textprop.c \
ui.c \
undo.c \
+ usercmd.c \
userfunc.c \
version.c \
window.c \
@@ -1747,6 +1748,7 @@ OBJ_COMMON = \
objects/textprop.o \
objects/ui.o \
objects/undo.o \
+ objects/usercmd.o \
objects/userfunc.o \
objects/version.o \
objects/window.o \
@@ -1885,6 +1887,7 @@ PRO_AUTO = \
textprop.pro \
ui.pro \
undo.pro \
+ usercmd.pro \
userfunc.pro \
version.pro \
window.pro \
@@ -3242,6 +3245,9 @@ objects/ui.o: ui.c
objects/undo.o: undo.c
$(CCC) -o $@ undo.c
+objects/usercmd.o: usercmd.c
+ $(CCC) -o $@ usercmd.c
+
objects/userfunc.o: userfunc.c
$(CCC) -o $@ userfunc.c
@@ -3657,6 +3663,10 @@ objects/undo.o: undo.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
proto.h globals.h
+objects/usercmd.o: usercmd.c vim.h protodef.h auto/config.h feature.h os_unix.h \
+ auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
+ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
+ proto.h globals.h
objects/userfunc.o: userfunc.c vim.h protodef.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h beval.h \
proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \
diff --git a/src/README.md b/src/README.md
index f1e7ec2c31..c6bb8ac25c 100644
--- a/src/README.md
+++ b/src/README.md
@@ -28,6 +28,7 @@ buffer.c | manipulating buffers (loaded files)
debugger.c | vim script debugger
diff.c | diff mode (vimdiff)
eval.c | expression evaluation
+evalfunc.c | built-in functions
fileio.c | reading and writing files
findfile.c | search for files in 'path'
fold.c | folding
@@ -40,7 +41,7 @@ memfile.c | storing lines for buffers in a swapfile
memline.c | storing lines for buffers in memory
menu.c | menus
message.c | (error) messages
-ops.c | handling operators ("d", "y", "p")
+ops.c | handling operators ("d", "y", "p")
option.c | options
quickfix.c | quickfix commands (":make", ":cn")
regexp.c | pattern matching
@@ -49,9 +50,11 @@ search.c | pattern searching
sign.c | signs
spell.c | spell checking
syntax.c | syntax and other highlighting
-tag.c | tags
+tag.c | tags
term.c | terminal handling, termcap codes
undo.c | undo and redo
+usercmd.c | user defined commands
+userfunc.c | user defined functions
window.c | handling split windows
diff --git a/src/buffer.c b/src/buffer.c
index 869150006f..5a30affabe 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -925,11 +925,9 @@ free_buffer_stuff(
CHANGEDTICK(buf) = tick;
}
#endif
-#ifdef FEAT_USR_CMDS
- uc_clear(&buf->b_ucmds); /* clear local user commands */
-#endif
+ uc_clear(&buf->b_ucmds); // clear local user commands
#ifdef FEAT_SIGNS
- buf_delete_signs(buf, (char_u *)"*"); // delete any signs */
+ buf_delete_signs(buf, (char_u *)"*"); // delete any signs
#endif
#ifdef FEAT_NETBEANS_INTG
netbeans_file_killed(buf);
diff --git a/src/eval.c b/src/eval.c
index bf82d02633..a1ad0e673b 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1120,10 +1120,10 @@ call_func_retnr(
return retval;
}
-#if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) \
+#if defined(FEAT_CMDL_COMPL) \
|| defined(FEAT_COMPL_FUNC) || defined(PROTO)
-# if (defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)) || defined(PROTO)
+# if defined(FEAT_CMDL_COMPL) || defined(PROTO)
/*
* Call Vim script function "func" and return the result as a string.
* Returns NULL when calling the function fails.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 228b71ad5c..58b8492e56 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -6611,10 +6611,8 @@ f_has(typval_T *argvars, typval_T *rettv)
#if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
"unnamedplus",
#endif
-#ifdef FEAT_USR_CMDS
"user-commands", /* was accidentally included in 5.4 */
"user_commands",
-#endif
#ifdef FEAT_VARTABS
"vartabs",
#endif
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index c080cbef0f..ac354cda24 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -1753,13 +1753,9 @@ EX(CMD_tilde, "~", do_sub,
ADDR_LINES),
#ifndef DO_DECLARE_EXCMD
-#ifdef FEAT_USR_CMDS
CMD_SIZE, /* MUST be after all real commands! */
CMD_USER = -1, /* User-defined command */
CMD_USER_BUF = -2 /* User-defined command local to buffer */
-#else
- CMD_SIZE /* MUST be the last one! */
-#endif
#endif
};
@@ -1795,9 +1791,7 @@ struct exarg
int force_ff; /* ++ff= argument (first char of argument) */
int force_enc; /* ++enc= argument (index in cmd[]) */
int bad_char; /* BAD_KEEP, BAD_DROP or replacement byte */
-#ifdef FEAT_USR_CMDS
int useridx; /* user command index */
-#endif
char *errmsg; /* returned error message */
char_u *(*getline)(int, void *, int);
void *cookie; /* argument for getline() */
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 6b2fe4628e..0086589342 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -19,48 +19,6 @@ static int ex_pressedreturn = FALSE;
# define ex_hardcopy ex_ni
#endif
-#ifdef FEAT_USR_CMDS
-typedef struct ucmd
-{
- char_u *uc_name; /* The command name */
- long_u uc_argt; /* The argument type */
- char_u *uc_rep; /* The command's replacement string */
- long uc_def; /* The default value for a range/count */
- int uc_compl; /* completion type */
- int uc_addr_type; /* The command's address type */
-# ifdef FEAT_EVAL
- sctx_T uc_script_ctx; /* SCTX where the command was defined */
-# ifdef FEAT_CMDL_COMPL
- char_u *uc_compl_arg; /* completion argument if any */
-# endif
-# endif
-} ucmd_T;
-
-#define UC_BUFFER 1 /* -buffer: local to current buffer */
-
-static garray_T ucmds = {0, 0, sizeof(ucmd_T), 4, NULL};
-
-#define USER_CMD(i) (&((ucmd_T *)(ucmds.ga_data))[i])
-#define USER_CMD_GA(gap, i) (&((ucmd_T *)((gap)->ga_data))[i])
-
-static void do_ucmd(exarg_T *eap);
-static void ex_command(exarg_T *eap);
-static void ex_delcommand(exarg_T *eap);
-# ifdef FEAT_CMDL_COMPL
-static char_u *get_user_command_name(int idx);
-# endif
-
-/* Wether a command index indicates a user command. */
-# define IS_USER_CMDIDX(idx) ((int)(idx) < 0)
-
-#else
-# define ex_command ex_ni
-# define ex_comclear ex_ni
-# define ex_delcommand ex_ni
-/* Wether a command index indicates a user command. */
-# define IS_USER_CMDIDX(idx) (FALSE)
-#endif
-
#ifdef FEAT_EVAL
static char_u *do_one_cmd(char_u **, int, struct condstack *, char_u *(*fgetline)(int, void *, int), void *cookie);
#else
@@ -300,10 +258,6 @@ static void ex_redrawtabline(exarg_T *eap);
static void close_redir(void);
static void ex_mkrc(exarg_T *eap);
static void ex_mark(exarg_T *eap);
-#ifdef FEAT_USR_CMDS
-static char *uc_fun_cmd(void);
-static char_u *find_ucmd(exarg_T *eap, char_u *p, int *full, expand_T *xp, int *compl);
-#endif
static void ex_startinsert(exarg_T *eap);
static void ex_stopinsert(exarg_T *eap);
#ifdef FEAT_FIND_ID
@@ -1929,21 +1883,20 @@ do_one_cmd(
) ? find_command(&ea, NULL) : ea.cmd;
}
-#ifdef FEAT_USR_CMDS
if (p == NULL)
{
if (!ea.skip)
errormsg = _("E464: Ambiguous use of user-defined command");
goto doend;
}
- /* Check for wrong commands. */
+ // Check for wrong commands.
if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78
&& !IS_USER_CMDIDX(ea.cmdidx))
{
errormsg = uc_fun_cmd();
goto doend;
}
-#endif
+
if (ea.cmdidx == CMD_SIZE)
{
if (!ea.skip)
@@ -2508,7 +2461,6 @@ do_one_cmd(
* 7. Execute the command.
*/
-#ifdef FEAT_USR_CMDS
if (IS_USER_CMDIDX(ea.cmdidx))
{
/*
@@ -2517,10 +2469,9 @@ do_one_cmd(
do_ucmd(&ea);
}
else
-#endif
{
/*
- * Call the function to execute the command.
+ * Call the function to execute the builtin command.
*/
ea.errmsg = NULL;
(cmdnames[ea.cmdidx].cmd_func)(&ea);
@@ -3235,18 +3186,16 @@ find_command(exarg_T *eap, int *full UNUSED)
break;
}
-#ifdef FEAT_USR_CMDS
- /* Look for a user defined command as a last resort. Let ":Print" be
- * overruled by a user defined command. */
+ // Look for a user defined command as a last resort. Let ":Print" be
+ // overruled by a user defined command.
if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print)
&& *eap->cmd >= 'A' && *eap->cmd <= 'Z')
{
- /* User defined commands may contain digits. */
+ // User defined commands may contain digits.
while (ASCII_ISALNUM(*p))
++p;
p = find_ucmd(eap, p, full, NULL, NULL);
}
-#endif
if (p == eap->cmd)
eap->cmdidx = CMD_SIZE;
}
@@ -3254,124 +3203,6 @@ find_command(exarg_T *eap, int *full UNUSED)
return p;
}
-#ifdef FEAT_USR_CMDS
-/*
- * Search for a user command that matches "eap->cmd".
- * Return cmdidx in "eap->cmdidx", flags in "eap->argt", idx in "eap->useridx".
- * Return a pointer to just after the command.
- * Return NULL if there is no matching command.
- */
- static char_u *
-find_ucmd(
- exarg_T *eap,
- char_u *p, /* end of the command (possibly including count) */
- int *full, /* set to TRUE for a full match */
- expand_T *xp, /* used for completion, NULL otherwise */
- int *compl) /* completion flags or NULL */
-{
- int len = (int)(p - eap->cmd);
- int j, k, matchlen = 0;
- ucmd_T *uc;
- int found = FALSE;
- int possible = FALSE;
- char_u *cp, *np; /* Point into typed cmd and test name */
- garray_T *gap;
- int amb_local = FALSE; /* Found ambiguous buffer-local command,
- only full match global is accepted. */
-
- /*
- * Look for buffer-local user commands first, then global ones.
- */
- gap = &curbuf->b_ucmds;
- for (;;)
- {
- for (j = 0; j < gap->ga_len; ++j)
- {
- uc = USER_CMD_GA(gap, j);
- cp = eap->cmd;
- np = uc->uc_name;
- k = 0;
- while (k < len && *np != NUL && *cp++ == *np++)
- k++;
- if (k == len || (*np == NUL && vim_isdigit(eap->cmd[k])))
- {
- /* If finding a second match, the command is ambiguous. But
- * not if a buffer-local command wasn't a full match and a
- * global command is a full match. */
- if (k == len && found && *np != NUL)
- {
- if (gap == &ucmds)
- return NULL;
- amb_local = TRUE;
- }
-
- if (!found || (k == len && *np == NUL))
- {
- /* If we matched up to a digit, then there could
- * be another command including the digit that we
- * should use instead.
- */
- if (k == len)
- found = TRUE;
- else
- possible = TRUE;
-
- if (gap == &ucmds)
- eap->cmdidx = CMD_USER;
- else
- eap->cmdidx = CMD_USER_BUF;
- eap->argt = (long)uc->uc_argt;
- eap->useridx = j;
- eap->addr_type = uc->uc_addr_type;
-
-# ifdef FEAT_CMDL_COMPL
- if (compl != NULL)
- *compl = uc->uc_compl;
-# ifdef FEAT_EVAL
- if (xp != NULL)
- {
- xp->xp_arg = uc->uc_compl_arg;
- xp->xp_script_ctx = uc->uc_script_ctx;
- xp->xp_script_ctx.sc_lnum += sourcing_lnum;
- }
-# endif
-# endif
- /* Do not search for further abbreviations
- * if this is an exact match. */
- matchlen = k;
- if (k == len && *np == NUL)
- {
- if (full != NULL)
- *full = TRUE;
- amb_local = FALSE;
- break;
- }
- }
- }
- }
-
- /* Stop if we found a full match or searched all. */
- if (j < gap->ga_len || gap == &ucmds)
- break;
- gap = &ucmds;
- }
-
- /* Only found ambiguous matches. */
- if (amb_local)
- {
- if (xp != NULL)
- xp->xp_context = EXPAND_UNSUCCESSFUL;
- return NULL;
- }
-
- /* The match we found may be followed immediately by a number. Move "p"
- * back to point to it. */
- if (found || possible)
- return p + (matchlen - len);
- return p;
-}
-#endif
-
#if defined(FEAT_EVAL) || defined(PROTO)
static struct cmdmod
{
@@ -3483,10 +3314,8 @@ set_one_cmd_context(
char_u *cmd, *arg;
int len = 0;
exarg_T ea;
-#if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
- int compl = EXPAND_NOTHING;
-#endif
#ifdef FEAT_CMDL_COMPL
+ int compl = EXPAND_NOTHING;
int delim;
#endif
int forceit = FALSE;
@@ -3572,11 +3401,9 @@ set_one_cmd_context(
(size_t)len) == 0)
break;
-#ifdef FEAT_USR_CMDS
if (cmd[0] >= 'A' && cmd[0] <= 'Z')
- while (ASCII_ISALNUM(*p) || *p == '*') /* Allow * wild card */
+ while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card
++p;
-#endif
}
/*
@@ -3593,21 +3420,19 @@ set_one_cmd_context(
ea.cmdidx = CMD_substitute;
p = cmd + 1;
}
-#ifdef FEAT_USR_CMDS
else if (cmd[0] >= 'A' && cmd[0] <= 'Z')
{
ea.cmd = cmd;
p = find_ucmd(&ea, p, NULL, xp,
-# if defined(FEAT_CMDL_COMPL)
+#if defined(FEAT_CMDL_COMPL)
&compl
-# else
+#else
NULL
-# endif
+#endif
);
if (p == NULL)
- ea.cmdidx = CMD_SIZE; /* ambiguous user command */
+ ea.cmdidx = CMD_SIZE; // ambiguous user command
}
-#endif
}
if (ea.cmdidx == CMD_SIZE)
{
@@ -3828,7 +3653,7 @@ set_one_cmd_context(
{
xp->xp_context = EXPAND_ENV_VARS;
++xp->xp_pattern;
-#if defined(FEAT_USR_CMDS) && defined(FEAT_CMDL_COMPL)
+#if defined(FEAT_CMDL_COMPL)
/* Avoid that the assignment uses EXPAND_FILES again. */
if (compl != EXPAND_USER_DEFINED && compl != EXPAND_USER_LIST)
compl = EXPAND_ENV_VARS;
@@ -3944,68 +3769,13 @@ set_one_cmd_context(
* All completion for the +cmdline_compl feature goes here.
*/
-# ifdef FEAT_USR_CMDS
case CMD_command:
- /* Check for attributes */
- while (*arg == '-')
- {
- arg++; /* Skip "-" */
- p = skiptowhite(arg);
- if (*p == NUL)
- {
- /* Cursor is still in the attribute */
- p = vim_strchr(arg, '=');
- if (p == NULL)
- {
- /* No "=", so complete attribute names */
- xp->xp_context = EXPAND_USER_CMD_FLAGS;
- xp->xp_pattern = arg;
- return NULL;
- }
-
- /* For the -complete, -nargs and -addr attributes, we complete
- * their arguments as well.
- */
- if (STRNICMP(arg, "complete", p - arg) == 0)
- {
- xp->xp_context = EXPAND_USER_COMPLETE;
- xp->xp_pattern = p + 1;
- return NULL;
- }
- else if (STRNICMP(arg, "nargs", p - arg) == 0)
- {
- xp->xp_context = EXPAND_USER_NARGS;
- xp->xp_pattern = p + 1;
- return NULL;
- }
- else if (STRNICMP(arg, "addr", p - arg) == 0)
- {
- xp->xp_context = EXPAND_USER_ADDR_TYPE;
- xp->xp_pattern = p + 1;
- return NULL;
- }
- return NULL;
- }
- arg = skipwhite(p);
- }
-
- /* After the attributes comes the new command name */
- p = skiptowhite(arg);
- if (*p == NUL)
- {
- xp->xp_context = EXPAND_USER_COMMANDS;
- xp->xp_pattern = arg;
- break;
- }
-
- /* And finally comes a normal command */
- return skipwhite(p);
+ return set_context_in_user_cmd(xp, arg);
case CMD_delcommand:
xp->xp_context = EXPAND_USER_COMMANDS;
xp->xp_pattern = arg;
break;
-# endif
case CMD_global:
case CMD_vglobal:
@@ -4186,32 +3956,32 @@ set_one_cmd_context(
xp->xp_context = EXPAND_BUFFERS;
xp->xp_pattern = arg;
break;
-#ifdef FEAT_USR_CMDS
+
case CMD_USER:
case CMD_USER_BUF:
if (compl != EXPAND_NOTHING)
{
- /* XFILE: file names are handled above */
+ // XFILE: file names are handled above
if (!(ea.argt & XFILE))
{
-# ifdef FEAT_MENU
+#ifdef FEAT_MENU
if (compl == EXPAND_MENUS)
return set_context_in_menu_cmd(xp, cmd, arg, forceit);
-# endif
+#endif
if (compl == EXPAND_COMMANDS)
return arg;
if (compl == EXPAND_MAPPINGS)
return set_context_in_map_cmd(xp, (char_u *)"map",
arg, forceit, FALSE, FALSE, CMD_map);
- /* Find start of last argument. */
+ // Find start of last argument.
p = arg;
while (*p)
{
if (*p == ' ')
- /* argument starts after a space */
+ // argument starts after a space
arg = p + 1;
else if (*p == '\\' && *(p + 1) != NUL)
- ++p; /* skip over escaped character */
+ ++p; // skip over escaped character
MB_PTR_ADV(p);
}
xp->xp_pattern = arg;
@@ -4219,7 +3989,7 @@ set_one_cmd_context(
xp->xp_context = compl;
}
break;
-#endif
+
case CMD_map: case CMD_noremap:
case CMD_nmap: case CMD_nnoremap:
case CMD_vmap: case CMD_vnoremap:
@@ -5771,7 +5541,7 @@ check_more(
return OK;
}
-#ifdef FEAT_CMDL_COMPL
+#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
/*
* Function given to ExpandGeneric() to obtain the list of command names.
*/
@@ -5779,1440 +5549,11 @@ check_more(
get_command_name(expand_T *xp UNUSED, int idx)
{
if (idx >= (int)CMD_SIZE)
-# ifdef FEAT_USR_CMDS
return get_user_command_name(idx);
-# else
- return NULL;
-# endif
return cmdnames[idx].cmd_name;
}
#endif
-#if defined(FEAT_USR_CMDS) || defined(PROTO)
- static int
-uc_add_command(
- char_u *name,
- size_t name_len,
- char_u *rep,
- long argt,
- long de