annotate src/ex_docmd.c @ 29263:8408ffd9af69 v8.2.5150

patch 8.2.5150: read past the end of the first line with ":0;'{" Commit: https://github.com/vim/vim/commit/f7c7c3fad6d2135d558f3b36d0d1a943118aeb5e Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 22 19:08:38 2022 +0100 patch 8.2.5150: read past the end of the first line with ":0;'{" Problem: Read past the end of the first line with ":0;'{". Solution: When on line zero check the column is valid for line one.
author Bram Moolenaar <Bram@vim.org>
date Wed, 22 Jun 2022 20:15:03 +0200
parents 9e0b45df95b0
children 98de9a961a64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9980
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * ex_docmd.c: functions for executing an Ex command line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 static int quitmore = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 static int ex_pressedreturn = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #ifndef FEAT_PRINTER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 # define ex_hardcopy ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
23 static char_u *do_one_cmd(char_u **, int, cstack_T *, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #else
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
25 static char_u *do_one_cmd(char_u **, int, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
26 static int if_level = 0; // depth in :if
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
28 static void append_command(char_u *cmd);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
29
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 #ifndef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # define ex_emenu ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # define ex_menu ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 # define ex_menutranslate ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
35 static void ex_autocmd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
36 static void ex_doautocmd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
37 static void ex_bunload(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
38 static void ex_buffer(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
39 static void ex_bmodified(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
40 static void ex_bnext(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
41 static void ex_bprevious(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
42 static void ex_brewind(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
43 static void ex_blast(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
44 static char_u *getargcmd(char_u **);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
45 static int getargopt(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 #ifndef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # define ex_make ex_ni
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
48 # define ex_cbuffer ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 # define ex_cc ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 # define ex_cnext ex_ni
16505
28e3ba82d8c8 patch 8.1.1256: cannot navigate through errors relative to the cursor
Bram Moolenaar <Bram@vim.org>
parents: 16479
diff changeset
51 # define ex_cbelow ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 # define ex_cfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 # define qf_list ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 # define qf_age ex_ni
9538
26da1efa9e46 commit https://github.com/vim/vim/commit/f6acffbe83e622542d9fdf3066f51933e46e4954
Christian Brabandt <cb@256bit.org>
parents: 9536
diff changeset
55 # define qf_history ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # define ex_helpgrep ex_ni
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
57 # define ex_vimgrep ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
59 #if !defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # define ex_cclose ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # define ex_copen ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 # define ex_cwindow ex_ni
9432
abb72f0b9e06 commit https://github.com/vim/vim/commit/dcb170018642ec144cd87d9d9fe076575b8d1263
Christian Brabandt <cb@256bit.org>
parents: 9284
diff changeset
63 # define ex_cbottom ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 #endif
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
65 #if !defined(FEAT_QUICKFIX) || !defined(FEAT_EVAL)
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
66 # define ex_cexpr ex_ni
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
67 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
69 static linenr_T default_address(exarg_T *eap);
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
70 static linenr_T get_address(exarg_T *, char_u **, cmd_addr_T addr_type, int skip, int silent, int to_other_file, int address_count);
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
71 static void address_default_all(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
72 static void get_flags(exarg_T *eap);
2333
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
73 #if !defined(FEAT_PERL) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
74 || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
75 || !defined(FEAT_TCL) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
76 || !defined(FEAT_RUBY) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
77 || !defined(FEAT_LUA) \
aee7e1e5e0ce Build problem when using all interfaces except Lua.
Bram Moolenaar <bram@vim.org>
parents: 2330
diff changeset
78 || !defined(FEAT_MZSCHEME)
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
79 # define HAVE_EX_SCRIPT_NI
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
80 static void ex_script_ni(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
81 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
82 static char *invalid_range(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
83 static void correct_range(exarg_T *eap);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
84 #ifdef FEAT_QUICKFIX
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
85 static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
86 #endif
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
87 static char_u *repl_cmdline(exarg_T *eap, char_u *src, int srclen, char_u *repl, char_u **cmdlinep);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
88 static void ex_highlight(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
89 static void ex_colorscheme(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
90 static void ex_cquit(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
91 static void ex_quit_all(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
92 static void ex_close(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
93 static void ex_win_close(int forceit, win_T *win, tabpage_T *tp);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
94 static void ex_only(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
95 static void ex_resize(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
96 static void ex_stag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
97 static void ex_tabclose(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
98 static void ex_tabonly(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
99 static void ex_tabnext(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
100 static void ex_tabmove(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
101 static void ex_tabs(exarg_T *eap);
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
102 #if defined(FEAT_QUICKFIX)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
103 static void ex_pclose(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
104 static void ex_ptag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
105 static void ex_pedit(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 # define ex_pclose ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 # define ex_ptag ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 # define ex_pedit ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
111 static void ex_hide(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
112 static void ex_exit(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
113 static void ex_print(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #ifdef FEAT_BYTEOFF
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
115 static void ex_goto(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 # define ex_goto ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
119 static void ex_shell(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
120 static void ex_preserve(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
121 static void ex_recover(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
122 static void ex_mode(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
123 static void ex_wrongmodifier(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
124 static void ex_find(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
125 static void ex_open(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
126 static void ex_edit(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #ifndef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 # define ex_gui ex_nogui
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
129 static void ex_nogui(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15866
diff changeset
131 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
132 static void ex_tearoff(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 # define ex_tearoff ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 #endif
13392
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
136 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
137 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
138 static void ex_popup(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 # define ex_popup ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 #ifndef FEAT_GUI_MSWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 # define ex_simalt ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 #endif
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
145 #if !defined(FEAT_GUI_MSWIN) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 # define gui_mch_find_dialog ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 # define gui_mch_replace_dialog ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 #endif
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
149 #if !defined(FEAT_GUI_GTK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 # define ex_helpfind ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 #ifndef FEAT_CSCOPE
10373
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
153 # define ex_cscope ex_ni
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
154 # define ex_scscope ex_ni
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
155 # define ex_cstag ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 #ifndef FEAT_SYN_HL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 # define ex_syntax ex_ni
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2238
diff changeset
159 # define ex_ownsyntax ex_ni
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
160 #endif
4766
ec24ff78a79c updated for version 7.3.1130
Bram Moolenaar <bram@vim.org>
parents: 4764
diff changeset
161 #if !defined(FEAT_SYN_HL) || !defined(FEAT_PROFILE)
4764
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4710
diff changeset
162 # define ex_syntime ex_ni
f824cb97eb92 updated for version 7.3.1129
Bram Moolenaar <bram@vim.org>
parents: 4710
diff changeset
163 #endif
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
164 #ifndef FEAT_SPELL
310
04bf54c587f4 updated for version 7.0082
vimboss
parents: 296
diff changeset
165 # define ex_spell ex_ni
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
166 # define ex_mkspell ex_ni
351
a89aebda7f37 updated for version 7.0091
vimboss
parents: 344
diff changeset
167 # define ex_spelldump ex_ni
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 698
diff changeset
168 # define ex_spellinfo ex_ni
372
a698eb686ded updated for version 7.0096
vimboss
parents: 358
diff changeset
169 # define ex_spellrepall ex_ni
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
170 #endif
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
171 #ifndef FEAT_PERSISTENT_UNDO
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
172 # define ex_rundo ex_ni
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
173 # define ex_wundo ex_ni
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
174 #endif
2320
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
175 #ifndef FEAT_LUA
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
176 # define ex_lua ex_script_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
177 # define ex_luado ex_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
178 # define ex_luafile ex_ni
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
179 #endif
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
180 #ifndef FEAT_MZSCHEME
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
181 # define ex_mzscheme ex_script_ni
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
182 # define ex_mzfile ex_ni
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
183 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 #ifndef FEAT_PERL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 # define ex_perl ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 # define ex_perldo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 #ifndef FEAT_PYTHON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 # define ex_python ex_script_ni
4435
9b800f0a757f updated for version 7.3.966
Bram Moolenaar <bram@vim.org>
parents: 4417
diff changeset
190 # define ex_pydo ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 # define ex_pyfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 #endif
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
193 #ifndef FEAT_PYTHON3
2350
06feaf4fe36a Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents: 2340
diff changeset
194 # define ex_py3 ex_script_ni
4417
c16602758d84 updated for version 7.3.957
Bram Moolenaar <bram@vim.org>
parents: 4365
diff changeset
195 # define ex_py3do ex_ni
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
196 # define ex_py3file ex_ni
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
197 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
198 #if !defined(FEAT_PYTHON) && !defined(FEAT_PYTHON3)
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
199 # define ex_pyx ex_script_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
200 # define ex_pyxdo ex_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
201 # define ex_pyxfile ex_ni
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10656
diff changeset
202 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 #ifndef FEAT_TCL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 # define ex_tcl ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 # define ex_tcldo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 # define ex_tclfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 #ifndef FEAT_RUBY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 # define ex_ruby ex_script_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 # define ex_rubydo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 # define ex_rubyfile ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #ifndef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 # define ex_loadkeymap ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
216 static void ex_swapname(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
217 static void ex_syncbind(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
218 static void ex_read(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
219 static void ex_pwd(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
220 static void ex_equal(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
221 static void ex_sleep(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
222 static void ex_winsize(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
223 static void ex_wincmd(exarg_T *eap);
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
224 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
225 static void ex_winpos(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 # define ex_winpos ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
229 static void ex_operators(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
230 static void ex_put(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
231 static void ex_copymove(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
232 static void ex_submagic(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
233 static void ex_join(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
234 static void ex_at(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
235 static void ex_bang(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
236 static void ex_undo(exarg_T *eap);
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
237 #ifdef FEAT_PERSISTENT_UNDO
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
238 static void ex_wundo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
239 static void ex_rundo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
240 #endif
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
241 static void ex_redo(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
242 static void ex_later(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
243 static void ex_redir(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
244 static void ex_redrawstatus(exarg_T *eap);
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
245 static void ex_redrawtabline(exarg_T *eap);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
246 static void close_redir(void);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
247 static void ex_mark(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
248 static void ex_startinsert(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
249 static void ex_stopinsert(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 #ifdef FEAT_FIND_ID
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
251 static void ex_checkpath(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
252 static void ex_findpat(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 # define ex_findpat ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 # define ex_checkpath ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 #endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
257 #if defined(FEAT_FIND_ID) && defined(FEAT_QUICKFIX)
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
258 static void ex_psearch(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 # define ex_psearch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
262 static void ex_tag(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
263 static void ex_tag_cmd(exarg_T *eap, char_u *name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 #ifndef FEAT_EVAL
22559
715e8f14f314 patch 8.2.1828: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 22555
diff changeset
265 # define ex_block ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
266 # define ex_break ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
267 # define ex_breakadd ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
268 # define ex_breakdel ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
269 # define ex_breaklist ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
270 # define ex_call ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
271 # define ex_catch ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
272 # define ex_compiler ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
273 # define ex_continue ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
274 # define ex_debug ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
275 # define ex_debuggreedy ex_ni
20528
489cb75c76b6 patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents: 20474
diff changeset
276 # define ex_defcompile ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
277 # define ex_delfunction ex_ni
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
278 # define ex_disassemble ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 # define ex_echo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 # define ex_echohl ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
281 # define ex_else ex_ni
22559
715e8f14f314 patch 8.2.1828: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 22555
diff changeset
282 # define ex_endblock ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
283 # define ex_endfunction ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 # define ex_endif ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
285 # define ex_endtry ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 # define ex_endwhile ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
287 # define ex_eval ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
288 # define ex_execute ex_ni
24535
f522ef9e5ea3 patch 8.2.2807: build fails with tiny features
Bram Moolenaar <Bram@vim.org>
parents: 24533
diff changeset
289 # define ex_incdec ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
290 # define ex_finally ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
291 # define ex_finish ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
292 # define ex_function ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
293 # define ex_if ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
294 # define ex_let ex_ni
22393
d1b9bd52d721 patch 8.2.1745: tiny version doesn't build
Bram Moolenaar <Bram@vim.org>
parents: 22391
diff changeset
295 # define ex_var ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
296 # define ex_lockvar ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
297 # define ex_oldfiles ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
298 # define ex_options ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
299 # define ex_packadd ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
300 # define ex_packloadall ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
301 # define ex_return ex_ni
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
302 # define ex_scriptnames ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 # define ex_throw ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 # define ex_try ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 # define ex_unlet ex_ni
17622
ccbf8c2a47ee patch 8.1.1808: build failure for tiny version
Bram Moolenaar <Bram@vim.org>
parents: 17576
diff changeset
306 # define ex_while ex_ni
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
307 # define ex_import ex_ni
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
308 # define ex_export ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 #endif
17536
e00d12c085a5 patch 8.1.1766: code for writing session file is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17496
diff changeset
310 #ifndef FEAT_SESSION
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 # define ex_loadview ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 #endif
17458
cfdef48743ed patch 8.1.1727: code for viminfo support is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
313 #ifndef FEAT_VIMINFO
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 # define ex_viminfo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
316 static void ex_behave(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
317 static void ex_filetype(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
318 static void ex_setfiletype(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 #ifndef FEAT_DIFF
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 14
diff changeset
320 # define ex_diffoff ex_ni
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 # define ex_diffpatch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 # define ex_diffgetput ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 # define ex_diffsplit ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 # define ex_diffthis ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 # define ex_diffupdate ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 #endif
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
327 static void ex_digraphs(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 #ifdef FEAT_SEARCH_EXTRA
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
329 static void ex_nohlsearch(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 # define ex_nohlsearch ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 # define ex_match ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 #ifdef FEAT_CRYPT
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
335 static void ex_X(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 # define ex_X ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 #ifdef FEAT_FOLDING
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
340 static void ex_fold(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
341 static void ex_foldopen(exarg_T *eap);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
342 static void ex_folddo(exarg_T *eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 # define ex_fold ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 # define ex_foldopen ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 # define ex_folddo ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 #endif
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
348 #if !(defined(HAVE_LOCALE_H) || defined(X_LOCALE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 # define ex_language ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 #ifndef FEAT_SIGNS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 # define ex_sign ex_ni
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 #endif
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
354 #ifndef FEAT_NETBEANS_INTG
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2180
diff changeset
355 # define ex_nbclose ex_ni
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
356 # define ex_nbkey ex_ni
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2180
diff changeset
357 # define ex_nbstart ex_ni
33
f6033dcbaf31 updated for version 7.0020
vimboss
parents: 28
diff changeset
358 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
360 #ifndef FEAT_PROFILE
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
361 # define ex_profile ex_ni
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
362 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
363 #ifndef FEAT_TERMINAL
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
364 # define ex_terminal ex_ni
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11547
diff changeset
365 #endif
16608
0422b14bce58 patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
366 #if !defined(FEAT_X11) || !defined(FEAT_XCLIPBOARD)
0422b14bce58 patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
367 # define ex_xrestore ex_ni
0422b14bce58 patch 8.1.1307: cannot reconnect to the X server after it restarted
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
368 #endif
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
369 #if !defined(FEAT_PROP_POPUP)
16780
491c01280a5d patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
370 # define ex_popupclear ex_ni
491c01280a5d patch 8.1.1392: build failure in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
371 #endif
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
372
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 * Declare cmdnames[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 #define DO_DECLARE_EXCMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 #include "ex_cmds.h"
11374
889da8649221 patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents: 11258
diff changeset
378 #include "ex_cmdidxs.h"
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
379
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 static char_u dollar_command[2] = {'$', 0};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
384 // Struct for storing a line inside a while/for loop
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
387 char_u *line; // command line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
388 linenr_T lnum; // sourcing_lnum of the line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 } wcmd_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
392 * Structure used to store info for line position in a while or for loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 * This is required, because do_one_cmd() may invoke ex_function(), which
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
394 * reads more lines that may come from the while/for loop.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
395 */
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
396 struct loop_cookie
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
398 garray_T *lines_gap; // growarray with line info
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
399 int current_line; // last read line from growarray
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
400 int repeating; // TRUE when looping a second time
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
401 // When "repeating" is FALSE use "getline" and "cookie" to get lines
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
402 char_u *(*getline)(int, void *, int, getline_opt_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 void *cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
406 static char_u *get_loop_line(int c, void *cookie, int indent, getline_opt_T options);
7799
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
407 static int store_loop_line(garray_T *gap, char_u *line);
af3c41a3c53f commit https://github.com/vim/vim/commit/f28dbcea371b3a35727d91afc90fb90e0527d78a
Christian Brabandt <cb@256bit.org>
parents: 7703
diff changeset
408 static void free_cmdlines(garray_T *gap);
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
409
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
410 // Struct to save a few things while debugging. Used in do_cmdline() only.
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
411 struct dbg_stuff
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
412 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
413 int trylevel;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
414 int force_abort;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
415 except_T *caught_stack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
416 char_u *vv_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
417 char_u *vv_throwpoint;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
418 int did_emsg;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
419 int got_int;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
420 int did_throw;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
421 int need_rethrow;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
422 int check_cstack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
423 except_T *current_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
424 };
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
425
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
426 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
427 save_dbg_stuff(struct dbg_stuff *dsp)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
428 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
429 dsp->trylevel = trylevel; trylevel = 0;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
430 dsp->force_abort = force_abort; force_abort = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
431 dsp->caught_stack = caught_stack; caught_stack = NULL;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
432 dsp->vv_exception = v_exception(NULL);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
433 dsp->vv_throwpoint = v_throwpoint(NULL);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
434
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
435 // Necessary for debugging an inactive ":catch", ":finally", ":endtry"
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
436 dsp->did_emsg = did_emsg; did_emsg = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
437 dsp->got_int = got_int; got_int = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
438 dsp->did_throw = did_throw; did_throw = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
439 dsp->need_rethrow = need_rethrow; need_rethrow = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
440 dsp->check_cstack = check_cstack; check_cstack = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
441 dsp->current_exception = current_exception; current_exception = NULL;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
442 }
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
443
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
444 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
445 restore_dbg_stuff(struct dbg_stuff *dsp)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
446 {
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
447 suppress_errthrow = FALSE;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
448 trylevel = dsp->trylevel;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
449 force_abort = dsp->force_abort;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
450 caught_stack = dsp->caught_stack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
451 (void)v_exception(dsp->vv_exception);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
452 (void)v_throwpoint(dsp->vv_throwpoint);
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
453 did_emsg = dsp->did_emsg;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
454 got_int = dsp->got_int;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
455 did_throw = dsp->did_throw;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
456 need_rethrow = dsp->need_rethrow;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
457 check_cstack = dsp->check_cstack;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
458 current_exception = dsp->current_exception;
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
459 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 * command is given.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
467 do_exmode(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
468 int improved) // TRUE for "improved Ex" mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 int save_msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 int prev_msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 linenr_T prev_line;
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10875
diff changeset
473 varnumber_T changedtick;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
474
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
475 if (improved)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
476 exmode_active = EXMODE_VIM;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
477 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
478 exmode_active = EXMODE_NORMAL;
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28741
diff changeset
479 State = MODE_NORMAL;
28397
d1702731786c patch 8.2.4723: the ModeChanged autocmd event is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 28367
diff changeset
480 may_trigger_modechanged();
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
481
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
482 // When using ":global /pat/ visual" and then "Q" we return to continue
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
483 // the :global command.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
484 if (global_busy)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
485 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 save_msg_scroll = msg_scroll;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
488 ++RedrawingDisabled; // don't redisplay the window
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
489 ++no_wait_return; // don't wait for return
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 #ifdef FEAT_GUI
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
491 // Ignore scrollbar and mouse events in Ex mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 ++hold_gui_events;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
495 msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode."));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 while (exmode_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
498 // Check for a ":normal" command and no more characters left.
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
499 if (ex_normal_busy > 0 && typebuf.tb_len == 0)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
500 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
501 exmode_active = FALSE;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
502 break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
503 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 msg_scroll = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 ex_pressedreturn = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 ex_no_reprint = FALSE;
10952
835604f3c37a patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
508 changedtick = CHANGEDTICK(curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 prev_msg_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 prev_line = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 if (improved)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 cmdline_row = msg_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 do_cmdline(NULL, getexline, NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 lines_left = Rows - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
520 if ((prev_line != curwin->w_cursor.lnum
10952
835604f3c37a patch 8.0.0365: might free a dict item that wasn't allocated
Christian Brabandt <cb@256bit.org>
parents: 10889
diff changeset
521 || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
522 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
523 if (curbuf->b_ml.ml_flags & ML_EMPTY)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
524 emsg(_(e_empty_buffer));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
525 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
526 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
527 if (ex_pressedreturn)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
528 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
529 // go up one line, to overwrite the ":<CR>" line, so the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
530 // output doesn't contain empty lines.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
531 msg_row = prev_msg_row;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
532 if (prev_msg_row == Rows - 1)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
533 msg_row--;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
534 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
535 msg_col = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
536 print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
537 msg_clr_eos();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
538 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
539 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
540 else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
541 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
542 if (curbuf->b_ml.ml_flags & ML_EMPTY)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
543 emsg(_(e_empty_buffer));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
544 else
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
545 emsg(_(e_at_end_of_file));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
546 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 --hold_gui_events;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 --RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 update_screen(CLEAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 msg_scroll = save_msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 /*
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
560 * Print the executed command for when 'verbose' is set.
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
561 * When "lnum" is 0 only print the command.
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
562 */
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
563 static void
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
564 msg_verbose_cmd(linenr_T lnum, char_u *cmd)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
565 {
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
566 ++no_wait_return;
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
567 verbose_enter_scroll();
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
568
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
569 if (lnum == 0)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
570 smsg(_("Executing: %s"), cmd);
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
571 else
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
572 smsg(_("line %ld: %s"), (long)lnum, cmd);
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
573 if (msg_silent == 0)
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
574 msg_puts("\n"); // don't overwrite this
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
575
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
576 verbose_leave_scroll();
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
577 --no_wait_return;
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
578 }
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
579
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
580 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 * Execute a simple command line. Used for translated commands like "*".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
584 do_cmdline_cmd(char_u *cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 return do_cmdline(cmd, NULL, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 /*
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
591 * Execute the "+cmd" argument of "edit +cmd fname" and the like.
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
592 * This allows for using a range without ":" in Vim9 script.
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
593 */
25567
0082503ff2ff patch 8.2.3320: some local functions are not static
Bram Moolenaar <Bram@vim.org>
parents: 25523
diff changeset
594 static int
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
595 do_cmd_argument(char_u *cmd)
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
596 {
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
597 return do_cmdline(cmd, NULL, NULL,
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
598 DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED|DOCMD_RANGEOK);
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
599 }
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
600
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
601 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 * do_cmdline(): execute one Ex command line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 * 1. Execute "cmdline" when it is not NULL.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
605 * If "cmdline" is NULL, or more lines are needed, fgetline() is used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 * 2. Split up in parts separated with '|'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 * This function can be called recursively!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 * flags:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 * DOCMD_VERBOSE - The command will be included in the error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 * DOCMD_NOWAIT - Don't call wait_return() and friends.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
613 * DOCMD_REPEAT - Repeat execution until fgetline() returns NULL.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 * DOCMD_KEYTYPED - Don't reset KeyTyped.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 * DOCMD_EXCRESET - Reset the exception environment (used for debugging).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 * DOCMD_KEEPLINE - Store first typed line (for repeating with ".").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 * return FAIL if cmdline could not be executed, OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
621 do_cmdline(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
622 char_u *cmdline,
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
623 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
624 void *cookie, // argument for fgetline()
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
625 int flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
627 char_u *next_cmdline; // next cmd to execute
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
628 char_u *cmdline_copy = NULL; // copy of cmd line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
629 int used_getline = FALSE; // used "fgetline" to obtain command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
630 static int recursive = 0; // recursive depth
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 int msg_didout_before_start = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
632 int count = 0; // line number count
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
633 int did_inc = FALSE; // incremented RedrawingDisabled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634 int retval = OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 #ifdef FEAT_EVAL
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
636 cstack_T cstack; // conditional stack
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
637 garray_T lines_ga; // keep lines for ":while"/":for"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
638 int current_line = 0; // active line in lines_ga
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
639 int current_line_before = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
640 char_u *fname = NULL; // function or script name
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
641 linenr_T *breakpoint = NULL; // ptr to breakpoint field in cookie
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
642 int *dbg_tick = NULL; // ptr to dbg_tick field in cookie
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
643 struct dbg_stuff debug_saved; // saved things for debug mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 int initial_trylevel;
20538
9f921ba86d05 patch 8.2.0823: Vim9: script reload test is disabled
Bram Moolenaar <Bram@vim.org>
parents: 20536
diff changeset
645 msglist_T **saved_msg_list = NULL;
22685
80b4e604d1d5 patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents: 22616
diff changeset
646 msglist_T *private_msg_list = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
648 // "fgetline" and "cookie" passed to do_one_cmd()
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
649 char_u *(*cmd_getline)(int, void *, int, getline_opt_T);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 void *cmd_cookie;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
651 struct loop_cookie cmd_loop_cookie;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 void *real_cookie;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
653 int getline_is_func;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 #else
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
655 # define cmd_getline fgetline
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 # define cmd_cookie cookie
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
658 static int call_depth = 0; // recursiveness
20009
6eb3c91d9875 patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
659 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
660 // For every pair of do_cmdline()/do_one_cmd() calls, use an extra memory
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
661 // location for storing error messages to be converted to an exception.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
662 // This ensures that the do_errthrow() call in do_one_cmd() does not
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
663 // combine the messages stored by an earlier invocation of do_one_cmd()
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
664 // with the command name of the later one. This would happen when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
665 // BufWritePost autocommands are executed after a write error.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 saved_msg_list = msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 msg_list = &private_msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
670 // It's possible to create an endless loop with ":execute", catch that
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
671 // here. The value of 200 allows nested function calls, ":source", etc.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
672 // Allow 200 or 'maxfuncdepth', whatever is larger.
10490
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
673 if (call_depth >= 200
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
674 #ifdef FEAT_EVAL
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
675 && call_depth >= p_mfd
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
676 #endif
8f2191b56d52 commit https://github.com/vim/vim/commit/b094ff4b2be4d8b7364c566a1cc7e27aa4452a50
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
677 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 {
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
679 emsg(_(e_command_too_recursive));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
681 // When converting to an exception, we do not include the command name
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
682 // since this is not an error of the specific command.
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
683 do_errthrow((cstack_T *)NULL, (char_u *)NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 msg_list = saved_msg_list;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 ++call_depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 #ifdef FEAT_EVAL
23742
1f24fcf5945a patch 8.2.2412: not all fields in "cstack" are initialized
Bram Moolenaar <Bram@vim.org>
parents: 23717
diff changeset
691 CLEAR_FIELD(cstack);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 cstack.cs_idx = -1;
27028
c9474ae175f4 patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
693 ga_init2(&lines_ga, sizeof(wcmd_T), 10);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
695 real_cookie = getline_cookie(fgetline, cookie);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
697 // Inside a function use a higher nesting level.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
698 getline_is_func = getline_equal(fgetline, cookie, get_func_line);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
699 if (getline_is_func && ex_nesting_level == func_level(real_cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 ++ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
702 // Get the function or script name and the address where the next breakpoint
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
703 // line and the debug tick for a function or script are stored.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
704 if (getline_is_func)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 fname = func_name(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 breakpoint = func_breakpoint(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 dbg_tick = func_dbg_tick(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
710 else if (getline_equal(fgetline, cookie, getsourceline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
712 fname = SOURCING_NAME;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 breakpoint = source_breakpoint(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 dbg_tick = source_dbg_tick(real_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 * Initialize "force_abort" and "suppress_errthrow" at the top level.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 if (!recursive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 force_abort = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 suppress_errthrow = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 * If requested, store and reset the global values controlling the
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
728 * exception handling (used when debugging). Otherwise clear it to avoid
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
729 * a bogus compiler warning when the optimizer uses inline functions...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 */
878
64be6e0b070a updated for version 7.0-004
vimboss
parents: 866
diff changeset
731 if (flags & DOCMD_EXCRESET)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
732 save_dbg_stuff(&debug_saved);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
733 else
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
734 CLEAR_FIELD(debug_saved);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 initial_trylevel = trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 * "did_throw" will be set to TRUE when an exception is being thrown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 did_throw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 * "did_emsg" will be set to TRUE when emsg() is used, in which case we
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
745 * cancel the whole command line, and any if/endif or loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 * If force_abort is set, we cancel everything.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 */
22948
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
748 #ifdef FEAT_EVAL
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
749 did_emsg_cumul += did_emsg;
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
750 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 did_emsg = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 * KeyTyped is only set when calling vgetc(). Reset it here when not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 * calling vgetc() (sourced command lines).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
757 if (!(flags & DOCMD_KEYTYPED)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
758 && !getline_equal(fgetline, cookie, getexline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 KeyTyped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 * Continue executing command lines:
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
763 * - when inside an ":if", ":while" or ":for"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 * - for multiple commands on one line, separated with '|'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 * - when repeating until there are no more lines (for ":source")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 next_cmdline = cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
770 #ifdef FEAT_EVAL
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
771 getline_is_func = getline_equal(fgetline, cookie, get_func_line);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
772 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
773
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
774 // stop skipping cmds for an error msg after all endif/while/for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 if (next_cmdline == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 && !force_abort
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 && cstack.cs_idx < 0
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
779 && !(getline_is_func && func_has_abort(real_cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 )
22948
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
782 {
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
783 #ifdef FEAT_EVAL
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
784 did_emsg_cumul += did_emsg;
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
785 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 did_emsg = FALSE;
22948
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
787 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
790 * 1. If repeating a line in a loop, get a line from lines_ga.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
791 * 2. If no line given: Get an allocated line with fgetline().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 * 3. If a line is given: Make a copy, so we can mess with it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
796 // 1. If repeating, get a previous line from lines_ga.
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
797 if (cstack.cs_looplevel > 0 && current_line < lines_ga.ga_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
799 // Each '|' separated command is stored separately in lines_ga, to
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
800 // be able to jump to it. Don't use next_cmdline now.
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
801 VIM_CLEAR(cmdline_copy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
803 // Check if a function has returned or, unless it has an unclosed
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
804 // try conditional, aborted.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
805 if (getline_is_func)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
806 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
807 # ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
808 if (do_profiling == PROF_YES)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
809 func_line_end(real_cookie);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
810 # endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
811 if (func_has_ended(real_cookie))
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
812 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
813 retval = FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
814 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
815 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
816 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
817 #ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
818 else if (do_profiling == PROF_YES
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
819 && getline_equal(fgetline, cookie, getsourceline))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
820 script_line_end();
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
821 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
823 // Check if a sourced file hit a ":finish" command.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
824 if (source_finished(fgetline, cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
830 // If breakpoints have been added/deleted need to check for it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 if (breakpoint != NULL && dbg_tick != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 && *dbg_tick != debug_tick)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
835 getline_equal(fgetline, cookie, getsourceline),
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
836 fname, SOURCING_LNUM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 next_cmdline = ((wcmd_T *)(lines_ga.ga_data))[current_line].line;
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
841 SOURCING_LNUM = ((wcmd_T *)(lines_ga.ga_data))[current_line].lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
843 // Did we encounter a breakpoint?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 if (breakpoint != NULL && *breakpoint != 0
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
845 && *breakpoint <= SOURCING_LNUM)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
847 dbg_breakpoint(fname, SOURCING_LNUM);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
848 // Find next breakpoint.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
850 getline_equal(fgetline, cookie, getsourceline),
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
851 fname, SOURCING_LNUM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
854 # ifdef FEAT_PROFILE
788
b5aed52a4881 updated for version 7.0230
vimboss
parents: 771
diff changeset
855 if (do_profiling == PROF_YES)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
856 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
857 if (getline_is_func)
23717
e3720756acdc patch 8.2.2400: Vim9: compiled functions are not profiled
Bram Moolenaar <Bram@vim.org>
parents: 23709
diff changeset
858 func_line_start(real_cookie, SOURCING_LNUM);
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
859 else if (getline_equal(fgetline, cookie, getsourceline))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
860 script_line_start();
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
861 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
862 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
866 // 2. If no line given, get an allocated line with fgetline().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 * Need to set msg_didout for the first line after an ":if",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 * otherwise the ":if" will be overwritten.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
873 if (count == 1 && getline_equal(fgetline, cookie, getexline))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 msg_didout = TRUE;
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
875 if (fgetline == NULL || (next_cmdline = fgetline(':', cookie,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 cstack.cs_idx < 0 ? 0 : (cstack.cs_idx + 1) * 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 #endif
23398
40f824f5c7c7 patch 8.2.2242: Vim9: bar line continuation does not work at script level
Bram Moolenaar <Bram@vim.org>
parents: 23390
diff changeset
881 , in_vim9script() ? GETLINE_CONCAT_CONTBAR
40f824f5c7c7 patch 8.2.2242: Vim9: bar line continuation does not work at script level
Bram Moolenaar <Bram@vim.org>
parents: 23390
diff changeset
882 : GETLINE_CONCAT_CONT)) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
884 // Don't call wait_return for aborted command line. The NULL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
885 // returned for the end of a sourced file or executed function
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
886 // doesn't do this.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 if (KeyTyped && !(flags & DOCMD_REPEAT))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 need_wait_return = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 used_getline = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 * Keep the first typed line. Clear it when more lines are typed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 if (flags & DOCMD_KEEPLINE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 vim_free(repeat_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 if (count == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 repeat_cmdline = vim_strsave(next_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 repeat_cmdline = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
907 // 3. Make a copy of the command so we can mess with it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 else if (cmdline_copy == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 next_cmdline = vim_strsave(next_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 {
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25304
diff changeset
913 emsg(_(e_out_of_memory));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 cmdline_copy = next_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 /*
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
922 * Inside a while/for loop, and when the command looks like a ":while"
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
923 * or ":for", the line is stored, because we may need it later when
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
924 * looping.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
925 *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
926 * When there is a '|' and another command, it is stored separately,
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
927 * because we need to be able to jump back to it from an
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
928 * :endwhile/:endfor.
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
929 *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
930 * Pass a different "fgetline" function to do_one_cmd() below,
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
931 * that it stores lines in or reads them from "lines_ga". Makes it
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
932 * possible to define a function inside a while/for loop and handles
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
933 * line continuation.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 */
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
935 if ((cstack.cs_looplevel > 0 || has_loop_cmd(next_cmdline)))
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
936 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
937 cmd_getline = get_loop_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
938 cmd_cookie = (void *)&cmd_loop_cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
939 cmd_loop_cookie.lines_gap = &lines_ga;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
940 cmd_loop_cookie.current_line = current_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
941 cmd_loop_cookie.getline = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
942 cmd_loop_cookie.cookie = cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
943 cmd_loop_cookie.repeating = (current_line < lines_ga.ga_len);
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
944
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
945 // Save the current line when encountering it the first time.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
946 if (current_line == lines_ga.ga_len
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
947 && store_loop_line(&lines_ga, next_cmdline) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 retval = FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 }
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
952 current_line_before = current_line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
953 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
954 else
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
955 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
956 cmd_getline = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
957 cmd_cookie = cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
958 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
959
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 did_endif = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 if (count++ == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 * All output from the commands is put below each other, without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * waiting for a return. Don't do this when executing commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 * from a script or when being called recursive (e.g. for ":e
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 * +command file").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 if (!(flags & DOCMD_NOWAIT) && !recursive)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 msg_didout_before_start = msg_didout;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
974 msg_didany = FALSE; // no output yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 msg_start();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
976 msg_scroll = TRUE; // put messages below each other
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
977 ++no_wait_return; // don't wait for return until finished
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 ++RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 did_inc = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982
20575
501b72481d0a patch 8.2.0841: 'verbose' value 16 causes duplicate output
Bram Moolenaar <Bram@vim.org>
parents: 20538
diff changeset
983 if ((p_verbose >= 15 && SOURCING_NAME != NULL) || p_verbose >= 16)
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
984 msg_verbose_cmd(SOURCING_LNUM, cmdline_copy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 * 2. Execute one '|' separated command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 * do_one_cmd() will return NULL if there is no trailing '|'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 * "cmdline_copy" can change, e.g. for '%' and '#' expansion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 ++recursive;
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
992 next_cmdline = do_one_cmd(&cmdline_copy, flags,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 &cstack,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 cmd_getline, cmd_cookie);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 --recursive;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 #ifdef FEAT_EVAL
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1000 if (cmd_cookie == (void *)&cmd_loop_cookie)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1001 // Use "current_line" from "cmd_loop_cookie", it may have been
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1002 // incremented when defining a function.
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1003 current_line = cmd_loop_cookie.current_line;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 if (next_cmdline == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
1008 VIM_CLEAR(cmdline_copy);
17652
9efb4dda9720 patch 8.1.1823: command line history code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17650
diff changeset
1009
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 * If the command was typed, remember it for the ':' register.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 * Do this AFTER executing the command to make :@: work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1014 if (getline_equal(fgetline, cookie, getexline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 && new_last_cmdline != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 vim_free(last_cmdline);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 last_cmdline = new_last_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 new_last_cmdline = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1024 // need to copy the command after the '|' to cmdline_copy, for the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1025 // next do_one_cmd()
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
1026 STRMOVE(cmdline_copy, next_cmdline);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1027 next_cmdline = cmdline_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1032 // reset did_emsg for a function that is not aborted by an error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 if (did_emsg && !force_abort
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1034 && getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 && !func_has_abort(real_cookie))
22948
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1036 {
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1037 // did_emsg_cumul is not set here
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 did_emsg = FALSE;
22948
707b90980de5 patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1039 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1041 if (cstack.cs_looplevel > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 ++current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1046 * An ":endwhile", ":endfor" and ":continue" is handled here.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1047 * If we were executing commands, jump back to the ":while" or
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1048 * ":for".
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1049 * If we were not executing commands, decrement cs_looplevel.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1051 if (cstack.cs_lflags & (CSL_HAD_CONT | CSL_HAD_ENDLOOP))
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1052 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1053 cstack.cs_lflags &= ~(CSL_HAD_CONT | CSL_HAD_ENDLOOP);
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1054
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1055 // Jump back to the matching ":while" or ":for". Be careful
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1056 // not to use a cs_line[] from an entry that isn't a ":while"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1057 // or ":for": It would make "current_line" invalid and can
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1058 // cause a crash.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059 if (!did_emsg && !got_int && !did_throw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 && cstack.cs_idx >= 0
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1061 && (cstack.cs_flags[cstack.cs_idx]
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1062 & (CSF_WHILE | CSF_FOR))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 && cstack.cs_line[cstack.cs_idx] >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 && (cstack.cs_flags[cstack.cs_idx] & CSF_ACTIVE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 current_line = cstack.cs_line[cstack.cs_idx];
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1067 // remember we jumped there
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1068 cstack.cs_lflags |= CSL_HAD_LOOP;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1069 line_breakcheck(); // check if CTRL-C typed
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1070
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1071 // Check for the next breakpoint at or after the ":while"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1072 // or ":for".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 if (breakpoint != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 *breakpoint = dbg_find_breakpoint(
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1076 getline_equal(fgetline, cookie, getsourceline),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 fname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 ((wcmd_T *)lines_ga.ga_data)[current_line].lnum-1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 *dbg_tick = debug_tick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 }
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1082 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1084 // can only get here with ":endwhile" or ":endfor"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 if (cstack.cs_idx >= 0)
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1086 rewind_conditionals(&cstack, cstack.cs_idx - 1,
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1087 CSF_WHILE | CSF_FOR, &cstack.cs_looplevel);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1092 * For a ":while" or ":for" we need to remember the line number.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1094 else if (cstack.cs_lflags & CSL_HAD_LOOP)
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1095 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1096 cstack.cs_lflags &= ~CSL_HAD_LOOP;
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1097 cstack.cs_line[cstack.cs_idx] = current_line_before;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1101 // Check for the next breakpoint after a watchexpression
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1102 if (breakpoint != NULL && has_watchexpr())
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1103 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1104 *breakpoint = dbg_find_breakpoint(FALSE, fname, SOURCING_LNUM);
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1105 *dbg_tick = debug_tick;
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1106 }
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
1107
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 * When not inside any ":while" loop, clear remembered lines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1111 if (cstack.cs_looplevel == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 if (lines_ga.ga_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 {
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1115 SOURCING_LNUM =
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 ((wcmd_T *)lines_ga.ga_data)[lines_ga.ga_len - 1].lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 free_cmdlines(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 current_line = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1123 * A ":finally" makes did_emsg, got_int, and did_throw pending for
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1124 * being restored at the ":endtry". Reset them here and set the
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1125 * ACTIVE and FINALLY flags, so that the finally clause gets executed.
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1126 * This includes the case where a missing ":endif", ":endwhile" or
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1127 * ":endfor" was detected by the ":finally" itself.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 */
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1129 if (cstack.cs_lflags & CSL_HAD_FINA)
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1130 {
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1131 cstack.cs_lflags &= ~CSL_HAD_FINA;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1132 report_make_pending(cstack.cs_pending[cstack.cs_idx]
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1133 & (CSTP_ERROR | CSTP_INTERRUPT | CSTP_THROW),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 did_throw ? (void *)current_exception : NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 did_emsg = got_int = did_throw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 cstack.cs_flags[cstack.cs_idx] |= CSF_ACTIVE | CSF_FINALLY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1139 // Update global "trylevel" for recursive calls to do_cmdline() from
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1140 // within this loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 trylevel = initial_trylevel + cstack.cs_trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 /*
1190
4e90dc161511 updated for version 7.1b
vimboss
parents: 1132
diff changeset
1144 * If the outermost try conditional (across function calls and sourced
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 * files) is aborted because of an error, an interrupt, or an uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 * exception, cancel everything. If it is left normally, reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 * force_abort to get the non-EH compatible abortion behavior for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 * the rest of the script.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 if (trylevel == 0 && !did_emsg && !got_int && !did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 force_abort = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1153 // Convert an interrupt to an exception if appropriate.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 (void)do_intthrow(&cstack);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1155 #endif // FEAT_EVAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 * Continue executing command lines when:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 * - no CTRL-C typed, no aborting error, no exception thrown or try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 * conditionals need to be checked for executing finally clauses or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 * catching an interrupt exception
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 * - didn't get an error message or lines are not typed
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1164 * - there is a command after '|', inside a :if, :while, :for or :try, or
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 * looping for ":source" command or function call.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 while (!((got_int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 #ifdef FEAT_EVAL
24555
83877a1b66fd patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents: 24543
diff changeset
1169 || (did_emsg && (force_abort || in_vim9script()))
83877a1b66fd patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents: 24543
diff changeset
1170 || did_throw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 && cstack.cs_trylevel == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 )
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1177 && !(did_emsg
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1178 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1179 // Keep going when inside try/catch, so that the error can be
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1180 // deal with, except when it is a syntax error, it may cause
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1181 // the :endtry to be missed.
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1182 && (cstack.cs_trylevel == 0 || did_emsg_syntax)
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1183 #endif
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1184 && used_getline
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1185 && (getline_equal(fgetline, cookie, getexmodeline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1186 || getline_equal(fgetline, cookie, getexline)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 && (next_cmdline != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 || cstack.cs_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 || (flags & DOCMD_REPEAT)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 vim_free(cmdline_copy);
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
1194 did_emsg_syntax = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 free_cmdlines(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 ga_clear(&lines_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 if (cstack.cs_idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 * If a sourced file or executed function ran to its end, report the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 * unclosed conditional.
24555
83877a1b66fd patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents: 24543
diff changeset
1204 * In Vim9 script do not give a second error, executing aborts after
83877a1b66fd patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents: 24543
diff changeset
1205 * the first one.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 */
29010
36ef8d453ade patch 8.2.5027: error for missing :endif when an exception was thrown
Bram Moolenaar <Bram@vim.org>
parents: 29008
diff changeset
1207 if (!got_int && !did_throw && !aborting()
36ef8d453ade patch 8.2.5027: error for missing :endif when an exception was thrown
Bram Moolenaar <Bram@vim.org>
parents: 29008
diff changeset
1208 && !(did_emsg && in_vim9script())
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1209 && ((getline_equal(fgetline, cookie, getsourceline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1210 && !source_finished(fgetline, cookie))
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1211 || (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 && !func_has_ended(real_cookie))))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 if (cstack.cs_flags[cstack.cs_idx] & CSF_TRY)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
1215 emsg(_(e_missing_endtry));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 else if (cstack.cs_flags[cstack.cs_idx] & CSF_WHILE)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
1217 emsg(_(e_missing_endwhile));
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1218 else if (cstack.cs_flags[cstack.cs_idx] & CSF_FOR)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
1219 emsg(_(e_missing_endfor));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 else
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
1221 emsg(_(e_missing_endif));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 * Reset "trylevel" in case of a ":finish" or ":return" or a missing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 * ":endtry" in a sourced file or executed function. If the try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 * conditional is in its finally clause, ignore anything pending.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 * If it is in a catch clause, finish the caught exception.
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1229 * Also cleanup any "cs_forinfo" structures.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 do
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1232 {
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1233 int idx = cleanup_conditionals(&cstack, 0, TRUE);
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1234
111
a3d7e800ddec updated for version 7.0041
vimboss
parents: 98
diff changeset
1235 if (idx >= 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1236 --idx; // remove try block not in its finally clause
77
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1237 rewind_conditionals(&cstack, idx, CSF_WHILE | CSF_FOR,
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1238 &cstack.cs_looplevel);
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1239 }
31e555c6c691 updated for version 7.0032
vimboss
parents: 72
diff changeset
1240 while (cstack.cs_idx >= 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 trylevel = initial_trylevel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1244 // If a missing ":endtry", ":endwhile", ":endfor", or ":endif" or a memory
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1245 // lack was reported above and the error message is to be converted to an
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1246 // exception, do this now after rewinding the cstack.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1247 do_errthrow(&cstack, getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 ? (char_u *)"endfunction" : (char_u *)NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 if (trylevel == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 {
22543
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1252 // Just in case did_throw got set but current_exception wasn't.
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1253 if (current_exception == NULL)
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1254 did_throw = FALSE;
1722ed01c729 patch 8.2.1820: Vim9: crash when error happens in timer callback
Bram Moolenaar <Bram@vim.org>
parents: 22442
diff changeset
1255
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 * When an exception is being thrown out of the outermost try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 * conditional, discard the uncaught exception, disable the conversion
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 * of interrupts or errors to exceptions, and ensure that no more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 * commands are executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 if (did_throw)
25445
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1263 handle_did_throw();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 * On an interrupt or an aborting error not converted to an exception,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 * disable the conversion of errors to exceptions. (Interrupts are not
20009
6eb3c91d9875 patch 8.2.0560: compiler warning in tiny build
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1268 * converted anymore, here.) This enables also the interrupt message
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 * when force_abort is set and did_emsg unset in case of an interrupt
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 * from a finally clause after an error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 else if (got_int || (did_emsg && force_abort))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 suppress_errthrow = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 * The current cstack will be freed when do_cmdline() returns. An uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 * exception will have to be rethrown in the previous cstack. If a function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 * has just returned or a script file was just finished and the previous
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 * cstack belongs to the same function or, respectively, script file, it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 * will have to be checked for finally clauses to be executed due to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 * ":return" or ":finish". This is done in do_one_cmd().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 if (did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 need_rethrow = TRUE;
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1286 if ((getline_equal(fgetline, cookie, getsourceline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 && ex_nesting_level > source_level(real_cookie))
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1288 || (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 && ex_nesting_level > func_level(real_cookie) + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 if (!did_throw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 check_cstack = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1296 // When leaving a function, reduce nesting level.
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1297 if (getline_equal(fgetline, cookie, get_func_line))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 --ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 * Go to debug mode when returning from a function in which we are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 * single-stepping.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 */
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1303 if ((getline_equal(fgetline, cookie, getsourceline)
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1304 || getline_equal(fgetline, cookie, get_func_line))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 && ex_nesting_level + 1 <= debug_break_level)
2635
1c4ec9ed71ca updated for version 7.3.056
Bram Moolenaar <bram@vim.org>
parents: 2633
diff changeset
1306 do_debug(getline_equal(fgetline, cookie, getsourceline)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 ? (char_u *)_("End of sourced file")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 : (char_u *)_("End of function"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 * Restore the exception environment (done after returning from the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 * debugger).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 if (flags & DOCMD_EXCRESET)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
1316 restore_dbg_stuff(&debug_saved);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 msg_list = saved_msg_list;
19685
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1319
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1320 // Cleanup if "cs_emsg_silent_list" remains.
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1321 if (cstack.cs_emsg_silent_list != NULL)
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1322 {
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1323 eslist_T *elem, *temp;
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1324
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1325 for (elem = cstack.cs_emsg_silent_list; elem != NULL; elem = temp)
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1326 {
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1327 temp = elem->next;
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1328 vim_free(elem);
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1329 }
d64f403289db patch 8.2.0399: various memory leaks
Bram Moolenaar <Bram@vim.org>
parents: 19621
diff changeset
1330 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1331 #endif // FEAT_EVAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 * If there was too much output to fit on the command line, ask the user to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 * hit return before redrawing the screen. With the ":global" command we do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 * this only once after the command is finished.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 if (did_inc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 --RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 --no_wait_return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 * When just finished an ":if"-":else" which was typed, no need to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 * wait for hit-return. Also for an error situation.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 if (retval == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 || (did_endif && KeyTyped && !did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 need_wait_return = FALSE;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1355 msg_didany = FALSE; // don't wait when restarting edit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 else if (need_wait_return)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 * The msg_start() above clears msg_didout. The wait_return we do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 * here should not overwrite the command that may be shown before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 * doing that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 msg_didout |= msg_didout_before_start;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 wait_return(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368
3976
67e3b2753a6e updated for version 7.3.743
Bram Moolenaar <bram@vim.org>
parents: 3972
diff changeset
1369 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1370 did_endif = FALSE; // in case do_cmdline used recursively
3976
67e3b2753a6e updated for version 7.3.743
Bram Moolenaar <bram@vim.org>
parents: 3972
diff changeset
1371 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 * Reset if_level, in case a sourced script file contains more ":if" than
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 * ":endif" (could be ":if x | foo | endif").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 if_level = 0;
3972
6e1fe64cf440 updated for version 7.3.741
Bram Moolenaar <bram@vim.org>
parents: 3963
diff changeset
1377 #endif
3963
1773d5aa6437 updated for version 7.3.737
Bram Moolenaar <bram@vim.org>
parents: 3839
diff changeset
1378
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 --call_depth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382
25447
93f8b181db8f patch 8.2.3260: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 25445
diff changeset
1383 #if defined(FEAT_EVAL) || defined(PROTO)
25445
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1384 /*
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1385 * Handle when "did_throw" is set after executing commands.
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1386 */
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1387 void
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1388 handle_did_throw()
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1389 {
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1390 char *p = NULL;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1391 msglist_T *messages = NULL;
25451
6f2384c064e4 patch 8.2.3262: build failure when ABORT_ON_INTERNAL_ERROR is defined
Bram Moolenaar <Bram@vim.org>
parents: 25447
diff changeset
1392 ESTACK_CHECK_DECLARATION
25445
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1393
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1394 /*
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1395 * If the uncaught exception is a user exception, report it as an
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1396 * error. If it is an error exception, display the saved error
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1397 * message now. For an interrupt exception, do nothing; the
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1398 * interrupt message is given elsewhere.
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1399 */
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1400 switch (current_exception->type)
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1401 {
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1402 case ET_USER:
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1403 vim_snprintf((char *)IObuff, IOSIZE,
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26941
diff changeset
1404 _(e_exception_not_caught_str),
25445
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1405 current_exception->value);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1406 p = (char *)vim_strsave(IObuff);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1407 break;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1408 case ET_ERROR:
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1409 messages = current_exception->messages;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1410 current_exception->messages = NULL;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1411 break;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1412 case ET_INTERRUPT:
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1413 break;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1414 }
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1415
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1416 estack_push(ETYPE_EXCEPT, current_exception->throw_name,
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1417 current_exception->throw_lnum);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1418 ESTACK_CHECK_SETUP
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1419 current_exception->throw_name = NULL;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1420
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1421 discard_current_exception(); // uses IObuff if 'verbose'
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1422 suppress_errthrow = TRUE;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1423 force_abort = TRUE;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1424
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1425 if (messages != NULL)
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1426 {
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1427 do
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1428 {
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1429 msglist_T *next = messages->next;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1430 int save_compiling = estack_compiling;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1431
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1432 estack_compiling = messages->msg_compiling;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1433 emsg(messages->msg);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1434 vim_free(messages->msg);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1435 vim_free(messages->sfile);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1436 vim_free(messages);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1437 messages = next;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1438 estack_compiling = save_compiling;
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1439 }
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1440 while (messages != NULL);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1441 }
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1442 else if (p != NULL)
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1443 {
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1444 emsg(p);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1445 vim_free(p);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1446 }
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1447 vim_free(SOURCING_NAME);
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1448 ESTACK_CHECK_NOW
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1449 estack_pop();
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1450 }
65f04b6effd5 patch 8.2.3259: when 'indentexpr' causes an error did_throw may hang
Bram Moolenaar <Bram@vim.org>
parents: 25384
diff changeset
1451
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1453 * Obtain a line when inside a ":while" or ":for" loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 static char_u *
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1456 get_loop_line(int c, void *cookie, int indent, getline_opt_T options)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 {
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1458 struct loop_cookie *cp = (struct loop_cookie *)cookie;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 wcmd_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 if (cp->current_line + 1 >= cp->lines_gap->ga_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 if (cp->repeating)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1465 return NULL; // trying to read past ":endwhile"/":endfor"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1466
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1467 // First time inside the ":while"/":for": get line normally.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 if (cp->getline == NULL)
26804
34f1b7d6974a patch 8.2.3930: getcmdline() argument has a misleading type
Bram Moolenaar <Bram@vim.org>
parents: 26771
diff changeset
1469 line = getcmdline(c, 0L, indent, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 else
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1471 line = cp->getline(c, cp->cookie, indent, options);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
1472 if (line != NULL && store_loop_line(cp->lines_gap, line) == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 ++cp->current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 return line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 KeyTyped = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 ++cp->current_line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line;
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1481 SOURCING_LNUM = wp->lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 return vim_strsave(wp->line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 * Store a line in "gap" so that a ":while" loop can execute it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1489 store_loop_line(garray_T *gap, char_u *line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 if (ga_grow(gap, 1) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 ((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line);
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
1494 ((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = SOURCING_LNUM;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 ++gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 /*
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1500 * Free the lines stored for a ":while" or ":for" loop.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1503 free_cmdlines(garray_T *gap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 while (gap->ga_len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 vim_free(((wcmd_T *)(gap->ga_data))[gap->ga_len - 1].line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 --gap->ga_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 /*
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1514 * If "fgetline" is get_loop_line(), return TRUE if the getline it uses equals
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1515 * "func". * Otherwise return TRUE when "fgetline" equals "func".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1518 getline_equal(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1519 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1520 void *cookie UNUSED, // argument for fgetline()
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1521 char_u *(*func)(int, void *, int, getline_opt_T))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1524 char_u *(*gp)(int, void *, int, getline_opt_T);
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1525 struct loop_cookie *cp;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1526
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1527 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1528 // function that's originally used to obtain the lines. This may be
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1529 // nested several levels.
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1530 gp = fgetline;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1531 cp = (struct loop_cookie *)cookie;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1532 while (gp == get_loop_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 gp = cp->getline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 cp = cp->cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 return gp == func;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 #else
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1539 return fgetline == func;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 /*
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1544 * If "fgetline" is get_loop_line(), return the cookie used by the original
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 * getline function. Otherwise return "cookie".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 void *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1548 getline_cookie(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1549 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1550 void *cookie) // argument for fgetline()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1552 #ifdef FEAT_EVAL
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1553 char_u *(*gp)(int, void *, int, getline_opt_T);
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1554 struct loop_cookie *cp;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1555
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1556 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1557 // cookie that's originally used to obtain the lines. This may be nested
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1558 // several levels.
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1559 gp = fgetline;
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1560 cp = (struct loop_cookie *)cookie;
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
1561 while (gp == get_loop_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 gp = cp->getline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 cp = cp->cookie;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 return cp;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1567 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 return cookie;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1569 #endif
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
1570 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1572 #if defined(FEAT_EVAL) || defined(PROT)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1573 /*
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1574 * Get the next line source line without advancing.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1575 */
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1576 char_u *
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1577 getline_peek(
21883
a427f5f26419 patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Bram Moolenaar <Bram@vim.org>
parents: 21845
diff changeset
1578 char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1579 void *cookie) // argument for fgetline()
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1580 {
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1581 char_u *(*gp)(int, void *, int, getline_opt_T);
21056
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1582 struct loop_cookie *cp;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1583 wcmd_T *wp;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1584
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1585 // When "fgetline" is "get_loop_line()" use the "cookie" to find the
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1586 // cookie that's originally used to obtain the lines. This may be nested
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1587 // several levels.
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1588 gp = fgetline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1589 cp = (struct loop_cookie *)cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1590 while (gp == get_loop_line)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1591 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1592 if (cp->current_line + 1 < cp->lines_gap->ga_len)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1593 {
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1594 // executing lines a second time, use the stored copy
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1595 wp = (wcmd_T *)(cp->lines_gap->ga_data) + cp->current_line + 1;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1596 return wp->line;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1597 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1598 gp = cp->getline;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1599 cp = cp->cookie;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1600 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1601 if (gp == getsourceline)
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1602 return source_nextline(cp);
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1603 return NULL;
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1604 }
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1605 #endif
a7c202f5cbe9 patch 8.2.1079: Vim9: no line break allowed in a while loop
Bram Moolenaar <Bram@vim.org>
parents: 21016
diff changeset
1606
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1607
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1608 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1609 * Helper function to apply an offset for buffer commands, i.e. ":bdelete",
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1610 * ":bwipeout", etc.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1611 * Returns the buffer number.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1612 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1613 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1614 compute_buffer_local_count(int addr_type, int lnum, int offset)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1615 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1616 buf_T *buf;
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1617 buf_T *nextbuf;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1618 int count = offset;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1619
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1620 buf = firstbuf;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1621 while (buf->b_next != NULL && buf->b_fnum < lnum)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1622 buf = buf->b_next;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1623 while (count != 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1624 {
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1625 count += (offset < 0) ? 1 : -1;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1626 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1627 if (nextbuf == NULL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1628 break;
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1629 buf = nextbuf;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1630 if (addr_type == ADDR_LOADED_BUFFERS)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1631 // skip over unloaded buffers
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1632 while (buf->b_ml.ml_mfp == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1633 {
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1634 nextbuf = (offset < 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1635 if (nextbuf == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1636 break;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1637 buf = nextbuf;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1638 }
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1639 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1640 // we might have gone too far, last buffer is not loadedd
6417
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1641 if (addr_type == ADDR_LOADED_BUFFERS)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1642 while (buf->b_ml.ml_mfp == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1643 {
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1644 nextbuf = (offset >= 0) ? buf->b_prev : buf->b_next;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1645 if (nextbuf == NULL)
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1646 break;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1647 buf = nextbuf;
77fe94082f53 updated for version 7.4.539
Bram Moolenaar <bram@vim.org>
parents: 6409
diff changeset
1648 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1649 return buf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1650 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1651
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1652 /*
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1653 * Return the window number of "win".
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1654 * When "win" is NULL return the number of windows.
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
1655 */
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1656 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1657 current_win_nr(win_T *win)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1658 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1659 win_T *wp;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1660 int nr = 0;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1661
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
1662 FOR_ALL_WINDOWS(wp)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1663 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1664 ++nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1665 if (wp == win)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1666 break;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1667 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1668 return nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1669 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1670
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1671 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1672 current_tab_nr(tabpage_T *tab)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1673 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1674 tabpage_T *tp;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1675 int nr = 0;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1676
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
1677 FOR_ALL_TABPAGES(tp)
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1678 {
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1679 ++nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1680 if (tp == tab)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1681 break;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1682 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1683 return nr;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1684 }
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1685
21357
72bf1b368cfe patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1686 static int
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1687 comment_start(char_u *p, int starts_with_colon UNUSED)
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1688 {
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1689 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1690 if (in_vim9script())
23179
821701ecbde7 patch 8.2.2135: Vim9: #{ still seen as start of dict in some places
Bram Moolenaar <Bram@vim.org>
parents: 23171
diff changeset
1691 return p[0] == '#' && !starts_with_colon;
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1692 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1693 return *p == '"';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1694 }
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1695
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1696 # define CURRENT_WIN_NR current_win_nr(curwin)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1697 # define LAST_WIN_NR current_win_nr(NULL)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1698 # define CURRENT_TAB_NR current_tab_nr(curtab)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
1699 # define LAST_TAB_NR current_tab_nr(NULL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1700
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 * Execute one Ex command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 *
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1704 * If "flags" has DOCMD_VERBOSE, the command will be included in the error
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1705 * message.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 * 1. skip comment lines and leading space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 * 2. handle command modifiers
6400
2c0cddd0df8c updated for version 7.4.531
Bram Moolenaar <bram@vim.org>
parents: 6398
diff changeset
1709 * 3. find the command
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1710 * 4. parse range
6400
2c0cddd0df8c updated for version 7.4.531
Bram Moolenaar <bram@vim.org>
parents: 6398
diff changeset
1711 * 5. Parse the command.
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1712 * 6. parse arguments
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1713 * 7. switch on command name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 *
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1715 * Note: "fgetline" can be NULL.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 * This function may be called recursively!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
1720 do_one_cmd(
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1721 char_u **cmdlinep,
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1722 int flags,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 #ifdef FEAT_EVAL
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1724 cstack_T *cstack,
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1725 #endif
21885
72525eabfe61 patch 8.2.1492: build failures
Bram Moolenaar <Bram@vim.org>
parents: 21883
diff changeset
1726 char_u *(*fgetline)(int, void *, int, getline_opt_T),
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1727 void *cookie) // argument for fgetline()
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1728 {
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1729 char_u *p;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1730 linenr_T lnum;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1731 long n;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1732 char *errormsg = NULL; // error message
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1733 char_u *after_modifier = NULL;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1734 exarg_T ea; // Ex command arguments
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1735 cmdmod_T save_cmdmod;
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1736 int save_reg_executing = reg_executing;
28359
390dfc3e409b patch 8.2.4705: jump list marker disappears
Bram Moolenaar <Bram@vim.org>
parents: 28313
diff changeset
1737 int save_pending_end_reg_executing = pending_end_reg_executing;
18904
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1738 int ni; // set when Not Implemented
2bdc2e1f6e1f patch 8.2.0013: not using a typedef for condstack
Bram Moolenaar <Bram@vim.org>
parents: 18849
diff changeset
1739 char_u *cmd;
21357
72bf1b368cfe patch 8.2.1229: build error without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21353
diff changeset
1740 int starts_with_colon = FALSE;
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1741 #ifdef FEAT_EVAL
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1742 int may_have_range;
23938
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
1743 int vim9script;
22732
4c21a3a47707 patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents: 22724
diff changeset
1744 int did_set_expr_line = FALSE;
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1745 #endif
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1746 int sourcing = flags & DOCMD_VERBOSE;
29146
72108041757c patch 8.2.5093: error message for unknown command may have the command twice
Bram Moolenaar <Bram@vim.org>
parents: 29144
diff changeset
1747 int did_append_cmd = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
1749 CLEAR_FIELD(ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 ea.line1 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 ea.line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 ++ex_nesting_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1756 // When the last file has not been edited :q has to be typed twice.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 if (quitmore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1759 // avoid that a function call in 'statusline' does this
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
1760 && !getline_equal(fgetline, cookie, get_func_line)
4133
36fd800b8c6c updated for version 7.3.819
Bram Moolenaar <bram@vim.org>
parents: 3997
diff changeset
1761 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1762 // avoid that an autocommand, e.g. QuitPre, does this
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1763 && !getline_equal(fgetline, cookie, getnextac))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 --quitmore;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 * Reset browse, confirm, etc.. They are restored when returning, for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 * recursive calls.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 save_cmdmod = cmdmod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1772 // "#!anything" is handled like a comment.
930
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1773 if ((*cmdlinep)[0] == '#' && (*cmdlinep)[1] == '!')
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1774 goto doend;
529c6a431ff5 updated for version 7.0-056
vimboss
parents: 878
diff changeset
1775
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1776 /*
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1777 * 1. Skip comment lines and leading white space and colons.
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1778 * 2. Handle command modifiers.
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1779 */
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
1780 // The "ea" structure holds the arguments that can be used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 ea.cmd = *cmdlinep;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1782 ea.cmdlinep = cmdlinep;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1783 ea.getline = fgetline;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1784 ea.cookie = cookie;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1785 #ifdef FEAT_EVAL
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1786 ea.cstack = cstack;
19497
639b1d672757 patch 8.2.0306: Vim9: :substitute(pat(repl does not work in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19481
diff changeset
1787 starts_with_colon = *skipwhite(ea.cmd) == ':';
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1788 #endif
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
1789 if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
1790 goto doend;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
1791 apply_cmdmod(&cmdmod);
23944
6e593e0aaadf patch 8.2.2514: Vim9: build error in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 23938
diff changeset
1792 #ifdef FEAT_EVAL
23938
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
1793 vim9script = in_vim9script();
23944
6e593e0aaadf patch 8.2.2514: Vim9: build error in tiny version
Bram Moolenaar <Bram@vim.org>
parents: 23938
diff changeset
1794 #endif
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
1795 after_modifier = ea.cmd;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 ea.skip = did_emsg || got_int || did_throw || (cstack->cs_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 && !(cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 ea.skip = (if_level > 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 /*
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1805 * 3. Skip over the range to find the command. Let "p" point to after it.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1806 *
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1807 * We need the command to know what kind of range it uses.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1808 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1809 cmd = ea.cmd;
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1810 #ifdef FEAT_EVAL
22772
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1811 // In Vim9 script a colon is required before the range. This may also be
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1812 // after command modifiers.
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
1813 if (vim9script && (flags & DOCMD_RANGEOK) == 0)
22772
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1814 {
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1815 may_have_range = FALSE;
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1816 for (p = ea.cmd; p >= *cmdlinep; --p)
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1817 {
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1818 if (*p == ':')
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1819 may_have_range = TRUE;
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1820 if (p < ea.cmd && !VIM_ISWHITE(*p))
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1821 break;
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1822 }
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1823 }
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1824 else
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1825 may_have_range = TRUE;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1826 if (may_have_range)
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1827 #endif
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
1828 ea.cmd = skip_range(ea.cmd, TRUE, NULL);
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1829
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1830 #ifdef FEAT_EVAL
22772
82a7aff951d2 patch 8.2.1934: Vim9: command modifiers in :def function not tested
Bram Moolenaar <Bram@vim.org>
parents: 22750
diff changeset
1831 if (vim9script && !may_have_range)
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1832 {
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1833 if (ea.cmd == cmd + 1 && *cmd == '$')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1834 // should be "$VAR = val"
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
1835 --ea.cmd;
24049
fc4c2beea99a patch 8.2.2566: Vim9: Function name is not recognized
Bram Moolenaar <Bram@vim.org>
parents: 23978
diff changeset
1836 p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
22790
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1837 if (ea.cmdidx == CMD_SIZE)
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1838 {
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1839 char_u *ar = skip_range(ea.cmd, TRUE, NULL);
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1840
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1841 // If a ':' before the range is missing, give a clearer error
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1842 // message.
24934
75bd12f3bfeb patch 8.2.3004: Vim9: error for missing colon given while skipping
Bram Moolenaar <Bram@vim.org>
parents: 24846
diff changeset
1843 if (ar > ea.cmd && !ea.skip)
22790
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1844 {
23346
2060f53b7c17 patch 8.2.2216: Vim9: range with missing colon can be hard to spot
Bram Moolenaar <Bram@vim.org>
parents: 23342
diff changeset
1845 semsg(_(e_colon_required_before_range_str), ea.cmd);
22790
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1846 goto doend;
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1847 }
44317eb799d7 patch 8.2.1943: Vim9: wrong error message when colon is missing
Bram Moolenaar <Bram@vim.org>
parents: 22772
diff changeset
1848 }
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
1849 }
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1850 else
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1851 #endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1852 p = find_ex_command(&ea, NULL, NULL, NULL);
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1853
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1854 #ifdef FEAT_EVAL
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1855 # ifdef FEAT_PROFILE
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1856 // Count this line for profiling if skip is TRUE.
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1857 if (do_profiling == PROF_YES
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1858 && (!ea.skip || cstack->cs_idx == 0 || (cstack->cs_idx > 0
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1859 && (cstack->cs_flags[cstack->cs_idx - 1] & CSF_ACTIVE))))
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1860 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1861 int skip = did_emsg || got_int || did_throw;
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1862
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1863 if (ea.cmdidx == CMD_catch)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1864 skip = !skip && !(cstack->cs_idx >= 0
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1865 && (cstack->cs_flags[cstack->cs_idx] & CSF_THROWN)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1866 && !(cstack->cs_flags[cstack->cs_idx] & CSF_CAUGHT));
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1867 else if (ea.cmdidx == CMD_else || ea.cmdidx == CMD_elseif)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1868 skip = skip || !(cstack->cs_idx >= 0
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1869 && !(cstack->cs_flags[cstack->cs_idx]
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1870 & (CSF_ACTIVE | CSF_TRUE)));
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1871 else if (ea.cmdidx == CMD_finally)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1872 skip = FALSE;
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1873 else if (ea.cmdidx != CMD_endif
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1874 && ea.cmdidx != CMD_endfor
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1875 && ea.cmdidx != CMD_endtry
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1876 && ea.cmdidx != CMD_endwhile)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1877 skip = ea.skip;
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1878
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1879 if (!skip)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1880 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1881 if (getline_equal(fgetline, cookie, get_func_line))
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1882 func_line_exec(getline_cookie(fgetline, cookie));
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1883 else if (getline_equal(fgetline, cookie, getsourceline))
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1884 script_line_exec();
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1885 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1886 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1887 # endif
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1888
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1889 // May go to debug mode. If this happens and the ">quit" debug command is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1890 // used, throw an interrupt exception and skip the next command.
14591
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1891 dbg_check_breakpoint(&ea);
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1892 if (!ea.skip && got_int)
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1893 {
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1894 ea.skip = TRUE;
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1895 (void)do_intthrow(cstack);
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1896 }
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1897 #endif
96878f6f5d4c patch 8.1.0309: profiling does not show a count for condition lines
Christian Brabandt <cb@256bit.org>
parents: 14585
diff changeset
1898
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1899 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1900 * 4. parse a range specifier of the form: addr [,addr] [;addr] ..
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 * where 'addr' is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 * % (entire file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 * $ [+-NUM]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 * 'x [+-NUM] (where x denotes a currently defined mark)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 * . [+-NUM]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 * [+-NUM]..
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 * NUM
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 * The ea.cmd pointer is updated to point to the first character following the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 * range spec. If an initial address is found, but no second, the upper bound
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 * is equal to the lower.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1916 // ea.addr_type for user commands is set by find_ucmd
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1917 if (!IS_USER_CMDIDX(ea.cmdidx))
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1918 {
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1919 if (ea.cmdidx != CMD_SIZE)
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1920 ea.addr_type = cmdnames[(int)ea.cmdidx].cmd_addr_type;
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1921 else
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1922 ea.addr_type = ADDR_LINES;
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1923
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1924 // :wincmd range depends on the argument.
6506
a5a6f1467b1e updated for version 7.4.580
Bram Moolenaar <bram@vim.org>
parents: 6489
diff changeset
1925 if (ea.cmdidx == CMD_wincmd && p != NULL)
a5a6f1467b1e updated for version 7.4.580
Bram Moolenaar <bram@vim.org>
parents: 6489
diff changeset
1926 get_wincmd_addr_type(skipwhite(p), &ea);
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1927 #ifdef FEAT_QUICKFIX
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1928 // :.cc in quickfix window uses line number
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1929 if ((ea.cmdidx == CMD_cc || ea.cmdidx == CMD_ll) && bt_quickfix(curbuf))
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1930 ea.addr_type = ADDR_OTHER;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
1931 #endif
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1932 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1933
6489
cba15023c403 updated for version 7.4.572
Bram Moolenaar <bram@vim.org>
parents: 6480
diff changeset
1934 ea.cmd = cmd;
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1935 #ifdef FEAT_EVAL
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1936 if (!may_have_range)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1937 ea.line1 = ea.line2 = default_address(&ea);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
1938 else
21335
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1939 #endif
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1940 if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
af3663df42bf patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents: 21279
diff changeset
1941 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 /*
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
1944 * 5. Parse the command.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 * Skip ':' and any white space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 ea.cmd = skipwhite(ea.cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 while (*ea.cmd == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 ea.cmd = skipwhite(ea.cmd + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 * If we got a line, but no command, then go to the line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 * If we find a '|' or '\n' we set ea.nextcmd.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 */
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1958 if (*ea.cmd == NUL || comment_start(ea.cmd, starts_with_colon)
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
1959 || (ea.nextcmd = check_nextcmd(ea.cmd)) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 * strange vi behaviour:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 * ":3" jumps to line 3
23954
9c8a20cfa540 patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents: 23944
diff changeset
1964 * ":3|..." prints line 3 (not in Vim9 script)
9c8a20cfa540 patch 8.2.2519: Vim9: no reason to keep strange Vi behavior
Bram Moolenaar <Bram@vim.org>
parents: 23944
diff changeset
1965 * ":|" prints current line (not in Vim9 script)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1967 if (ea.skip) // skip this if inside :if
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 goto doend;
26370
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
1969 errormsg = ex_range_without_command(&ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1973 // If this looks like an undefined user command and there are CmdUndefined
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1974 // autocommands defined, trigger the matching autocommands.
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1975 if (p != NULL && ea.cmdidx == CMD_SIZE && !ea.skip
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1976 && ASCII_ISUPPER(*ea.cmd)
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1977 && has_cmdundefined())
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1978 {
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1979 int ret;
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1980
6156
20dbceb6f471 updated for version 7.4.415
Bram Moolenaar <bram@vim.org>
parents: 6154
diff changeset
1981 p = ea.cmd;
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1982 while (ASCII_ISALNUM(*p))
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1983 ++p;
20897
213fb059e02e patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents: 20711
diff changeset
1984 p = vim_strnsave(ea.cmd, p - ea.cmd);
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1985 ret = apply_autocmds(EVENT_CMDUNDEFINED, p, p, TRUE, NULL);
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1986 vim_free(p);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1987 // If the autocommands did something and didn't cause an error, try
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
1988 // finding the command again.
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1989 p = (ret
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1990 #ifdef FEAT_EVAL
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1991 && !aborting()
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1992 #endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
1993 ) ? find_ex_command(&ea, NULL, NULL, NULL) : ea.cmd;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
1994 }
6154
67edf731a240 updated for version 7.4.414
Bram Moolenaar <bram@vim.org>
parents: 6122
diff changeset
1995
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 if (!ea.skip)
23513
872239543313 patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
1999 errormsg = _(e_ambiguous_use_of_user_defined_command);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 }
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
2002 // Check for wrong commands.
11547
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2003 if (*p == '!' && ea.cmd[1] == 0151 && ea.cmd[0] == 78
3d03ed329a54 patch 8.0.0656: cannot use ! after some user commands
Christian Brabandt <cb@256bit.org>
parents: 11521
diff changeset
2004 && !IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 errormsg = uc_fun_cmd();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 }
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
2009
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 if (ea.cmdidx == CMD_SIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 if (!ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
2014 STRCPY(IObuff, _(e_not_an_editor_command));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 if (!sourcing)
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2016 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2017 // If the modifier was parsed OK the error must be in the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2018 // following command
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2019 if (after_modifier != NULL)
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2020 append_command(after_modifier);
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2021 else
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2022 append_command(*cmdlinep);
29146
72108041757c patch 8.2.5093: error message for unknown command may have the command twice
Bram Moolenaar <Bram@vim.org>
parents: 29144
diff changeset
2023 did_append_cmd = TRUE;
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2024 }
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2025 errormsg = (char *)IObuff;
3757
3b62d8f36cdf updated for version 7.3.637
Bram Moolenaar <bram@vim.org>
parents: 3744
diff changeset
2026 did_emsg_syntax = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2031 ni = (!IS_USER_CMDIDX(ea.cmdidx)
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2032 && (cmdnames[ea.cmdidx].cmd_func == ex_ni
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2033 #ifdef HAVE_EX_SCRIPT_NI
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2034 || cmdnames[ea.cmdidx].cmd_func == ex_script_ni
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2035 #endif
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
2036 ));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 #ifndef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 * When the expression evaluation is disabled, recognize the ":if" and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 * ":endif" commands and ignore everything in between it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 if (ea.cmdidx == CMD_if)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 ++if_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 if (if_level)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 if (ea.cmdidx == CMD_endif)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 --if_level;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2054 // forced commands
1613
a0a98a0f1281 updated for version 7.1-326
vimboss
parents: 1603
diff changeset
2055 if (*p == '!' && ea.cmdidx != CMD_substitute
a0a98a0f1281 updated for version 7.1-326
vimboss
parents: 1603
diff changeset
2056 && ea.cmdidx != CMD_smagic && ea.cmdidx != CMD_snomagic)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 ea.forceit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 ea.forceit = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 /*
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2065 * 6. Parse arguments. Then check for errors.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 */
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2067 if (!IS_USER_CMDIDX(ea.cmdidx))
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 827
diff changeset
2068 ea.argt = (long)cmdnames[(int)ea.cmdidx].cmd_argt;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 if (!ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 #ifdef HAVE_SANDBOX
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2073 if (sandbox != 0 && !(ea.argt & EX_SBOXOK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 {
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2075 // Command not allowed in sandbox.
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25306
diff changeset
2076 errormsg = _(e_not_allowed_in_sandbox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 #endif
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2080 if (restricted != 0 && (ea.argt & EX_RESTRICT))
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2081 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
2082 errormsg = _(e_command_not_allowed_in_rvim);
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2083 goto doend;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15713
diff changeset
2084 }
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2085 if (!curbuf->b_p_ma && (ea.argt & EX_MODIFY))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2087 // Command not allowed in non-'modifiable' buffer
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2088 errormsg = _(e_cannot_make_changes_modifiable_is_off);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 }
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
2091
21487
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2092 if (!IS_USER_CMDIDX(ea.cmdidx))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2093 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2094 #ifdef FEAT_CMDWIN
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2095 if (cmdwin_type != 0 && !(ea.argt & EX_CMDWIN))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2096 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2097 // Command not allowed in the command line window
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
2098 errormsg = _(e_invalid_in_cmdline_window);
21487
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2099 goto doend;
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2100 }
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2101 #endif
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2102 if (text_locked() && !(ea.argt & EX_LOCK_OK))
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2103 {
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2104 // Command not allowed when text is locked
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2105 errormsg = _(get_text_locked_msg());
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2106 goto doend;
5c92877092f9 patch 8.2.1294: Vim9: error when using vim9script in TextYankPost
Bram Moolenaar <Bram@vim.org>
parents: 21475
diff changeset
2107 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 }
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2109
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2110 // Disallow editing another buffer when "curbuf_lock" is set.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2111 // Do allow ":checktime" (it is postponed).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2112 // Do allow ":edit" (check for an argument later).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2113 // Do allow ":file" with no arguments (check for an argument later).
21664
60ba361a7fdb patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Bram Moolenaar <Bram@vim.org>
parents: 21618
diff changeset
2114 if (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2115 && ea.cmdidx != CMD_checktime
822
45fad0f590d0 updated for version 7.0c12
vimboss
parents: 820
diff changeset
2116 && ea.cmdidx != CMD_edit
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2117 && ea.cmdidx != CMD_file
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2118 && !IS_USER_CMDIDX(ea.cmdidx)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
2119 && curbuf_locked())
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
2120 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2122 if (!ni && !(ea.argt & EX_RANGE) && ea.addr_count > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2124 errormsg = _(e_no_range_allowed);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2129 if (!ni && !(ea.argt & EX_BANG) && ea.forceit)
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2130 {
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2131 errormsg = _(e_no_bang_allowed);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 * Don't complain about the range if it is not used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 * (could happen if line_count is accidentally set to 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2139 if (!ea.skip && !ni && (ea.argt & EX_RANGE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 * If the range is backwards, ask for confirmation and, if given, swap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 * ea.line1 & ea.line2 so it's forwards again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 * When global command is busy, don't ask, will fail below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 if (!global_busy && ea.line1 > ea.line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 {
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2148 if (msg_silent == 0)
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2149 {
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2150 if (sourcing || exmode_active)
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2151 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
2152 errormsg = _(e_backwards_range_given);
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2153 goto doend;
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2154 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 if (ask_yesno((char_u *)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 _("Backwards range given, OK to swap"), FALSE) != 'y')
557
862863033fdd updated for version 7.0158
vimboss
parents: 534
diff changeset
2157 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 lnum = ea.line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 ea.line1 = ea.line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 ea.line2 = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 if ((errormsg = invalid_range(&ea)) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2167 if ((ea.addr_type == ADDR_OTHER) && ea.addr_count == 0)
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2168 // default is 1, not cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 ea.line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 correct_range(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 #ifdef FEAT_FOLDING
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2174 if (((ea.argt & EX_WHOLEFOLD) || ea.addr_count >= 2) && !global_busy
7465
71e2aca45b81 commit https://github.com/vim/vim/commit/a3306958dcb9aadff1e1e8521d908d86b10ac99a
Christian Brabandt <cb@256bit.org>
parents: 7410
diff changeset
2175 && ea.addr_type == ADDR_LINES)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2177 // Put the first line at the start of a closed fold, put the last line
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2178 // at the end of a closed fold.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 (void)hasFolding(ea.line1, &ea.line1, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 (void)hasFolding(ea.line2, NULL, &ea.line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
2186 * For the ":make" and ":grep" commands we insert the 'makeprg'/'grepprg'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 * option here, so things like % get expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 */
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2189 p = replace_makeprg(&ea, p, cmdlinep);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2190 if (p == NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
2191 goto doend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195 * Skip to start of argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 * Don't do this for the ":!" command, because ":!! -l" needs the space.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 if (ea.cmdidx == CMD_bang)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 ea.arg = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 ea.arg = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202
14648
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2203 // ":file" cannot be run with an argument when "curbuf_lock" is set
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2204 if (ea.cmdidx == CMD_file && *ea.arg != NUL && curbuf_locked())
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2205 goto doend;
c3222a7342ab patch 8.1.0337: :file fails in quickfix command
Christian Brabandt <cb@256bit.org>
parents: 14640
diff changeset
2206
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 * Check for "++opt=val" argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 * Must be first, allow ":w ++enc=utf8 !cmd"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2211 if (ea.argt & EX_ARGOPT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 while (ea.arg[0] == '+' && ea.arg[1] == '+')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 if (getargopt(&ea) == FAIL && !ni)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
2215 errormsg = _(e_invalid_argument);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 if (ea.cmdidx == CMD_write || ea.cmdidx == CMD_update)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2221 if (*ea.arg == '>') // append
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2222 {
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2223 if (*++ea.arg != '>') // typed wrong
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
2225 errormsg = _(e_use_w_or_w_gt_gt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 ea.arg = skipwhite(ea.arg + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 ea.append = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2231 else if (*ea.arg == '!' && ea.cmdidx == CMD_write) // :w !filter
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 ea.usefilter = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 if (ea.cmdidx == CMD_read)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 if (ea.forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2242 ea.usefilter = TRUE; // :r! filter if ea.forceit
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 ea.forceit = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2245 else if (*ea.arg == '!') // :r !filter
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 ea.usefilter = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 if (ea.cmdidx == CMD_lshift || ea.cmdidx == CMD_rshift)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 ea.amount = 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2255 while (*ea.arg == *ea.cmd) // count number of '>' or '<'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 ++ea.arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 ++ea.amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 ea.arg = skipwhite(ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 * Check for "+command" argument, before checking for next command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 * Don't do this for ":read !cmd" and ":write !cmd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2267 if ((ea.argt & EX_CMDARG) && !ea.usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 ea.do_ecmd_cmd = getargcmd(&ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 /*
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2271 * For commands that do not use '|' inside their argument: Check for '|' to
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2272 * separate commands and '"' or '#' to start comments.
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2273 *
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2274 * Otherwise: Check for <newline> to end a shell command.
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2275 * Also do this for ":read !cmd", ":write !cmd" and ":global".
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2276 * Also do this inside a { - } block after :command and :autocmd.
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2277 * Any others?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2279 if ((ea.argt & EX_TRLBAR) && !ea.usefilter)
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2280 {
28179
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
2281 separate_nextcmd(&ea, FALSE);
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2282 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2283 else if (ea.cmdidx == CMD_bang
11806
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2284 || ea.cmdidx == CMD_terminal
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2285 || ea.cmdidx == CMD_global
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2286 || ea.cmdidx == CMD_vglobal
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
2287 || ea.usefilter
25523
a1804f725a9a patch 8.2.3298: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
2288 #ifdef FEAT_EVAL
a1804f725a9a patch 8.2.3298: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
2289 || inside_block(&ea)
a1804f725a9a patch 8.2.3298: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
2290 #endif
a1804f725a9a patch 8.2.3298: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 25521
diff changeset
2291 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 for (p = ea.arg; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2295 // Remove one backslash before a newline, so that it's possible to
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2296 // pass a newline to the shell and also a newline that is preceded
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2297 // with a backslash. This makes it impossible to end a shell
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2298 // command in a backslash, but that doesn't appear useful.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2299 // Halving the number of backslashes is incompatible with previous
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2300 // versions.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 if (*p == '\\' && p[1] == '\n')
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
2302 STRMOVE(p, p + 1);
26576
5ea6db641b5e patch 8.2.3817: Vim9: Not using NL as command end does not work for :autocmd
Bram Moolenaar <Bram@vim.org>
parents: 26572
diff changeset
2303 else if (*p == '\n' && !(ea.argt & EX_EXPR_ARG))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 ea.nextcmd = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2312 if ((ea.argt & EX_DFLALL) && ea.addr_count == 0)
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
2313 address_default_all(&ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2315 // accept numbered register only when no count allowed (:put)
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2316 if ( (ea.argt & EX_REGSTR)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 && *ea.arg != NUL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2318 // Do not allow register = for user commands
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2319 && (!IS_USER_CMDIDX(ea.cmdidx) || *ea.arg != '=')
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2320 && !((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 {
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2322 #ifndef FEAT_CLIPBOARD
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2323 // check these explicitly for a more specific error message
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2324 if (*ea.arg == '*' || *ea.arg == '+')
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2325 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
2326 errormsg = _(e_invalid_register_name);
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2327 goto doend;
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2328 }
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2329 #endif
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2330 if (valid_yank_reg(*ea.arg, (ea.cmdidx != CMD_put
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2331 && !IS_USER_CMDIDX(ea.cmdidx))))
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2332 {
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2333 ea.regname = *ea.arg++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2335 // for '=' register: accept the rest of the line as an expression
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2336 if (ea.arg[-1] == '=' && ea.arg[0] != NUL)
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2337 {
25883
826c36b4640b patch 8.2.3475: expression register set by not executed put command
Bram Moolenaar <Bram@vim.org>
parents: 25790
diff changeset
2338 if (!ea.skip)
826c36b4640b patch 8.2.3475: expression register set by not executed put command
Bram Moolenaar <Bram@vim.org>
parents: 25790
diff changeset
2339 {
826c36b4640b patch 8.2.3475: expression register set by not executed put command
Bram Moolenaar <Bram@vim.org>
parents: 25790
diff changeset
2340 set_expr_line(vim_strsave(ea.arg), &ea);
826c36b4640b patch 8.2.3475: expression register set by not executed put command
Bram Moolenaar <Bram@vim.org>
parents: 25790
diff changeset
2341 did_set_expr_line = TRUE;
826c36b4640b patch 8.2.3475: expression register set by not executed put command
Bram Moolenaar <Bram@vim.org>
parents: 25790
diff changeset
2342 }
2791
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2343 ea.arg += STRLEN(ea.arg);
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2344 }
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2345 #endif
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2346 ea.arg = skipwhite(ea.arg);
1bd8af13fb43 updated for version 7.3.171
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2347 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 /*
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2351 * Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 * count, it's a buffer name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2354 if ((ea.argt & EX_COUNT) && VIM_ISDIGIT(*ea.arg)
24665
661d15592d3c patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents: 24555
diff changeset
2355 && (!(ea.argt & EX_BUFNAME) || *(p = skipdigits(ea.arg + 1)) == NUL
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
2356 || VIM_ISWHITE(*p)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 {
26327
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
2358 n = getdigits_quoted(&ea.arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 ea.arg = skipwhite(ea.arg);
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2360 if (n <= 0 && !ni && (ea.argt & EX_ZEROR) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
2362 errormsg = _(e_positive_count_required);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 }
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2365 if (ea.addr_type != ADDR_LINES) // e.g. :buffer 2, :sleep 3
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 ea.line2 = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 if (ea.addr_count == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 ea.addr_count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 ea.line1 = ea.line2;
27072
0878d7c64140 patch 8.2.4065: computation overflow with large cound for :yank
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2374 if (ea.line2 >= LONG_MAX - (n - 1))
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
2375 ea.line2 = LONG_MAX; // avoid overflow
27072
0878d7c64140 patch 8.2.4065: computation overflow with large cound for :yank
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2376 else
0878d7c64140 patch 8.2.4065: computation overflow with large cound for :yank
Bram Moolenaar <Bram@vim.org>
parents: 27028
diff changeset
2377 ea.line2 += n - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 ++ea.addr_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 * Be vi compatible: no error message for out of range.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 */
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
2382 if (ea.line2 > curbuf->b_ml.ml_line_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 ea.line2 = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2386
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2387 /*
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2388 * Check for flags: 'l', 'p' and '#'.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2389 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2390 if (ea.argt & EX_FLAGS)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
2391 get_flags(&ea);
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2392 if (!ni && !(ea.argt & EX_EXTRA) && *ea.arg != NUL
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2393 && *ea.arg != '"' && (*ea.arg != '|' || (ea.argt & EX_TRLBAR) == 0))
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2394 {
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2395 // no arguments allowed but there is something
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
2396 errormsg = ex_errmsg(e_trailing_characters_str, ea.arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2400 if (!ni && (ea.argt & EX_NEEDARG) && *ea.arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
2402 errormsg = _(e_argument_required);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408 * Skip the command when it's not going to be executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 * The commands like :if, :endif, etc. always need to be executed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 * Also make an exception for commands that handle a trailing command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 * themselves.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 if (ea.skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 switch (ea.cmdidx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2417 // commands that need evaluation
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 case CMD_while:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 case CMD_endwhile:
72
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
2420 case CMD_for:
2b454a43b2c6 updated for version 7.0031
vimboss
parents: 42
diff changeset
2421 case CMD_endfor:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 case CMD_if:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 case CMD_elseif:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 case CMD_else:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 case CMD_endif:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 case CMD_try:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 case CMD_catch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 case CMD_finally:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 case CMD_endtry:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 case CMD_function:
19575
3c0de44077cd patch 8.2.0344: ":def" not skipped properly
Bram Moolenaar <Bram@vim.org>
parents: 19497
diff changeset
2431 case CMD_def:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2434 // Commands that handle '|' themselves. Check: A command should
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2435 // either have the EX_TRLBAR flag, appear in this list or appear in
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2436 // the list at ":help :bar".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 case CMD_aboveleft:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 case CMD_and:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 case CMD_belowright:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 case CMD_botright:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 case CMD_browse:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 case CMD_call:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 case CMD_confirm:
18713
baf890fa1621 patch 8.1.2348: :const cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18406
diff changeset
2444 case CMD_const:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 case CMD_delfunction:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 case CMD_djump:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 case CMD_dlist:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 case CMD_dsearch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 case CMD_dsplit:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 case CMD_echo:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 case CMD_echoerr:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 case CMD_echomsg:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 case CMD_echon:
19415
90e24240904b patch 8.2.0265: "eval" after "if 0" doesn't check for following command
Bram Moolenaar <Bram@vim.org>
parents: 19348
diff changeset
2454 case CMD_eval:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 case CMD_execute:
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
2456 case CMD_filter:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2457 case CMD_final:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 case CMD_help:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 case CMD_hide:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 case CMD_ijump:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 case CMD_ilist:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 case CMD_isearch:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 case CMD_isplit:
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 17
diff changeset
2464 case CMD_keepalt:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 case CMD_keepjumps:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 case CMD_keepmarks:
5467
6367a766027d updated for version 7.4.083
Bram Moolenaar <bram@vim.org>
parents: 5464
diff changeset
2467 case CMD_keeppatterns:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 case CMD_leftabove:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 case CMD_let:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 case CMD_lockmarks:
18715
bd4c34db84ab patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
2471 case CMD_lockvar:
2320
966a5609669e Added Lua interfae. (Luis Carvalho)
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
2472 case CMD_lua:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 case CMD_match:
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
2474 case CMD_mzscheme:
5737
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2475 case CMD_noautocmd:
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2476 case CMD_noswapfile:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 case CMD_perl:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 case CMD_psearch:
2350
06feaf4fe36a Rename some "python3" symbols to "py3", as the command name.
Bram Moolenaar <bram@vim.org>
parents: 2340
diff changeset
2479 case CMD_py3:
2366
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
2480 case CMD_python3:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2481 case CMD_python:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 case CMD_return:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 case CMD_rightbelow:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 case CMD_ruby:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 case CMD_silent:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 case CMD_smagic:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 case CMD_snomagic:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 case CMD_substitute:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 case CMD_syntax:
690
0e922220d322 updated for version 7.0208
vimboss
parents: 685
diff changeset
2490 case CMD_tab:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 case CMD_tcl:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 case CMD_throw:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 case CMD_tilde:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 case CMD_topleft:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 case CMD_unlet:
18715
bd4c34db84ab patch 8.1.2349: :lockvar and :unlockvar cannot be followed by "| endif"
Bram Moolenaar <Bram@vim.org>
parents: 18713
diff changeset
2496 case CMD_unlockvar:
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
2497 case CMD_var:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 case CMD_verbose:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 case CMD_vertical:
2887
15705b520c29 updated for version 7.3.217
Bram Moolenaar <bram@vim.org>
parents: 2853
diff changeset
2500 case CMD_wincmd:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 default: goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2508 if (ea.argt & EX_XFILE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 if (expand_filename(&ea, cmdlinep, &errormsg) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 * Accept buffer name. Cannot be used at the same time with a buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 * number. Don't do this for a user command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2518 if ((ea.argt & EX_BUFNAME) && *ea.arg != NUL && ea.addr_count == 0
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2519 && !IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 * :bdelete, :bwipeout and :bunload take several arguments, separated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 * by spaces: find next space (skipping over escaped characters).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 * The others take one argument: ignore trailing spaces.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 if (ea.cmdidx == CMD_bdelete || ea.cmdidx == CMD_bwipeout
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 || ea.cmdidx == CMD_bunload)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 p = skiptowhite_esc(ea.arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 p = ea.arg + STRLEN(ea.arg);
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
2532 while (p > ea.arg && VIM_ISWHITE(p[-1]))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 --p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 }
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
2535 ea.line2 = buflist_findpat(ea.arg, p, (ea.argt & EX_BUFUNL) != 0,
4236
23ce9a61bdc2 updated for version 7.3.869
Bram Moolenaar <bram@vim.org>
parents: 4211
diff changeset
2536 FALSE, FALSE);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2537 if (ea.line2 < 0) // failed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 goto doend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 ea.addr_count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 ea.arg = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2543 // The :try command saves the emsg_silent flag, reset it here when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2544 // ":silent! try" was used, it should only apply to :try itself.
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2545 if (ea.cmdidx == CMD_try && cmdmod.cmod_did_esilent > 0)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2546 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2547 emsg_silent -= cmdmod.cmod_did_esilent;
13288
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2548 if (emsg_silent < 0)
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2549 emsg_silent = 0;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2550 cmdmod.cmod_did_esilent = 0;
13288
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2551 }
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2552
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2553 /*
530943a23d3f patch 8.0.1518: error messages suppressed after ":silent! try"
Christian Brabandt <cb@256bit.org>
parents: 13268
diff changeset
2554 * 7. Execute the command.
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2555 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2557 if (IS_USER_CMDIDX(ea.cmdidx))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 * Execute a user-defined command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 do_ucmd(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 /*
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
2567 * Call the function to execute the builtin command.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 ea.errmsg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 (cmdnames[ea.cmdidx].cmd_func)(&ea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 if (ea.errmsg != NULL)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2572 errormsg = ea.errmsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 #ifdef FEAT_EVAL
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
2576 // Set flag that any command was executed, used by ex_vim9script().
23974
d4f7e4138544 patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents: 23966
diff changeset
2577 // Not if this was a command that wasn't executed or :endif.
28158
e1d1fa6ba1ed patch 8.2.4603: sourcing buffer lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 28129
diff changeset
2578 if (sourcing_a_script(&ea)
23974
d4f7e4138544 patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents: 23966
diff changeset
2579 && current_sctx.sc_sid > 0
d4f7e4138544 patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents: 23966
diff changeset
2580 && ea.cmdidx != CMD_endif
d4f7e4138544 patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents: 23966
diff changeset
2581 && (cstack->cs_idx < 0
d4f7e4138544 patch 8.2.2529: Vim9: Not possible to use legacy and Vim9 script in one file
Bram Moolenaar <Bram@vim.org>
parents: 23966
diff changeset
2582 || (cstack->cs_flags[cstack->cs_idx] & CSF_ACTIVE)))
23358
b3142fc0a414 patch 8.2.2222: Vim9: cannot keep script variables when reloading
Bram Moolenaar <Bram@vim.org>
parents: 23346
diff changeset
2583 SCRIPT_ITEM(current_sctx.sc_sid)->sn_state = SN_STATE_HAD_COMMAND;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
2584
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 * If the command just executed called do_cmdline(), any throw or ":return"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 * or ":finish" encountered there must also check the cstack of the still
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 * active do_cmdline() that called this do_one_cmd(). Rethrow an uncaught
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 * exception, or reanimate a returned function or finished script file and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 * return or finish it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 if (need_rethrow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 do_throw(cstack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 else if (check_cstack)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 {
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
2596 if (source_finished(fgetline, cookie))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 do_finish(&ea, TRUE);
944
b2dcb8457067 updated for version 7.0-070
vimboss
parents: 930
diff changeset
2598 else if (getline_equal(fgetline, cookie, get_func_line)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 && current_func_returned())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 do_return(&ea, TRUE, FALSE, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 need_rethrow = check_cstack = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 doend:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2606 if (curwin->w_cursor.lnum == 0) // can happen with zero line number
11374
889da8649221 patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents: 11258
diff changeset
2607 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 curwin->w_cursor.lnum = 1;
11374
889da8649221 patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents: 11258
diff changeset
2609 curwin->w_cursor.col = 0;
889da8649221 patch 8.0.0572: building the command table requires Perl
Christian Brabandt <cb@256bit.org>
parents: 11258
diff changeset
2610 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 if (errormsg != NULL && *errormsg != NUL && !did_emsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 {
29146
72108041757c patch 8.2.5093: error message for unknown command may have the command twice
Bram Moolenaar <Bram@vim.org>
parents: 29144
diff changeset
2614 if ((sourcing || !KeyTyped) && !did_append_cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2616 if (errormsg != (char *)IObuff)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 STRCPY(IObuff, errormsg);
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
2619 errormsg = (char *)IObuff;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 }
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
2621 append_command(*cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 emsg(errormsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 do_errthrow(cstack,
6305
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2627 (ea.cmdidx != CMD_SIZE && !IS_USER_CMDIDX(ea.cmdidx))
b8caf7045e3d updated for version 7.4.486
Bram Moolenaar <bram@vim.org>
parents: 6230
diff changeset
2628 ? cmdnames[(int)ea.cmdidx].cmd_name : (char_u *)NULL);
22732
4c21a3a47707 patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents: 22724
diff changeset
2629
4c21a3a47707 patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents: 22724
diff changeset
2630 if (did_set_expr_line)
4c21a3a47707 patch 8.2.1914: Vim9: cannot put line break in expression for '=' register
Bram Moolenaar <Bram@vim.org>
parents: 22724
diff changeset
2631 set_expr_line(NULL, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2634 undo_cmdmod(&cmdmod);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 cmdmod = save_cmdmod;
16144
4850744dc181 patch 8.1.1077: reg_executing() is reset by calling input()
Bram Moolenaar <Bram@vim.org>
parents: 15973
diff changeset
2636 reg_executing = save_reg_executing;
28359
390dfc3e409b patch 8.2.4705: jump list marker disappears
Bram Moolenaar <Bram@vim.org>
parents: 28313
diff changeset
2637 pending_end_reg_executing = save_pending_end_reg_executing;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2639 if (ea.nextcmd && *ea.nextcmd == NUL) // not really a next command
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 ea.nextcmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 --ex_nesting_level;
20996
3af71cbcfdbe patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents: 20982
diff changeset
2644 vim_free(ea.cmdline_tofree);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 return ea.nextcmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2650 static char ex_error_buf[MSG_BUF_LEN];
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2651
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2652 /*
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2653 * Return an error message with argument included.
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2654 * Uses a static buffer, only the last error will be kept.
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2655 * "msg" will be translated, caller should use N_().
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2656 */
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2657 char *
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2658 ex_errmsg(char *msg, char_u *arg)
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2659 {
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2660 vim_snprintf(ex_error_buf, MSG_BUF_LEN, _(msg), arg);
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2661 return ex_error_buf;
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2662 }
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
2663
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 /*
26370
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2665 * Handle a range without a command.
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2666 * Returns an error message on failure.
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2667 */
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2668 char *
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2669 ex_range_without_command(exarg_T *eap)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2670 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2671 char *errormsg = NULL;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2672
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2673 if ((*eap->cmd == '|' || (exmode_active && eap->line1 != eap->line2))
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2674 #ifdef FEAT_EVAL
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2675 && !in_vim9script()
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2676 #endif
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2677 )
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2678 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2679 eap->cmdidx = CMD_print;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2680 eap->argt = EX_RANGE+EX_COUNT+EX_TRLBAR;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2681 if ((errormsg = invalid_range(eap)) == NULL)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2682 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2683 correct_range(eap);
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2684 ex_print(eap);
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2685 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2686 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2687 else if (eap->addr_count != 0)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2688 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2689 if (eap->line2 > curbuf->b_ml.ml_line_count)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2690 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2691 // With '-' in 'cpoptions' a line number past the file is an
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2692 // error, otherwise put it at the end of the file.
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2693 if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2694 eap->line2 = -1;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2695 else
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2696 eap->line2 = curbuf->b_ml.ml_line_count;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2697 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2698
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2699 if (eap->line2 < 0)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2700 errormsg = _(e_invalid_range);
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2701 else
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2702 {
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2703 if (eap->line2 == 0)
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2704 curwin->w_cursor.lnum = 1;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2705 else
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2706 curwin->w_cursor.lnum = eap->line2;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2707 beginline(BL_SOL | BL_FIX);
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2708 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2709 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2710 return errormsg;
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2711 }
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2712
a3a0885d9dd8 patch 8.2.3716: Vim9: range without a command is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
2713 /*
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2714 * Check for an Ex command with optional tail.
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2715 * If there is a match advance "pp" to the argument and return TRUE.
27499
df414fc12eed patch 8.2.4277: Vim9: an import does not shadow a command modifier
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
2716 * If "noparen" is TRUE do not recognize the command followed by "(" or ".".
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2717 */
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2718 static int
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2719 checkforcmd_opt(
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2720 char_u **pp, // start of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2721 char *cmd, // name of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2722 int len, // required length
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2723 int noparen)
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2724 {
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2725 int i;
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2726
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2727 for (i = 0; cmd[i] != NUL; ++i)
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2728 if (((char_u *)cmd)[i] != (*pp)[i])
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2729 break;
27499
df414fc12eed patch 8.2.4277: Vim9: an import does not shadow a command modifier
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
2730 if (i >= len && !isalpha((*pp)[i]) && (*pp)[i] != '_'
df414fc12eed patch 8.2.4277: Vim9: an import does not shadow a command modifier
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
2731 && (!noparen || ((*pp)[i] != '(' && (*pp)[i] != '.')))
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2732 {
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2733 *pp = skipwhite(*pp + i);
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2734 return TRUE;
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2735 }
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2736 return FALSE;
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2737 }
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2738
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2739 /*
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2740 * Check for an Ex command with optional tail.
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2741 * If there is a match advance "pp" to the argument and return TRUE.
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2742 */
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2743 int
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2744 checkforcmd(
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2745 char_u **pp, // start of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2746 char *cmd, // name of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2747 int len) // required length
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2748 {
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2749 return checkforcmd_opt(pp, cmd, len, FALSE);
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2750 }
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2751
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2752 /*
27499
df414fc12eed patch 8.2.4277: Vim9: an import does not shadow a command modifier
Bram Moolenaar <Bram@vim.org>
parents: 27453
diff changeset
2753 * Check for an Ex command with optional tail, not followed by "(" or ".".
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2754 * If there is a match advance "pp" to the argument and return TRUE.
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2755 */
25469
dcd45fe7fe2e patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Bram Moolenaar <Bram@vim.org>
parents: 25463
diff changeset
2756 int
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2757 checkforcmd_noparen(
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2758 char_u **pp, // start of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2759 char *cmd, // name of command
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2760 int len) // required length
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2761 {
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2762 return checkforcmd_opt(pp, cmd, len, TRUE);
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2763 }
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2764
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2765 /*
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2766 * Parse and skip over command modifiers:
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2767 * - update eap->cmd
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2768 * - store flags in "cmod".
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2769 * - Set ex_pressedreturn for an empty command line.
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2770 * When "skip_only" is TRUE the global variables are not changed, except for
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2771 * "cmdmod".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2772 * When "skip_only" is FALSE then undo_cmdmod() must be called later to free
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2773 * any cmod_filter_regmatch.regprog.
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2774 * Call apply_cmdmod() to get the side effects of the modifiers:
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2775 * - Increment "sandbox" for ":sandbox"
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
2776 * - set p_verbose for ":verbose"
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2777 * - set msg_silent for ":silent"
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2778 * - set 'eventignore' to "all" for ":noautocmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2779 * Return FAIL when the command is not to be executed.
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2780 * May set "errormsg" to an error message.
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2781 */
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2782 int
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2783 parse_command_modifiers(
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2784 exarg_T *eap,
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2785 char **errormsg,
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2786 cmdmod_T *cmod,
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2787 int skip_only)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2788 {
28477
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
2789 char_u *orig_cmd = eap->cmd;
28222
85540173d3ca patch 8.2.4637: warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 28220
diff changeset
2790 char_u *cmd_start = NULL;
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2791 int use_plus_cmd = FALSE;
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2792 int starts_with_colon = FALSE;
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2793 int vim9script = in_vim9script();
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2794 int has_visual_range = FALSE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2795
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2796 CLEAR_POINTER(cmod);
27645
1712b102d642 patch 8.2.4348: "legacy exe cmd" does not do what one would expect
Bram Moolenaar <Bram@vim.org>
parents: 27617
diff changeset
2797 cmod->cmod_flags = sticky_cmdmod_flags;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2798
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2799 if (STRNCMP(eap->cmd, "'<,'>", 5) == 0)
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2800 {
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2801 // The automatically inserted Visual area range is skipped, so that
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2802 // typing ":cmdmod cmd" in Visual mode works without having to move the
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2803 // range to after the modififiers. The command will be
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2804 // "'<,'>cmdmod cmd", parse "cmdmod cmd" and then put back "'<,'>"
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2805 // before "cmd" below.
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2806 eap->cmd += 5;
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2807 cmd_start = eap->cmd;
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2808 has_visual_range = TRUE;
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2809 }
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2810
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2811 // Repeat until no more command modifiers are found.
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2812 for (;;)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2813 {
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2814 char_u *p;
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2815
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2816 while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':')
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2817 {
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2818 if (*eap->cmd == ':')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2819 starts_with_colon = TRUE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2820 ++eap->cmd;
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2821 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2822
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2823 // in ex mode, an empty command (after modifiers) works like :+
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2824 if (*eap->cmd == NUL && exmode_active
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2825 && (getline_equal(eap->getline, eap->cookie, getexmodeline)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2826 || getline_equal(eap->getline, eap->cookie, getexline))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2827 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2828 {
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2829 use_plus_cmd = TRUE;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2830 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2831 ex_pressedreturn = TRUE;
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
2832 break; // no modifiers following
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2833 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2834
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2835 // ignore comment and empty lines
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
2836 if (comment_start(eap->cmd, starts_with_colon))
25739
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2837 {
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2838 // a comment ends at a NL
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2839 if (eap->nextcmd == NULL)
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2840 {
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2841 eap->nextcmd = vim_strchr(eap->cmd, '\n');
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2842 if (eap->nextcmd != NULL)
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2843 ++eap->nextcmd;
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2844 }
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2845 if (vim9script && has_cmdmod(cmod, FALSE))
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2846 *errormsg = _(e_command_modifier_without_command);
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2847 return FAIL;
25739
8c4dee4d1ac6 patch 8.2.3405: cannot have a comment line in a {} block of a user command
Bram Moolenaar <Bram@vim.org>
parents: 25670
diff changeset
2848 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2849 if (*eap->cmd == NUL)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2850 {
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2851 if (!skip_only)
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2852 {
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2853 ex_pressedreturn = TRUE;
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2854 if (vim9script && has_cmdmod(cmod, FALSE))
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2855 *errormsg = _(e_command_modifier_without_command);
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2856 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2857 return FAIL;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2858 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2859
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
2860 p = skip_range(eap->cmd, TRUE, NULL);
23537
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2861
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2862 // In Vim9 script a variable can shadow a command modifier:
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2863 // verbose = 123
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2864 // verbose += 123
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2865 // silent! verbose = func()
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2866 // verbose.member = 2
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2867 // verbose[expr] = 2
23549
4156f972efb1 patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23537
diff changeset
2868 // But not:
4156f972efb1 patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23537
diff changeset
2869 // verbose [a, b] = list
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2870 if (vim9script)
23537
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2871 {
23549
4156f972efb1 patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23537
diff changeset
2872 char_u *s, *n;
23537
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2873
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2874 for (s = eap->cmd; ASCII_ISALPHA(*s); ++s)
23537
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2875 ;
23549
4156f972efb1 patch 8.2.2317: Vim9: command modifier before list unpack doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23537
diff changeset
2876 n = skipwhite(s);
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2877 if (*n == '.' || *n == '=' || (*n != NUL && n[1] == '=')
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
2878 || *s == '[')
23537
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2879 break;
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2880 }
7f0fc2ab90e3 patch 8.2.2311: Vim9: cannot assign to variable that shadows command modifier
Bram Moolenaar <Bram@vim.org>
parents: 23513
diff changeset
2881
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2882 switch (*p)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2883 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2884 // When adding an entry, also modify cmd_exists().
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2885 case 'a': if (!checkforcmd_noparen(&eap->cmd, "aboveleft", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2886 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2887 cmod->cmod_split |= WSP_ABOVE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2888 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2889
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2890 case 'b': if (checkforcmd_noparen(&eap->cmd, "belowright", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2891 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2892 cmod->cmod_split |= WSP_BELOW;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2893 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2894 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2895 if (checkforcmd_opt(&eap->cmd, "browse", 3, TRUE))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2896 {
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2897 #ifdef FEAT_BROWSE_CMD
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2898 cmod->cmod_flags |= CMOD_BROWSE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2899 #endif
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2900 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2901 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2902 if (!checkforcmd_noparen(&eap->cmd, "botright", 2))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2903 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2904 cmod->cmod_split |= WSP_BOT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2905 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2906
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2907 case 'c': if (!checkforcmd_opt(&eap->cmd, "confirm", 4, TRUE))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2908 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2909 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2910 cmod->cmod_flags |= CMOD_CONFIRM;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2911 #endif
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2912 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2913
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2914 case 'k': if (checkforcmd_noparen(&eap->cmd, "keepmarks", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2915 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2916 cmod->cmod_flags |= CMOD_KEEPMARKS;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2917 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2918 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2919 if (checkforcmd_noparen(&eap->cmd, "keepalt", 5))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2920 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2921 cmod->cmod_flags |= CMOD_KEEPALT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2922 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2923 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2924 if (checkforcmd_noparen(&eap->cmd, "keeppatterns", 5))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2925 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2926 cmod->cmod_flags |= CMOD_KEEPPATTERNS;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2927 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2928 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2929 if (!checkforcmd_noparen(&eap->cmd, "keepjumps", 5))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2930 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2931 cmod->cmod_flags |= CMOD_KEEPJUMPS;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2932 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2933
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2934 case 'f': // only accept ":filter {pat} cmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2935 {
24834
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2936 char_u *reg_pat;
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2937 char_u *nulp = NULL;
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2938 int c = 0;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2939
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2940 if (!checkforcmd_noparen(&p, "filter", 4)
26319
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2941 || *p == NUL
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2942 || (ends_excmd(*p)
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2943 #ifdef FEAT_EVAL
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2944 // in ":filter #pat# cmd" # does not
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2945 // start a comment
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2946 && (!vim9script || VIM_ISWHITE(p[1]))
26319
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2947 #endif
8b594193dcb6 patch 8.2.3690: Vim9: "filter #pat# cmd" does not work
Bram Moolenaar <Bram@vim.org>
parents: 26256
diff changeset
2948 ))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2949 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2950 if (*p == '!')
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2951 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2952 cmod->cmod_filter_force = TRUE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2953 p = skipwhite(p + 1);
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2954 if (*p == NUL || ends_excmd(*p))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2955 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2956 }
21259
ee0e2ada88c0 patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents: 21255
diff changeset
2957 #ifdef FEAT_EVAL
21255
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2958 // Avoid that "filter(arg)" is recognized.
27716
4097434c7c67 patch 8.2.4384: Vim9: error message not tested, some code not tested
Bram Moolenaar <Bram@vim.org>
parents: 27645
diff changeset
2959 if (vim9script && !VIM_ISWHITE(p[-1]))
21255
4be91a7eafb2 patch 8.2.1178: Vim9: filter function recognized as command modifier
Bram Moolenaar <Bram@vim.org>
parents: 21212
diff changeset
2960 break;
21259
ee0e2ada88c0 patch 8.2.1180: build failure in small version
Bram Moolenaar <Bram@vim.org>
parents: 21255
diff changeset
2961 #endif
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2962 if (skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2963 p = skip_vimgrep_pat(p, NULL, NULL);
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2964 else
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2965 // NOTE: This puts a NUL after the pattern.
24834
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2966 p = skip_vimgrep_pat_ext(p, &reg_pat, NULL,
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2967 &nulp, &c);
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2968 if (p == NULL || *p == NUL)
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2969 break;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2970 if (!skip_only)
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2971 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2972 cmod->cmod_filter_regmatch.regprog =
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2973 vim_regcomp(reg_pat, RE_MAGIC);
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2974 if (cmod->cmod_filter_regmatch.regprog == NULL)
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2975 break;
24834
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2976 // restore the character overwritten by NUL
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2977 if (nulp != NULL)
adcd50a18236 patch 8.2.2955: Vim9: using filter in compiled command does not work
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
2978 *nulp = c;
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
2979 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2980 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2981 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2982 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2983
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2984 // ":hide" and ":hide | cmd" are not modifiers
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2985 case 'h': if (p != eap->cmd || !checkforcmd_noparen(&p, "hide", 3)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2986 || *p == NUL || ends_excmd(*p))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2987 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2988 eap->cmd = p;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2989 cmod->cmod_flags |= CMOD_HIDE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2990 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2991
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
2992 case 'l': if (checkforcmd_noparen(&eap->cmd, "lockmarks", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2993 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
2994 cmod->cmod_flags |= CMOD_LOCKMARKS;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2995 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
2996 }
24531
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
2997 if (checkforcmd_noparen(&eap->cmd, "legacy", 3))
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
2998 {
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
2999 if (ends_excmd2(p, eap->cmd))
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3000 {
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3001 *errormsg =
25622
15b54e0a576b patch 8.2.3347: check for legacy script is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 25575
diff changeset
3002 _(e_legacy_must_be_followed_by_command);
24531
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3003 return FAIL;
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3004 }
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3005 cmod->cmod_flags |= CMOD_LEGACY;
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3006 continue;
3bfec39ce31c patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24462
diff changeset
3007 }
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3008
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3009 if (!checkforcmd_noparen(&eap->cmd, "leftabove", 5))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3010 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3011 cmod->cmod_split |= WSP_ABOVE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3012 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3013
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3014 case 'n': if (checkforcmd_noparen(&eap->cmd, "noautocmd", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3015 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3016 cmod->cmod_flags |= CMOD_NOAUTOCMD;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3017 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3018 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3019 if (!checkforcmd_noparen(&eap->cmd, "noswapfile", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3020 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3021 cmod->cmod_flags |= CMOD_NOSWAPFILE;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3022 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3023
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3024 case 'r': if (!checkforcmd_noparen(&eap->cmd, "rightbelow", 6))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3025 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3026 cmod->cmod_split |= WSP_BELOW;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3027 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3028
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3029 case 's': if (checkforcmd_noparen(&eap->cmd, "sandbox", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3030 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3031 cmod->cmod_flags |= CMOD_SANDBOX;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3032 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3033 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3034 if (!checkforcmd_noparen(&eap->cmd, "silent", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3035 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3036 cmod->cmod_flags |= CMOD_SILENT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3037 if (*eap->cmd == '!' && !VIM_ISWHITE(eap->cmd[-1]))
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3038 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3039 // ":silent!", but not "silent !cmd"
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3040 eap->cmd = skipwhite(eap->cmd + 1);
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3041 cmod->cmod_flags |= CMOD_ERRSILENT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3042 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3043 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3044
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3045 case 't': if (checkforcmd_noparen(&p, "tab", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3046 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3047 if (!skip_only)
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3048 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3049 long tabnr = get_address(eap, &eap->cmd,
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3050 ADDR_TABS, eap->skip,
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3051 skip_only, FALSE, 1);
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3052 if (tabnr == MAXLNUM)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3053 cmod->cmod_tab = tabpage_index(curtab) + 1;
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3054 else
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3055 {
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3056 if (tabnr < 0 || tabnr > LAST_TAB_NR)
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3057 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
3058 *errormsg = _(e_invalid_range);
15263
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3059 return FAIL;
ad065b8123e8 patch 8.1.0640: get E14 while typing command :tab with 'incsearch' set
Bram Moolenaar <Bram@vim.org>
parents: 15239
diff changeset
3060 }
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3061 cmod->cmod_tab = tabnr + 1;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3062 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3063 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3064 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3065 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3066 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3067 if (!checkforcmd_noparen(&eap->cmd, "topleft", 2))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3068 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3069 cmod->cmod_split |= WSP_TOP;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3070 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3071
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3072 case 'u': if (!checkforcmd_noparen(&eap->cmd, "unsilent", 3))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3073 break;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3074 cmod->cmod_flags |= CMOD_UNSILENT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3075 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3076
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3077 case 'v': if (checkforcmd_noparen(&eap->cmd, "vertical", 4))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3078 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3079 cmod->cmod_split |= WSP_VERT;
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3080 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3081 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3082 if (checkforcmd_noparen(&eap->cmd, "vim9cmd", 4))
23938
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3083 {
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3084 if (ends_excmd2(p, eap->cmd))
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3085 {
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3086 *errormsg =
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3087 _(e_vim9cmd_must_be_followed_by_command);
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3088 return FAIL;
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3089 }
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3090 cmod->cmod_flags |= CMOD_VIM9CMD;
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3091 continue;
2a885d095bff patch 8.2.2511: Vim9: cannot use Vim9 script syntax in some places
Bram Moolenaar <Bram@vim.org>
parents: 23884
diff changeset
3092 }
24254
0868ac82ef18 patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 24222
diff changeset
3093 if (!checkforcmd_noparen(&p, "verbose", 4))
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3094 break;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3095 if (vim_isdigit(*eap->cmd))
28433
367439b95aba patch 8.2.4741: startup test fails
Bram Moolenaar <Bram@vim.org>
parents: 28403
diff changeset
3096 {
29136
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3097 // zero means not set, one is verbose == 0, etc.
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3098 cmod->cmod_verbose = atoi((char *)eap->cmd) + 1;
28433
367439b95aba patch 8.2.4741: startup test fails
Bram Moolenaar <Bram@vim.org>
parents: 28403
diff changeset
3099 }
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3100 else
29136
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3101 cmod->cmod_verbose = 2; // default: verbose == 1
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3102 eap->cmd = p;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3103 continue;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3104 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3105 break;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3106 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3107
28220
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3108 if (has_visual_range)
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3109 {
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3110 if (eap->cmd > cmd_start)
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3111 {
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3112 // Move the '<,'> range to after the modifiers and insert a colon.
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3113 // Since the modifiers have been parsed put the colon on top of the
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3114 // space: "'<,'>mod cmd" -> "mod:'<,'>cmd
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3115 // Put eap->cmd after the colon.
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3116 if (use_plus_cmd)
28477
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3117 {
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3118 size_t len = STRLEN(cmd_start);
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3119
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3120 // Special case: empty command uses "+":
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3121 // "'<,'>mods" -> "mods'<,'>+
28477
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3122 mch_memmove(orig_cmd, cmd_start, len);
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3123 STRCPY(orig_cmd + len, "'<,'>+");
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3124 }
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3125 else
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3126 {
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3127 mch_memmove(cmd_start - 5, cmd_start, eap->cmd - cmd_start);
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3128 eap->cmd -= 5;
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3129 mch_memmove(eap->cmd - 1, ":'<,'>", 6);
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3130 }
28220
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3131 }
73c5dbdc4236 patch 8.2.4636: not using Visual range
Bram Moolenaar <Bram@vim.org>
parents: 28215
diff changeset
3132 else
28477
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3133 // No modifiers, move the pointer back.
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3134 // Special case: change empty command to "+".
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3135 if (use_plus_cmd)
28477
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3136 eap->cmd = (char_u *)"'<,'>+";
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3137 else
0ae0946ebf9b patch 8.2.4763: using invalid pointer with "V:" in Ex mode
Bram Moolenaar <Bram@vim.org>
parents: 28457
diff changeset
3138 eap->cmd = orig_cmd;
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
3139 }
29144
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3140 else if (use_plus_cmd)
dee6b7c32f2c patch 8.2.5092: using "'<,'>" in Ex mode may compare unrelated pointers
Bram Moolenaar <Bram@vim.org>
parents: 29136
diff changeset
3141 eap->cmd = (char_u *)"+";
28215
cb462f4c6b12 patch 8.2.4633: Visual range does not work before command modifiers
Bram Moolenaar <Bram@vim.org>
parents: 28195
diff changeset
3142
14536
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3143 return OK;
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3144 }
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3145
4caa51067cb8 patch 8.1.0281: parsing command modifiers is not separated
Christian Brabandt <cb@256bit.org>
parents: 14505
diff changeset
3146 /*
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3147 * Return TRUE if "cmod" has anything set.
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3148 */
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3149 int
25575
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3150 has_cmdmod(cmdmod_T *cmod, int ignore_silent)
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3151 {
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3152 return (cmod->cmod_flags != 0 && (!ignore_silent
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3153 || (cmod->cmod_flags
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3154 & ~(CMOD_SILENT | CMOD_ERRSILENT | CMOD_UNSILENT)) != 0))
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3155 || cmod->cmod_split != 0
29136
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3156 || cmod->cmod_verbose > 0
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3157 || cmod->cmod_tab != 0
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3158 || cmod->cmod_filter_regmatch.regprog != NULL;
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3159 }
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3160
27720
2631b9021808 patch 8.2.4386: still cannot build tiny version
Bram Moolenaar <Bram@vim.org>
parents: 27716
diff changeset
3161 #if defined(FEAT_EVAL) || defined(PROTO)
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3162 /*
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3163 * If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3164 */
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3165 int
25575
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3166 cmdmod_error(int ignore_silent)
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3167 {
9f691e8a74e3 patch 8.2.3324: Vim9: Cannot use :silent with :endwhile
Bram Moolenaar <Bram@vim.org>
parents: 25567
diff changeset
3168 if (in_vim9script() && has_cmdmod(&cmdmod, ignore_silent))
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3169 {
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3170 emsg(_(e_misplaced_command_modifier));
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3171 return TRUE;
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3172 }
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3173 return FALSE;
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3174 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3175 #endif
24222
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3176
a2e6029d354e patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents: 24176
diff changeset
3177 /*
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3178 * Apply the command modifiers. Saves current state in "cmdmod", call
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3179 * undo_cmdmod() later.
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3180 */
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3181 void
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3182 apply_cmdmod(cmdmod_T *cmod)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3183 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3184 #ifdef HAVE_SANDBOX
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3185 if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3186 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3187 ++sandbox;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3188 cmod->cmod_did_sandbox = TRUE;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3189 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3190 #endif
29136
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3191 if (cmod->cmod_verbose > 0)
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3192 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3193 if (cmod->cmod_verbose_save == 0)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3194 cmod->cmod_verbose_save = p_verbose + 1;
29136
ff98d9c228d4 patch 8.2.5088: value of cmod_verbose is a bit complicated to use
Bram Moolenaar <Bram@vim.org>
parents: 29117
diff changeset
3195 p_verbose = cmod->cmod_verbose - 1;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3196 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3197
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3198 if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT))
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3199 && cmod->cmod_save_msg_silent == 0)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3200 {
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3201 cmod->cmod_save_msg_silent = msg_silent + 1;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3202 cmod->cmod_save_msg_scroll = msg_scroll;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3203 }
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3204 if (cmod->cmod_flags & CMOD_SILENT)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3205 ++msg_silent;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3206 if (cmod->cmod_flags & CMOD_UNSILENT)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3207 msg_silent = 0;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3208
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3209 if (cmod->cmod_flags & CMOD_ERRSILENT)
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3210 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3211 ++emsg_silent;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3212 ++cmod->cmod_did_esilent;
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3213 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3214
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3215 if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL)
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3216 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3217 // Set 'eventignore' to "all".
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3218 // First save the existing option value for restoring it later.
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3219 cmod->cmod_save_ei = vim_strsave(p_ei);
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3220 set_string_option_direct((char_u *)"ei", -1,
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3221 (char_u *)"all", OPT_FREE, SID_NONE);
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3222 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3223 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3224
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3225 /*
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3226 * Undo and free contents of "cmod".
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3227 */
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3228 void
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3229 undo_cmdmod(cmdmod_T *cmod)
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3230 {
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3231 if (cmod->cmod_verbose_save > 0)
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3232 {
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3233 p_verbose = cmod->cmod_verbose_save - 1;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3234 cmod->cmod_verbose_save = 0;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3235 }
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3236
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3237 #ifdef HAVE_SANDBOX
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3238 if (cmod->cmod_did_sandbox)
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3239 {
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3240 --sandbox;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3241 cmod->cmod_did_sandbox = FALSE;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3242 }
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3243 #endif
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3244
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3245 if (cmod->cmod_save_ei != NULL)
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
3246 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3247 // Restore 'eventignore' to the value before ":noautocmd".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3248 set_string_option_direct((char_u *)"ei", -1, cmod->cmod_save_ei,
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3249 OPT_FREE, SID_NONE);
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3250 free_string_option(cmod->cmod_save_ei);
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3251 cmod->cmod_save_ei = NULL;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3252 }
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3253
22724
51bc501a13ca patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
3254 vim_regfree(cmod->cmod_filter_regmatch.regprog);
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3255
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3256 if (cmod->cmod_save_msg_silent > 0)
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3257 {
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3258 // messages could be enabled for a serious error, need to check if the
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3259 // counters don't become negative
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3260 if (!did_emsg || msg_silent > cmod->cmod_save_msg_silent - 1)
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3261 msg_silent = cmod->cmod_save_msg_silent - 1;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3262 emsg_silent -= cmod->cmod_did_esilent;
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3263 if (emsg_silent < 0)
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3264 emsg_silent = 0;
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3265 // Restore msg_scroll, it's set by file I/O commands, even when no
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3266 // message is actually displayed.
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3267 msg_scroll = cmod->cmod_save_msg_scroll;
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3268
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3269 // "silent reg" or "silent echo x" inside "redir" leaves msg_col
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3270 // somewhere in the line. Put it back in the first column.
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3271 if (redirecting())
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3272 msg_col = 0;
22697
c996700d569f patch 8.2.1897: command modifiers are saved and set inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 22693
diff changeset
3273
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3274 cmod->cmod_save_msg_silent = 0;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
3275 cmod->cmod_did_esilent = 0;
21172
96ae8622cfb6 patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents: 21130
diff changeset
3276 }
14538
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
3277 }
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
3278
213f1a519378 patch 8.1.0282: 'incsearch' does not work with command modifiers
Christian Brabandt <cb@256bit.org>
parents: 14536
diff changeset
3279 /*
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3280 * Parse the address range, if any, in "eap".
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3281 * May set the last search pattern, unless "silent" is TRUE.
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3282 * Return FAIL and set "errormsg" or return OK.
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3283 */
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3284 int
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
3285 parse_cmd_address(exarg_T *eap, char **errormsg, int silent)
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3286 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3287 int address_count = 1;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3288 linenr_T lnum;
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3289 int need_check_cursor = FALSE;
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3290 int ret = FAIL;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3291
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3292 // Repeat for all ',' or ';' separated addresses.
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3293 for (;;)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3294 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3295 eap->line1 = eap->line2;
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
3296 eap->line2 = default_address(eap);
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3297 eap->cmd = skipwhite(eap->cmd);
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
3298 lnum = get_address(eap, &eap->cmd, eap->addr_type, eap->skip, silent,
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3299 eap->addr_count == 0, address_count++);
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3300 if (eap->cmd == NULL) // error detected
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3301 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3302 if (lnum == MAXLNUM)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3303 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3304 if (*eap->cmd == '%') // '%' - all lines
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3305 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3306 ++eap->cmd;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3307 switch (eap->addr_type)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3308 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3309 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3310 case ADDR_OTHER:
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3311 eap->line1 = 1;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3312 eap->line2 = curbuf->b_ml.ml_line_count;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3313 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3314 case ADDR_LOADED_BUFFERS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3315 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3316 buf_T *buf = firstbuf;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3317
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3318 while (buf->b_next != NULL
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3319 && buf->b_ml.ml_mfp == NULL)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3320 buf = buf->b_next;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3321 eap->line1 = buf->b_fnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3322 buf = lastbuf;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3323 while (buf->b_prev != NULL
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3324 && buf->b_ml.ml_mfp == NULL)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3325 buf = buf->b_prev;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3326 eap->line2 = buf->b_fnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3327 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3328 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3329 case ADDR_BUFFERS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3330 eap->line1 = firstbuf->b_fnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3331 eap->line2 = lastbuf->b_fnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3332 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3333 case ADDR_WINDOWS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3334 case ADDR_TABS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3335 if (IS_USER_CMDIDX(eap->cmdidx))
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3336 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3337 eap->line1 = 1;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3338 eap->line2 = eap->addr_type == ADDR_WINDOWS
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3339 ? LAST_WIN_NR : LAST_TAB_NR;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3340 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3341 else
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3342 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3343 // there is no Vim command which uses '%' and
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3344 // ADDR_WINDOWS or ADDR_TABS
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
3345 *errormsg = _(e_invalid_range);
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3346 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3347 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3348 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3349 case ADDR_TABS_RELATIVE:
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3350 case ADDR_UNSIGNED:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3351 case ADDR_QUICKFIX:
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
3352 *errormsg = _(e_invalid_range);
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3353 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3354 case ADDR_ARGUMENTS:
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3355 if (ARGCOUNT == 0)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3356 eap->line1 = eap->line2 = 0;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3357 else
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3358 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3359 eap->line1 = 1;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3360 eap->line2 = ARGCOUNT;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3361 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3362 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3363 case ADDR_QUICKFIX_VALID:
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3364 #ifdef FEAT_QUICKFIX
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3365 eap->line1 = 1;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3366 eap->line2 = qf_get_valid_size(eap);
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3367 if (eap->line2 == 0)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3368 eap->line2 = 1;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
3369 #endif
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3370 break;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3371 case ADDR_NONE:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3372 // Will give an error later if a range is found.
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3373 break;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3374 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3375 ++eap->addr_count;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3376 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3377 else if (*eap->cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3378 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3379 pos_T *fp;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3380
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3381 // '*' - visual area
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3382 if (eap->addr_type != ADDR_LINES)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3383 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
3384 *errormsg = _(e_invalid_range);
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3385 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3386 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3387
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3388 ++eap->cmd;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3389 if (!eap->skip)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3390 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3391 fp = getmark('<', FALSE);
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3392 if (check_mark(fp) == FAIL)
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3393 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3394 eap->line1 = fp->lnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3395 fp = getmark('>', FALSE);
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3396 if (check_mark(fp) == FAIL)
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3397 goto theend;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3398 eap->line2 = fp->lnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3399 ++eap->addr_count;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3400 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3401 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3402 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3403 else
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3404 eap->line2 = lnum;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3405 eap->addr_count++;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3406
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3407 if (*eap->cmd == ';')
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3408 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3409 if (!eap->skip)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3410 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3411 curwin->w_cursor.lnum = eap->line2;
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3412
20185
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3413 // Don't leave the cursor on an illegal line or column, but do
29263
8408ffd9af69 patch 8.2.5150: read past the end of the first line with ":0;'{"
Bram Moolenaar <Bram@vim.org>
parents: 29214
diff changeset
3414 // accept zero as address, so 0;/PATTERN/ works correctly
8408ffd9af69 patch 8.2.5150: read past the end of the first line with ":0;'{"
Bram Moolenaar <Bram@vim.org>
parents: 29214
diff changeset
3415 // (where zero usually means to use the first line).
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3416 // Check the cursor position before returning.
20185
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3417 if (eap->line2 > 0)
0610f1ddb3a0 patch 8.2.0648: semicolon search does not work in first line
Bram Moolenaar <Bram@vim.org>
parents: 20111
diff changeset
3418 check_cursor();
29263
8408ffd9af69 patch 8.2.5150: read past the end of the first line with ":0;'{"
Bram Moolenaar <Bram@vim.org>
parents: 29214
diff changeset
3419 else
8408ffd9af69 patch 8.2.5150: read past the end of the first line with ":0;'{"
Bram Moolenaar <Bram@vim.org>
parents: 29214
diff changeset
3420 check_cursor_col();
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3421 need_check_cursor = TRUE;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3422 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3423 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3424 else if (*eap->cmd != ',')
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3425 break;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3426 ++eap->cmd;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3427 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3428
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3429 // One address given: set start and end lines.
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3430 if (eap->addr_count == 1)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3431 {
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3432 eap->line1 = eap->line2;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3433 // ... but only implicit: really no address given
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3434 if (lnum == MAXLNUM)
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3435 eap->addr_count = 0;
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3436 }
29030
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3437 ret = OK;
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3438
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3439 theend:
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3440 if (need_check_cursor)
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3441 check_cursor();
f79cff615e69 patch 8.2.5037: cursor position may be invalid after "0;" range
Bram Moolenaar <Bram@vim.org>
parents: 29010
diff changeset
3442 return ret;
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3443 }
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3444
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3445 /*
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3446 * Append "cmd" to the error message in IObuff.
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3447 * Takes care of limiting the length and handling 0xa0, which would be
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3448 * invisible otherwise.
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3449 */
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3450 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3451 append_command(char_u *cmd)
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3452 {
29083
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3453 size_t len = STRLEN(IObuff);
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3454 char_u *s = cmd;
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3455 char_u *d;
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3456
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3457 if (len > IOSIZE - 100)
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3458 {
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3459 // Not enough space, truncate and put in "...".
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3460 d = IObuff + IOSIZE - 100;
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3461 d -= mb_head_off(IObuff, d);
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3462 STRCPY(d, "...");
3de91964bbd6 patch 8.2.5063: error for a command may go over the end of IObuff
Bram Moolenaar <Bram@vim.org>
parents: 29030
diff changeset
3463 }
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3464 STRCAT(IObuff, ": ");
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3465 d = IObuff + STRLEN(IObuff);
28741
b44f15083faf patch 8.2.4895: buffer overflow with invalid command with composing chars
Bram Moolenaar <Bram@vim.org>
parents: 28723
diff changeset
3466 while (*s != NUL && d - IObuff + 5 < IOSIZE)
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3467 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
3468 if (enc_utf8 ? (s[0] == 0xc2 && s[1] == 0xa0) : *s == 0xa0)
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
3469 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
3470 s += enc_utf8 ? 2 : 1;
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3471 STRCPY(d, "<a0>");
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3472 d += 4;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3473 }
28741
b44f15083faf patch 8.2.4895: buffer overflow with invalid command with composing chars
Bram Moolenaar <Bram@vim.org>
parents: 28723
diff changeset
3474 else if (d - IObuff + (*mb_ptr2len)(s) + 1 >= IOSIZE)
b44f15083faf patch 8.2.4895: buffer overflow with invalid command with composing chars
Bram Moolenaar <Bram@vim.org>
parents: 28723
diff changeset
3475 break;
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3476 else
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3477 MB_COPY_CHAR(s, d);
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3478 }
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3479 *d = NUL;
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3480 }
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3481
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3482 #if defined(FEAT_EVAL) || defined(PROTO)
3097
738ea87c1964 updated for version 7.3.320
Bram Moolenaar <bram@vim.org>
parents: 2970
diff changeset
3483 /*
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3484 * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3485 * the name. Otherwise just return "start".
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3486 */
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3487 char_u *
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3488 skip_option_env_lead(char_u *start)
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3489 {
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3490 char_u *name = start;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3491
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3492 if (*start == '&')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3493 {
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3494 if ((start[1] == 'l' || start[1] == 'g') && start[2] == ':')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3495 name += 3;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3496 else
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3497 name += 1;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3498 }
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3499 else if (*start == '$')
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3500 name += 1;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3501 return name;
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3502 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3503 #endif
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3504
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3505 /*
28185
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3506 * Return TRUE and set "*idx" if "p" points to a one letter command.
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3507 * If not in Vim9 script:
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3508 * - The 'k' command can directly be followed by any character.
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3509 * - The 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r'
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3510 * but :sre[wind] is another command, as are :scr[iptnames],
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3511 * :scs[cope], :sim[alt], :sig[ns] and :sil[ent].
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3512 */
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3513 static int
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3514 one_letter_cmd(char_u *p, cmdidx_T *idx)
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3515 {
28189
7456bc6bf077 patch 8.2.4620: two letter substitute commands don't work
Bram Moolenaar <Bram@vim.org>
parents: 28185
diff changeset
3516 if (in_vim9script())
28185
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3517 return FALSE;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3518 if (*p == 'k')
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3519 {
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3520 *idx = CMD_k;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3521 return TRUE;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3522 }
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3523 if (p[0] == 's'
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3524 && ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3525 && (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3526 || p[1] == 'g'
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3527 || (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3528 || p[1] == 'I'
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3529 || (p[1] == 'r' && p[2] != 'e')))
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3530 {
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3531 *idx = CMD_substitute;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3532 return TRUE;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3533 }
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3534 return FALSE;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3535 }
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3536
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3537 /*
29008
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3538 * Return TRUE if "cmd" starts with "123->", a number followed by a method
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3539 * call.
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3540 */
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3541 int
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3542 number_method(char_u *cmd)
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3543 {
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3544 char_u *p = skipdigits(cmd);
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3545
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3546 return p > cmd && (p = skipwhite(p))[0] == '-' && p[1] == '>';
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3547 }
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3548
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3549 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3550 * Find an Ex command by its name, either built-in or user.
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3551 * Start of the name can be found at eap->cmd.
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
3552 * Sets eap->cmdidx and returns a pointer to char after the command name.
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3553 * "full" is set to TRUE if the whole command name matched.
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3554 *
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3555 * If "lookup" is not NULL recognize expression without "eval" or "call" and
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3556 * assignment without "let". Sets eap->cmdidx to the command while returning
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3557 * "eap->cmd".
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3558 *
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559 * Returns NULL for an ambiguous user command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3560 */
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3561 char_u *
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3562 find_ex_command(
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3563 exarg_T *eap,
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3564 int *full UNUSED,
24124
f4061617c438 patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents: 24114
diff changeset
3565 int (*lookup)(char_u *, size_t, int cmd, cctx_T *) UNUSED,
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3566 cctx_T *cctx UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3568 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3569 char_u *p;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3570 int i;
24699
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3571 #ifndef FEAT_EVAL
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3572 int vim9 = FALSE;
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3573 #else
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3574 int vim9 = in_vim9script();
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3575
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3576 /*
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3577 * Recognize a Vim9 script function/method call and assignment:
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3578 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3579 */
19481
c27837cbe922 patch 8.2.0298: Vim9 script: cannot start command with a string constant
Bram Moolenaar <Bram@vim.org>
parents: 19475
diff changeset
3580 p = eap->cmd;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3581 if (lookup != NULL)
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3582 {
21937
b931df03adcc patch 8.2.1518: Vim9: cannot assign to local option
Bram Moolenaar <Bram@vim.org>
parents: 21893
diff changeset
3583 char_u *pskip = skip_option_env_lead(eap->cmd);
21618
9ab43576a13b patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 21596
diff changeset
3584
25670
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3585 if (vim_strchr((char_u *)"{('[\"@&$", *p) != NULL
27800
6e5d378919c4 patch 8.2.4426: map() function on string and blob does not check types
Bram Moolenaar <Bram@vim.org>
parents: 27720
diff changeset
3586 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)
6e5d378919c4 patch 8.2.4426: map() function on string and blob does not check types
Bram Moolenaar <Bram@vim.org>
parents: 27720
diff changeset
3587 || (p[0] == '0' && p[1] == 'z'))
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3588 {
23709
a0c4d04a58c4 patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents: 23648
diff changeset
3589 int oplen;
a0c4d04a58c4 patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents: 23648
diff changeset
3590 int heredoc;
25658
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3591 char_u *swp;
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3592
25670
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3593 if (*eap->cmd == '&'
28897
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3594 || (eap->cmd[0] == '$'
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3595 && eap->cmd[1] != '\'' && eap->cmd[1] != '"')
25670
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3596 || (eap->cmd[0] == '@'
25662
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3597 && (valid_yank_reg(eap->cmd[1], FALSE)
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3598 || eap->cmd[1] == '@')))
25658
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3599 {
25662
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3600 if (*eap->cmd == '&')
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3601 {
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3602 p = eap->cmd + 1;
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3603 if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0)
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3604 p += 2;
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3605 p = to_name_end(p, FALSE);
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3606 }
25670
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3607 else if (*eap->cmd == '$')
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3608 p = to_name_end(eap->cmd + 1, FALSE);
25662
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3609 else
23f065f27d2e patch 8.2.3367: Vim9: :@r executing a register is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 25658
diff changeset
3610 p = eap->cmd + 2;
25658
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3611 if (ends_excmd(*skipwhite(p)))
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3612 {
25670
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3613 // "&option <NL>", "$ENV <NL>" and "@r <NL>" are the start
812c75fd255c patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next line
Bram Moolenaar <Bram@vim.org>
parents: 25662
diff changeset
3614 // of an expression.
25658
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3615 eap->cmdidx = CMD_eval;
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3616 return eap->cmd;
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3617 }
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3618 // "&option" can be followed by "->" or "=", check below
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3619 }
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3620
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3621 swp = skipwhite(p);
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3622
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3623 if (
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3624 // "(..." is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3625 // "funcname(" is always a function call.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3626 *p == '('
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3627 || (p == eap->cmd
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3628 ? (
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3629 // "{..." is a dict expression or block start.
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3630 *eap->cmd == '{'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3631 // "'string'->func()" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3632 || *eap->cmd == '\''
21544
6c67c86a202a patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 21526
diff changeset
3633 // '"string"->func()' is an expression.
28897
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3634 || *eap->cmd == '"'
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3635 // '$"string"->func()' is an expression.
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3636 // "$'string'->func()" is an expression.
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3637 || (eap->cmd[0] == '$'
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3638 && (eap->cmd[1] == '\'' || eap->cmd[1] == '"'))
37e05627acb1 patch 8.2.4971: Vim9: interpolated string seen as range
Bram Moolenaar <Bram@vim.org>
parents: 28809
diff changeset
3639 // '0z1234->func()' is an expression.
27800
6e5d378919c4 patch 8.2.4426: map() function on string and blob does not check types
Bram Moolenaar <Bram@vim.org>
parents: 27720
diff changeset
3640 || (eap->cmd[0] == '0' && eap->cmd[1] == 'z')
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3641 // "g:varname" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3642 || eap->cmd[1] == ':'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3643 )
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3644 // "varname->func()" is an expression.
23709
a0c4d04a58c4 patch 8.2.2396: Vim9: no white space allowed before "->"
Bram Moolenaar <Bram@vim.org>
parents: 23648
diff changeset
3645 : (*swp == '-' && swp[1] == '>')))
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3646 {
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3647 if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1)))
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3648 {
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3649 // "{" by itself is the start of a block.
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3650 eap->cmdidx = CMD_block;
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3651 return eap->cmd + 1;
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3652 }
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3653 eap->cmdidx = CMD_eval;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3654 return eap->cmd;
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3655 }
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3656
28129
dd2ed5345f20 patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents: 27978
diff changeset
3657 if ((p != eap->cmd && (
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3658 // "varname[]" is an expression.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3659 *p == '['
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3660 // "varname.key" is an expression.
28129
dd2ed5345f20 patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents: 27978
diff changeset
3661 || (*p == '.'
dd2ed5345f20 patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents: 27978
diff changeset
3662 && (ASCII_ISALPHA(p[1]) || p[1] == '_'))))
dd2ed5345f20 patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents: 27978
diff changeset
3663 // g:[key] is an expression
dd2ed5345f20 patch 8.2.4589: cannot index the g: dictionary
Bram Moolenaar <Bram@vim.org>
parents: 27978
diff changeset
3664 || STRNCMP(eap->cmd, "g:[", 3) == 0)
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3665 {
24434
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3666 char_u *after = eap->cmd;
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3667
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3668 // When followed by "=" or "+=" then it is an assignment.
24434
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3669 // Skip over the whole thing, it can be:
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3670 // name.member = val
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3671 // name[a : b] = val
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3672 // name[idx] = val
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3673 // name[idx].member = val
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3674 // etc.
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3675 eap->cmdidx = CMD_eval;
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3676 ++emsg_silent;
23039
75241f4377a4 patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23023
diff changeset
3677 if (skip_expr(&after, NULL) == OK)
24434
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3678 {
23039
75241f4377a4 patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23023
diff changeset
3679 after = skipwhite(after);
24434
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3680 if (*after == '=' || (*after != NUL && after[1] == '=')
23039
75241f4377a4 patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23023
diff changeset
3681 || (after[0] == '.' && after[1] == '.'
75241f4377a4 patch 8.2.2066: Vim9: assignment with += doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23023
diff changeset
3682 && after[2] == '='))
24434
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3683 eap->cmdidx = CMD_var;
602e528a8e43 patch 8.2.2757: Vim9: blob tests for legacy and Vim9 script are separate
Bram Moolenaar <Bram@vim.org>
parents: 24428
diff changeset
3684 }
22268
2eaee3396f7a patch 8.2.1683: Vim9: assignment test fails
Bram Moolenaar <Bram@vim.org>
parents: 22260
diff changeset
3685 --emsg_silent;
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3686 return eap->cmd;
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3687 }
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3688
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3689 // "[...]->Method()" is a list expression, but "[a, b] = Func()" is
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3690 // an assignment.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3691 // If there is no line break inside the "[...]" then "p" is
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3692 // advanced to after the "]" by to_name_const_end(): check if a "="
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3693 // follows.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3694 // If "[...]" has a line break "p" still points at the "[" and it
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3695 // can't be an assignment.
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3696 if (*eap->cmd == '[')
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3697 {
24984
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3698 char_u *eq;
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3699
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3700 p = to_name_const_end(eap->cmd);
23050
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3701 if (p == eap->cmd && *p == '[')
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3702 {
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3703 int count = 0;
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3704 int semicolon = FALSE;
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3705
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3706 p = skip_var_list(eap->cmd, TRUE, &count, &semicolon, TRUE);
50442f932ff7 patch 8.2.2071: Vim9: list assign doesn't except empty remainder list
Bram Moolenaar <Bram@vim.org>
parents: 23039
diff changeset
3707 }
24984
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3708 eq = p;
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3709 if (eq != NULL)
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3710 {
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3711 eq = skipwhite(eq);
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3712 if (vim_strchr((char_u *)"+-*/%", *eq) != NULL)
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3713 ++eq;
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3714 }
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3715 if (p == NULL || p == eap->cmd || *eq != '=')
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3716 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3717 eap->cmdidx = CMD_eval;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3718 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3719 }
24984
71b1e2ef0069 patch 8.2.3029: Vim9: crash when using operator and list unpack assignment
Bram Moolenaar <Bram@vim.org>
parents: 24966
diff changeset
3720 if (p > eap->cmd && *eq == '=')
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3721 {
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
3722 eap->cmdidx = CMD_var;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3723 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3724 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3725 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3726
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3727 // Recognize an assignment if we recognize the variable name:
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3728 // "g:var = expr"
25658
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3729 // "@r = expr"
483b40e87ca5 patch 8.2.3365: Vim9: cannot use option for all operations
Bram Moolenaar <Bram@vim.org>
parents: 25622
diff changeset
3730 // "&opt = expr"
24462
7c4f50c02e18 patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
3731 // "var = expr" where "var" is a variable name or we are skipping
7c4f50c02e18 patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Bram Moolenaar <Bram@vim.org>
parents: 24434
diff changeset
3732 // (variable declaration might have been skipped).
28723
930f1bb1649d patch 8.2.4886: Vim9: redir in skipped block seen as assignment
Bram Moolenaar <Bram@vim.org>
parents: 28637
diff changeset
3733 // Not "redir => var" (when skipping).
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3734 oplen = assignment_len(skipwhite(p), &heredoc);
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3735 if (oplen > 0)
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3736 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3737 if (((p - eap->cmd) > 2 && eap->cmd[1] == ':')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3738 || *eap->cmd == '&'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3739 || *eap->cmd == '$'
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3740 || *eap->cmd == '@'
28723
930f1bb1649d patch 8.2.4886: Vim9: redir in skipped block seen as assignment
Bram Moolenaar <Bram@vim.org>
parents: 28637
diff changeset
3741 || (eap->skip && IS_WHITE_OR_NUL(
930f1bb1649d patch 8.2.4886: Vim9: redir in skipped block seen as assignment
Bram Moolenaar <Bram@vim.org>
parents: 28637
diff changeset
3742 *(skipwhite(p) + oplen)))
24124
f4061617c438 patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents: 24114
diff changeset
3743 || lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK)
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3744 {
22391
a9fb7efa31d6 patch 8.2.1744: Vim9: using ":const!" is weird
Bram Moolenaar <Bram@vim.org>
parents: 22361
diff changeset
3745 eap->cmdidx = CMD_var;
21526
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3746 return eap->cmd;
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3747 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3748 }
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3749
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3750 // Recognize using a type for a w:, b:, t: or g: variable:
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3751 // "w:varname: number = 123".
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3752 if (eap->cmd[1] == ':' && *p == ':')
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3753 {
a7afee13873d patch 8.2.1313: Vim9 script: cannot assign to environment variable
Bram Moolenaar <Bram@vim.org>
parents: 21518
diff changeset
3754 eap->cmdidx = CMD_eval;
21413
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3755 return eap->cmd;
8992d4f63761 patch 8.2.1257: Vim9: list unpack doesn't work at the script level
Bram Moolenaar <Bram@vim.org>
parents: 21357
diff changeset
3756 }
21130
4a1e8086759b patch 8.2.1116: Vim9: parsing command checks for list twice
Bram Moolenaar <Bram@vim.org>
parents: 21122
diff changeset
3757 }
23823
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3758
29008
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3759 // 1234->func() is a method call
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3760 if (number_method(eap->cmd))
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3761 {
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3762 eap->cmdidx = CMD_eval;
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3763 return eap->cmd;
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3764 }
49d8b54802f3 patch 8.2.5026: Vim9: a few lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 28897
diff changeset
3765
25939
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3766 // "g:", "s:" and "l:" are always assumed to be a variable, thus start
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3767 // an expression. A global/substitute/list command needs to use a
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3768 // longer name.
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3769 if (vim_strchr((char_u *)"gsl", *p) != NULL && p[1] == ':')
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3770 {
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3771 eap->cmdidx = CMD_eval;
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3772 return eap->cmd;
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3773 }
377a7686a52f patch 8.2.3503: Vim9: using g:pat:cmd is confusing
Bram Moolenaar <Bram@vim.org>
parents: 25911
diff changeset
3774
23823
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3775 // If it is an ID it might be a variable with an operator on the next
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3776 // line, if the variable exists it can't be an Ex command.
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3777 if (p > eap->cmd && ends_excmd(*skipwhite(p))
24124
f4061617c438 patch 8.2.2603: Vim9: no effect if user command is also a function
Bram Moolenaar <Bram@vim.org>
parents: 24114
diff changeset
3778 && (lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK
23823
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3779 || (ASCII_ISALPHA(eap->cmd[0]) && eap->cmd[1] == ':')))
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3780 {
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3781 eap->cmdidx = CMD_eval;
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3782 return eap->cmd;
262ab14b27db patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 23742
diff changeset
3783 }
24533
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3784
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3785 // Check for "++nr" and "--nr".
26960
043a15b37bf1 patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
3786 if (p == eap->cmd && p[0] != NUL && p[0] == p[1]
043a15b37bf1 patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents: 26958
diff changeset
3787 && (*p == '+' || *p == '-'))
24533
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3788 {
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3789 eap->cmdidx = *p == '+' ? CMD_increment : CMD_decrement;
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3790 return eap->cmd + 2;
9c404d78d767 patch 8.2.2806: Vim9: using "++nr" as a command might not work
Bram Moolenaar <Bram@vim.org>
parents: 24531
diff changeset
3791 }
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3792 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3793 #endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3794
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 * Isolate the command and search for it in the command table.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798 p = eap->cmd;
28185
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3799 if (one_letter_cmd(p, &eap->cmdidx))
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3800 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3805 while (ASCII_ISALPHA(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806 ++p;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3807 // for python 3.x support ":py3", ":python3", ":py3file", etc.
2330
ea4bf6df1a8a Whitespace cleanup.
Bram Moolenaar <bram@vim.org>
parents: 2329
diff changeset
3808 if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3809 {
2366
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
3810 while (ASCII_ISALNUM(*p))
7a57fe6a5157 Fix that :py3file was not working.
Bram Moolenaar <bram@vim.org>
parents: 2360
diff changeset
3811 ++p;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3812 }
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3813 else if (*p == '9' && STRNCMP("vim9", eap->cmd, 4) == 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3814 {
24256
b471a413d36a patch 8.2.2669: command line completion does not work after "vim9"
Bram Moolenaar <Bram@vim.org>
parents: 24254
diff changeset
3815 // include "9" for "vim9*" commands; "vim9cmd" and "vim9script".
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3816 ++p;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3817 while (ASCII_ISALPHA(*p))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3818 ++p;
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
3819 }
2329
ad2889f48843 Added support for Python 3. (Roland Puntaier)
Bram Moolenaar <bram@vim.org>
parents: 2320
diff changeset
3820
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3821 // check for non-alpha command
22555
7d25264c246c patch 8.2.1826: Vim9: cannot use a {} block at script level
Bram Moolenaar <Bram@vim.org>
parents: 22543
diff changeset
3822 if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3824 len = (int)(p - eap->cmd);
28185
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3825 // The "d" command can directly be followed by 'l' or 'p' flag, when
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
3826 // not in Vim9 script.
24699
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3827 if (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3828 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3829 // Check for ":dl", ":dell", etc. to ":deletel": that's
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3830 // :delete with the 'l' flag. Same for 'p'.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3831 for (i = 0; i < len; ++i)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
3832 if (eap->cmd[i] != ((char_u *)"delete")[i])
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3833 break;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3834 if (i == len - 1)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3835 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3836 --len;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3837 if (p[-1] == 'l')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3838 eap->flags |= EXFLAG_LIST;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3839 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3840 eap->flags |= EXFLAG_PRINT;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3841 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
3842 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3843
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3844 if (ASCII_ISLOWER(eap->cmd[0]))
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3845 {
11240
06307d812ca7 patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents: 11236
diff changeset
3846 int c1 = eap->cmd[0];
17496
c8152af9fa33 patch 8.1.1746: ":dl" is seen as ":dlist" instead of ":delete"
Bram Moolenaar <Bram@vim.org>
parents: 17488
diff changeset
3847 int c2 = len == 1 ? NUL : eap->cmd[1];
11240
06307d812ca7 patch 8.0.0506: can't build with ANSI C
Christian Brabandt <cb@256bit.org>
parents: 11236
diff changeset
3848
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3849 if (command_count != (int)CMD_SIZE)
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3850 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
3851 iemsg(_(e_command_table_needs_to_be_updated_run_make_cmdidxs));
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3852 getout(1);
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3853 }
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3854
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3855 // Use a precomputed index for fast look-up in cmdnames[]
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3856 // taking into account the first 2 letters of eap->cmd.
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3857 eap->cmdidx = cmdidxs1[CharOrdLow(c1)];
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3858 if (ASCII_ISLOWER(c2))
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3859 eap->cmdidx += cmdidxs2[CharOrdLow(c1)][CharOrdLow(c2)];
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3860 }
20075
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3861 else if (ASCII_ISUPPER(eap->cmd[0]))
516b10943fdb patch 8.2.0593: finding a user command is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 20063
diff changeset
3862 eap->cmdidx = CMD_Next;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3863 else
11236
62c96fee518e patch 8.0.0504: looking up an Ex command is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 11158
diff changeset
3864 eap->cmdidx = CMD_bang;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866 for ( ; (int)eap->cmdidx < (int)CMD_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 eap->cmdidx = (cmdidx_T)((int)eap->cmdidx + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868 if (STRNCMP(cmdnames[(int)eap->cmdidx].cmd_name, (char *)eap->cmd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3869 (size_t)len) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3871 #ifdef FEAT_EVAL
27970
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3872 if (full != NULL && cmdnames[eap->cmdidx].cmd_name[len] == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3873 *full = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3874 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3875 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3877
27970
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3878 // :Print and :mode are not supported in Vim9 script.
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3879 // Some commands cannot be shortened in Vim9 script.
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3880 if (vim9 && eap->cmdidx != CMD_SIZE)
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3881 {
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3882 if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3883 eap->cmdidx = CMD_SIZE;
27978
442ca2007bec patch 8.2.4514: Vim9: some flow commands can be shortened
Bram Moolenaar <Bram@vim.org>
parents: 27970
diff changeset
3884 else if ((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
27970
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3885 && len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3886 {
27978
442ca2007bec patch 8.2.4514: Vim9: some flow commands can be shortened
Bram Moolenaar <Bram@vim.org>
parents: 27970
diff changeset
3887 semsg(_(e_command_cannot_be_shortened_str), eap->cmd);
27970
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3888 eap->cmdidx = CMD_SIZE;
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3889 }
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3890 }
27956
2485bf68de34 patch 8.2.4503: Vim9: there is no point in supporting :Print and :mode
Bram Moolenaar <Bram@vim.org>
parents: 27800
diff changeset
3891
26771
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 26576
diff changeset
3892 // Do not recognize ":*" as the star command unless '*' is in
22950
1270401054d8 patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents: 22948
diff changeset
3893 // 'cpoptions'.
1270401054d8 patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents: 22948
diff changeset
3894 if (eap->cmdidx == CMD_star && vim_strchr(p_cpo, CPO_STAR) == NULL)
1270401054d8 patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents: 22948
diff changeset
3895 p = eap->cmd;
1270401054d8 patch 8.2.2022: Vim9: star command recognized errornously
Bram Moolenaar <Bram@vim.org>
parents: 22948
diff changeset
3896
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
3897 // Look for a user defined command as a last resort. Let ":Print" be
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
3898 // overruled by a user defined command.
2633
7002404b17b1 updated for version 7.3.054
Bram Moolenaar <bram@vim.org>
parents: 2602
diff changeset
3899 if ((eap->cmdidx == CMD_SIZE || eap->cmdidx == CMD_Print)
7002404b17b1 updated for version 7.3.054
Bram Moolenaar <bram@vim.org>
parents: 2602
diff changeset
3900 && *eap->cmd >= 'A' && *eap->cmd <= 'Z')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3901 {
16411
5b5c5daf57de patch 8.1.1210: support for user commands is spread out
Bram Moolenaar <Bram@vim.org>
parents: 16399
diff changeset
3902 // User defined commands may contain digits.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3903 while (ASCII_ISALNUM(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3904 ++p;
184
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3905 p = find_ucmd(eap, p, full, NULL, NULL);
476198990769 updated for version 7.0057
vimboss
parents: 171
diff changeset
3906 }
23205
d998222d314d patch 8.2.2148: Vim9: crash when user command doesn't match
Bram Moolenaar <Bram@vim.org>
parents: 23189
diff changeset
3907 if (p == NULL || p == eap->cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3908 eap->cmdidx = CMD_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3910
27970
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3911 // ":fina" means ":finally" in legacy script, for backwards compatibility.
212c5894b8b1 patch 8.2.4510: Vim9: shortening commands leads to confusing script
Bram Moolenaar <Bram@vim.org>
parents: 27956
diff changeset
3912 if (eap->cmdidx == CMD_final && p - eap->cmd == 4 && !vim9)
22395
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3913 eap->cmdidx = CMD_finally;
03249b8976a9 patch 8.2.1746: Vim9: cannot use "fina" for "finally"
Bram Moolenaar <Bram@vim.org>
parents: 22393
diff changeset
3914
23189
ea43f4117d06 patch 8.2.2140: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents: 23185
diff changeset
3915 #ifdef FEAT_EVAL
23513
872239543313 patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
3916 if (eap->cmdidx < CMD_SIZE
24699
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
3917 && vim9
25304
d39c12f97298 patch 8.2.3189: Vim9: error when using "try|"
Bram Moolenaar <Bram@vim.org>
parents: 25294
diff changeset
3918 && !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!' && *p != '|'
23513
872239543313 patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
3919 && (eap->cmdidx < 0 ||
872239543313 patch 8.2.2299: Vim9: invalid memory access making error message flaky
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
3920 (cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 23179
diff changeset
3921 {
24543
b3bd27751e09 patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents: 24535
diff changeset
3922 char_u *cmd = vim_strnsave(eap->cmd, p - eap->cmd);
b3bd27751e09 patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents: 24535
diff changeset
3923
b3bd27751e09 patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents: 24535
diff changeset
3924 semsg(_(e_command_str_not_followed_by_white_space_str), cmd, eap->cmd);
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 23179
diff changeset
3925 eap->cmdidx = CMD_SIZE;
24543
b3bd27751e09 patch 8.2.2811: Vim9: error for missing white space doesn't say where
Bram Moolenaar <Bram@vim.org>
parents: 24535
diff changeset
3926 vim_free(cmd);
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 23179
diff changeset
3927 }
23189
ea43f4117d06 patch 8.2.2140: build failure with tiny features
Bram Moolenaar <Bram@vim.org>
parents: 23185
diff changeset
3928 #endif
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 23179
diff changeset
3929
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3930 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3931 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3933 #if defined(FEAT_EVAL) || defined(PROTO)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3934 static struct cmdmod
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3935 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3936 char *name;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3937 int minlen;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3938 int has_count; // :123verbose :3tab
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3939 } cmdmods[] = {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3940 {"aboveleft", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3941 {"belowright", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3942 {"botright", 2, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3943 {"browse", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3944 {"confirm", 4, FALSE},
9941
e975914c17e9 commit https://github.com/vim/vim/commit/7b668e83d0635d082b7ec90d7d2aa30a9d7d8928
Christian Brabandt <cb@256bit.org>
parents: 9927
diff changeset
3945 {"filter", 4, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3946 {"hide", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3947 {"keepalt", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3948 {"keepjumps", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3949 {"keepmarks", 3, FALSE},
5467
6367a766027d updated for version 7.4.083
Bram Moolenaar <bram@vim.org>
parents: 5464
diff changeset
3950 {"keeppatterns", 5, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3951 {"leftabove", 5, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3952 {"lockmarks", 3, FALSE},
1721
d23a400b7184 updated for version 7.2-019
vimboss
parents: 1689
diff changeset
3953 {"noautocmd", 3, FALSE},
5737
e25a04c1c515 updated for version 7.4.213
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
3954 {"noswapfile", 3, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3955 {"rightbelow", 6, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3956 {"sandbox", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3957 {"silent", 3, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3958 {"tab", 3, TRUE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3959 {"topleft", 2, FALSE},
1926
43d337097e4c updated for version 7.2-223
vimboss
parents: 1925
diff changeset
3960 {"unsilent", 3, FALSE},
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3961 {"verbose", 4, TRUE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3962 {"vertical", 4, FALSE},
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3963 };
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3964
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3965 /*
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3966 * Return length of a command modifier (including optional count).
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3967 * Return zero when it's not a modifier.
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3968 */
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3969 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3970 modifier_len(char_u *cmd)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3971 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3972 int i, j;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3973 char_u *p = cmd;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3974
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3975 if (VIM_ISDIGIT(*cmd))
24665
661d15592d3c patch 8.2.2871: unnessary VIM_ISDIGIT() calls, badly indented code
Bram Moolenaar <Bram@vim.org>
parents: 24555
diff changeset
3976 p = skipwhite(skipdigits(cmd + 1));
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24723
diff changeset
3977 for (i = 0; i < (int)ARRAY_LENGTH(cmdmods); ++i)
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3978 {
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3979 for (j = 0; p[j] != NUL; ++j)
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3980 if (p[j] != cmdmods[i].name[j])
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3981 break;
4857
84a8d1ba81c3 updated for version 7.3.1175
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
3982 if (!ASCII_ISALPHA(p[j]) && j >= cmdmods[i].minlen
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3983 && (p == cmd || cmdmods[i].has_count))
1570
f0cfff4dcc2f updated for version 7.1-283
vimboss
parents: 1557
diff changeset
3984 return j + (int)(p - cmd);
1447
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3985 }
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3986 return 0;
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3987 }
dac5006b4443 updated for version 7.1-162
vimboss
parents: 1442
diff changeset
3988
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3989 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3990 * Return > 0 if an Ex command "name" exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3991 * Return 2 if there is an exact match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3992 * Return 3 if there is an ambiguous match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3994 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
3995 cmd_exists(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3996 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3997 exarg_T ea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3998 int full = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3999 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4000 int j;
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
4001 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4002
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4003 // Check command modifiers.
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24723
diff changeset
4004 for (i = 0; i < (int)ARRAY_LENGTH(cmdmods); ++i)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4006 for (j = 0; name[j] != NUL; ++j)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4007 if (name[j] != cmdmods[i].name[j])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4008 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4009 if (name[j] == NUL && j >= cmdmods[i].minlen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4010 return (cmdmods[i].name[j] == NUL ? 2 : 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4012
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4013 // Check built-in commands and user defined commands.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4014 // For ":2match" and ":3match" we need to skip the number.
862
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
4015 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4016 ea.cmdidx = (cmdidx_T)0;
28195
20ad2fd9f745 patch 8.2.4623: Coverity warns for using uninitialized field
Bram Moolenaar <Bram@vim.org>
parents: 28189
diff changeset
4017 ea.flags = 0;
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
4018 p = find_ex_command(&ea, &full, NULL, NULL);
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
4019 if (p == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4020 return 3;
862
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
4021 if (vim_isdigit(*name) && ea.cmdidx != CMD_match)
bb084e291010 updated for version 7.0g03
vimboss
parents: 859
diff changeset
4022 return 0;
866
5de6b337e1a2 updated for version 7.0g04
vimboss
parents: 862
diff changeset
4023 if (*skipwhite(p) != NUL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4024 return 0; // trailing garbage
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025 return (ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026 }
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4027
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4028 /*
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4029 * "fullcommand" function
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4030 */
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4031 void
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4032 f_fullcommand(typval_T *argvars, typval_T *rettv)
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4033 {
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4034 exarg_T ea;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4035 char_u *name;
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4036 char_u *p;
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4037
24697
a6e43da449af patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
4038 rettv->v_type = VAR_STRING;
a6e43da449af patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
4039 rettv->vval.v_string = NULL;
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4040
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4041 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4042 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4043
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25330
diff changeset
4044 name = argvars[0].vval.v_string;
24697
a6e43da449af patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
4045 if (name == NULL)
a6e43da449af patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
4046 return;
a6e43da449af patch 8.2.2887: crash when passing null string to fullcommand()
Bram Moolenaar <Bram@vim.org>
parents: 24665
diff changeset
4047
26941
33120321ff2c patch 8.2.3999: redundant check for NUL byte
Bram Moolenaar <Bram@vim.org>
parents: 26915
diff changeset
4048 while (*name == ':')
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4049 name++;
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4050 name = skip_range(name, TRUE, NULL);
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4051
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4052 ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4053 ea.cmdidx = (cmdidx_T)0;
24699
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4054 ea.addr_count = 0;
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4055 p = find_ex_command(&ea, NULL, NULL, NULL);
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4056 if (p == NULL || ea.cmdidx == CMD_SIZE)
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4057 return;
24699
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4058 if (in_vim9script())
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4059 {
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4060 int res;
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4061
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4062 ++emsg_silent;
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4063 res = not_in_vim9(&ea);
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4064 --emsg_silent;
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4065
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4066 if (res == FAIL)
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4067 return;
b19c8150ee9d patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 24697
diff changeset
4068 }
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4069
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4070 rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
25757
589226a5f317 patch 8.2.3414: fullcommand() gives wrong name with buffer-local user command
Bram Moolenaar <Bram@vim.org>
parents: 25739
diff changeset
4071 ? get_user_command_name(ea.useridx, ea.cmdidx)
589226a5f317 patch 8.2.3414: fullcommand() gives wrong name with buffer-local user command
Bram Moolenaar <Bram@vim.org>
parents: 25739
diff changeset
4072 : cmdnames[ea.cmdidx].cmd_name);
23853
a9ed31ab85c3 patch 8.2.2468: not easy to get the full command name from a shortened one
Bram Moolenaar <Bram@vim.org>
parents: 23823
diff changeset
4073 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4074 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4075
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4076 cmdidx_T
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4077 excmd_get_cmdidx(char_u *cmd, int len)
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4078 {
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4079 cmdidx_T idx;
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4080
28185
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
4081 if (!one_letter_cmd(cmd, &idx))
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
4082 for (idx = (cmdidx_T)0; (int)idx < (int)CMD_SIZE;
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
4083 idx = (cmdidx_T)((int)idx + 1))
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
4084 if (STRNCMP(cmdnames[(int)idx].cmd_name, cmd, (size_t)len) == 0)
dcb449ae45c9 patch 8.2.4618: cmdline completion does not recognize single letter commands
Bram Moolenaar <Bram@vim.org>
parents: 28179
diff changeset
4085 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4086
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4087 return idx;
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4088 }
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4089
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4090 long
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4091 excmd_get_argt(cmdidx_T idx)
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4092 {
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
4093 return (long)cmdnames[(int)idx].cmd_argt;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4096 /*
14505
3f1a17863b73 patch 8.1.0266: parsing Ex address range is not a separate function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
4097 * Skip a range specifier of the form: addr [,addr] [;addr] ..
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 * Backslashed delimiters after / or ? will be skipped, and commands will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 * not be expanded between /'s and ?'s or after "'".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 *
20982
bb49b5090a9c patch 8.2.1042: Vim9: cannot put an operator on the next line
Bram Moolenaar <Bram@vim.org>
parents: 20897
diff changeset
4102 * Also skip white space and ":" characters after the range.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 * Returns the "cmd" pointer advanced to beyond the range.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4106 skip_range(
26327
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4107 char_u *cmd_start,
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4108 int skip_star, // skip "*" used for Visual range
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4109 int *ctx) // pointer to xp_context or NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 {
26327
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4111 char_u *cmd = cmd_start;
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
4112 unsigned delim;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113
10817
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4114 while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4115 {
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4116 if (*cmd == '\\')
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4117 {
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4118 if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&')
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4119 ++cmd;
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4120 else
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4121 break;
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4122 }
cc8079703414 patch 8.0.0298: Ex command range with repeated search does not work
Christian Brabandt <cb@256bit.org>
parents: 10809
diff changeset
4123 else if (*cmd == '\'')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4124 {
26327
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4125 char_u *p = cmd;
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4126
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4127 // a quote is only valid at the start or after a separator
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4128 while (p > cmd_start)
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4129 {
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4130 --p;
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4131 if (!VIM_ISWHITE(*p))
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4132 break;
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4133 }
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4134 if (cmd > cmd_start && !VIM_ISWHITE(*p) && *p != ',' && *p != ';')
227543e4181f patch 8.2.3694: cannot use quotes in the count of an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 26319
diff changeset
4135 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 if (*++cmd == NUL && ctx != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 *ctx = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139 else if (*cmd == '/' || *cmd == '?')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 delim = *cmd++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 while (*cmd != NUL && *cmd != delim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 if (*cmd++ == '\\' && *cmd != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 ++cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145 if (*cmd == NUL && ctx != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 *ctx = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4148 if (*cmd != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149 ++cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4151
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4152 // Skip ":" and white space.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4153 while (*cmd == ':')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4154 cmd = skipwhite(cmd + 1);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4155
22260
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4156 // Skip "*" used for Visual range.
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4157 if (skip_star && *cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4158 cmd = skipwhite(cmd + 1);
d7c1e3efa88e patch 8.2.1679: Vim9: ":*" is not recognized as a range
Bram Moolenaar <Bram@vim.org>
parents: 22208
diff changeset
4159
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 return cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4162
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4163 static void
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4164 addr_error(cmd_addr_T addr_type)
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4165 {
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4166 if (addr_type == ADDR_NONE)
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4167 emsg(_(e_no_range_allowed));
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4168 else
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4169 emsg(_(e_invalid_range));
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4170 }
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4171
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4172 /*
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4173 * Return the default address for an address type.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4174 */
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4175 static linenr_T
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4176 default_address(exarg_T *eap)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4177 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4178 linenr_T lnum = 0;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4179
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4180 switch (eap->addr_type)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4181 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4182 case ADDR_LINES:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4183 case ADDR_OTHER:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4184 // Default is the cursor line number. Avoid using an invalid
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4185 // line number though.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4186 if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4187 lnum = curbuf->b_ml.ml_line_count;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4188 else
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4189 lnum = curwin->w_cursor.lnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4190 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4191 case ADDR_WINDOWS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4192 lnum = CURRENT_WIN_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4193 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4194 case ADDR_ARGUMENTS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4195 lnum = curwin->w_arg_idx + 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4196 if (lnum > ARGCOUNT)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4197 lnum = ARGCOUNT;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4198 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4199 case ADDR_LOADED_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4200 case ADDR_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4201 lnum = curbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4202 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4203 case ADDR_TABS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4204 lnum = CURRENT_TAB_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4205 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4206 case ADDR_TABS_RELATIVE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4207 case ADDR_UNSIGNED:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4208 lnum = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4209 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4210 case ADDR_QUICKFIX:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4211 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4212 lnum = qf_get_cur_idx(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4213 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4214 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4215 case ADDR_QUICKFIX_VALID:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4216 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4217 lnum = qf_get_cur_valid_idx(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4218 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4219 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4220 case ADDR_NONE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4221 // Will give an error later if a range is found.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4222 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4223 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4224 return lnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4225 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4226
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4227 /*
14677
7771a1ff8b99 patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents: 14648
diff changeset
4228 * Get a single EX address.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4229 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230 * Set ptr to the next character after the part that was interpreted.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231 * Set ptr to NULL when an error is encountered.
14677
7771a1ff8b99 patch 8.1.0351: 'incsearch' for :/foo/s//<Esc> changes last search pattern
Christian Brabandt <cb@256bit.org>
parents: 14648
diff changeset
4232 * This may set the last used search pattern.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234 * Return MAXLNUM when no Ex address was found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236 static linenr_T
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4237 get_address(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4238 exarg_T *eap UNUSED,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4239 char_u **ptr,
18849
b77ef4b8af7c patch 8.1.2411: function argument copied unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 18779
diff changeset
4240 cmd_addr_T addr_type,
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4241 int skip, // only skip the address, don't use it
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4242 int silent, // no errors or side effects
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4243 int to_other_file, // flag: may jump to other file
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4244 int address_count UNUSED) // 1 for first address, >1 after comma
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4246 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4247 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4248 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4250 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4251 pos_T *fp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4252 linenr_T lnum;
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4253 buf_T *buf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4255 cmd = skipwhite(*ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4256 lnum = MAXLNUM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4257 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4259 switch (*cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4260 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4261 case '.': // '.' - Cursor position
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4262 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4263 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4264 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4265 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4266 case ADDR_OTHER:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4267 lnum = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4268 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4269 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4270 lnum = CURRENT_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4271 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4272 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4273 lnum = curwin->w_arg_idx + 1;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4274 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4275 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4276 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4277 lnum = curbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4278 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4279 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4280 lnum = CURRENT_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4281 break;
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4282 case ADDR_NONE:
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4283 case ADDR_TABS_RELATIVE:
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4284 case ADDR_UNSIGNED:
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4285 addr_error(addr_type);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4286 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4287 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4288 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4289 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
4290 #ifdef FEAT_QUICKFIX
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4291 lnum = qf_get_cur_idx(eap);
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4292 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4293 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4294 case ADDR_QUICKFIX_VALID:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4295 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4296 lnum = qf_get_cur_valid_idx(eap);
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4297 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4298 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4299 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4300 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4301
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4302 case '$': // '$' - last line
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4303 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4304 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4305 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4306 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4307 case ADDR_OTHER:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4308 lnum = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4309 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4310 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4311 lnum = LAST_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4312 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4313 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4314 lnum = ARGCOUNT;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4315 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4316 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4317 buf = lastbuf;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4318 while (buf->b_ml.ml_mfp == NULL)
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4319 {
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4320 if (buf->b_prev == NULL)
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4321 break;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4322 buf = buf->b_prev;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4323 }
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4324 lnum = buf->b_fnum;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4325 break;
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4326 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4327 lnum = lastbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4328 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4329 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4330 lnum = LAST_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4331 break;
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4332 case ADDR_NONE:
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4333 case ADDR_TABS_RELATIVE:
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4334 case ADDR_UNSIGNED:
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4335 addr_error(addr_type);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4336 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4337 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4338 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4339 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
4340 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4341 lnum = qf_get_size(eap);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4342 if (lnum == 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4343 lnum = 1;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4344 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4345 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4346 case ADDR_QUICKFIX_VALID:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4347 #ifdef FEAT_QUICKFIX
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4348 lnum = qf_get_valid_size(eap);
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4349 if (lnum == 0)
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4350 lnum = 1;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4351 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4352 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4353 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4354 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4355
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4356 case '\'': // ''' - mark
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4357 if (*++cmd == NUL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4358 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4359 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4360 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4361 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4362 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4363 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4364 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4365 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4366 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4367 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4368 if (skip)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4369 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4370 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4371 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4372 // Only accept a mark in another file when it is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4373 // used by itself: ":'M".
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4374 fp = getmark(*cmd, to_other_file && cmd[1] == NUL);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4375 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4376 if (fp == (pos_T *)-1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4377 // Jumped to another file.
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4378 lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4379 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4380 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4381 if (check_mark(fp) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383 cmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4384 goto error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4386 lnum = fp->lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4387 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4388 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4389 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391 case '/':
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4392 case '?': // '/' or '?' - search
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4393 c = *cmd++;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4394 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4395 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4396 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4397 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4398 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4399 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4400 if (skip) // skip "/pat/"
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4401 {
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 23239
diff changeset
4402 cmd = skip_regexp(cmd, c, magic_isset());
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4403 if (*cmd == c)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4404 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4405 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4406 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4407 {
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4408 int flags;
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4409
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4410 pos = curwin->w_cursor; // save curwin->w_cursor
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4411
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4412 // When '/' or '?' follows another address, start from
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4413 // there.
25911
d6d31972c76d patch 8.2.3489: ml_get error after search with range
Bram Moolenaar <Bram@vim.org>
parents: 25883
diff changeset
4414 if (lnum > 0 && lnum != MAXLNUM)
d6d31972c76d patch 8.2.3489: ml_get error after search with range
Bram Moolenaar <Bram@vim.org>
parents: 25883
diff changeset
4415 curwin->w_cursor.lnum =
d6d31972c76d patch 8.2.3489: ml_get error after search with range
Bram Moolenaar <Bram@vim.org>
parents: 25883
diff changeset
4416 lnum > curbuf->b_ml.ml_line_count
d6d31972c76d patch 8.2.3489: ml_get error after search with range
Bram Moolenaar <Bram@vim.org>
parents: 25883
diff changeset
4417 ? curbuf->b_ml.ml_line_count : lnum;
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4418
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4419 // Start a forward search at the end of the line (unless
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4420 // before the first line).
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4421 // Start a backward search at the start of the line.
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4422 // This makes sure we never match in the current
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4423 // line, and can match anywhere in the
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4424 // next/previous line.
13082
a80082fd1a1d patch 8.0.1416: crash when searching for a sentence
Christian Brabandt <cb@256bit.org>
parents: 12824
diff changeset
4425 if (c == '/' && curwin->w_cursor.lnum > 0)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4426 curwin->w_cursor.col = MAXCOL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4427 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4428 curwin->w_cursor.col = 0;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4429 searchcmdlen = 0;
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
4430 flags = silent ? 0 : SEARCH_HIS | SEARCH_MSG;
19475
5512aa74cb62 patch 8.2.0295: highlighting for :s wrong when using different separator
Bram Moolenaar <Bram@vim.org>
parents: 19433
diff changeset
4431 if (!do_search(NULL, c, c, cmd, 1L, flags, NULL))
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4432 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4433 curwin->w_cursor = pos;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4434 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4435 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4436 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4437 lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4438 curwin->w_cursor = pos;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4439 // adjust command string pointer
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4440 cmd += searchcmdlen;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4441 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4442 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4443
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4444 case '\\': // "\?", "\/" or "\&", repeat search
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4445 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4446 if (addr_type != ADDR_LINES)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4447 {
17650
a1437b8f2fac patch 8.1.1822: confusing error message when range is not allowed
Bram Moolenaar <Bram@vim.org>
parents: 17644
diff changeset
4448 addr_error(addr_type);
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4449 cmd = NULL;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4450 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4451 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4452 if (*cmd == '&')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4453 i = RE_SUBST;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4454 else if (*cmd == '?' || *cmd == '/')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4455 i = RE_SEARCH;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4456 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4457 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4458 emsg(_(e_backslash_should_be_followed_by));
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4459 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4460 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4461 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4462
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4463 if (!skip)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4464 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4465 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4466 * When search follows another address, start from
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4467 * there.
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4468 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4469 if (lnum != MAXLNUM)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4470 pos.lnum = lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4471 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4472 pos.lnum = curwin->w_cursor.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4473
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4474 /*
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4475 * Start the search just like for the above
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4476 * do_search().
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4477 */
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4478 if (*cmd != '?')
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4479 pos.col = MAXCOL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4480 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4481 pos.col = 0;
7007
5ea5bd9c18d2 patch 7.4.821
Bram Moolenaar <bram@vim.org>
parents: 6987
diff changeset
4482 pos.coladd = 0;
15239
db5d2429bda3 patch 8.1.0629: "gn" selects the wrong text with a multi-line match
Bram Moolenaar <Bram@vim.org>
parents: 15227
diff changeset
4483 if (searchit(curwin, curbuf, &pos, NULL,
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4484 *cmd == '?' ? BACKWARD : FORWARD,
18358
34d5cd432cac patch 8.1.2173: searchit() has too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 18297
diff changeset
4485 (char_u *)"", 1L, SEARCH_MSG, i, NULL) != FAIL)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4486 lnum = pos.lnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4487 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4488 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4489 cmd = NULL;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4490 goto error;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4491 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4492 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4493 ++cmd;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4494 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496 default:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4497 if (VIM_ISDIGIT(*cmd)) // absolute line number
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4498 lnum = getdigits(&cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4501 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 cmd = skipwhite(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4504 if (*cmd != '-' && *cmd != '+' && !VIM_ISDIGIT(*cmd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 if (lnum == MAXLNUM)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4508 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4509 switch (addr_type)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4510 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4511 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4512 case ADDR_OTHER:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4513 // "+1" is same as ".+1"
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4514 lnum = curwin->w_cursor.lnum;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4515 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4516 case ADDR_WINDOWS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4517 lnum = CURRENT_WIN_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4518 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4519 case ADDR_ARGUMENTS:
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4520 lnum = curwin->w_arg_idx + 1;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4521 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4522 case ADDR_LOADED_BUFFERS:
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4523 case ADDR_BUFFERS:
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4524 lnum = curbuf->b_fnum;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4525 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4526 case ADDR_TABS:
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
4527 lnum = CURRENT_TAB_NR;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4528 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4529 case ADDR_TABS_RELATIVE:
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4530 lnum = 1;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4531 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4532 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
4533 #ifdef FEAT_QUICKFIX
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4534 lnum = qf_get_cur_idx(eap);
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4535 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4536 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4537 case ADDR_QUICKFIX_VALID:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4538 #ifdef FEAT_QUICKFIX
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4539 lnum = qf_get_cur_valid_idx(eap);
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4540 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4541 break;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4542 case ADDR_NONE:
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4543 case ADDR_UNSIGNED:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4544 lnum = 0;
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4545 break;
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4546 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4547 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
4548
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4549 if (VIM_ISDIGIT(*cmd))
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4550 i = '+'; // "number" is same as "+number"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 i = *cmd++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4553 if (!VIM_ISDIGIT(*cmd)) // '+' is '+1', but '+0' is not '+1'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4554 n = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 else
26256
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4556 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 n = getdigits(&cmd);
26256
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4558 if (n == MAXLNUM)
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4559 {
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4560 emsg(_(e_line_number_out_of_range));
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4561 goto error;
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4562 }
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4563 }
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4564
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4565 if (addr_type == ADDR_TABS_RELATIVE)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4566 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4567 emsg(_(e_invalid_range));
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4568 cmd = NULL;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4569 goto error;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4570 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4571 else if (addr_type == ADDR_LOADED_BUFFERS
6424
de877dab1c31 updated for version 7.4.542
Bram Moolenaar <bram@vim.org>
parents: 6419
diff changeset
4572 || addr_type == ADDR_BUFFERS)
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4573 lnum = compute_buffer_local_count(
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4574 addr_type, lnum, (i == '-') ? -1 * n : n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 else
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4576 {
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4577 #ifdef FEAT_FOLDING
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4578 // Relative line addressing, need to adjust for folded lines
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4579 // now, but only do it after the first address.
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4580 if (addr_type == ADDR_LINES && (i == '-' || i == '+')
26256
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4581 && address_count >= 2)
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4582 (void)hasFolding(lnum, NULL, &lnum);
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4583 #endif
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4584 if (i == '-')
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4585 lnum -= n;
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4586 else
26256
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4587 {
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4588 if (n >= LONG_MAX - lnum)
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4589 {
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4590 emsg(_(e_line_number_out_of_range));
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4591 goto error;
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4592 }
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4593 lnum += n;
26256
92fbed13ca4d patch 8.2.3659: integer overflow with large line number
Bram Moolenaar <Bram@vim.org>
parents: 26181
diff changeset
4594 }
10484
c7de1536780a commit https://github.com/vim/vim/commit/ded2782783f352201ac0b05c6dbe4831adb4a58b
Christian Brabandt <cb@256bit.org>
parents: 10480
diff changeset
4595 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4597 } while (*cmd == '/' || *cmd == '?');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4599 error:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4600 *ptr = cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4601 return lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604 /*
21939
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4605 * Set eap->line1 and eap->line2 to the whole range.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4606 * Used for commands with the EX_DFLALL flag and no range given.
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4607 */
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4608 static void
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4609 address_default_all(exarg_T *eap)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4610 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4611 eap->line1 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4612 switch (eap->addr_type)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4613 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4614 case ADDR_LINES:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4615 case ADDR_OTHER:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4616 eap->line2 = curbuf->b_ml.ml_line_count;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4617 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4618 case ADDR_LOADED_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4619 {
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4620 buf_T *buf = firstbuf;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4621
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4622 while (buf->b_next != NULL && buf->b_ml.ml_mfp == NULL)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4623 buf = buf->b_next;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4624 eap->line1 = buf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4625 buf = lastbuf;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4626 while (buf->b_prev != NULL && buf->b_ml.ml_mfp == NULL)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4627 buf = buf->b_prev;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4628 eap->line2 = buf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4629 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4630 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4631 case ADDR_BUFFERS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4632 eap->line1 = firstbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4633 eap->line2 = lastbuf->b_fnum;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4634 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4635 case ADDR_WINDOWS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4636 eap->line2 = LAST_WIN_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4637 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4638 case ADDR_TABS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4639 eap->line2 = LAST_TAB_NR;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4640 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4641 case ADDR_TABS_RELATIVE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4642 eap->line2 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4643 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4644 case ADDR_ARGUMENTS:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4645 if (ARGCOUNT == 0)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4646 eap->line1 = eap->line2 = 0;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4647 else
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4648 eap->line2 = ARGCOUNT;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4649 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4650 case ADDR_QUICKFIX_VALID:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4651 #ifdef FEAT_QUICKFIX
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4652 eap->line2 = qf_get_valid_size(eap);
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4653 if (eap->line2 == 0)
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4654 eap->line2 = 1;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4655 #endif
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4656 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4657 case ADDR_NONE:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4658 case ADDR_UNSIGNED:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4659 case ADDR_QUICKFIX:
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4660 iemsg(_("INTERNAL: Cannot use EX_DFLALL with ADDR_NONE, ADDR_UNSIGNED or ADDR_QUICKFIX"));
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4661 break;
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4662 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4663 }
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4664
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4665
8350bdbdbb28 patch 8.2.1519: Vim9: Ex command default range is not set
Bram Moolenaar <Bram@vim.org>
parents: 21937
diff changeset
4666 /*
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4667 * Get flags from an Ex command argument.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4668 */
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4669 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4670 get_flags(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4671 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4672 while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4673 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4674 if (*eap->arg == 'l')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4675 eap->flags |= EXFLAG_LIST;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4676 else if (*eap->arg == 'p')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4677 eap->flags |= EXFLAG_PRINT;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4678 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4679 eap->flags |= EXFLAG_NR;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4680 eap->arg = skipwhite(eap->arg + 1);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4681 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4682 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4683
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
4684 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4685 * Function called for command which is Not Implemented. NI!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4687 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4688 ex_ni(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4690 if (!eap->skip)
21459
a422bd80b434 patch 8.2.1280: Ex command error cannot contain an argument
Bram Moolenaar <Bram@vim.org>
parents: 21413
diff changeset
4691 eap->errmsg =
26909
aa65d1808bd0 patch 8.2.3983: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
4692 _(e_sorry_command_is_not_available_in_this_version);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4693 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694
1315
0868e4e53fb2 updated for version 7.1-029
vimboss
parents: 1305
diff changeset
4695 #ifdef HAVE_EX_SCRIPT_NI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4697 * Function called for script command which is Not Implemented. NI!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 * Skips over ":perl <<EOF" constructs.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4700 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4701 ex_script_ni(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4703 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 ex_ni(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 vim_free(script_get(eap, eap->arg));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711 * Check range in Ex command for validity.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 * Return NULL when valid, error message when invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4714 static char *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4715 invalid_range(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 {
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4717 buf_T *buf;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4718
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 if ( eap->line1 < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 || eap->line2 < 0
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4721 || eap->line1 > eap->line2)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4722 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4723
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4724 if (eap->argt & EX_RANGE)
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4725 {
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4726 switch (eap->addr_type)
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4727 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4728 case ADDR_LINES:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4729 if (eap->line2 > curbuf->b_ml.ml_line_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730 #ifdef FEAT_DIFF
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4731 + (eap->cmdidx == CMD_diffget)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4732 #endif
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4733 )
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4734 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4735 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4736 case ADDR_ARGUMENTS:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4737 // add 1 if ARGCOUNT is 0
6581
05202d6ba0ef updated for version 7.4.617
Bram Moolenaar <bram@vim.org>
parents: 6506
diff changeset
4738 if (eap->line2 > ARGCOUNT + (!ARGCOUNT))
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4739 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4740 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4741 case ADDR_BUFFERS:
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4742 // Only a boundary check, not whether the buffers actually
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4743 // exist.
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
4744 if (eap->line1 < 1 || eap->line2 > get_highest_fnum())
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4745 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4746 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4747 case ADDR_LOADED_BUFFERS:
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4748 buf = firstbuf;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4749 while (buf->b_ml.ml_mfp == NULL)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4750 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4751 if (buf->b_next == NULL)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4752 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4753 buf = buf->b_next;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4754 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4755 if (eap->line1 < buf->b_fnum)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4756 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4757 buf = lastbuf;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4758 while (buf->b_ml.ml_mfp == NULL)
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4759 {
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4760 if (buf->b_prev == NULL)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4761 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4762 buf = buf->b_prev;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4763 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4764 if (eap->line2 > buf->b_fnum)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4765 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4766 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4767 case ADDR_WINDOWS:
6480
747cbac7047b updated for version 7.4.568
Bram Moolenaar <bram@vim.org>
parents: 6472
diff changeset
4768 if (eap->line2 > LAST_WIN_NR)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4769 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4770 break;
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4771 case ADDR_TABS:
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4772 if (eap->line2 > LAST_TAB_NR)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4773 return _(e_invalid_range);
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4774 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4775 case ADDR_TABS_RELATIVE:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4776 case ADDR_OTHER:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4777 // Any range is OK.
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
4778 break;
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4779 case ADDR_QUICKFIX:
7105
f4456e686406 commit https://github.com/vim/vim/commit/e906c502079770ae0e0071c74cefb802689ff193
Christian Brabandt <cb@256bit.org>
parents: 7092
diff changeset
4780 #ifdef FEAT_QUICKFIX
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4781 // No error for value that is too big, will use the last entry.
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4782 if (eap->line2 <= 0)
26568
c675779d5f2b patch 8.2.3813: confusing error when using :cc without error list
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
4783 {
c675779d5f2b patch 8.2.3813: confusing error when using :cc without error list
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
4784 if (eap->addr_count == 0)
c675779d5f2b patch 8.2.3813: confusing error when using :cc without error list
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
4785 return _(e_no_errors);
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4786 return _(e_invalid_range);
26568
c675779d5f2b patch 8.2.3813: confusing error when using :cc without error list
Bram Moolenaar <Bram@vim.org>
parents: 26532
diff changeset
4787 }
16479
7dcf301d1432 patch 8.1.1243: compiler warnings for incomplete switch statement
Bram Moolenaar <Bram@vim.org>
parents: 16475
diff changeset
4788 #endif
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
4789 break;
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4790 case ADDR_QUICKFIX_VALID:
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4791 #ifdef FEAT_QUICKFIX
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4792 if ((eap->line2 != 1 && eap->line2 > qf_get_valid_size(eap))
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4793 || eap->line2 < 0)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
4794 return _(e_invalid_range);
16515
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4795 #endif
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4796 break;
6e87a69b8e0c patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents: 16505
diff changeset
4797 case ADDR_UNSIGNED:
16475
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4798 case ADDR_NONE:
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4799 // Will give an error elsewhere.
854fb0ad4be6 patch 8.1.1241: Ex command info contains confusing information
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
4800 break;
6472
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4801 }
22f95a018b13 updated for version 7.4.565
Bram Moolenaar <bram@vim.org>
parents: 6464
diff changeset
4802 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4803 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4805
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807 * Correct the range for zero line number, if required.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4810 correct_range(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811 {
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
4812 if (!(eap->argt & EX_ZEROR)) // zero in range not allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814 if (eap->line1 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 eap->line1 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 if (eap->line2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 eap->line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4821 #ifdef FEAT_QUICKFIX
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4822 /*
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4823 * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4824 * pattern. Otherwise return eap->arg.
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4825 */
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4826 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4827 skip_grep_pat(exarg_T *eap)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4828 {
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4829 char_u *p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4830
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4831 if (*p != NUL && (eap->cmdidx == CMD_vimgrep || eap->cmdidx == CMD_lvimgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4832 || eap->cmdidx == CMD_vimgrepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4833 || eap->cmdidx == CMD_lvimgrepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4834 || grep_internal(eap->cmdidx)))
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4835 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4836 p = skip_vimgrep_pat(p, NULL, NULL);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4837 if (p == NULL)
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4838 p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4839 }
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4840 return p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4841 }
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4842
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4843 /*
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4844 * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4845 * in the command line, so that things like % get expanded.
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4846 */
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4847 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4848 replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4849 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4850 char_u *new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4851 char_u *program;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4852 char_u *pos;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4853 char_u *ptr;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4854 int len;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4855 int i;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4856
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4857 /*
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4858 * Don't do it when ":vimgrep" is used for ":grep".
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4859 */
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4860 if ((eap->cmdidx == CMD_make || eap->cmdidx == CMD_lmake
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4861 || eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4862 || eap->cmdidx == CMD_grepadd
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4863 || eap->cmdidx == CMD_lgrepadd)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4864 && !grep_internal(eap->cmdidx))
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4865 {
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4866 if (eap->cmdidx == CMD_grep || eap->cmdidx == CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
4867 || eap->cmdidx == CMD_grepadd || eap->cmdidx == CMD_lgrepadd)
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4868 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4869 if (*curbuf->b_p_gp == NUL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4870 program = p_gp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4871 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4872 program = curbuf->b_p_gp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4873 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4874 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4875 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4876 if (*curbuf->b_p_mp == NUL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4877 program = p_mp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4878 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4879 program = curbuf->b_p_mp;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4880 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4881
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4882 p = skipwhite(p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4883
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4884 if ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4885 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4886 // replace $* by given arguments
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4887 i = 1;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4888 while ((pos = (char_u *)strstr((char *)pos + 2, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4889 ++i;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4890 len = (int)STRLEN(p);
27453
c7f614c9ceb3 patch 8.2.4255: theoretical computation overflow
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4891 new_cmdline = alloc(STRLEN(program) + (size_t)i * (len - 2) + 1);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4892 if (new_cmdline == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4893 return NULL; // out of memory
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4894 ptr = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4895 while ((pos = (char_u *)strstr((char *)program, "$*")) != NULL)
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4896 {
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4897 i = (int)(pos - program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4898 STRNCPY(ptr, program, i);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4899 STRCPY(ptr += i, p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4900 ptr += len;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4901 program = pos + 2;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4902 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4903 STRCPY(ptr, program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4904 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4905 else
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4906 {
16782
fc58fee685e2 patch 8.1.1393: unnecessary type casts
Bram Moolenaar <Bram@vim.org>
parents: 16780
diff changeset
4907 new_cmdline = alloc(STRLEN(program) + STRLEN(p) + 2);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4908 if (new_cmdline == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4909 return NULL; // out of memory
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4910 STRCPY(new_cmdline, program);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4911 STRCAT(new_cmdline, " ");
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4912 STRCAT(new_cmdline, p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4913 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4914 msg_make(p);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4915
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4916 // 'eap->cmd' is not set here, because it is not used at CMD_make
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4917 vim_free(*cmdlinep);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4918 *cmdlinep = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4919 p = new_cmdline;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4920 }
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4921 return p;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 330
diff changeset
4922 }
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4923 #endif
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4924
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4926 * Expand file name in Ex command argument.
17081
81b791a843bc patch 8.1.1540: cannot build without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
4927 * When an error is detected, "errormsgp" is set to a non-NULL pointer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4928 * Return FAIL for failure, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4929 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4930 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4931 expand_filename(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4932 exarg_T *eap,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
4933 char_u **cmdlinep,
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
4934 char **errormsgp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4935 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4936 int has_wildcards; // need to expand wildcards
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4937 char_u *repl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4938 int srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4939 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4940 int n;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4941 int escaped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4943 #ifdef FEAT_QUICKFIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4944 // Skip a regexp pattern for ":vimgrep[add] pat file..."
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4945 p = skip_grep_pat(eap);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4946 #else
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4947 p = eap->arg;
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4948 #endif
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4949
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4951 * Decide to expand wildcards *before* replacing '%', '#', etc. If
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4952 * the file name contains a wildcard it should not cause expanding.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4953 * (it will be expanded anyway if there is a wildcard before replacing).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4954 */
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4955 has_wildcards = mch_has_wildcard(p);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
4956 while (*p != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4958 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4959 // Skip over `=expr`, wildcards in it are not expanded.
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4960 if (p[0] == '`' && p[1] == '=')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4961 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4962 p += 2;
22685
80b4e604d1d5 patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents: 22616
diff changeset
4963 (void)skip_expr(&p, NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4964 if (*p == '`')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4965 ++p;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4966 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4967 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
4968 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4969 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4970 * Quick check if this cannot be the start of a special string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4971 * Also removes backslash before '%', '#' and '<'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4972 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4973 if (vim_strchr((char_u *)"%#<", *p) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4974 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4975 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4976 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4978
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4979 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980 * Try to find a match at this position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4981 */
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
4982 repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
28635
dfe18756f2ad patch 8.2.4841: empty string considered an error for expand()
Bram Moolenaar <Bram@vim.org>
parents: 28530
diff changeset
4983 errormsgp, &escaped, TRUE);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4984 if (*errormsgp != NULL) // error detected
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4985 return FAIL;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4986 if (repl == NULL) // no match found
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 p += srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4992 // Wildcards won't be expanded below, the replacement is taken
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
4993 // literally. But do expand "~/file", "~user/file" and "$HOME/file".
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4994 if (vim_strchr(repl, '$') != NULL || vim_strchr(repl, '~') != NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4995 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4996 char_u *l = repl;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4997
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4998 repl = expand_env_save(repl);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
4999 vim_free(l);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
5000 }
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
5001
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5002 // Need to escape white space et al. with a backslash.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5003 // Don't do this for:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5004 // - replacement that already has been escaped: "##"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5005 // - shell commands (may have to use quotes instead).
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5006 // - non-unix systems when there is a single argument (spaces don't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5007 // separate arguments then).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008 if (!eap->usefilter
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
5009 && !escaped
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5010 && eap->cmdidx != CMD_bang
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 && eap->cmdidx != CMD_grep
11806
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5012 && eap->cmdidx != CMD_grepadd
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5013 && eap->cmdidx != CMD_hardcopy
655
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
5014 && eap->cmdidx != CMD_lgrep
7566e1cda7bf updated for version 7.0193
vimboss
parents: 649
diff changeset
5015 && eap->cmdidx != CMD_lgrepadd
11806
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5016 && eap->cmdidx != CMD_lmake
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5017 && eap->cmdidx != CMD_make
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5018 && eap->cmdidx != CMD_terminal
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 #ifndef UNIX
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
5020 && !(eap->argt & EX_NOSPC)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 char_u *l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 #ifdef BACKSLASH_IN_FILENAME
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5026 // Don't escape a backslash here, because rem_backslash() doesn't
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5027 // remove it later.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5028 static char_u *nobslash = (char_u *)" \t\"|";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5029 # define ESCAPE_CHARS nobslash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5030 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5031 # define ESCAPE_CHARS escape_chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5032 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5034 for (l = repl; *l; ++l)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5035 if (vim_strchr(ESCAPE_CHARS, *l) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5037 l = vim_strsave_escaped(repl, ESCAPE_CHARS);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5038 if (l != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5040 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5041 repl = l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5042 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5043 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5045 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5046
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5047 // For a shell command a '!' must be escaped.
11806
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5048 if ((eap->usefilter || eap->cmdidx == CMD_bang
1c1cb1e9b7b3 patch 8.0.0785: wildcards are not expanded for :terminal
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
5049 || eap->cmdidx == CMD_terminal)
5778
22a1d5762ba3 updated for version 7.4.233
Bram Moolenaar <bram@vim.org>
parents: 5776
diff changeset
5050 && vim_strpbrk(repl, (char_u *)"!") != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5052 char_u *l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5053
5778
22a1d5762ba3 updated for version 7.4.233
Bram Moolenaar <bram@vim.org>
parents: 5776
diff changeset
5054 l = vim_strsave_escaped(repl, (char_u *)"!");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055 if (l != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5057 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 repl = l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 p = repl_cmdline(eap, p, srclen, repl, cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5064 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5065 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 * One file argument: Expand wildcards.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070 * Don't do this with ":r !command" or ":w !command".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071 */
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
5072 if ((eap->argt & EX_NOSPC) && !eap->usefilter)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 * May do this twice:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5076 * 1. Replace environment variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077 * 2. Replace any other wildcards, remove backslashes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 for (n = 1; n <= 2; ++n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081 if (n == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084 * Halve the number of backslashes (this is Vi compatible).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5085 * For Unix and OS/2, when wildcards are expanded, this is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 * done by ExpandOne() below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 */
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7262
diff changeset
5088 #if defined(UNIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 if (!has_wildcards)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 backslash_halve(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 if (has_wildcards)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 if (n == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 * First loop: May expand environment variables. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5100 * can be done much faster with expand_env() than with
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 * something else (e.g., calling a shell).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 * After expanding environment variables, check again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103 * if there are still wildcards present.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 if (vim_strchr(eap->arg, '$') != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 || vim_strchr(eap->arg, '~') != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 {
372
a698eb686ded updated for version 7.0096
vimboss
parents: 358
diff changeset
5108 expand_env_esc(eap->arg, NameBuff, MAXPATHL,
1408
db8309865794 updated for version 7.1-123
vimboss
parents: 1369
diff changeset
5109 TRUE, TRUE, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 has_wildcards = mch_has_wildcard(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 p = NameBuff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 p = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5116 else // n == 2
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 expand_T xpc;
18386
105c6cf8b266 patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
5119 int options = WILD_LIST_NOTFOUND
105c6cf8b266 patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents: 18358
diff changeset
5120 | WILD_NOERROR | WILD_ADD_SLASH;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 ExpandInit(&xpc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 xpc.xp_context = EXPAND_FILES;
2652
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
5124 if (p_wic)
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
5125 options += WILD_ICASE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 p = ExpandOne(&xpc, eap->arg, NULL,
2652
b2a7d143abe2 updated for version 7.3.072
Bram Moolenaar <bram@vim.org>
parents: 2645
diff changeset
5127 options, WILD_EXPAND_FREE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 (void)repl_cmdline(eap, eap->arg, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 p, cmdlinep);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5135 if (n == 2) // p came from ExpandOne()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5136 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 * Replace part of the command line, keeping eap->cmd, eap->arg and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 * eap->nextcmd correct.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 * "src" points to the part that is to be replaced, of length "srclen".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 * "repl" is the replacement string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 * Returns a pointer to the character after the replaced string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150 * Returns NULL for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5153 repl_cmdline(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5154 exarg_T *eap,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5155 char_u *src,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5156 int srclen,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5157 char_u *repl,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5158 char_u **cmdlinep)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 char_u *new_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5164 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 * The new command line is build in new_cmdline[].
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166 * First allocate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 * Careful: a "+cmd" argument may have been NUL terminated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 len = (int)STRLEN(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 i = (int)(src - *cmdlinep) + (int)STRLEN(src + srclen) + len + 3;
698
e402b0af6083 updated for version 7.0211
vimboss
parents: 694
diff changeset
5171 if (eap->nextcmd != NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5172 i += (int)STRLEN(eap->nextcmd);// add space for next command
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
5173 if ((new_cmdline = alloc(i)) == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5174 return NULL; // out of memory!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 * Copy the stuff before the expanded part.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 * Copy the expanded stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179 * Copy what came after the expanded part.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 * Copy the next commands, if there are any.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5182 i = (int)(src - *cmdlinep); // length of part before match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5183 mch_memmove(new_cmdline, *cmdlinep, (size_t)i);
434
9595cf1d80a7 updated for version 7.0112
vimboss
parents: 416
diff changeset
5184
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 mch_memmove(new_cmdline + i, repl, (size_t)len);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5186 i += len; // remember the end of the string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5187 STRCPY(new_cmdline + i, src + srclen);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5188 src = new_cmdline + i; // remember where to continue
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5189
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5190 if (eap->nextcmd != NULL) // append next command
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 i = (int)STRLEN(new_cmdline) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 STRCPY(new_cmdline + i, eap->nextcmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194 eap->nextcmd = new_cmdline + i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5195 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5196 eap->cmd = new_cmdline + (eap->cmd - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 eap->arg = new_cmdline + (eap->arg - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198 if (eap->do_ecmd_cmd != NULL && eap->do_ecmd_cmd != dollar_command)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5199 eap->do_ecmd_cmd = new_cmdline + (eap->do_ecmd_cmd - *cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 vim_free(*cmdlinep);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 *cmdlinep = new_cmdline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 return src;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5206 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5207 * Check for '|' to separate commands and '"' to start comments.
28179
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5208 * If "keep_backslash" is TRUE do not remove any backslash.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5209 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5210 void
28179
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5211 separate_nextcmd(exarg_T *eap, int keep_backslash)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5213 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
5215 #ifdef FEAT_QUICKFIX
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
5216 p = skip_grep_pat(eap);
19670b05ee32 updated for version 7.0047
vimboss
parents: 146
diff changeset
5217 #else
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
5218 p = eap->arg;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
5219 #endif
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
5220
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11010
diff changeset
5221 for ( ; *p; MB_PTR_ADV(p))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5223 if (*p == Ctrl_V)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5224 {
28179
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5225 if ((eap->argt & (EX_CTRLV | EX_XFILE)) || keep_backslash)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5226 ++p; // skip CTRL-V and next char
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5227 else
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5228 // remove CTRL-V and skip next char
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
5229 STRMOVE(p, p + 1);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5230 if (*p == NUL) // stop at NUL after CTRL-V
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5233
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5234 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5235 // Skip over `=expr` when wildcards are expanded.
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
5236 else if (p[0] == '`' && p[1] == '=' && (eap->argt & EX_XFILE))
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5237 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5238 p += 2;
22685
80b4e604d1d5 patch 8.2.1891: Vim9: skipping over expression doesn't handle line breaks
Bram Moolenaar <Bram@vim.org>
parents: 22616
diff changeset
5239 (void)skip_expr(&p, NULL);
22724
51bc501a13ca patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
5240 if (*p == NUL) // stop at NUL after CTRL-V
51bc501a13ca patch 8.2.1910: reading past the end of the command line
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
5241 break;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5242 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5243 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 8
diff changeset
5244
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5245 // Check for '"': start of comment or '|': next command
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5246 // :@" and :*" do not start a comment!
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5247 // :redir @" doesn't either.
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5248 else if ((*p == '"'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5249 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5250 && !in_vim9script()
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5251 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5252 && !(eap->argt & EX_NOTRLCOM)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253 && ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5254 || p != eap->arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5255 && (eap->cmdidx != CMD_redir
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5256 || p != eap->arg + 1 || p[-1] != '@'))
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20075
diff changeset
5257 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5258 || (*p == '#'
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5259 && in_vim9script()
21893
f19ac9b8b011 patch 8.2.1496: Vim9: cannot use " #" in a mapping
Bram Moolenaar <Bram@vim.org>
parents: 21885
diff changeset
5260 && !(eap->argt & EX_NOTRLCOM)
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5261 && p > eap->cmd && VIM_ISWHITE(p[-1]))
20079
336483164ca6 patch 8.2.0595: Vim9: not all commands using ends_excmd() tested
Bram Moolenaar <Bram@vim.org>
parents: 20075
diff changeset
5262 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5263 || *p == '|' || *p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 /*
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
5266 * We remove the '\' before the '|', unless EX_CTRLV is used
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 * AND 'b' is present in 'cpoptions'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5269 if ((vim_strchr(p_cpo, CPO_BAR) == NULL
17336
81705f4d9e03 patch 8.1.1667: flags for Ex commands may clash with other symbols
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
5270 || !(eap->argt & EX_CTRLV)) && *(p - 1) == '\\')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 {
28179
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5272 if (!keep_backslash)
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5273 {
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5274 STRMOVE(p - 1, p); // remove the '\'
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5275 --p;
49631bf057d3 patch 8.2.4615: mapping with escaped bar does not work in :def function
Bram Moolenaar <Bram@vim.org>
parents: 28158
diff changeset
5276 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280 eap->nextcmd = check_nextcmd(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
5285 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
5286
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5287 if (!(eap->argt & EX_NOTRLCOM)) // remove trailing spaces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 del_trailing_spaces(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 * get + command from ex argument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 static char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5295 getargcmd(char_u **argp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5297 char_u *arg = *argp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 char_u *command = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5300 if (*arg == '+') // +[command]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 ++arg;
5790
98bfec9ea760 updated for version 7.4.239
Bram Moolenaar <bram@vim.org>
parents: 5778
diff changeset
5303 if (vim_isspace(*arg) || *arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304 command = dollar_command;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 command = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 arg = skip_cmd_arg(command, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 if (*arg != NUL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5310 *arg++ = NUL; // terminate command with NUL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5311 }
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5312
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5313 arg = skipwhite(arg); // skip over spaces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 *argp = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 return command;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 * Find end of "+command" argument. Skip over "\ " and "\\".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 */
17835
fd6c8dc33152 patch 8.1.1914: command line expansion code is spread out
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
5322 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5323 skip_cmd_arg(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5324 char_u *p,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5325 int rembs) // TRUE to halve the number of backslashes
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 while (*p && !vim_isspace(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 if (*p == '\\' && p[1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 if (rembs)
1619
b9740fb41986 updated for version 7.2a
vimboss
parents: 1613
diff changeset
5332 STRMOVE(p, p + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 }
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11010
diff changeset
5336 MB_PTR_ADV(p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340
13575
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5341 int
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5342 get_bad_opt(char_u *p, exarg_T *eap)
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5343 {
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5344 if (STRICMP(p, "keep") == 0)
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5345 eap->bad_char = BAD_KEEP;
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5346 else if (STRICMP(p, "drop") == 0)
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5347 eap->bad_char = BAD_DROP;
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5348 else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL)
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5349 eap->bad_char = *p;
14051
c1ead25ed819 patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents: 14035
diff changeset
5350 else
c1ead25ed819 patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents: 14035
diff changeset
5351 return FAIL;
c1ead25ed819 patch 8.1.0043: ++bad argument of :edit does not work properly
Christian Brabandt <cb@256bit.org>
parents: 14035
diff changeset
5352 return OK;
13575
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5353 }
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5354
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5355 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 * Get "++opt=arg" argument.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 * Return FAIL or OK.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5360 getargopt(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362 char_u *arg = eap->arg + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5363 int *pp = NULL;
2168
99b00399c7b4 updated for version 7.2.435
Bram Moolenaar <bram@vim.org>
parents: 2148
diff changeset
5364 int bad_char_idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5365 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5366
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5367 // ":edit ++[no]bin[ary] file"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 if (STRNCMP(arg, "bin", 3) == 0 || STRNCMP(arg, "nobin", 5) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5370 if (*arg == 'n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5371 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5372 arg += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5373 eap->force_bin = FORCE_NOBIN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5374 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5375 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5376 eap->force_bin = FORCE_BIN;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377 if (!checkforcmd(&arg, "binary", 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379 eap->arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5383 // ":read ++edit file"
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5384 if (STRNCMP(arg, "edit", 4) == 0)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5385 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5386 eap->read_edit = TRUE;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5387 eap->arg = skipwhite(arg + 4);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5388 return OK;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5389 }
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5390
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 if (STRNCMP(arg, "ff", 2) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 arg += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 pp = &eap->force_ff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 else if (STRNCMP(arg, "fileformat", 10) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398 arg += 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399 pp = &eap->force_ff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 else if (STRNCMP(arg, "enc", 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 {
3208
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
5403 if (STRNCMP(arg, "encoding", 8) == 0)
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
5404 arg += 8;
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
5405 else
0a9d7cf90f94 updated for version 7.3.374
Bram Moolenaar <bram@vim.org>
parents: 3151
diff changeset
5406 arg += 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5407 pp = &eap->force_enc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5408 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5409 else if (STRNCMP(arg, "bad", 3) == 0)
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5410 {
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5411 arg += 3;
2168
99b00399c7b4 updated for version 7.2.435
Bram Moolenaar <bram@vim.org>
parents: 2148
diff changeset
5412 pp = &bad_char_idx;
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5413 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 if (pp == NULL || *arg != '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418 ++arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 *pp = (int)(arg - eap->cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 arg = skip_cmd_arg(arg, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 eap->arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 *arg = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 if (pp == &eap->force_ff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 if (check_ff_value(eap->cmd + eap->force_ff) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 return FAIL;
13575
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5428 eap->force_ff = eap->cmd[eap->force_ff];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5430 else if (pp == &eap->force_enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5432 // Make 'fileencoding' lower case.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 for (p = eap->cmd + eap->force_enc; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 *p = TOLOWER_ASC(*p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 }
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5436 else
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5437 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5438 // Check ++bad= argument. Must be a single-byte character, "keep" or
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5439 // "drop".
13575
4df23d9bad47 patch 8.0.1660: the terminal API "drop" command doesn't support options
Christian Brabandt <cb@256bit.org>
parents: 13553
diff changeset
5440 if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL)
595
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5441 return FAIL;
fea48f63efc8 updated for version 7.0169
vimboss
parents: 588
diff changeset
5442 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5448 ex_autocmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 /*
14266
7346b2ea80d8 patch 8.1.0149: session is wrong with multiple tabs when :lcd was used
Christian Brabandt <cb@256bit.org>
parents: 14155
diff changeset
5451 * Disallow autocommands from .exrc and .vimrc in current
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 * directory for security reasons.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5453 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5454 if (secure)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5455 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 secure = 2;
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
5457 eap->errmsg =
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
5458 _(e_command_not_allowed_from_vimrc_in_current_dir_or_tag_search);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 else if (eap->cmdidx == CMD_autocmd)
25463
05f9e8f2016c patch 8.2.3268: cannot use a block with :autocmd like with :command
Bram Moolenaar <Bram@vim.org>
parents: 25451
diff changeset
5461 do_autocmd(eap, eap->arg, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463 do_augroup(eap->arg, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5464 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467 * ":doautocmd": Apply the automatic commands to the current buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5469 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5470 ex_doautocmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471 {
3350
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
5472 char_u *arg = eap->arg;
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
5473 int call_do_modelines = check_nomodeline(&arg);
9260
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
5474 int did_aucmd;
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
5475
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
5476 (void)do_doautocmd(arg, TRUE, &did_aucmd);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5477 // Only when there is no <nomodeline>.
9260
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
5478 if (call_do_modelines && did_aucmd)
3350
198ec1fff71a updated for version 7.3.442
Bram Moolenaar <bram@vim.org>
parents: 3304
diff changeset
5479 do_modelines(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 * :[N]bunload[!] [N] [bufname] unload buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5485 * :[N]bwipeout[!] [N] [bufname] delete buffer really
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5488 ex_bunload(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5490 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5491 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5492 eap->errmsg = do_bufdel(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5493 eap->cmdidx == CMD_bdelete ? DOBUF_DEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5494 : eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495 : DOBUF_UNLOAD, eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5496 eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 * :[N]buffer [N] to buffer N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 * :[N]sbuffer [N] to buffer N
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5502 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5504 ex_buffer(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5506 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5507 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5508 if (*eap->arg)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
5509 eap->errmsg = ex_errmsg(e_trailing_characters_str, eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5510 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5511 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5512 if (eap->addr_count == 0) // default is current buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513 goto_buffer(eap, DOBUF_CURRENT, FORWARD, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515 goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5516 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5517 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 * :[N]bmodified [N] to next mod. buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5523 * :[N]sbmodified [N] to next mod. buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5526 ex_bmodified(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5527 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5528 goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5529 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5530 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5533 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5534 * :[N]bnext [N] to next buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535 * :[N]sbnext [N] split and to next buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5536 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5537 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5538 ex_bnext(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5539 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5540 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5541 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5542
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5543 goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5544 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5545 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5548 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5549 * :[N]bNext [N] to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5550 * :[N]bprevious [N] to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5551 * :[N]sbNext [N] split and to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5552 * :[N]sbprevious [N] split and to previous buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5553 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5554 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5555 ex_bprevious(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5556 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5557 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5558 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5559
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5560 goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5561 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5562 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5566 * :brewind to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 * :bfirst to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 * :sbrewind split and to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5569 * :sbfirst split and to first buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5572 ex_brewind(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5574 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5575 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5576
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5577 goto_buffer(eap, DOBUF_FIRST, FORWARD, 0);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5578 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5579 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 * :blast to last buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 * :sblast split and to last buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5587 ex_blast(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 {
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5589 if (ERROR_IF_ANY_POPUP_WINDOW)
19135
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5590 return;
17722555af22 patch 8.2.0127: some buffer commands work in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19131
diff changeset
5591
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
6230
7c9abc70ffc1 updated for version 7.4.450
Bram Moolenaar <bram@vim.org>
parents: 6191
diff changeset
5593 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
5594 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5596
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5597 /*
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5598 * Check if "c" ends an Ex command.
23185
055fa9db6f39 patch 8.2.2138: Vim9: "exit_cb" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 23179
diff changeset
5599 * In Vim9 script does not check for white space before #.
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5600 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5602 ends_excmd(int c)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 {
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5604 int comment_char = '"';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5605
20027
23a4aef4f923 patch 8.2.0569: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 20023
diff changeset
5606 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5607 if (in_vim9script())
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5608 comment_char = '#';
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5609 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5610 return (c == NUL || c == '|' || c == comment_char || c == '\n');
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5611 }
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5612
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5613 /*
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5614 * Like ends_excmd() but checks that a # in Vim9 script either has "cmd" equal
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5615 * to "cmd_start" or has a white space character before it.
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5616 */
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5617 int
20063
cc146cde0b4d patch 8.2.0587: compiler warning for unused variable
Bram Moolenaar <Bram@vim.org>
parents: 20059
diff changeset
5618 ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5619 {
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5620 int c = *cmd;
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5621
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5622 if (c == NUL || c == '|' || c == '\n')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5623 return TRUE;
20059
de756b3f4dee patch 8.2.0585: Vim9: # comment not recognized after :vim9script
Bram Moolenaar <Bram@vim.org>
parents: 20027
diff changeset
5624 #ifdef FEAT_EVAL
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5625 if (in_vim9script())
24176
12378fbc99bc patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents: 24174
diff changeset
5626 // # starts a comment, #{ might be a mistake, #{{ can start a fold
12378fbc99bc patch 8.2.2629: Vim9: error for #{{ is not desired
Bram Moolenaar <Bram@vim.org>
parents: 24174
diff changeset
5627 return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
24174
99bfaa4693db patch 8.2.2628: Vim9: #{ can still be used at the script level
Bram Moolenaar <Bram@vim.org>
parents: 24124
diff changeset
5628 && (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5629 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
5630 return c == '"';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 #if defined(FEAT_SYN_HL) || defined(FEAT_SEARCH_EXTRA) || defined(FEAT_EVAL) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5634 || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5635 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636 * Return the next command, after the first '|' or '\n'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5637 * Return NULL if not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5638 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5639 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5640 find_nextcmd(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5641 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5642 while (*p != '|' && *p != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5648 return (p + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5649 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 /*
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5653 * Check if *p is a separator between Ex commands, skipping over white space.
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5654 * Return NULL if it isn't, the following character if it is.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5656 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5657 check_nextcmd(char_u *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5658 {
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5659 char_u *s = skipwhite(p);
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5660
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5661 if (*s == '|' || *s == '\n')
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
5662 return (s + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667 /*
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5668 * If "eap->nextcmd" is not set, check for a next command at "p".
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5669 */
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5670 void
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5671 set_nextcmd(exarg_T *eap, char_u *arg)
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5672 {
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5673 char_u *p = check_nextcmd(arg);
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5674
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5675 if (eap->nextcmd == NULL)
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5676 eap->nextcmd = p;
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5677 else if (p != NULL)
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5678 // cannot use "| command" inside a {} block
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5679 semsg(_(e_cannot_use_bar_to_separate_commands_here_str), arg);
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5680 }
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5681
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
5682 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 * - if there are more files to edit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 * - and this is the last window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 * - and forceit not used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686 * - and not repeated twice on a row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 * return FAIL and give error message if 'message' TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 * return OK otherwise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 static int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5691 check_more(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5692 int message, // when FALSE check only, no messages
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5693 int forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 int n = ARGCOUNT - curwin->w_arg_idx - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
5697 if (!forceit && only_one_window()
21845
0e6ee11977b3 patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents: 21821
diff changeset
5698 && ARGCOUNT > 1 && !arg_had_last && n > 0 && quitmore == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 if (message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
5703 if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
5704 && curbuf->b_fname != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 {
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
5706 char_u buff[DIALOG_MSG_SIZE];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5707
14585
c8f07e8b273e patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents: 14550
diff changeset
5708 vim_snprintf((char *)buff, DIALOG_MSG_SIZE,
c8f07e8b273e patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents: 14550
diff changeset
5709 NGETTEXT("%d more file to edit. Quit anyway?",
c8f07e8b273e patch 8.1.0306: plural messages are not translated properly
Christian Brabandt <cb@256bit.org>
parents: 14550
diff changeset
5710 "%d more files to edit. Quit anyway?", n), n);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 #endif
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
5716 semsg(NGETTEXT(e_nr_more_file_to_edit,
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
5717 e_nr_more_files_to_edit , n), n);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5718 quitmore = 2; // next try to quit is allowed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 * Function given to ExpandGeneric() to obtain the list of command names.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5727 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5729 get_command_name(expand_T *xp UNUSED, int idx)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 if (idx >= (int)CMD_SIZE)
25757
589226a5f317 patch 8.2.3414: fullcommand() gives wrong name with buffer-local user command
Bram Moolenaar <Bram@vim.org>
parents: 25739
diff changeset
5732 return expand_user_command_name(idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 return cmdnames[idx].cmd_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5737 ex_colorscheme(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5738 {
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5739 if (*eap->arg == NUL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5740 {
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5741 #ifdef FEAT_EVAL
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5742 char_u *expr = vim_strsave((char_u *)"g:colors_name");
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5743 char_u *p = NULL;
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5744
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5745 if (expr != NULL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5746 {
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5747 ++emsg_off;
20996
3af71cbcfdbe patch 8.2.1049: Vim9: leaking memory when using continuation line
Bram Moolenaar <Bram@vim.org>
parents: 20982
diff changeset
5748 p = eval_to_string(expr, FALSE);
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5749 --emsg_off;
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5750 vim_free(expr);
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5751 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5752 if (p != NULL)
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5753 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5754 msg((char *)p);
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5755 vim_free(p);
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5756 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5757 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5758 msg("default");
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5759 #else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5760 msg(_("unknown"));
2142
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5761 #endif
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5762 }
c60d231453cf updated for version 7.2.424
Bram Moolenaar <bram@zimbu.org>
parents: 2097
diff changeset
5763 else if (load_colors(eap->arg) == FAIL)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
5764 semsg(_(e_cannot_find_color_scheme_str), eap->arg);
15663
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5765
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5766 #ifdef FEAT_VTP
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5767 else if (has_vtp_working())
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5768 {
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5769 // background color change requires clear + redraw
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5770 update_screen(CLEAR);
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5771 redrawcmd();
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5772 }
61448894376e patch 8.1.0839: when using VTP wrong colors after a color scheme change
Bram Moolenaar <Bram@vim.org>
parents: 15643
diff changeset
5773 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5777 ex_highlight(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 if (*eap->arg == NUL && eap->cmd[2] == '!')
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
5780 msg(_("Greetings, Vim user!"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 do_highlight(eap->arg, eap->forceit, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 * Call this function if we thought we were going to exit, but we won't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 * (because of an error). May need to restore the terminal mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5790 not_exiting(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 exiting = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 settmode(TMODE_RAW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795
24719
4ae10e6c3a9c patch 8.2.2898: QuitPre and ExitPre not triggered when GUI window is closed
Bram Moolenaar <Bram@vim.org>
parents: 24699
diff changeset
5796 int
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5797 before_quit_autocmds(win_T *wp, int quit_all, int forceit)
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5798 {
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5799 apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer);
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5800
18406
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5801 // Bail out when autocommands closed the window.
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5802 // Refuse to quit when the buffer in the last window is being closed (can
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5803 // only happen in autocommands).
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5804 if (!win_valid(wp)
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5805 || curbuf_locked()
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5806 || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0))
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5807 return TRUE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5808
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5809 if (quit_all || (check_more(FALSE, forceit) == OK && only_one_window()))
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5810 {
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5811 apply_autocmds(EVENT_EXITPRE, NULL, NULL, FALSE, curbuf);
18406
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5812 // Refuse to quit when locked or when the window was closed or the
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5813 // buffer in the last window is being closed (can only happen in
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5814 // autocommands).
fa6efc49d71f patch 8.1.2197: ExitPre autocommand may cause accessing freed memory
Bram Moolenaar <Bram@vim.org>
parents: 18402
diff changeset
5815 if (!win_valid(wp) || curbuf_locked()
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5816 || (curbuf->b_nwindows == 1 && curbuf->b_locked > 0))
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5817 return TRUE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5818 }
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5819
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5820 return FALSE;
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5821 }
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5822
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 /*
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5824 * ":quit": quit current window, quit Vim if the last window is closed.
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5825 * ":{nr}quit": quit window {nr}
18402
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5826 * Also used when closing a terminal window that's the last one.
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5827 */
527b7084c556 patch 8.1.2195: Vim does not exit when the terminal window is last window
Bram Moolenaar <Bram@vim.org>
parents: 18386
diff changeset
5828 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5829 ex_quit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5831 win_T *wp;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5832
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 cmdwin_result = Ctrl_C;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5840 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5841 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5842 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5843 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5844 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5845 }
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5846 if (eap->addr_count > 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5847 {
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5848 int wnr = eap->line2;
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5849
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5850 for (wp = firstwin; wp->w_next != NULL; wp = wp->w_next)
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5851 if (--wnr <= 0)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5852 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5853 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5854 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5855 wp = curwin;
6409
83c5fd1b55bc updated for version 7.4.535
Bram Moolenaar <bram@vim.org>
parents: 6400
diff changeset
5856
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5857 // Refuse to quit when locked.
12652
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12624
diff changeset
5858 if (curbuf_locked())
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12624
diff changeset
5859 return;
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5860
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5861 // Trigger QuitPre and maybe ExitPre
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5862 if (before_quit_autocmds(wp, FALSE, eap->forceit))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5863 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866 netbeansForcedQuit = eap->forceit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 /*
24719
4ae10e6c3a9c patch 8.2.2898: QuitPre and ExitPre not triggered when GUI window is closed
Bram Moolenaar <Bram@vim.org>
parents: 24699
diff changeset
5870 * If there is only one relevant window we will exit.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 exiting = TRUE;
12654
d03798bddf5e patch 8.0.1205: it is possible to unload a changed buffer
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
5874 if ((!buf_hide(wp->w_buffer)
d03798bddf5e patch 8.0.1205: it is possible to unload a changed buffer
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
5875 && check_changed(wp->w_buffer, (p_awa ? CCGD_AW : 0)
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
5876 | (eap->forceit ? CCGD_FORCEIT : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
5877 | CCGD_EXCMD))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 || check_more(TRUE, eap->forceit) == FAIL
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7465
diff changeset
5879 || (only_one_window() && check_changed_any(eap->forceit, TRUE)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5881 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5884 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5885 // quit last window
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5886 // Note: only_one_window() returns true, even so a help window is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5887 // still open. In that case only quit, if no address has been
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5888 // specified. Example:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5889 // :h|wincmd w|1q - don't quit
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5890 // :h|wincmd w|q - quit
10349
cf988222b150 commit https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660
Christian Brabandt <cb@256bit.org>
parents: 10275
diff changeset
5891 if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 getout(0);
12624
ae2802b6bf7d patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents: 12622
diff changeset
5893 not_exiting();
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5894 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 need_mouse_correct = TRUE;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5896 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5897 // close window; may free buffer
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
5898 win_close(wp, !buf_hide(wp->w_buffer) || eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 * ":cquit".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5906 ex_cquit(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907 {
19069
e14feba578f1 patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5908 // this does not always pass on the exit code to the Manx compiler. why?
e14feba578f1 patch 8.2.0095: cannot specify exit code for :cquit
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5909 getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 * ":qall": try to quit all windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5915 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5916 ex_quit_all(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 # ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 if (eap->forceit)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5922 cmdwin_result = K_XF1; // ex_window() takes care of this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924 cmdwin_result = K_XF2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 # endif
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5928
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5929 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5930 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5931 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
5932 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5933 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5934 }
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5935
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
5936 if (before_quit_autocmds(curwin, TRUE, eap->forceit))
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 815
diff changeset
5937 return;
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
5938
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939 exiting = TRUE;
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7465
diff changeset
5940 if (eap->forceit || !check_changed_any(FALSE, FALSE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 getout(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946 * ":close": close current window, unless it is the last one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5949 ex_close(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5951 win_T *win;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5952 int winnr = 0;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5953 #ifdef FEAT_CMDWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 if (cmdwin_type != 0)
2839
e1c5f69de95b updated for version 7.3.193
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
5955 cmdwin_result = Ctrl_C;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 else
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5957 #endif
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
5958 if (!text_locked() && !curbuf_locked())
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5959 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5960 if (eap->addr_count == 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5961 ex_win_close(eap->forceit, curwin, NULL);
14035
bccd66fa00c1 patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents: 13866
diff changeset
5962 else
bccd66fa00c1 patch 8.1.0035: not easy to switch between prompt buffer and other windows
Christian Brabandt <cb@256bit.org>
parents: 13866
diff changeset
5963 {
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
5964 FOR_ALL_WINDOWS(win)
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5965 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5966 winnr++;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5967 if (winnr == eap->line2)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5968 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5969 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5970 if (win == NULL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5971 win = lastwin;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5972 ex_win_close(eap->forceit, win, NULL);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5973 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
5974 }
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5975 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5976
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5977 #ifdef FEAT_QUICKFIX
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5978 /*
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5979 * ":pclose": Close any preview window.
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5980 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5981 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
5982 ex_pclose(exarg_T *eap)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5983 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5984 win_T *win;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5985
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5986 // First close any normal window.
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
5987 FOR_ALL_WINDOWS(win)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5988 if (win->w_p_pvw)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5989 {
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
5990 ex_win_close(eap->forceit, win, NULL);
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5991 return;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5992 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
5993 # ifdef FEAT_PROP_POPUP
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5994 // Also when 'previewpopup' is empty, it might have been cleared.
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
5995 popup_close_preview();
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17336
diff changeset
5996 # endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5997 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
5998 #endif
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
5999
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6000 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6001 * Close window "win" and take care of handling closing the last window for a
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6002 * modified buffer.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6003 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6004 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6005 ex_win_close(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6006 int forceit,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6007 win_T *win,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6008 tabpage_T *tp) // NULL or the tab page "win" is in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 int need_hide;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 buf_T *buf = win->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012
21016
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6013 // Never close the autocommand window.
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6014 if (win == aucmd_win)
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6015 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
6016 emsg(_(e_cannot_close_autocmd_or_popup_window));
21016
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6017 return;
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6018 }
0738c44504cb patch 8.2.1059: crash when using :tabonly in an autocommand
Bram Moolenaar <Bram@vim.org>
parents: 20996
diff changeset
6019
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020 need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
6021 if (need_hide && !buf_hide(buf) && !forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6022 {
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6023 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6024 if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6025 {
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
6026 bufref_T bufref;
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
6027
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
6028 set_bufref(&bufref, buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 dialog_changed(buf, FALSE);
9487
69ed2c9d34a6 commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents: 9460
diff changeset
6030 if (bufref_valid(&bufref) && bufIsChanged(buf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 need_hide = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 else
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6035 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 {
12146
59c1e09cf1a9 patch 8.0.0953: get "no write since last change" error in terminal window
Christian Brabandt <cb@256bit.org>
parents: 11995
diff changeset
6037 no_write_message();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6042 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 need_mouse_correct = TRUE;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6044 #endif
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6045
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6046 // free buffer when not hiding it or when it's a scratch buffer
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6047 if (tp == NULL)
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
6048 win_close(win, !need_hide && !buf_hide(buf));
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6049 else
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
6050 win_close_othertab(win, !need_hide && !buf_hide(buf), tp);
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6051 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6052
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6053 /*
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6054 * Handle the argument for a tabpage related ex command.
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6055 * Returns a tabpage number.
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6056 * When an error is encountered then eap->errmsg is set.
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6057 */
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6058 static int
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6059 get_tabpage_arg(exarg_T *eap)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6060 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6061 int tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6062 int unaccept_arg0 = (eap->cmdidx == CMD_tabmove) ? 0 : 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6063
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6064 if (eap->arg && *eap->arg != NUL)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6065 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6066 char_u *p = eap->arg;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6067 char_u *p_save;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6068 int relative = 0; // argument +N/-N means: go to N places to the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6069 // right/left relative to the current position.
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6070
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6071 if (*p == '-')
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6072 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6073 relative = -1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6074 p++;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6075 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6076 else if (*p == '+')
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6077 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6078 relative = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6079 p++;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6080 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6081
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6082 p_save = p;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6083 tab_number = getdigits(&p);
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6084
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6085 if (relative == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6086 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6087 if (STRCMP(p, "$") == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6088 tab_number = LAST_TAB_NR;
21727
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6089 else if (STRCMP(p, "#") == 0)
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6090 if (valid_tabpage(lastused_tabpage))
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6091 tab_number = tabpage_index(lastused_tabpage);
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6092 else
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6093 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
6094 eap->errmsg = ex_errmsg(e_invalid_value_for_argument_str, eap->arg);
21727
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6095 tab_number = 0;
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6096 goto theend;
860cad58f557 patch 8.2.1413: previous tab page not usable from an Ex command
Bram Moolenaar <Bram@vim.org>
parents: 21664
diff changeset
6097 }
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6098 else if (p == p_save || *p_save == '-' || *p != NUL
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6099 || tab_number > LAST_TAB_NR)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6100 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6101 // No numbers as argument.
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
6102 eap->errmsg = ex_errmsg(e_invalid_argument_str, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6103 goto theend;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6104 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6105 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6106 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6107 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6108 if (*p_save == NUL)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6109 tab_number = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6110 else if (p == p_save || *p_save == '-' || *p != NUL
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6111 || tab_number == 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6112 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6113 // No numbers as argument.
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
6114 eap->errmsg = ex_errmsg(e_invalid_argument_str, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6115 goto theend;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6116 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6117 tab_number = tab_number * relative + tabpage_index(curtab);
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6118 if (!unaccept_arg0 && relative == -1)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6119 --tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6120 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6121 if (tab_number < unaccept_arg0 || tab_number > LAST_TAB_NR)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
6122 eap->errmsg = ex_errmsg(e_invalid_argument_str, eap->arg);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6123 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6124 else if (eap->addr_count > 0)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6125 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6126 if (unaccept_arg0 && eap->line2 == 0)
10753
4961e7acdd8c patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10741
diff changeset
6127 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
6128 eap->errmsg = _(e_invalid_range);
10753
4961e7acdd8c patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10741
diff changeset
6129 tab_number = 0;
4961e7acdd8c patch 8.0.0266: compiler warning for using uninitialized variable
Christian Brabandt <cb@256bit.org>
parents: 10741
diff changeset
6130 }
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6131 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6132 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6133 tab_number = eap->line2;
15573
060cb54565c1 patch 8.1.0794: white space before " -Ntabmove" causes problems
Bram Moolenaar <Bram@vim.org>
parents: 15565
diff changeset
6134 if (!unaccept_arg0 && *skipwhite(*eap->cmdlinep) == '-')
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6135 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6136 --tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6137 if (tab_number < unaccept_arg0)
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
6138 eap->errmsg = _(e_invalid_range);
10741
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6139 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6140 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6141 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6142 else
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6143 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6144 switch (eap->cmdidx)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6145 {
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6146 case CMD_tabnext:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6147 tab_number = tabpage_index(curtab) + 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6148 if (tab_number > LAST_TAB_NR)
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6149 tab_number = 1;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6150 break;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6151 case CMD_tabmove:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6152 tab_number = LAST_TAB_NR;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6153 break;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6154 default:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6155 tab_number = tabpage_index(curtab);
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6156 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6157 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6158
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6159 theend:
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6160 return tab_number;
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6161 }
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6162
3f70b142e8da patch 8.0.0260: build fails with tiny features
Christian Brabandt <cb@256bit.org>
parents: 10739
diff changeset
6163 /*
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6164 * ":tabclose": close current tab page, unless it is the last one.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6165 * ":tabclose N": close tab page N.
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6166 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6167 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6168 ex_tabclose(exarg_T *eap)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6169 {
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6170 tabpage_T *tp;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6171 int tab_number;
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6172
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6173 # ifdef FEAT_CMDWIN
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6174 if (cmdwin_type != 0)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6175 cmdwin_result = K_IGNORE;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6176 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6177 # endif
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6178 if (first_tabpage->tp_next == NULL)
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
6179 emsg(_(e_cannot_close_last_tab_page));
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6180 else
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6181 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6182 tab_number = get_tabpage_arg(eap);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6183 if (eap->errmsg == NULL)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6184 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6185 tp = find_tabpage(tab_number);
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6186 if (tp == NULL)
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6187 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6188 beep_flush();
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6189 return;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6190 }
674
4b8583e82cb8 updated for version 7.0201
vimboss
parents: 672
diff changeset
6191 if (tp != curtab)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6192 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6193 tabpage_close_other(tp, eap->forceit);
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6194 return;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6195 }
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6196 else if (!text_locked() && !curbuf_locked())
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6197 tabpage_close(eap->forceit);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6198 }
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6199 }
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6200 }
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6201
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6202 /*
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6203 * ":tabonly": close all tab pages except the current one
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6204 */
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6205 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6206 ex_tabonly(exarg_T *eap)
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6207 {
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6208 tabpage_T *tp;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6209 int done;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6210 int tab_number;
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6211
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6212 # ifdef FEAT_CMDWIN
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6213 if (cmdwin_type != 0)
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6214 cmdwin_result = K_IGNORE;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6215 else
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6216 # endif
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6217 if (first_tabpage->tp_next == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
6218 msg(_("Already only one tab page"));
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6219 else
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6220 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6221 tab_number = get_tabpage_arg(eap);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6222 if (eap->errmsg == NULL)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6223 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6224 goto_tabpage(tab_number);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6225 // Repeat this up to a 1000 times, because autocommands may
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6226 // mess up the lists.
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6227 for (done = 0; done < 1000; ++done)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6228 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6229 FOR_ALL_TABPAGES(tp)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6230 if (tp->tp_topframe != topframe)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6231 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6232 tabpage_close_other(tp, eap->forceit);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6233 // if we failed to close it quit
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6234 if (valid_tabpage(tp))
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6235 done = 1000;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6236 // start over, "tp" is now invalid
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6237 break;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6238 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6239 if (first_tabpage->tp_next == NULL)
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6240 break;
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6241 }
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6242 }
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6243 }
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6244 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6245
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6246 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6247 * Close the current tab page.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6248 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6249 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6250 tabpage_close(int forceit)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6251 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6252 // First close all the windows but the current one. If that worked then
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6253 // close the last window in this tab, that will close it.
10357
59d01e335858 commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
6254 if (!ONE_WINDOW)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6255 close_others(TRUE, forceit);
10357
59d01e335858 commit https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55
Christian Brabandt <cb@256bit.org>
parents: 10349
diff changeset
6256 if (ONE_WINDOW)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6257 ex_win_close(forceit, curwin, NULL);
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6258 # ifdef FEAT_GUI
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6259 need_mouse_correct = TRUE;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6260 # endif
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6261 }
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6262
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6263 /*
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6264 * Close tab page "tp", which is not the current tab page.
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6265 * Note that autocommands may make "tp" invalid.
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6266 * Also takes care of the tab pages line disappearing when closing the
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6267 * last-but-one tab page.
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6268 */
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6269 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6270 tabpage_close_other(tabpage_T *tp, int forceit)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6271 {
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6272 int done = 0;
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6273 win_T *wp;
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6274 int h = tabline_height();
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6275
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6276 // Limit to 1000 windows, autocommands may add a window while we close
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6277 // one. OK, so I'm paranoid...
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6278 while (++done < 1000)
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6279 {
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6280 wp = tp->tp_firstwin;
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6281 ex_win_close(forceit, wp, tp);
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6282
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6283 // Autocommands may delete the tab page under our fingers and we may
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6284 // fail to close a window with a modified buffer.
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6285 if (!valid_tabpage(tp) || tp->tp_firstwin == wp)
671
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6286 break;
83a006f81bac updated for version 7.0199
vimboss
parents: 667
diff changeset
6287 }
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6288
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
6289 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
6290
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6291 redraw_tabline = TRUE;
971
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6292 if (h != tabline_height())
a9ffa7c7db77 updated for version 7.0-097
vimboss
parents: 944
diff changeset
6293 shell_new_rows();
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6294 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 * ":only".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6300 ex_only(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 {
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6302 win_T *wp;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6303 int wnr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 # endif
6398
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6307 if (eap->addr_count > 0)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6308 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6309 wnr = eap->line2;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6310 for (wp = firstwin; --wnr > 0; )
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6311 {
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6312 if (wp->w_next == NULL)
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6313 break;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6314 else
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6315 wp = wp->w_next;
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6316 }
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6317 win_goto(wp);
5a76e36f07b1 updated for version 7.4.530
Bram Moolenaar <bram@vim.org>
parents: 6353
diff changeset
6318 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6319 close_others(TRUE, eap->forceit);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6322 static void
10492
b2cd5a71f4bb commit https://github.com/vim/vim/commit/5e1e6d265d26ee2952c4a018a5ff72c950d2d700
Christian Brabandt <cb@256bit.org>
parents: 10490
diff changeset
6323 ex_hide(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6324 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6325 // ":hide" or ":hide | cmd": hide current window
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6326 if (!eap->skip)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6327 {
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6328 #ifdef FEAT_GUI
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6329 need_mouse_correct = TRUE;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6330 #endif
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6331 if (eap->addr_count == 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6332 win_close(curwin, FALSE); // don't free buffer
10383
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6333 else
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6334 {
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6335 int winnr = 0;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6336 win_T *win;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6337
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6338 FOR_ALL_WINDOWS(win)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6339 {
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6340 winnr++;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6341 if (winnr == eap->line2)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6342 break;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6343 }
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6344 if (win == NULL)
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6345 win = lastwin;
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6346 win_close(win, FALSE);
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6347 }
b59df2194b01 commit https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298
Christian Brabandt <cb@256bit.org>
parents: 10373
diff changeset
6348 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6351 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6352 * ":stop" and ":suspend": Suspend Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6353 */
26825
3c1dcb63f579 patch 8.2.3941: SIGTSTP is not handled
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
6354 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6355 ex_stop(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6358 * Disallow suspending for "rvim".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10240
diff changeset
6360 if (!check_restricted())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 if (!eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363 autowrite_all();
23165
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 23062
diff changeset
6364 apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, FALSE, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6365 windgoto((int)Rows - 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6366 out_char('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6367 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 stoptermcap();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6369 out_flush(); // needed for SUN to restore xterm buffer
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6370 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6371 ui_suspend(); // call machine specific function
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6372 maketitle();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6373 resettitle(); // force updating the title
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6374 starttermcap();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6375 scroll_start(); // scroll screen before redrawing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6376 redraw_later_clear();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6377 shell_resized(); // may have resized window
23165
a916fca16d4b patch 8.2.2128: there is no way to do something on CTRL-Z
Bram Moolenaar <Bram@vim.org>
parents: 23062
diff changeset
6378 apply_autocmds(EVENT_VIMRESUME, NULL, NULL, FALSE, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6379 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6382 /*
24723
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6383 * ":exit", ":xit" and ":wq": Write file and quit the current window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6384 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6385 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6386 ex_exit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6387 {
21518
0b448762ebbd patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 21516
diff changeset
6388 #ifdef FEAT_EVAL
21516
c7b2ce90c2de patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
6389 if (not_in_vim9(eap) == FAIL)
c7b2ce90c2de patch 8.2.1308: Vim9: accidentally using "x" causes Vim to exit
Bram Moolenaar <Bram@vim.org>
parents: 21493
diff changeset
6390 return;
21518
0b448762ebbd patch 8.2.1309: build failure with tiny version
Bram Moolenaar <Bram@vim.org>
parents: 21516
diff changeset
6391 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 #ifdef FEAT_CMDWIN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 if (cmdwin_type != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 cmdwin_result = Ctrl_C;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6398 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6399 // Don't quit while editing the command line.
633
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
6400 if (text_locked())
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
6401 {
7437be625546 updated for version 7.0183
vimboss
parents: 631
diff changeset
6402 text_locked_msg();
631
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
6403 return;
68a196b7504d updated for version 7.0182
vimboss
parents: 625
diff changeset
6404 }
13442
94e638936d3e patch 8.0.1595: no autocommand triggered before exiting
Christian Brabandt <cb@256bit.org>
parents: 13435
diff changeset
6405
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 /*
24723
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6407 * we plan to exit if there is only one relevant window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6409 if (check_more(FALSE, eap->forceit) == OK && only_one_window())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6410 exiting = TRUE;
24723
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6411
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6412 // Write the buffer for ":wq" or when it was changed.
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6413 // Trigger QuitPre and ExitPre.
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6414 // Check if we can exit now, after autocommands have changed things.
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6415 if (((eap->cmdidx == CMD_wq || curbufIsChanged()) && do_write(eap) == FAIL)
5194fba32954 patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents: 24719
diff changeset
6416 || before_quit_autocmds(curwin, FALSE, eap->forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 || check_more(TRUE, eap->forceit) == FAIL
7469
15eefe1b0dad commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents: 7465
diff changeset
6418 || (only_one_window() && check_changed_any(eap->forceit, FALSE)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 not_exiting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6424 if (only_one_window()) // quit last window, exit Vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6425 getout(0);
12624
ae2802b6bf7d patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents: 12622
diff changeset
6426 not_exiting();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6427 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6428 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6429 # endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6430 // Quit current window, may free the buffer.
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
6431 win_close(curwin, !buf_hide(curwin->w_buffer));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6435 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6436 * ":print", ":list", ":number".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6438 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6439 ex_print(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6440 {
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6441 if (curbuf->b_ml.ml_flags & ML_EMPTY)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
6442 emsg(_(e_empty_buffer));
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6443 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6444 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6445 for ( ;!got_int; ui_breakcheck())
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6446 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6447 print_line(eap->line1,
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6448 (eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6449 || (eap->flags & EXFLAG_NR)),
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6450 eap->cmdidx == CMD_list || (eap->flags & EXFLAG_LIST));
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6451 if (++eap->line1 > eap->line2)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6452 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6453 out_flush(); // show one line at a time
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6454 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6455 setpcmark();
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6456 // put cursor at last line
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6457 curwin->w_cursor.lnum = eap->line2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6458 beginline(BL_SOL | BL_FIX);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
6459 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461 ex_no_reprint = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 #ifdef FEAT_BYTEOFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6466 ex_goto(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 goto_byte(eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6470 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6473 * ":shell".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6475 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6476 ex_shell(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 do_shell(NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6481 #if defined(HAVE_DROP_FILE) || defined(PROTO)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6482
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6483 static int drop_busy = FALSE;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6484 static int drop_filec;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6485 static char_u **drop_filev = NULL;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6486 static int drop_split;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6487 static void (*drop_callback)(void *);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6488 static void *drop_cookie;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6489
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6490 static void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6491 handle_drop_internal(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493 exarg_T ea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 int save_msg_scroll = msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6496 // Setting the argument list may cause screen updates and being called
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6497 // recursively. Avoid that by setting drop_busy.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6498 drop_busy = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6500 // Check whether the current buffer is changed. If so, we will need
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6501 // to split the current window or data could be lost.
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6502 // We don't need to check if the 'hidden' option is set, as in this
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6503 // case the buffer won't be lost.
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6504 if (!buf_hide(curbuf) && !drop_split)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 ++emsg_off;
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6507 drop_split = check_changed(curbuf, CCGD_AW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508 --emsg_off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 }
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6510 if (drop_split)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512 if (win_split(0, 0) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6513 return;
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2575
diff changeset
6514 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6515
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6516 // When splitting the window, create a new alist. Otherwise the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6517 // existing one is overwritten.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6518 alist_unlink(curwin->w_alist);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6519 alist_new();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 * Set up the new argument list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6524 */
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6525 alist_set(ALIST(curwin), drop_filec, drop_filev, FALSE, NULL, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6526
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6528 * Move to the first file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6529 */
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6530 // Fake up a minimal "next" command for do_argfile()
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
6531 CLEAR_FIELD(ea);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6532 ea.cmd = (char_u *)"next";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 do_argfile(&ea, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6534
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6535 // do_ecmd() may set need_start_insertmode, but since we never left Insert
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6536 // mode that is not needed here.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6537 need_start_insertmode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6538
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6539 // Restore msg_scroll, otherwise a following command may cause scrolling
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6540 // unexpectedly. The screen will be redrawn by the caller, thus
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6541 // msg_scroll being set by displaying a message is irrelevant.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6542 msg_scroll = save_msg_scroll;
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6543
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6544 if (drop_callback != NULL)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6545 drop_callback(drop_cookie);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6546
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6547 drop_filev = NULL;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6548 drop_busy = FALSE;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6549 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6550
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6551 /*
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6552 * Handle a file drop. The code is here because a drop is *nearly* like an
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6553 * :args command, but not quite (we have a list of exact filenames, so we
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15488
diff changeset
6554 * don't want to (a) parse a command line, or (b) expand wildcards). So the
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6555 * code is very similar to :args and hence needs access to a lot of the static
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6556 * functions in this file.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6557 *
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6558 * The "filev" list must have been allocated using alloc(), as should each item
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6559 * in the list. This function takes over responsibility for freeing the "filev"
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6560 * list.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6561 */
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6562 void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6563 handle_drop(
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6564 int filec, // the number of files dropped
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6565 char_u **filev, // the list of files dropped
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6566 int split, // force splitting the window
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6567 void (*callback)(void *), // to be called after setting the argument
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6568 // list
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6569 void *cookie) // argument for "callback" (allocated)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6570 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6571 // Cannot handle recursive drops, finish the pending one.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6572 if (drop_busy)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6573 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6574 FreeWild(filec, filev);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6575 vim_free(cookie);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6576 return;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6577 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6578
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6579 // When calling handle_drop() more than once in a row we only use the last
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6580 // one.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6581 if (drop_filev != NULL)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6582 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6583 FreeWild(drop_filec, drop_filev);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6584 vim_free(drop_cookie);
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6585 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6586
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6587 drop_filec = filec;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6588 drop_filev = filev;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6589 drop_split = split;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6590 drop_callback = callback;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6591 drop_cookie = cookie;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6592
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6593 // Postpone this when:
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6594 // - editing the command line
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6595 // - not possible to change the current buffer
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6596 // - updating the screen
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6597 // As it may change buffers and window structures that are in use and cause
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6598 // freed memory to be used.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6599 if (text_locked() || curbuf_locked() || updating_screen)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6600 return;
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6601
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6602 handle_drop_internal();
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6603 }
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6604
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6605 /*
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6606 * To be called when text is unlocked, curbuf is unlocked or updating_screen is
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6607 * reset: Handle a postponed drop.
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6608 */
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6609 void
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6610 handle_any_postponed_drop(void)
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6611 {
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6612 if (!drop_busy && drop_filev != NULL
20229
06a1dd50463e patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents: 20185
diff changeset
6613 && !text_locked() && !curbuf_locked() && !updating_screen)
14428
aab5947be7c5 patch 8.1.0228: dropping files is ignored while Vim is busy
Christian Brabandt <cb@256bit.org>
parents: 14409
diff changeset
6614 handle_drop_internal();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 * ":preserve".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6622 ex_preserve(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 {
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
6624 curbuf->b_flags |= BF_PRESERVED;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 ml_preserve(curbuf, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 * ":recover".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6632 ex_recover(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6634 // Set recoverymode right away to avoid the ATTENTION prompt.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 recoverymode = TRUE;
5464
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6636 if (!check_changed(curbuf, (p_awa ? CCGD_AW : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6637 | CCGD_MULTWIN
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6638 | (eap->forceit ? CCGD_FORCEIT : 0)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6639 | CCGD_EXCMD)
9c777e2c7024 updated for version 7.4.082
Bram Moolenaar <bram@vim.org>
parents: 5458
diff changeset
6640
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6641 && (*eap->arg == NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642 || setfname(curbuf, eap->arg, NULL, TRUE) == OK))
16738
b52ea9c5f1db patch 8.1.1371: cannot recover from a swap file
Bram Moolenaar <Bram@vim.org>
parents: 16608
diff changeset
6643 ml_recover(TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6644 recoverymode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 * Command modifier used in a wrong way.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6651 ex_wrongmodifier(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652 {
21821
0deb6f96a5a3 patch 8.2.1460: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 21789
diff changeset
6653 eap->errmsg = _(e_invalid_command);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6656 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657 * :sview [+command] file split window with new file, read-only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6658 * :split [[+command] file] split window with current or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 * :vsplit [[+command] file] split window vertically with current or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6660 * :new [[+command] file] split window with no or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 * :vnew [[+command] file] split vertically window with no or new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 * :sfind [+command] file split window with file in 'path'
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6663 *
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6664 * :tabedit open new Tab page with empty window
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6665 * :tabedit [+command] file open new Tab page and edit "file"
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6666 * :tabnew [[+command] file] just like :tabedit
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6667 * :tabfind [+command] file open new Tab page and find "file"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6668 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6669 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6670 ex_splitview(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6671 {
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6672 win_T *old_curwin = curwin;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6673 #if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674 char_u *fname = NULL;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6675 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6676 #ifdef FEAT_BROWSE
22588
050cff1294ab patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse
Bram Moolenaar <Bram@vim.org>
parents: 22559
diff changeset
6677 char_u dot_path[] = ".";
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6678 int save_cmod_flags = cmdmod.cmod_flags;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6679 #endif
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6680 int use_tab = eap->cmdidx == CMD_tabedit
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6681 || eap->cmdidx == CMD_tabfind
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6682 || eap->cmdidx == CMD_tabnew;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6683
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
6684 if (ERROR_IF_ANY_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6685 return;
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6686
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6687 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 need_mouse_correct = TRUE;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6689 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6690
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6691 #ifdef FEAT_QUICKFIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6692 // A ":split" in the quickfix window works like ":new". Don't want two
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6693 // quickfix windows. But it's OK when doing ":tab split".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6694 if (bt_quickfix(curbuf) && cmdmod.cmod_tab == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 if (eap->cmdidx == CMD_split)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 eap->cmdidx = CMD_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698 if (eap->cmdidx == CMD_vsplit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 eap->cmdidx = CMD_vnew;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6700 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6701 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6702
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6703 #ifdef FEAT_SEARCHPATH
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6704 if (eap->cmdidx == CMD_sfind || eap->cmdidx == CMD_tabfind)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6707 FNAME_MESS, TRUE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6710 eap->arg = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6711 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6712 # ifdef FEAT_BROWSE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6713 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6714 # endif
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6715 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6716 #ifdef FEAT_BROWSE
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6717 if ((cmdmod.cmod_flags & CMOD_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6718 && eap->cmdidx != CMD_vnew
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6719 && eap->cmdidx != CMD_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6720 {
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6721 if (
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6722 # ifdef FEAT_GUI
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6723 !gui.in_use &&
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
6724 # endif
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6725 au_has_group((char_u *)"FileExplorer"))
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6726 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6727 // No browsing supported but we do have the file explorer:
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6728 // Edit the directory.
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6729 if (*eap->arg == NUL || !mch_isdir(eap->arg))
22588
050cff1294ab patch 8.2.1842: crash when USE_FNAME_CASE is defined and using :browse
Bram Moolenaar <Bram@vim.org>
parents: 22559
diff changeset
6730 eap->arg = dot_path;
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6731 }
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6732 else
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6733 {
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6734 fname = do_browse(0, (char_u *)(use_tab
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6735 ? _("Edit File in new tab page")
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6736 : _("Edit File in new window")),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6737 eap->arg, NULL, NULL, NULL, curbuf);
461
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6738 if (fname == NULL)
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6739 goto theend;
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6740 eap->arg = fname;
f98374445f66 updated for version 7.0123
vimboss
parents: 446
diff changeset
6741 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 }
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6743 cmdmod.cmod_flags &= ~CMOD_BROWSE; // Don't browse again in do_ecmd().
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
6744 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6745
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6746 /*
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6747 * Either open new tab page or split the window.
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6748 */
14155
da09e29e59d9 patch 8.1.0095: dialog for ":browse tabnew" says "new window"
Christian Brabandt <cb@256bit.org>
parents: 14059
diff changeset
6749 if (use_tab)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6750 {
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6751 if (win_new_tabpage(cmdmod.cmod_tab != 0 ? cmdmod.cmod_tab
820
57c7403f6599 updated for version 7.0c11
vimboss
parents: 819
diff changeset
6752 : eap->addr_count == 0 ? 0
57c7403f6599 updated for version 7.0c11
vimboss
parents: 819
diff changeset
6753 : (int)eap->line2 + 1) != FAIL)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6754 {
1498
4845822f6a6c updated for version 7.1-213
vimboss
parents: 1496
diff changeset
6755 do_exedit(eap, old_curwin);
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6756
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6757 // set the alternate buffer for the window we came from
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6758 if (curwin != old_curwin
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6759 && win_valid(old_curwin)
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6760 && old_curwin->w_buffer != curbuf
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6761 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6762 old_curwin->w_alt_fnum = curbuf->b_fnum;
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6763 }
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6764 }
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
6765 else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6766 *eap->cmd == 'v' ? WSP_VERT : 0) != FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6767 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6768 // Reset 'scrollbind' when editing another file, but keep it when
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6769 // doing ":split" without arguments.
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6770 if (*eap->arg != NUL)
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2575
diff changeset
6771 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6772 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6773 do_check_scrollbind(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6774 do_exedit(eap, old_curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6776
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6777 # ifdef FEAT_BROWSE
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6778 cmdmod.cmod_flags = save_cmod_flags;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6779 # endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6780
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6781 # if defined(FEAT_SEARCHPATH) || defined(FEAT_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 theend:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 vim_free(fname);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6784 # endif
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6785 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6786
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6787 /*
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6788 * Open a new tab page.
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6789 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6790 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6791 tabpage_new(void)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6792 {
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6793 exarg_T ea;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6794
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19892
diff changeset
6795 CLEAR_FIELD(ea);
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6796 ea.cmdidx = CMD_tabnew;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6797 ea.cmd = (char_u *)"tabn";
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6798 ea.arg = (char_u *)"";
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6799 ex_splitview(&ea);
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6800 }
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6801
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6802 /*
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6803 * :tabnext command
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6804 */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6805 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6806 ex_tabnext(exarg_T *eap)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6807 {
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6808 int tab_number;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6809
17111
af861fccc309 patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17095
diff changeset
6810 if (ERROR_IF_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6811 return;
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6812 switch (eap->cmdidx)
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6813 {
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6814 case CMD_tabfirst:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6815 case CMD_tabrewind:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6816 goto_tabpage(1);
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6817 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6818 case CMD_tablast:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6819 goto_tabpage(9999);
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6820 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6821 case CMD_tabprevious:
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6822 case CMD_tabNext:
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6823 if (eap->arg && *eap->arg != NUL)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6824 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6825 char_u *p = eap->arg;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6826 char_u *p_save = p;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6827
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6828 tab_number = getdigits(&p);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6829 if (p == p_save || *p_save == '-' || *p != NUL
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6830 || tab_number == 0)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6831 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6832 // No numbers as argument.
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
6833 eap->errmsg = ex_errmsg(e_invalid_argument_str, eap->arg);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6834 return;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6835 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6836 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6837 else
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6838 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6839 if (eap->addr_count == 0)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6840 tab_number = 1;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6841 else
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6842 {
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6843 tab_number = eap->line2;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6844 if (tab_number < 1)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6845 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
6846 eap->errmsg = _(e_invalid_range);
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6847 return;
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6848 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6849 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6850 }
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6851 goto_tabpage(-tab_number);
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6852 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6853 default: // CMD_tabnext
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6854 tab_number = get_tabpage_arg(eap);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6855 if (eap->errmsg == NULL)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6856 goto_tabpage(tab_number);
685
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6857 break;
d7e33248b9c8 updated for version 7.0206
vimboss
parents: 682
diff changeset
6858 }
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6859 }
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6860
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6861 /*
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6862 * :tabmove command
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6863 */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6864 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6865 ex_tabmove(exarg_T *eap)
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6866 {
6775
c0bc9b60fb8a patch 7.4.709
Bram Moolenaar <bram@vim.org>
parents: 6739
diff changeset
6867 int tab_number;
3662
e5b925ae56e3 updated for version 7.3.591
Bram Moolenaar <bram@vim.org>
parents: 3570
diff changeset
6868
10739
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6869 tab_number = get_tabpage_arg(eap);
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6870 if (eap->errmsg == NULL)
380e706814da patch 8.0.0259: tab commands do not handle count correctly
Christian Brabandt <cb@256bit.org>
parents: 10726
diff changeset
6871 tabpage_move(tab_number);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6872 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6873
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6874 /*
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6875 * :tabs command: List tabs and their contents.
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6876 */
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6877 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6878 ex_tabs(exarg_T *eap UNUSED)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6879 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6880 tabpage_T *tp;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6881 win_T *wp;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6882 int tabcount = 1;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6883
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6884 msg_start();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6885 msg_scroll = TRUE;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6886 for (tp = first_tabpage; tp != NULL && !got_int; tp = tp->tp_next)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6887 {
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6888 msg_putchar('\n');
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6889 vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
11158
501f46f7644c patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
6890 msg_outtrans_attr(IObuff, HL_ATTR(HLF_T));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6891 out_flush(); // output one line at a time
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6892 ui_breakcheck();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6893
678
93a1bf1cb633 updated for version 7.0203
vimboss
parents: 675
diff changeset
6894 if (tp == curtab)
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6895 wp = firstwin;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6896 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6897 wp = tp->tp_firstwin;
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6898 for ( ; wp != NULL && !got_int; wp = wp->w_next)
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6899 {
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6900 msg_putchar('\n');
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6901 msg_putchar(wp == curwin ? '>' : ' ');
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
6902 msg_putchar(' ');
672
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6903 msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
db58b9066b21 updated for version 7.0200
vimboss
parents: 671
diff changeset
6904 msg_putchar(' ');
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6905 if (buf_spname(wp->w_buffer) != NULL)
3839
8115f449a574 updated for version 7.3.677
Bram Moolenaar <bram@vim.org>
parents: 3810
diff changeset
6906 vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6907 else
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6908 home_replace(wp->w_buffer, wp->w_buffer->b_fname,
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6909 IObuff, IOSIZE, TRUE);
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6910 msg_outtrans(IObuff);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6911 out_flush(); // output one line at a time
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6912 ui_breakcheck();
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6913 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6914 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6915 }
9090f866cd57 updated for version 7.0197
vimboss
parents: 655
diff changeset
6916
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6917 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6918 * ":mode": Set screen mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6919 * If no argument given, just get the screen size and redraw.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6920 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6921 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6922 ex_mode(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6923 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6924 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6925 shell_resized();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6926 else
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
6927 emsg(_(e_screen_mode_setting_not_supported));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6928 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6930 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6931 * ":resize".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6932 * set, increment or decrement current window height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6933 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6934 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6935 ex_resize(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6936 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6937 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6938 win_T *wp = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6939
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6940 if (eap->addr_count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6942 n = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6943 for (wp = firstwin; wp->w_next != NULL && --n > 0; wp = wp->w_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6944 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6945 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6946
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
6947 # ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6948 need_mouse_correct = TRUE;
8643
24b43dd167eb commit https://github.com/vim/vim/commit/44a2f923c00f1384c9ecde12fb5b4711bc20702e
Christian Brabandt <cb@256bit.org>
parents: 8577
diff changeset
6949 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6950 n = atol((char *)eap->arg);
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
6951 if (cmdmod.cmod_split & WSP_VERT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6953 if (*eap->arg == '-' || *eap->arg == '+')
22616
f773ac13c093 patch 8.2.1856: "2resize" uses size of current window
Bram Moolenaar <Bram@vim.org>
parents: 22610
diff changeset
6954 n += wp->w_width;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6955 else if (n == 0 && eap->arg[0] == NUL) // default is very wide
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6956 n = 9999;
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
6957 win_setwidth_win(n, wp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6958 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6959 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6961 if (*eap->arg == '-' || *eap->arg == '+')
22616
f773ac13c093 patch 8.2.1856: "2resize" uses size of current window
Bram Moolenaar <Bram@vim.org>
parents: 22610
diff changeset
6962 n += wp->w_height;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6963 else if (n == 0 && eap->arg[0] == NUL) // default is very high
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6964 n = 9999;
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
6965 win_setheight_win(n, wp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6966 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6967 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6968
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6969 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6970 * ":find [+command] <file>" command.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6971 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6972 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
6973 ex_find(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6974 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6975 #ifdef FEAT_SEARCHPATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6976 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6977 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6978
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6979 fname = find_file_in_path(eap->arg, (int)STRLEN(eap->arg), FNAME_MESS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6980 TRUE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6981 if (eap->addr_count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6982 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6983 // Repeat finding the file "count" times. This matters when it
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6984 // appears several times in the path.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6985 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6986 while (fname != NULL && --count > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6987 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6988 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6989 fname = find_file_in_path(NULL, 0, FNAME_MESS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6990 FALSE, curbuf->b_ffname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6991 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6992 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6994 if (fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6995 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6996 eap->arg = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6997 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6998 do_exedit(eap, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6999 #ifdef FEAT_SEARCHPATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7000 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7002 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7005 /*
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7006 * ":open" simulation: for now just work like ":visual".
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7007 */
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7008 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7009 ex_open(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7010 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7011 regmatch_T regmatch;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7012 char_u *p;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7013
24114
291c57cf4731 patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents: 24049
diff changeset
7014 #ifdef FEAT_EVAL
291c57cf4731 patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents: 24049
diff changeset
7015 if (not_in_vim9(eap) == FAIL)
291c57cf4731 patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents: 24049
diff changeset
7016 return;
291c57cf4731 patch 8.2.2598: Vim9: :open does not need to be supported
Bram Moolenaar <Bram@vim.org>
parents: 24049
diff changeset
7017 #endif
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7018 curwin->w_cursor.lnum = eap->line2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7019 beginline(BL_SOL | BL_FIX);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7020 if (*eap->arg == '/')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7021 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7022 // ":open /pattern/": put cursor in column found with pattern
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7023 ++eap->arg;
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 23239
diff changeset
7024 p = skip_regexp(eap->arg, '/', magic_isset());
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7025 *p = NUL;
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 23239
diff changeset
7026 regmatch.regprog = vim_regcomp(eap->arg, magic_isset() ? RE_MAGIC : 0);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7027 if (regmatch.regprog != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7028 {
26420
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7029 // make a copy of the line, when searching for a mark it might be
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7030 // flushed
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7031 char_u *line = vim_strsave(ml_get_curline());
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7032
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7033 regmatch.rm_ic = p_ic;
26420
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7034 if (vim_regexec(&regmatch, line, (colnr_T)0))
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7035 curwin->w_cursor.col = (colnr_T)(regmatch.startp[0] - line);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7036 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
7037 emsg(_(e_no_match));
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4803
diff changeset
7038 vim_regfree(regmatch.regprog);
26420
75e6d917696e patch 8.2.3741: using freed memory in open command
Bram Moolenaar <Bram@vim.org>
parents: 26370
diff changeset
7039 vim_free(line);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7040 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7041 // Move to the NUL, ignore any other arguments.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7042 eap->arg += STRLEN(eap->arg);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7043 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7044 check_cursor();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7045
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7046 eap->cmdidx = CMD_visual;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7047 do_exedit(eap, NULL);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7048 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7049
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7050 /*
22840
7c1e2e3f2d8d patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents: 22790
diff changeset
7051 * ":edit", ":badd", ":balt", ":visual".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7052 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7053 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7054 ex_edit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7056 do_exedit(eap, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7057 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7059 /*
19195
2ef19eed524a patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents: 19191
diff changeset
7060 * ":edit <file>" command and alike.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7061 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7062 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7063 do_exedit(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7064 exarg_T *eap,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7065 win_T *old_curwin) // curwin before doing a split or NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7066 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7067 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7068 int need_hide;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7069 int exmode_was = exmode_active;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7070
19271
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
7071 if ((eap->cmdidx != CMD_pedit && ERROR_IF_POPUP_WINDOW)
ebeeb4b4a1fa patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
7072 || ERROR_IF_TERM_POPUP_WINDOW)
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
7073 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7074 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 * ":vi" command ends Ex mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7076 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7077 if (exmode_active && (eap->cmdidx == CMD_visual
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7078 || eap->cmdidx == CMD_view))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7079 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7080 exmode_active = FALSE;
20897
213fb059e02e patch 8.2.1000: get error when leaving Ex mode with :visual
Bram Moolenaar <Bram@vim.org>
parents: 20711
diff changeset
7081 ex_pressedreturn = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7082 if (*eap->arg == NUL)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7083 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7084 // Special case: ":global/pat/visual\NLvi-commands"
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7085 if (global_busy)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7086 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7087 int rd = RedrawingDisabled;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7088 int nwr = no_wait_return;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7089 int ms = msg_scroll;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7090 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7091 int he = hold_gui_events;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7092 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7093
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7094 if (eap->nextcmd != NULL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7095 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7096 stuffReadbuff(eap->nextcmd);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7097 eap->nextcmd = NULL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7098 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7099
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7100 if (exmode_was != EXMODE_VIM)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7101 settmode(TMODE_RAW);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7102 RedrawingDisabled = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7103 no_wait_return = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7104 need_wait_return = FALSE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7105 msg_scroll = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7106 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7107 hold_gui_events = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7108 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7109 must_redraw = CLEAR;
19433
af9d5585cfbf patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents: 19415
diff changeset
7110 pending_exmode_active = TRUE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7111
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7112 main_loop(FALSE, TRUE);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7113
19433
af9d5585cfbf patch 8.2.0274: hang with combination of feedkeys(), Ex mode and :global
Bram Moolenaar <Bram@vim.org>
parents: 19415
diff changeset
7114 pending_exmode_active = FALSE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7115 RedrawingDisabled = rd;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7116 no_wait_return = nwr;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7117 msg_scroll = ms;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7118 #ifdef FEAT_GUI
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7119 hold_gui_events = he;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7120 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7121 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7122 return;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7123 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7126 if ((eap->cmdidx == CMD_new
675
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
7127 || eap->cmdidx == CMD_tabnew
51794dc170f7 updated for version 7.0202
vimboss
parents: 674
diff changeset
7128 || eap->cmdidx == CMD_tabedit
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7129 || eap->cmdidx == CMD_vnew) && *eap->arg == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7130 {
26771
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 26576
diff changeset
7131 // ":new" or ":tabnew" without argument: edit a new empty buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7132 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7133 (void)do_ecmd(0, NULL, NULL, eap, ECMD_ONE,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
7134 ECMD_HIDE + (eap->forceit ? ECMD_FORCEIT : 0),
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
7135 old_curwin == NULL ? curwin : NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7136 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7137 else if ((eap->cmdidx != CMD_split && eap->cmdidx != CMD_vsplit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7138 || *eap->arg != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7139 #ifdef FEAT_BROWSE
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
7140 || (cmdmod.cmod_flags & CMOD_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7141 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7142 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7143 {
29214
9e0b45df95b0 patch 8.2.5126: substitute may overrun destination buffer
Bram Moolenaar <Bram@vim.org>
parents: 29146
diff changeset
7144 // Can't edit another file when "textlock" or "curbuf_lock" is set.
9e0b45df95b0 patch 8.2.5126: substitute may overrun destination buffer
Bram Moolenaar <Bram@vim.org>
parents: 29146
diff changeset
7145 // Only ":edit" or ":script" can bring us here, others are stopped
9e0b45df95b0 patch 8.2.5126: substitute may overrun destination buffer
Bram Moolenaar <Bram@vim.org>
parents: 29146
diff changeset
7146 // earlier.
9e0b45df95b0 patch 8.2.5126: substitute may overrun destination buffer
Bram Moolenaar <Bram@vim.org>
parents: 29146
diff changeset
7147 if (*eap->arg != NUL && text_or_buf_locked())
822
45fad0f590d0 updated for version 7.0c12
vimboss
parents: 820
diff changeset
7148 return;
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
7149
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7150 n = readonlymode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7151 if (eap->cmdidx == CMD_view || eap->cmdidx == CMD_sview)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7152 readonlymode = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7153 else if (eap->cmdidx == CMD_enew)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7154 readonlymode = FALSE; // 'readonly' doesn't make sense in an
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7155 // empty buffer
23023
4384c44c031a patch 8.2.2058: using mkview/loadview changes the jumplist
Bram Moolenaar <Bram@vim.org>
parents: 23011
diff changeset
7156 if (eap->cmdidx != CMD_balt && eap->cmdidx != CMD_badd)
4384c44c031a patch 8.2.2058: using mkview/loadview changes the jumplist
Bram Moolenaar <Bram@vim.org>
parents: 23011
diff changeset
7157 setpcmark();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7158 if (do_ecmd(0, (eap->cmdidx == CMD_enew ? NULL : eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7159 NULL, eap,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7160 // ":edit" goes to first line if Vi compatible
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7161 (*eap->arg == NUL && eap->do_ecmd_lnum == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7162 && vim_strchr(p_cpo, CPO_GOTO1) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7163 ? ECMD_ONE : eap->do_ecmd_lnum,
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
7164 (buf_hide(curbuf) ? ECMD_HIDE : 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7165 + (eap->forceit ? ECMD_FORCEIT : 0)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7166 // after a split we can use an existing buffer
5741
f069a3a0f844 updated for version 7.4.215
Bram Moolenaar <bram@vim.org>
parents: 5737
diff changeset
7167 + (old_curwin != NULL ? ECMD_OLDBUF : 0)
22840
7c1e2e3f2d8d patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents: 22790
diff changeset
7168 + (eap->cmdidx == CMD_badd ? ECMD_ADDBUF : 0)
7c1e2e3f2d8d patch 8.2.1967: the session file does not restore the alternate file
Bram Moolenaar <Bram@vim.org>
parents: 22790
diff changeset
7169 + (eap->cmdidx == CMD_balt ? ECMD_ALTBUF : 0)
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1733
diff changeset
7170 , old_curwin == NULL ? curwin : NULL) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7171 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7172 // Editing the file failed. If the window was split, close it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7173 if (old_curwin != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7175 need_hide = (curbufIsChanged() && curbuf->b_nwindows <= 1);
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
7176 if (!need_hide || buf_hide(curbuf))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7177 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
7178 #if defined(FEAT_EVAL)
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
7179 cleanup_T cs;
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
7180
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7181 // Reset the error/interrupt/exception state here so that
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7182 // aborting() returns FALSE when closing a window.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
7183 enter_cleanup(&cs);
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7184 #endif
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7185 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7186 need_mouse_correct = TRUE;
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7187 #endif
11957
bc0fee081e1e patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents: 11806
diff changeset
7188 win_close(curwin, !need_hide && !buf_hide(curbuf));
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
7189
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
7190 #if defined(FEAT_EVAL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7191 // Restore the error/interrupt/exception state if not
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7192 // discarded by a new aborting error, interrupt, or
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7193 // uncaught exception.
24
8ff7fd162d3c updated for version 7.0016
vimboss
parents: 23
diff changeset
7194 leave_cleanup(&cs);
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
7195 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7196 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7197 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 else if (readonlymode && curbuf->b_nwindows == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7201 // When editing an already visited buffer, 'readonly' won't be set
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7202 // but the previous value is kept. With ":view" and ":sview" we
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7203 // want the file to be readonly, except when another window is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7204 // editing the same buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 curbuf->b_p_ro = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7207 readonlymode = n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7209 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7211 if (eap->do_ecmd_cmd != NULL)
23011
ec23d84a096d patch 8.2.2052: Vim9: "edit +4 fname" gives an error
Bram Moolenaar <Bram@vim.org>
parents: 22973
diff changeset
7212 do_cmd_argument(eap->do_ecmd_cmd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7213 n = curwin->w_arg_idx_invalid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7214 check_arg_idx(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7215 if (n != curwin->w_arg_idx_invalid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7216 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 * if ":split file" worked, set alternate file name in old window to new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7221 * file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7222 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7223 if (old_curwin != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224 && *eap->arg != NUL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7225 && curwin != old_curwin
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226 && win_valid(old_curwin)
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 17
diff changeset
7227 && old_curwin->w_buffer != curbuf
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
7228 && (cmdmod.cmod_flags & CMOD_KEEPALT) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7229 old_curwin->w_alt_fnum = curbuf->b_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7231 ex_no_reprint = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7234 #ifndef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7235 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7236 * ":gui" and ":gvim" when there is no GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7238 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7239 ex_nogui(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7240 {
25306
078edc1821bf patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25304
diff changeset
7241 eap->errmsg = _(e_gui_cannot_be_used_not_enabled_at_compile_time);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7244
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15866
diff changeset
7245 #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7246 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7247 ex_tearoff(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7249 gui_make_tearoff(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7251 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252
13392
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7253 #if (defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK) \
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7254 || defined(FEAT_TERM_POPUP_MENU)) && defined(FEAT_MENU)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7256 ex_popup(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 {
13392
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7258 # if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_GTK)
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7259 if (gui.in_use)
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7260 gui_make_popup(eap->arg, eap->forceit);
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7261 # ifdef FEAT_TERM_POPUP_MENU
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7262 else
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7263 # endif
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7264 # endif
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7265 # ifdef FEAT_TERM_POPUP_MENU
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7266 pum_make_popup(eap->arg, eap->forceit);
d5347779fb20 patch 8.0.1570: can't use :popup for a menu in the terminal
Christian Brabandt <cb@256bit.org>
parents: 13384
diff changeset
7267 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7268 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7269 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7271 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7272 ex_swapname(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274 if (curbuf->b_ml.ml_mfp == NULL || curbuf->b_ml.ml_mfp->mf_fname == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
7275 msg(_("No swap file"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
7277 msg((char *)curbuf->b_ml.ml_mfp->mf_fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7278 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7280 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 * ":syncbind" forces all 'scrollbind' windows to have the same relative
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 * offset.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283 * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7286 ex_syncbind(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 win_T *wp;
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7289 win_T *save_curwin = curwin;
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7290 buf_T *save_curbuf = curbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 long topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 long y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 linenr_T old_linenr = curwin->w_cursor.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298 * determine max topline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7299 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302 topline = curwin->w_topline;
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
7303 FOR_ALL_WINDOWS(wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7305 if (wp->w_p_scb && wp->w_buffer)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306 {
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15663
diff changeset
7307 y = wp->w_buffer->b_ml.ml_line_count - get_scrolloff_value();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 if (topline > y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309 topline = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7312 if (topline < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7313 topline = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7315 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317 topline = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321 /*
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7322 * Set all scrollbind windows to the same topline.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323 */
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9538
diff changeset
7324 FOR_ALL_WINDOWS(curwin)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7327 {
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7328 curbuf = curwin->w_buffer;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7329 y = topline - curwin->w_topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7330 if (y > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7331 scrollup(y, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7332 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7333 scrolldown(-y, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7334 curwin->w_scbind_pos = topline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 cursor_correct();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7337 curwin->w_redr_status = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 }
5566
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7340 curwin = save_curwin;
4b23119cb584 updated for version 7.4.131
Bram Moolenaar <bram@vim.org>
parents: 5545
diff changeset
7341 curbuf = save_curbuf;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7342 if (curwin->w_p_scb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344 did_syncbind = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 checkpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7346 if (old_linenr != curwin->w_cursor.lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 char_u ctrl_o[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 ctrl_o[0] = Ctrl_O;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7351 ctrl_o[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7352 ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7354 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7358 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7359 ex_read(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 {
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7361 int i;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7362 int empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7363 linenr_T lnum;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7365 if (eap->usefilter) // :r!cmd
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7366 do_bang(1, eap, FALSE, FALSE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7369 if (u_save(eap->line2, (linenr_T)(eap->line2 + 1)) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7370 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7372 #ifdef FEAT_BROWSE
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
7373 if (cmdmod.cmod_flags & CMOD_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7374 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7375 char_u *browseFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
7377 browseFile = do_browse(0, (char_u *)_("Append File"), eap->arg,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7378 NULL, NULL, NULL, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 if (browseFile != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7380 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381 i = readfile(browseFile, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383 vim_free(browseFile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7385 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7386 i = OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7388 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7389 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7390 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7391 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7392 if (check_fname() == FAIL) // check for no file name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7393 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7394 i = readfile(curbuf->b_ffname, curbuf->b_fname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7395 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7397 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7398 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7399 if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7400 (void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7401 i = readfile(eap->arg, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7402 eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7404 }
10575
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10520
diff changeset
7405 if (i != OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7406 {
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
7407 #if defined(FEAT_EVAL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7408 if (!aborting())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7409 #endif
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
7410 semsg(_(e_cant_open_file_str), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7412 else
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7413 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7414 if (empty && exmode_active)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7415 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7416 // Delete the empty line that remains. Historically ex does
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7417 // this but vi doesn't.
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7418 if (eap->line2 == 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7419 lnum = curbuf->b_ml.ml_line_count;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7420 else
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7421 lnum = 1;
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
7422 if (*ml_get(lnum) == NUL && u_savedel(lnum, 1L) == OK)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7423 {
20599
d571231175b4 patch 8.2.0853: ml_delete() often called with FALSE argument
Bram Moolenaar <Bram@vim.org>
parents: 20575
diff changeset
7424 ml_delete(lnum);
573
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
7425 if (curwin->w_cursor.lnum > 1
c85bf6a4999b updated for version 7.0163
vimboss
parents: 557
diff changeset
7426 && curwin->w_cursor.lnum >= lnum)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7427 --curwin->w_cursor.lnum;
1929
9230c45fdde6 updated for version 7.2-226
vimboss
parents: 1926
diff changeset
7428 deleted_lines_mark(lnum, 1L);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7429 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7430 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7431 redraw_curbuf_later(VALID);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7432 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7435
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7436 static char_u *prev_dir = NULL;
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7437
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7438 #if defined(EXITFREE) || defined(PROTO)
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7439 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7440 free_cd_dir(void)
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7441 {
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
7442 VIM_CLEAR(prev_dir);
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
7443 VIM_CLEAR(globaldir);
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7444 }
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7445 #endif
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7446
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7447 /*
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7448 * Get the previous directory for the given chdir scope.
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7449 */
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7450 static char_u *
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7451 get_prevdir(cdscope_T scope)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7452 {
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7453 if (scope == CDSCOPE_WINDOW)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7454 return curwin->w_prevdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7455 else if (scope == CDSCOPE_TABPAGE)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7456 return curtab->tp_prevdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7457 return prev_dir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7458 }
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7459
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7460 /*
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7461 * Deal with the side effects of changing the current directory.
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7462 * When 'scope' is CDSCOPE_TABPAGE then this was after an ":tcd" command.
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7463 * When 'scope' is CDSCOPE_WINDOW then this was after an ":lcd" command.
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7464 */
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7465 void
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7466 post_chdir(cdscope_T scope)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7467 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7468 if (scope != CDSCOPE_WINDOW)
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7469 // Clear tab local directory for both :cd and :tcd
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7470 VIM_CLEAR(curtab->tp_localdir);
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
7471 VIM_CLEAR(curwin->w_localdir);
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7472 if (scope != CDSCOPE_GLOBAL)
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7473 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7474 char_u *pdir = get_prevdir(scope);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7475
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7476 // If still in the global directory, need to remember current
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7477 // directory as the global directory.
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7478 if (globaldir == NULL && pdir != NULL)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7479 globaldir = vim_strsave(pdir);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7480
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7481 // Remember this local directory for the window.
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7482 if (mch_dirname(NameBuff, MAXPATHL) == OK)
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7483 {
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7484 if (scope == CDSCOPE_TABPAGE)
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7485 curtab->tp_localdir = vim_strsave(NameBuff);
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7486 else
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7487 curwin->w_localdir = vim_strsave(NameBuff);
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7488 }
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7489 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7490 else
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7491 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7492 // We are now in the global directory, no need to remember its name.
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13221
diff changeset
7493 VIM_CLEAR(globaldir);
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7494 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7495
26181
027c5b4b6f07 patch 8.2.3622: "verbose pwd" shows confusing info
Bram Moolenaar <Bram@vim.org>
parents: 26171
diff changeset
7496 last_chdir_reason = NULL;
4704
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7497 shorten_fnames(TRUE);
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7498 }
542af01979be updated for version 7.3.1099
Bram Moolenaar <bram@vim.org>
parents: 4435
diff changeset
7499
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7500 /*
27617
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7501 * Trigger DirChangedPre for "acmd_fname" with directory "new_dir".
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7502 */
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7503 void
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7504 trigger_DirChangedPre(char_u *acmd_fname, char_u *new_dir)
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7505 {
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7506 #ifdef FEAT_EVAL
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7507 dict_T *v_event;
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7508 save_v_event_T save_v_event;
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7509
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7510 v_event = get_v_event(&save_v_event);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7511 (void)dict_add_string(v_event, "directory", new_dir);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7512 dict_set_items_ro(v_event);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7513 #endif
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7514 apply_autocmds(EVENT_DIRCHANGEDPRE, acmd_fname, new_dir, FALSE, curbuf);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7515 #ifdef FEAT_EVAL
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7516 restore_v_event(v_event, &save_v_event);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7517 #endif
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7518 }
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7519
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7520 /*
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7521 * Change directory function used by :cd/:tcd/:lcd Ex commands and the
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7522 * chdir() function.
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7523 * scope == CDSCOPE_WINDOW: changes the window-local directory
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7524 * scope == CDSCOPE_TABPAGE: changes the tab-local directory
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7525 * Otherwise: changes the global directory
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7526 * Returns TRUE if the directory is successfully changed.
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7527 */
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7528 int
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7529 changedir_func(
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7530 char_u *new_dir,
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7531 int forceit,
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7532 cdscope_T scope)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7533 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7534 char_u *pdir = NULL;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7535 int dir_differs;
27617
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7536 char_u *acmd_fname = NULL;
27511
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7537 char_u **pp;
29117
c7a8d4bf4d04 patch 8.2.5079: DirChanged autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents: 29083
diff changeset
7538 char_u *tofree;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7539
19261
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
7540 if (new_dir == NULL || allbuf_locked())
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7541 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7542
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7543 if (vim_strchr(p_cpo, CPO_CHDIR) != NULL && curbufIsChanged() && !forceit)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7544 {
26958
d92e0d85923f patch 8.2.4008: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
7545 emsg(_(e_cannot_change_directory_buffer_is_modified_add_bang_to_override));
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7546 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7547 }
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7548
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7549 // ":cd -": Change to previous directory
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7550 if (STRCMP(new_dir, "-") == 0)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7551 {
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7552 pdir = get_prevdir(scope);
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7553 if (pdir == NULL)
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7554 {
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
7555 emsg(_(e_no_previous_directory));
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7556 return FALSE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7557 }
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7558 new_dir = pdir;
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7559 }
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7560
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7561 // Save current directory for next ":cd -"
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7562 if (mch_dirname(NameBuff, MAXPATHL) == OK)
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7563 pdir = vim_strsave(NameBuff);
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7564 else
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20659
diff changeset
7565 pdir = NULL;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7566
26500
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7567 // For UNIX ":cd" means: go to home directory.
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7568 // On other systems too if 'cdhome' is set.
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7569 #if defined(UNIX) || defined(VMS)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7570 if (*new_dir == NUL)
26500
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7571 #else
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7572 if (*new_dir == NUL && p_cdh)
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7573 #endif
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7574 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7575 // use NameBuff for home directory name
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7576 # ifdef VMS
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7577 char_u *p;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7578
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7579 p = mch_getenv((char_u *)"SYS$LOGIN");
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7580 if (p == NULL || *p == NUL) // empty is the same as not set
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7581 NameBuff[0] = NUL;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7582 else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7583 vim_strncpy(NameBuff, p, MAXPATHL - 1);
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7584 # else
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7585 expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7586 # endif
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7587 new_dir = NameBuff;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7588 }
26837
6aae8f25790a patch 8.2.3947: unnecessary check for NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 26825
diff changeset
7589 dir_differs = pdir == NULL
27617
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7590 || pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7591 if (dir_differs)
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7592 {
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7593 if (scope == CDSCOPE_WINDOW)
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7594 acmd_fname = (char_u *)"window";
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7595 else if (scope == CDSCOPE_TABPAGE)
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7596 acmd_fname = (char_u *)"tabpage";
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7597 else
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7598 acmd_fname = (char_u *)"global";
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7599 trigger_DirChangedPre(acmd_fname, new_dir);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7600
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7601 if (vim_chdir(new_dir))
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7602 {
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7603 emsg(_(e_command_failed));
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7604 vim_free(pdir);
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7605 return FALSE;
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7606 }
27511
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7607 }
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7608
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7609 if (scope == CDSCOPE_WINDOW)
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7610 pp = &curwin->w_prevdir;
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7611 else if (scope == CDSCOPE_TABPAGE)
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7612 pp = &curtab->tp_prevdir;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7613 else
27511
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7614 pp = &prev_dir;
29117
c7a8d4bf4d04 patch 8.2.5079: DirChanged autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents: 29083
diff changeset
7615 tofree = *pp; // new_dir may use this
27511
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7616 *pp = pdir;
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7617
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7618 post_chdir(scope);
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7619
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7620 if (dir_differs)
27617
269f89efb06a patch 8.2.4335: no autocommand event triggered before changing directory
Bram Moolenaar <Bram@vim.org>
parents: 27511
diff changeset
7621 apply_autocmds(EVENT_DIRCHANGED, acmd_fname, new_dir, FALSE, curbuf);
29117
c7a8d4bf4d04 patch 8.2.5079: DirChanged autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents: 29083
diff changeset
7622 vim_free(tofree);
27511
9986f96fb1bd patch 8.2.4283: using a variable for the return value is not needed
Bram Moolenaar <Bram@vim.org>
parents: 27499
diff changeset
7623 return TRUE;
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7624 }
358
e111db373ca4 updated for version 7.0093
vimboss
parents: 355
diff changeset
7625
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7626 /*
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
7627 * ":cd", ":tcd", ":lcd", ":chdir" ":tchdir" and ":lchdir".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7628 */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1408
diff changeset
7629 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7630 ex_cd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7631 {
15184
90ab2d3ce11d patch 8.1.0602: DirChanged is also triggered when directory didn't change
Bram Moolenaar <Bram@vim.org>
parents: 15152
diff changeset
7632 char_u *new_dir;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7634 new_dir = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7635 #if !defined(UNIX) && !defined(VMS)
26500
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7636 // for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
8088fa133b93 patch 8.2.3780: ":cd" works differently on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 26439
diff changeset
7637 if (*new_dir == NUL && !p_cdh)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638 ex_pwd(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7639 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7640 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7641 {
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7642 cdscope_T scope = CDSCOPE_GLOBAL;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7643
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7644 if (eap->cmdidx == CMD_lcd || eap->cmdidx == CMD_lchdir)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7645 scope = CDSCOPE_WINDOW;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7646 else if (eap->cmdidx == CMD_tcd || eap->cmdidx == CMD_tchdir)
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7647 scope = CDSCOPE_TABPAGE;
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7648
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7649 if (changedir_func(new_dir, eap->forceit, scope))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7650 {
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7651 // Echo the new current directory if the command was typed.
1930
89d1e8ed6c1d updated for version 7.2-227
vimboss
parents: 1929
diff changeset
7652 if (KeyTyped || p_verbose >= 5)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7653 ex_pwd(eap);
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 16515
diff changeset
7654 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7658 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7659 * ":pwd".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7660 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7661 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7662 ex_pwd(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7663 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7664 if (mch_dirname(NameBuff, MAXPATHL) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7666 #ifdef BACKSLASH_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7667 slash_adjust(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7668 #endif
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7669 if (p_verbose > 0)
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7670 {
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7671 char *context = "global";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7672
26171
fa8161b003f6 patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents: 26096
diff changeset
7673 if (last_chdir_reason != NULL)
fa8161b003f6 patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents: 26096
diff changeset
7674 context = last_chdir_reason;
fa8161b003f6 patch 8.2.3617: ":verbose pwd" does not mention 'autochdir' was applied
Bram Moolenaar <Bram@vim.org>
parents: 26096
diff changeset
7675 else if (curwin->w_localdir != NULL)
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7676 context = "window";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7677 else if (curtab->tp_localdir != NULL)
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7678 context = "tabpage";
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7679 smsg("[%s] %s", context, (char *)NameBuff);
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7680 }
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7681 else
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20599
diff changeset
7682 msg((char *)NameBuff);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7683 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7684 else
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
7685 emsg(_(e_directory_unknown));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7688 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7689 * ":=".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7690 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7691 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7692 ex_equal(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7693 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
7694 smsg("%ld", (long)eap->line2);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7695 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7696 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7697
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7699 ex_sleep(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7700 {
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7701 int n;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7702 long len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7704 if (cursor_valid())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7706 n = W_WINROW(curwin) + curwin->w_wrow - msg_scrolled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7707 if (n >= 0)
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
7708 windgoto(n, curwin->w_wincol + curwin->w_wcol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7709 }
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7710
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7711 len = eap->line2;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7712 switch (*eap->arg)
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7713 {
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7714 case 'm': break;
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7715 case NUL: len *= 1000L; break;
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
7716 default: semsg(_(e_invalid_argument_str), eap->arg); return;
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 198
diff changeset
7717 }
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7718
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7719 // Hide the cursor if invoked with !
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7720 do_sleep(len, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7723 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724 * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second.
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7725 * Hide the cursor if "hide_cursor" is TRUE.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7727 void
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7728 do_sleep(long msec, int hide_cursor)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7729 {
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7730 long done = 0;
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7731 long wait_now;
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7732 # ifdef ELAPSED_FUNC
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7733 elapsed_T start_tv;
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7734
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7735 // Remember at what time we started, so that we know how much longer we
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7736 // should wait after waiting for a bit.
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7737 ELAPSED_INIT(start_tv);
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7738 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7740 if (hide_cursor)
26809
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26804
diff changeset
7741 cursor_sleep();
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7742 else
26809
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26804
diff changeset
7743 cursor_on();
23648
b7d3c79075c5 patch 8.2.2366: when using ":sleep" the cursor is always displayed
Bram Moolenaar <Bram@vim.org>
parents: 23616
diff changeset
7744
14860
ac5d0d27aef9 patch 8.1.0442: GUI: cursor not drawn after ":redraw | sleep"
Christian Brabandt <cb@256bit.org>
parents: 14760
diff changeset
7745 out_flush_cursor(FALSE, FALSE);
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7746 while (!got_int && done < msec)
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7747 {
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7748 wait_now = msec - done > 1000L ? 1000L : msec - done;
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7749 #ifdef FEAT_TIMERS
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7750 {
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7751 long due_time = check_due_timer();
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7752
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7753 if (due_time > 0 && due_time < wait_now)
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7754 wait_now = due_time;
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7755 }
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7756 #endif
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7757 #ifdef FEAT_JOB_CHANNEL
17708
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7758 if (has_any_channel() && wait_now > 20L)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7759 wait_now = 20L;
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7760 #endif
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7761 #ifdef FEAT_SOUND
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7762 if (has_any_sound_callback() && wait_now > 20L)
10696f279e20 patch 8.1.1851: crash when sound_playfile() callback plays sound
Bram Moolenaar <Bram@vim.org>
parents: 17652
diff changeset
7763 wait_now = 20L;
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7764 #endif
8577
63dc856bd13d commit https://github.com/vim/vim/commit/975b5271eed4fa0500c24a8f37be0b1797cb9db7
Christian Brabandt <cb@256bit.org>
parents: 8524
diff changeset
7765 ui_delay(wait_now, TRUE);
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7766
10240
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7767 #ifdef FEAT_JOB_CHANNEL
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7768 if (has_any_channel())
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7769 ui_breakcheck_force(TRUE);
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7770 else
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7771 #endif
175b1116f96a commit https://github.com/vim/vim/commit/b9c31e71f5a4653a27e81c21226039bfa35b9131
Christian Brabandt <cb@256bit.org>
parents: 10184
diff changeset
7772 ui_breakcheck();
7109
fa95595fbc52 commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents: 7105
diff changeset
7773 #ifdef MESSAGE_QUEUE
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7774 // Process the netbeans and clientserver messages that may have been
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7775 // received in the call to ui_breakcheck() when the GUI is in use. This
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7776 // may occur when running a test case.
7109
fa95595fbc52 commit https://github.com/vim/vim/commit/93c88e0f6a4a8f7634ed84721daf4af46fc0d5db
Christian Brabandt <cb@256bit.org>
parents: 7105
diff changeset
7777 parse_queued_messages();
3151
af76a61a7f79 updated for version 7.3.346
Bram Moolenaar <bram@vim.org>
parents: 3116
diff changeset
7778 #endif
17712
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7779
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7780 # ifdef ELAPSED_FUNC
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7781 // actual time passed
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7782 done = ELAPSED_FUNC(start_tv);
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7783 # else
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7784 // guestimate time passed (will actually be more)
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7785 done += wait_now;
316ae5631c1d patch 8.1.1853: timers test is still flaky
Bram Moolenaar <Bram@vim.org>
parents: 17708
diff changeset
7786 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 }
14284
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7788
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7789 // If CTRL-C was typed to interrupt the sleep, drop the CTRL-C from the
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7790 // input buffer, otherwise a following call to input() fails.
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7791 if (got_int)
7cd8298c4c04 patch 8.1.0158: GUI: input() fails if CTRL-C was pressed before
Christian Brabandt <cb@256bit.org>
parents: 14266
diff changeset
7792 (void)vpeekc();
24428
9299d21d1d5d patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents: 24369
diff changeset
7793
9299d21d1d5d patch 8.2.2754: :sleep! does not always hide the cursor
Bram Moolenaar <Bram@vim.org>
parents: 24369
diff changeset
7794 if (hide_cursor)
26809
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26804
diff changeset
7795 cursor_unsleep();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7798 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7799 * ":winsize" command (obsolete).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7800 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7801 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7802 ex_winsize(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804 int w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7805 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7806 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7807
23855
a7098bc3810e patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
7808 if (!isdigit(*arg))
a7098bc3810e patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
7809 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
7810 semsg(_(e_invalid_argument_str), arg);
23855
a7098bc3810e patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
7811 return;
a7098bc3810e patch 8.2.2469: confusing error if :winsize has a wrong argument
Bram Moolenaar <Bram@vim.org>
parents: 23853
diff changeset
7812 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7813 w = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7814 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7815 p = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7816 h = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7817 if (*p != NUL && *arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7818 set_shellsize(w, h, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7819 else
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
7820 emsg(_(e_winsize_requires_two_number_arguments));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7823 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7824 ex_wincmd(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7826 int xchar = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7827 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7829 if (*eap->arg == 'g' || *eap->arg == Ctrl_G)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7831 // CTRL-W g and CTRL-W CTRL-G have an extra command character
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7832 if (eap->arg[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7833 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
7834 emsg(_(e_invalid_argument));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7835 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837 xchar = eap->arg[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 p = eap->arg + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7839 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7840 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841 p = eap->arg + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
7843 set_nextcmd(eap, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7844 p = skipwhite(p);
21353
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7845 if (*p != NUL && *p != (
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7846 #ifdef FEAT_EVAL
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7847 in_vim9script() ? '#' :
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7848 #endif
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7849 '"')
fb8c8fcb7b60 patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents: 21335
diff changeset
7850 && eap->nextcmd == NULL)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
7851 emsg(_(e_invalid_argument));
2887
15705b520c29 updated for version 7.3.217
Bram Moolenaar <bram@vim.org>
parents: 2853
diff changeset
7852 else if (!eap->skip)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7853 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7854 // Pass flags on for ":vertical wincmd ]".
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
7855 postponed_split_flags = cmdmod.cmod_split;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
7856 postponed_split_tab = cmdmod.cmod_tab;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7857 do_window(*eap->arg, eap->addr_count > 0 ? eap->line2 : 0L, xchar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7858 postponed_split_flags = 0;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
7859 postponed_split_tab = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7860 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7861 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7862
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7863 #if defined(FEAT_GUI) || defined(UNIX) || defined(VMS) || defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7864 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7865 * ":winpos".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7866 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7867 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7868 ex_winpos(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7869 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7870 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7871 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7872 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7874 if (*arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7875 {
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7876 # if defined(FEAT_GUI) || defined(MSWIN)
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7877 # ifdef VIMDLL
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7878 if (gui.in_use ? gui_mch_get_winpos(&x, &y) != FAIL :
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7879 mch_get_winpos(&x, &y) != FAIL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7880 # elif defined(FEAT_GUI)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7881 if (gui.in_use && gui_mch_get_winpos(&x, &y) != FAIL)
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7882 # else
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7883 if (mch_get_winpos(&x, &y) != FAIL)
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7884 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7886 sprintf((char *)IObuff, _("Window position: X %d, Y %d"), x, y);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
7887 msg((char *)IObuff);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7888 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7889 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7890 # endif
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
7891 emsg(_(e_obtaining_window_position_not_implemented_for_this_platform));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7892 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7893 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7895 x = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7896 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7897 p = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7898 y = getdigits(&arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7899 if (*p == NUL || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7900 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
7901 emsg(_(e_winpos_requires_two_number_arguments));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7902 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7904 # ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7905 if (gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7906 gui_mch_set_winpos(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7907 else if (gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7908 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7909 // Remember the coordinates for when the window is opened.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7910 gui_win_x = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7911 gui_win_y = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7912 }
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7913 # if defined(HAVE_TGETENT) || defined(VIMDLL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7914 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7915 # endif
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7916 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
7917 # if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
11
4424b47a0797 updated for version 7.0003
vimboss
parents: 9
diff changeset
7918 mch_set_winpos(x, y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7919 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7920 # ifdef HAVE_TGETENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7921 if (*T_CWP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7922 term_set_winpos(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7923 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7925 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7926 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7928 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7929 * Handle command that work like operators: ":delete", ":yank", ":>" and ":<".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7930 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7931 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7932 ex_operators(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7933 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7934 oparg_T oa;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7935
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7936 clear_oparg(&oa);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7937 oa.regname = eap->regname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 oa.start.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 oa.end.lnum = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7940 oa.line_count = eap->line2 - eap->line1 + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7941 oa.motion_type = MLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7942 virtual_op = FALSE;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7943 if (eap->cmdidx != CMD_yank) // position cursor for undo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7944 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7945 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7946 curwin->w_cursor.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7947 beginline(BL_SOL | BL_FIX);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7948 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7949
5498
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7950 if (VIsual_active)
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7951 end_visual_mode();
79a8bac614c0 updated for version 7.4.098
Bram Moolenaar <bram@vim.org>
parents: 5467
diff changeset
7952
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 switch (eap->cmdidx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7954 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7955 case CMD_delete:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956 oa.op_type = OP_DELETE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 op_delete(&oa);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7958 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7959
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7960 case CMD_yank:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7961 oa.op_type = OP_YANK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7962 (void)op_yank(&oa, FALSE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7963 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7964
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7965 default: // CMD_rshift or CMD_lshift
4889
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7966 if (
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7967 #ifdef FEAT_RIGHTLEFT
4889
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7968 (eap->cmdidx == CMD_rshift) ^ curwin->w_p_rl
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7969 #else
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7970 eap->cmdidx == CMD_rshift
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7971 #endif
25d64a4edc0b updated for version 7.3.1190
Bram Moolenaar <bram@vim.org>
parents: 4857
diff changeset
7972 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7973 oa.op_type = OP_RSHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7974 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7975 oa.op_type = OP_LSHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7976 op_shift(&oa, FALSE, eap->amount);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7977 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7978 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7979 virtual_op = MAYBE;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7980 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7981 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7983 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7984 * ":put".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7985 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7986 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
7987 ex_put(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7988 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7989 // ":0put" works like ":1put!".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7990 if (eap->line2 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7991 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7992 eap->line2 = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7993 eap->forceit = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7995 curwin->w_cursor.lnum = eap->line2;
26096
e353ace59e62 patch 8.2.3581: reading character past end of line
Bram Moolenaar <Bram@vim.org>
parents: 25939
diff changeset
7996 check_cursor_col();
22176
6941d3205be9 patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Bram Moolenaar <Bram@vim.org>
parents: 21939
diff changeset
7997 do_put(eap->regname, NULL, eap->forceit ? BACKWARD : FORWARD, 1L,
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
7998 PUT_LINE|PUT_CURSLINE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7999 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8001 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8002 * Handle ":copy" and ":move".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8003 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8004 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8005 ex_copymove(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8006 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8007 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8008
21592
7d721e95dc51 patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents: 21584
diff changeset
8009 #ifdef FEAT_EVAL
21584
d0c76ce48326 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
8010 if (not_in_vim9(eap) == FAIL)
d0c76ce48326 patch 8.2.1342: Vim9: accidentally using "t" gives a confusing error
Bram Moolenaar <Bram@vim.org>
parents: 21544
diff changeset
8011 return;
21592
7d721e95dc51 patch 8.2.1346: small build fails
Bram Moolenaar <Bram@vim.org>
parents: 21584
diff changeset
8012 #endif
14760
fd69edd2c67e patch 8.1.0392: error while typing :/foo/s// with 'incsearch' enabled
Christian Brabandt <cb@256bit.org>
parents: 14700
diff changeset
8013 n = get_address(eap, &eap->arg, eap->addr_type, FALSE, FALSE, FALSE, 1);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8014 if (eap->arg == NULL) // error detected
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8016 eap->nextcmd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8017 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8018 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8019 get_flags(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8021 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8022 * move or copy lines from 'eap->line1'-'eap->line2' to below line 'n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8023 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8024 if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8025 {
25064
8f2262c72178 patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 24984
diff changeset
8026 emsg(_(e_invalid_range));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8027 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8028 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8030 if (eap->cmdidx == CMD_move)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8031 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8032 if (do_move(eap->line1, eap->line2, n) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8033 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8035 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8036 ex_copy(eap->line1, eap->line2, n);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8037 u_clearline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8038 beginline(BL_SOL | BL_FIX);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8039 ex_may_print(eap);
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8040 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8041
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8042 /*
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8043 * Print the current line if flags were given to the Ex command.
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8044 */
5776
845608965bd9 updated for version 7.4.232
Bram Moolenaar <bram@vim.org>
parents: 5741
diff changeset
8045 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8046 ex_may_print(exarg_T *eap)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8047 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8048 if (eap->flags != 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8049 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8050 print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR),
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8051 (eap->flags & EXFLAG_LIST));
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8052 ex_no_reprint = TRUE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8053 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8056 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8057 * ":smagic" and ":snomagic".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8058 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8059 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8060 ex_submagic(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8061 {
23505
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23398
diff changeset
8062 optmagic_T saved = magic_overruled;
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23398
diff changeset
8063
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23398
diff changeset
8064 magic_overruled = eap->cmdidx == CMD_smagic
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23398
diff changeset
8065 ? OPTION_MAGIC_ON : OPTION_MAGIC_OFF;
21773
2f2e528c5782 patch 8.2.1436: function implementing :substitute has unexpected name
Bram Moolenaar <Bram@vim.org>
parents: 21727
diff changeset
8066 ex_substitute(eap);
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 23239
diff changeset
8067 magic_overruled = saved;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8069
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8070 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8071 * ":join".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8072 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8073 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8074 ex_join(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8076 curwin->w_cursor.lnum = eap->line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8077 if (eap->line1 == eap->line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8078 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8079 if (eap->addr_count >= 2) // :2,2join does nothing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8080 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8081 if (eap->line2 == curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8083 beep_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8084 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8085 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8086 ++eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8087 }
5848
75f222d67cea updated for version 7.4.267
Bram Moolenaar <bram@vim.org>
parents: 5790
diff changeset
8088 (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8089 beginline(BL_WHITE | BL_FIX);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8090 ex_may_print(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8091 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8092
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8093 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8094 * ":[addr]@r" or ":[addr]*r": execute register
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8095 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8096 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8097 ex_at(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8098 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8099 int c;
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
8100 int prev_len = typebuf.tb_len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8102 curwin->w_cursor.lnum = eap->line2;
10184
4669440016f2 commit https://github.com/vim/vim/commit/4930a76a0357f76a829eafe4985d04cf3ce0e9e0
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
8103 check_cursor_col();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8105 #ifdef USE_ON_FLY_SCROLL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8106 dont_scroll = TRUE; // disallow scrolling here
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8107 #endif
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8108
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8109 // get the register name. No name means to use the previous one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8110 c = *eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8111 if (c == NUL || (c == '*' && *eap->cmd == '*'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8112 c = '@';
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8113 // Put the register in the typeahead buffer with the "silent" flag.
1034
98d1c149be76 updated for version 7.0-160
vimboss
parents: 1021
diff changeset
8114 if (do_execreg(c, TRUE, vim_strchr(p_cpo, CPO_EXECBUF) != NULL, TRUE)
98d1c149be76 updated for version 7.0-160
vimboss
parents: 1021
diff changeset
8115 == FAIL)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8116 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8117 beep_flush();
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8118 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8119 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8121 int save_efr = exec_from_reg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8123 exec_from_reg = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8125 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8126 * Execute from the typeahead buffer.
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
8127 * Continue until the stuff buffer is empty and all added characters
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
8128 * have been consumed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8129 */
1973
1e52efdc900c updated for version 7.2-270
vimboss
parents: 1968
diff changeset
8130 while (!stuff_empty() || typebuf.tb_len > prev_len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8131 (void)do_cmdline(NULL, getexline, NULL, DOCMD_NOWAIT|DOCMD_VERBOSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8133 exec_from_reg = save_efr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8134 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8137 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8138 * ":!".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8139 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8140 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8141 ex_bang(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8143 do_bang(eap->addr_count, eap, eap->forceit, TRUE, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8146 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8147 * ":undo".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8149 static void
8368
db2a07b710ed commit https://github.com/vim/vim/commit/f1d2501ebe33e148886c2914acd33140e20ee222
Christian Brabandt <cb@256bit.org>
parents: 8281
diff changeset
8150 ex_undo(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8151 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8152 if (eap->addr_count == 1) // :undo 123
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8153 undo_time(eap->line2, FALSE, FALSE, TRUE);
771
c0f1b710ce07 updated for version 7.0226
vimboss
parents: 756
diff changeset
8154 else
c0f1b710ce07 updated for version 7.0226
vimboss
parents: 756
diff changeset
8155 u_undo(1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8156 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8157
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8158 #ifdef FEAT_PERSISTENT_UNDO
2340
99c1eba60b2d Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents: 2333
diff changeset
8159 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8160 ex_wundo(exarg_T *eap)
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8161 {
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8162 char_u hash[UNDO_HASH_SIZE];
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8163
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8164 u_compute_hash(hash);
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8165 u_write_undo(eap->arg, eap->forceit, curbuf, hash);
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8166 }
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8167
2340
99c1eba60b2d Make automatic prototype generation work with more interfaces.
Bram Moolenaar <bram@vim.org>
parents: 2333
diff changeset
8168 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8169 ex_rundo(exarg_T *eap)
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8170 {
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8171 char_u hash[UNDO_HASH_SIZE];
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8172
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8173 u_compute_hash(hash);
2238
3d0a7beb0d75 Made reading/writing undo info a bit more robust.
Bram Moolenaar <bram@vim.org>
parents: 2215
diff changeset
8174 u_read_undo(eap->arg, hash, NULL);
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8175 }
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8176 #endif
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2210
diff changeset
8177
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8179 * ":redo".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8180 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8181 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8182 ex_redo(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8184 u_redo(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8185 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8187 /*
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8188 * ":earlier" and ":later".
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8189 */
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8190 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8191 ex_later(exarg_T *eap)
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8192 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8193 long count = 0;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8194 int sec = FALSE;
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8195 int file = FALSE;
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8196 char_u *p = eap->arg;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8197
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8198 if (*p == NUL)
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8199 count = 1;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8200 else if (isdigit(*p))
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8201 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8202 count = getdigits(&p);
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8203 switch (*p)
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8204 {
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8205 case 's': ++p; sec = TRUE; break;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8206 case 'm': ++p; sec = TRUE; count *= 60; break;
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8207 case 'h': ++p; sec = TRUE; count *= 60 * 60; break;
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8208 case 'd': ++p; sec = TRUE; count *= 24 * 60 * 60; break;
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8209 case 'f': ++p; file = TRUE; break;
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8210 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8211 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8212
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8213 if (*p != NUL)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
8214 semsg(_(e_invalid_argument_str), eap->arg);
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8215 else
2281
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8216 undo_time(eap->cmdidx == CMD_earlier ? -count : count,
e41433ea71df Added ":earlier 1f" and ":later 1f".
Bram Moolenaar <bram@vim.org>
parents: 2276
diff changeset
8217 sec, file, FALSE);
756
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8218 }
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8219
f0edbe50b896 updated for version 7.0224
vimboss
parents: 737
diff changeset
8220 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8221 * ":redir": start/stop redirection.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8222 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8223 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8224 ex_redir(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8226 char *mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8227 char_u *fname;
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8228 char_u *arg = eap->arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8229
9440
73c0d07cc15e commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents: 9438
diff changeset
8230 #ifdef FEAT_EVAL
9454
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents: 9440
diff changeset
8231 if (redir_execute)
9da0cb39cbee commit https://github.com/vim/vim/commit/79815f1ec77406f2f21a618c053e5793b597db7a
Christian Brabandt <cb@256bit.org>
parents: 9440
diff changeset
8232 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
8233 emsg(_(e_cannot_use_redir_inside_execute));
9438
7897b1e4f3e7 commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
8234 return;
7897b1e4f3e7 commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
8235 }
9440
73c0d07cc15e commit https://github.com/vim/vim/commit/ba768495c2e6bae74e49d22d489fbf211ecad55e
Christian Brabandt <cb@256bit.org>
parents: 9438
diff changeset
8236 #endif
9438
7897b1e4f3e7 commit https://github.com/vim/vim/commit/245a7cb6d33e556415c9fcaa874b784a6d8f0ef3
Christian Brabandt <cb@256bit.org>
parents: 9432
diff changeset
8237
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8238 if (STRICMP(eap->arg, "END") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8239 close_redir();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8240 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8241 {
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8242 if (*arg == '>')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8243 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8244 ++arg;
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8245 if (*arg == '>')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8246 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8247 ++arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8248 mode = "a";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8249 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8250 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8251 mode = "w";
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8252 arg = skipwhite(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8254 close_redir();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8255
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8256 // Expand environment variables and "~/".
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8257 fname = expand_env_save(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8258 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8259 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8260 #ifdef FEAT_BROWSE
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
8261 if (cmdmod.cmod_flags & CMOD_BROWSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8262 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8263 char_u *browseFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8264
28
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
8265 browseFile = do_browse(BROWSE_SAVE,
726bdc53fa49 updated for version 7.0018
vimboss
parents: 24
diff changeset
8266 (char_u *)_("Save Redirection"),
13802
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13792
diff changeset
8267 fname, NULL, NULL,
378f9f8e6d8f patch 8.0.1773: dialog messages are not translated
Christian Brabandt <cb@256bit.org>
parents: 13792
diff changeset
8268 (char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8269 if (browseFile == NULL)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8270 return; // operation cancelled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8271 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8272 fname = browseFile;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8273 eap->forceit = TRUE; // since dialog already asked
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8274 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8275 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8277 redir_fd = open_exfile(fname, eap->forceit, mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8278 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8280 #ifdef FEAT_EVAL
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8281 else if (*arg == '@')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8282 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8283 // redirect to a register a-z (resp. A-Z for appending)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8284 close_redir();
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8285 ++arg;
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8286 if (ASCII_ISALPHA(*arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8287 # ifdef FEAT_CLIPBOARD
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8288 || *arg == '*'
1038
777d5460622d updated for version 7.0-164
vimboss
parents: 1034
diff changeset
8289 || *arg == '+'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8290 # endif
122
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8291 || *arg == '"')
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8292 {
56eb9755174b updated for version 7.0043
vimboss
parents: 111
diff changeset
8293 redir_reg = *arg++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8294 if (*arg == '>' && arg[1] == '>') // append
268
8e3c690f1f3c updated for version 7.0072
vimboss
parents: 236
diff changeset
8295 arg += 2;
1427
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
8296 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8297 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8298 // Can use both "@a" and "@a>".
296
00b73c762d77 updated for version 7.0078
vimboss
parents: 291
diff changeset
8299 if (*arg == '>')
00b73c762d77 updated for version 7.0078
vimboss
parents: 291
diff changeset
8300 arg++;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8301 // Make register empty when not using @A-@Z and the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8302 // command is valid.
1427
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
8303 if (*arg == NUL && !isupper(redir_reg))
0e5eb96dc18c updated for version 7.1-142
vimboss
parents: 1411
diff changeset
8304 write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8305 }
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8306 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8307 if (*arg != NUL)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8308 {
268
8e3c690f1f3c updated for version 7.0072
vimboss
parents: 236
diff changeset
8309 redir_reg = 0;
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
8310 semsg(_(e_invalid_argument_str), eap->arg);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8311 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8312 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8313 else if (*arg == '=' && arg[1] == '>')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8314 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8315 int append;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8316
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8317 // redirect to a variable
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8318 close_redir();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8319 arg += 2;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8320
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8321 if (*arg == '>')
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8322 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8323 ++arg;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8324 append = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8326 else
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8327 append = FALSE;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8328
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8329 if (var_redir_start(skipwhite(arg), append) == OK)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8330 redir_vname = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8331 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8332 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8333
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8334 // TODO: redirect to a buffer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8336 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
8337 semsg(_(e_invalid_argument_str), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8338 }
972
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8339
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8340 // Make sure redirection is not off. Can happen for cmdline completion
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8341 // that indirectly invokes a command to catch its output.
972
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8342 if (redir_fd != NULL
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8343 #ifdef FEAT_EVAL
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8344 || redir_reg || redir_vname
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8345 #endif
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8346 )
decce137e7be updated for version 7.0-098
vimboss
parents: 971
diff changeset
8347 redir_off = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8350 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8351 * ":redraw": force redraw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8352 */
7864
6b0891de44a9 commit https://github.com/vim/vim/commit/fb1f62691eae7c79a28b3b17a60e72ce198c71a2
Christian Brabandt <cb@256bit.org>
parents: 7850
diff changeset
8353 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8354 ex_redraw(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8355 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8356 int r = RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8357 int p = p_lz;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8359 RedrawingDisabled = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8360 p_lz = FALSE;
11010
c004e17fa36b patch 8.0.0394: tabs are not aligned when scrolling horizontally
Christian Brabandt <cb@256bit.org>
parents: 10952
diff changeset
8361 validate_cursor();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8362 update_topline();
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 5720
diff changeset
8363 update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8364 if (need_maketitle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8365 maketitle();
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
8366 #if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
8367 # ifdef VIMDLL
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
8368 if (!gui.in_use)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
8369 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16427
diff changeset
8370 resize_console_buf();
15866
6ddcd10aa7af patch 8.1.0940: MS-Windows console resizing not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 15748
diff changeset
8371 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8372 RedrawingDisabled = r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8373 p_lz = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8374
28367
0902a477cd03 patch 8.2.4709: after :redraw the statusline highlight might be used
Bram Moolenaar <Bram@vim.org>
parents: 28359
diff changeset
8375 // After drawing the statusline screen_attr may still be set.
0902a477cd03 patch 8.2.4709: after :redraw the statusline highlight might be used
Bram Moolenaar <Bram@vim.org>
parents: 28359
diff changeset
8376 screen_stop_highlight();
0902a477cd03 patch 8.2.4709: after :redraw the statusline highlight might be used
Bram Moolenaar <Bram@vim.org>
parents: 28359
diff changeset
8377
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8378 // Reset msg_didout, so that a message that's there is overwritten.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8379 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8380 msg_col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8381
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8382 // No need to wait after an intentional redraw.
5198
1b89e3f916c5 updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents: 4928
diff changeset
8383 need_wait_return = FALSE;
1b89e3f916c5 updated for version 7.4a.025
Bram Moolenaar <bram@vim.org>
parents: 4928
diff changeset
8384
28530
80085afc2f4d patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline
Bram Moolenaar <Bram@vim.org>
parents: 28477
diff changeset
8385 // When invoked from a callback or autocmd the command line may be active.
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28741
diff changeset
8386 if (State & MODE_CMDLINE)
28530
80085afc2f4d patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline
Bram Moolenaar <Bram@vim.org>
parents: 28477
diff changeset
8387 redrawcmdline();
80085afc2f4d patch 8.2.4789: cursor pos wrong when using :redraw while editing the cmdline
Bram Moolenaar <Bram@vim.org>
parents: 28477
diff changeset
8388
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8389 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8392 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8393 * ":redrawstatus": force redraw of status line(s)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8394 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8395 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8396 ex_redrawstatus(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8398 int r = RedrawingDisabled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8399 int p = p_lz;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8401 RedrawingDisabled = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8402 p_lz = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8403 if (eap->forceit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8404 status_redraw_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8405 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8406 status_redraw_curbuf();
5735
50dbef5e774a updated for version 7.4.212
Bram Moolenaar <bram@vim.org>
parents: 5720
diff changeset
8407 update_screen(VIsual_active ? INVERTED : 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8408 RedrawingDisabled = r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8409 p_lz = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8410 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8412
15396
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8413 /*
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8414 * ":redrawtabline": force redraw of the tabline
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8415 */
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8416 static void
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8417 ex_redrawtabline(exarg_T *eap UNUSED)
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8418 {
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8419 int r = RedrawingDisabled;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8420 int p = p_lz;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8421
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8422 RedrawingDisabled = 0;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8423 p_lz = FALSE;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8424
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8425 draw_tabline();
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8426
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8427 RedrawingDisabled = r;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8428 p_lz = p;
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8429 out_flush();
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8430 }
325e4a8ba1b6 patch 8.1.0706: tabline is not always redrawn
Bram Moolenaar <Bram@vim.org>
parents: 15263
diff changeset
8431
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8432 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8433 close_redir(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8434 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8435 if (redir_fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8436 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8437 fclose(redir_fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8438 redir_fd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8440 #ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8441 redir_reg = 0;
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8442 if (redir_vname)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8443 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8444 var_redir_stop();
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8445 redir_vname = 0;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8446 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8447 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8449
17539
554240b9574b patch 8.1.1767: FEAT_SESSION defined separately
Bram Moolenaar <Bram@vim.org>
parents: 17536
diff changeset
8450 #if (defined(FEAT_SESSION) || defined(FEAT_EVAL)) || defined(PROTO)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8451 int
18139
59bc3cd42cf5 patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents: 18135
diff changeset
8452 vim_mkdir_emsg(char_u *name, int prot UNUSED)
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8453 {
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8454 if (vim_mkdir(name, prot) != 0)
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8455 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
8456 semsg(_(e_cannot_create_directory_str), name);
167
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8457 return FAIL;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8458 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8459 return OK;
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8460 }
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8461 #endif
c93c9cad9618 updated for version 7.0051
vimboss
parents: 164
diff changeset
8462
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8463 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8464 * Open a file for writing for an Ex command, with some checks.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8465 * Return file descriptor, or NULL on failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8466 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8467 FILE *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8468 open_exfile(
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8469 char_u *fname,
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8470 int forceit,
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8471 char *mode) // "w" for create new file or "a" for append
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8472 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8473 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8475 #ifdef UNIX
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8476 // with Unix it is possible to open a directory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8477 if (mch_isdir(fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8478 {
28255
48b9ffd40f38 patch 8.2.4653: "import autoload" does not check the file name
Bram Moolenaar <Bram@vim.org>
parents: 28222
diff changeset
8479 semsg(_(e_str_is_directory), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8480 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8481 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8482 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8483 if (!forceit && *mode != 'a' && vim_fexists(fname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8484 {
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
8485 semsg(_(e_str_exists_add_bang_to_override), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8486 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8489 if ((fd = mch_fopen((char *)fname, mode)) == NULL)
26857
2aeea8611342 patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26837
diff changeset
8490 semsg(_(e_cannot_open_str_for_writing_2), fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8492 return fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8495 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8496 * ":mark" and ":k".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8497 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8498 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8499 ex_mark(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8500 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8501 pos_T pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8502
23978
54b2aa1f0d42 patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents: 23974
diff changeset
8503 #ifdef FEAT_EVAL
54b2aa1f0d42 patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents: 23974
diff changeset
8504 if (not_in_vim9(eap) == FAIL)
54b2aa1f0d42 patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents: 23974
diff changeset
8505 return;
54b2aa1f0d42 patch 8.2.2531: Vim9: the :k command is obscure
Bram Moolenaar <Bram@vim.org>
parents: 23974
diff changeset
8506 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8507 if (*eap->arg == NUL) // No argument?
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
8508 emsg(_(e_argument_required));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8509 else if (eap->arg[1] != NUL) // more than one character?
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
8510 semsg(_(e_trailing_characters_str), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8511 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8512 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8513 pos = curwin->w_cursor; // save curwin->w_cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8514 curwin->w_cursor.lnum = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8515 beginline(BL_WHITE | BL_FIX);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8516 if (setmark(*eap->arg) == FAIL) // set mark
26861
df2de1e63de0 patch 8.2.3959: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26857
diff changeset
8517 emsg(_(e_argument_must_be_letter_or_forward_backward_quote));
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8518 curwin->w_cursor = pos; // restore curwin->w_cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8522 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8523 * Update w_topline, w_leftcol and the cursor position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8524 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8525 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8526 update_topline_cursor(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8527 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8528 check_cursor(); // put cursor on valid line
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8529 update_topline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8530 if (!curwin->w_p_wrap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8531 validate_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8532 update_curswant();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8534
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8535 /*
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8536 * Save the current State and go to Normal mode.
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8537 * Return TRUE if the typeahead could be saved.
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8538 */
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8539 int
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8540 save_current_state(save_state_T *sst)
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8541 {
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8542 sst->save_msg_scroll = msg_scroll;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8543 sst->save_restart_edit = restart_edit;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8544 sst->save_msg_didout = msg_didout;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8545 sst->save_State = State;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8546 sst->save_insertmode = p_im;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8547 sst->save_finish_op = finish_op;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8548 sst->save_opcount = opcount;
15973
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
8549 sst->save_reg_executing = reg_executing;
28359
390dfc3e409b patch 8.2.4705: jump list marker disappears
Bram Moolenaar <Bram@vim.org>
parents: 28313
diff changeset
8550 sst->save_pending_end_reg_executing = pending_end_reg_executing;
23056
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8551
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8552 msg_scroll = FALSE; // no msg scrolling in Normal mode
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8553 restart_edit = 0; // don't go to Insert mode
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8554 p_im = FALSE; // don't use 'insertmode'
23390
9a5f12b36273 patch 8.2.2238: Vim9: cannot load a Vim9 script without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 23378
diff changeset
8555
23062
fa87b0d1277b patch 8.2.2077: build failure with small features
Bram Moolenaar <Bram@vim.org>
parents: 23056
diff changeset
8556 sst->save_script_version = current_sctx.sc_version;
23056
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8557 current_sctx.sc_version = 1; // not in Vim9 script
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8558
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8559 /*
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8560 * Save the current typeahead. This is required to allow using ":normal"
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8561 * from an event handler and makes sure we don't hang when the argument
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8562 * ends with half a command.
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8563 */
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8564 save_typeahead(&sst->tabuf);
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8565 return sst->tabuf.typebuf_valid;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8566 }
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8567
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8568 void
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8569 restore_current_state(save_state_T *sst)
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8570 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8571 // Restore the previous typeahead.
24846
fdc6a7769045 patch 8.2.2961: keys typed during a :normal command are discarded
Bram Moolenaar <Bram@vim.org>
parents: 24834
diff changeset
8572 restore_typeahead(&sst->tabuf, FALSE);
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8573
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8574 msg_scroll = sst->save_msg_scroll;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8575 restart_edit = sst->save_restart_edit;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8576 p_im = sst->save_insertmode;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8577 finish_op = sst->save_finish_op;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8578 opcount = sst->save_opcount;
15973
393a9a3a2da2 patch 8.1.0992: a :normal command resets the reg_executing() result
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
8579 reg_executing = sst->save_reg_executing;
28359
390dfc3e409b patch 8.2.4705: jump list marker disappears
Bram Moolenaar <Bram@vim.org>
parents: 28313
diff changeset
8580 pending_end_reg_executing = sst->save_pending_end_reg_executing;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8581 msg_didout |= sst->save_msg_didout; // don't reset msg_didout now
23056
57b6427c18e4 patch 8.2.2074: Vim9: using :normal from Vim9 script can't handle range
Bram Moolenaar <Bram@vim.org>
parents: 23050
diff changeset
8582 current_sctx.sc_version = sst->save_script_version;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8583
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8584 // Restore the state (needed when called from a function executed for
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8585 // 'indentexpr'). Update the mouse and cursor, they may have changed.
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8586 State = sst->save_State;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8587 #ifdef CURSOR_SHAPE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8588 ui_cursor_shape(); // may show different cursor shape
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8589 #endif
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8590 }
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8591
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8592 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8593 * ":normal[!] {commands}": Execute normal mode commands.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8594 */
7840
28f569c7dab9 commit https://github.com/vim/vim/commit/20fb9f346497daca4d19402fdfa5de7958642477
Christian Brabandt <cb@256bit.org>
parents: 7819
diff changeset
8595 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8596 ex_normal(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8597 {
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8598 save_state_T save_state;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8599 char_u *arg = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8600 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8601 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8602
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
8603 if (ex_normal_lock > 0)
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
8604 {
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
8605 emsg(_(e_not_allowed_here));
856
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
8606 return;
8cd729851562 updated for version 7.0g
vimboss
parents: 844
diff changeset
8607 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8608 if (ex_normal_busy >= p_mmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8609 {
26861
df2de1e63de0 patch 8.2.3959: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26857
diff changeset
8610 emsg(_(e_recursive_use_of_normal_too_deep));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8611 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8614 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8615 * vgetc() expects a CSI and K_SPECIAL to have been escaped. Don't do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8616 * this for the K_SPECIAL leading byte, otherwise special keys will not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8617 * work.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8618 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8619 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8621 int len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8622
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8623 // Count the number of characters to be escaped.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8624 for (p = eap->arg; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8625 {
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8626 #ifdef FEAT_GUI
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8627 if (*p == CSI) // leadbyte CSI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8628 len += 2;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8629 #endif
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 461
diff changeset
8630 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8631 if (*++p == K_SPECIAL // trailbyte K_SPECIAL or CSI
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8632 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8633 || *p == CSI
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8634 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8635 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8636 len += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8638 if (len > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8639 {
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16738
diff changeset
8640 arg = alloc(STRLEN(eap->arg) + len + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8641 if (arg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8642 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8643 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8644 for (p = eap->arg; *p != NUL; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8645 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8646 arg[len++] = *p;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8647 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8648 if (*p == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8649 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8650 arg[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8651 arg[len++] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8652 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8653 #endif
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 461
diff changeset
8654 for (l = (*mb_ptr2len)(p) - 1; l > 0; --l)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8656 arg[len++] = *++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8657 if (*p == K_SPECIAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8658 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8659 arg[len++] = KS_SPECIAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8660 arg[len++] = KE_FILLER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8661 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8662 #ifdef FEAT_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8663 else if (*p == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8665 arg[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8666 arg[len++] = (int)KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8667 }
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8668 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8670 arg[len] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8671 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8672 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8675
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8676 ++ex_normal_busy;
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8677 if (save_current_state(&save_state))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8678 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8679 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8680 * Repeat the :normal command for each line in the range. When no
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8681 * range given, execute it just once, without positioning the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8682 * first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8683 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8684 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8685 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8686 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8688 curwin->w_cursor.lnum = eap->line1++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8689 curwin->w_cursor.col = 0;
11258
84f71a8a5f2c patch 8.0.0515: ml_get errors in silent Ex mode
Christian Brabandt <cb@256bit.org>
parents: 11256
diff changeset
8690 check_cursor_moved(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8692
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8693 exec_normal_cmd(arg != NULL
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8694 ? arg
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15591
diff changeset
8695 : eap->arg, eap->forceit ? REMAP_NONE : REMAP_YES, FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8696 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8697 while (eap->addr_count > 0 && eap->line1 <= eap->line2 && !got_int);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8699
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8700 // Might not return to the main loop when in an event handler.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8701 update_topline_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8702
12521
718787498836 patch 8.0.1139: using window toolbar changes state
Christian Brabandt <cb@256bit.org>
parents: 12515
diff changeset
8703 restore_current_state(&save_state);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8704 --ex_normal_busy;
6322
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8705 setmouse();
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8706 #ifdef CURSOR_SHAPE
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8707 ui_cursor_shape(); // may show different cursor shape
6322
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8708 #endif
85d8cde3b432 updated for version 7.4.494
Bram Moolenaar <bram@vim.org>
parents: 6305
diff changeset
8709
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8710 vim_free(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8713 /*
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8714 * ":startinsert", ":startreplace" and ":startgreplace"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8715 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8716 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8717 ex_startinsert(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8718 {
98
98435a8ddb09 updated for version 7.0038
vimboss
parents: 93
diff changeset
8719 if (eap->forceit)
98435a8ddb09 updated for version 7.0038
vimboss
parents: 93
diff changeset
8720 {
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8721 // cursor line can be zero on startup
12545
241fbf588b95 patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents: 12521
diff changeset
8722 if (!curwin->w_cursor.lnum)
241fbf588b95 patch 8.0.1151: "vim -c startinsert!" doesn't append
Christian Brabandt <cb@256bit.org>
parents: 12521
diff changeset
8723 curwin->w_cursor.lnum = 1;
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8724 set_cursor_for_append_to_line();
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8725 }
20097
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8726 #ifdef FEAT_TERMINAL
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8727 // Ignore this when running in an active terminal.
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8728 if (term_job_running(curbuf->b_term))
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8729 return;
165ec447ca77 patch 8.2.0604: :startinsert in a terminal window used later
Bram Moolenaar <Bram@vim.org>
parents: 20079
diff changeset
8730 #endif
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8731
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8732 // Ignore the command when already in Insert mode. Inserting an
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8733 // expression register that invokes a function can do this.
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28741
diff changeset
8734 if (State & MODE_INSERT)
89
e1a8191c6768 updated for version 7.0036
vimboss
parents: 84
diff changeset
8735 return;
e1a8191c6768 updated for version 7.0036
vimboss
parents: 84
diff changeset
8736
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8737 if (eap->cmdidx == CMD_startinsert)
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8738 restart_edit = 'a';
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8739 else if (eap->cmdidx == CMD_startreplace)
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8740 restart_edit = 'R';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8741 else
598
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8742 restart_edit = 'V';
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8743
05c67faedc8b updated for version 7.0170
vimboss
parents: 595
diff changeset
8744 if (!eap->forceit)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8745 {
14
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
8746 if (eap->cmdidx == CMD_startinsert)
946da5994c01 updated for version 7.0006
vimboss
parents: 11
diff changeset
8747 restart_edit = 'i';
17984
2ea47dee7ddd patch 8.1.1988: :startinsert! does not work the same way as "A"
Bram Moolenaar <Bram@vim.org>
parents: 17966
diff changeset
8748 curwin->w_curswant = 0; // avoid MAXCOL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8749 }
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22840
diff changeset
8750
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22840
diff changeset
8751 if (VIsual_active)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22840
diff changeset
8752 showmode();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8753 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8755 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8756 * ":stopinsert"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8757 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8758 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8759 ex_stopinsert(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8760 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8761 restart_edit = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8762 stop_insert_mode = TRUE;
8817
b7eb7bbd71d0 commit https://github.com/vim/vim/commit/fd773e9e88add7d1ffef890fb9f3a00d613b4326
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
8763 clearmode();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8764 }
7850
10f17a228661 commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents: 7840
diff changeset
8765
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8766 /*
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8767 * Execute normal mode command "cmd".
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8768 * "remap" can be REMAP_NONE or REMAP_YES.
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8769 */
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8770 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8771 exec_normal_cmd(char_u *cmd, int remap, int silent)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8772 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8773 // Stuff the argument into the typeahead buffer.
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8774 ins_typebuf(cmd, remap, 0, TRUE, silent);
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8775 exec_normal(FALSE, FALSE, FALSE);
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8776 }
7850
10f17a228661 commit https://github.com/vim/vim/commit/e2c3810c2ae290bbc2cba18eb47cc2d44e4b9797
Christian Brabandt <cb@256bit.org>
parents: 7840
diff changeset
8777
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8778 /*
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8779 * Execute normal_cmd() until there is no typeahead left.
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8780 * When "use_vpeekc" is TRUE use vpeekc() to check for available chars.
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8781 */
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8782 void
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8783 exec_normal(int was_typed, int use_vpeekc, int may_use_terminal_loop UNUSED)
7703
39251e981d1f commit https://github.com/vim/vim/commit/25281634cda03ce302aaf9f906a9520b5f81f91e
Christian Brabandt <cb@256bit.org>
parents: 7549
diff changeset
8784 {
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8785 oparg_T oa;
16263
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8786 int c;
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8787
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8788 // When calling vpeekc() from feedkeys() it will return Ctrl_C when there
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8789 // is nothing to get, so also check for Ctrl_C.
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8790 clear_oparg(&oa);
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8791 finish_op = FALSE;
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8792 while ((!stuff_empty()
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8793 || ((was_typed || !typebuf_typed()) && typebuf.tb_len > 0)
16263
d3377393e3d9 patch 8.1.1136: decoding of mouse click escape sequence is not tested
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8794 || (use_vpeekc && (c = vpeekc()) != NUL && c != Ctrl_C))
14871
f20df682c8af patch 8.1.0447: GUI scrollbar test fails with Athena and Motif
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
8795 && !got_int)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8796 {
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8797 update_topline_cursor();
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8798 #ifdef FEAT_TERMINAL
13866
4b35f2835ce4 patch 8.0.1804: using :normal in terminal window causes problems
Christian Brabandt <cb@256bit.org>
parents: 13829
diff changeset
8799 if (may_use_terminal_loop && term_use_loop()
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8800 && oa.op_type == OP_NOP && oa.regname == NUL
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8801 && !VIsual_active)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8802 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8803 // If terminal_loop() returns OK we got a key that is handled
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8804 // in Normal model. With FAIL we first need to position the
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8805 // cursor and the screen needs to be redrawn.
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8806 if (terminal_loop(TRUE) == OK)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8807 normal_cmd(&oa, TRUE);
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8808 }
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8809 else
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8810 #endif
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8811 // execute a Normal mode cmd
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13802
diff changeset
8812 normal_cmd(&oa, TRUE);
36
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8813 }
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8814 }
125e80798a85 updated for version 7.0021
vimboss
parents: 33
diff changeset
8815
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8816 #ifdef FEAT_FIND_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8817 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8818 ex_checkpath(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8819 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8820 find_pattern_in_path(NULL, 0, 0, FALSE, FALSE, CHECK_PATH, 1L,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8821 eap->forceit ? ACTION_SHOW_ALL : ACTION_SHOW,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8822 (linenr_T)1, (linenr_T)MAXLNUM);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8824
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8825 #if defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8826 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8827 * ":psearch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8828 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8829 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8830 ex_psearch(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8831 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8832 g_do_tagpreview = p_pvh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8833 ex_findpat(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8834 g_do_tagpreview = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8836 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8838 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8839 ex_findpat(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8840 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8841 int whole = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8842 long n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8843 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8844 int action;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8846 switch (cmdnames[eap->cmdidx].cmd_name[2])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8847 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8848 case 'e': // ":psearch", ":isearch" and ":dsearch"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8849 if (cmdnames[eap->cmdidx].cmd_name[0] == 'p')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8850 action = ACTION_GOTO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8851 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8852 action = ACTION_SHOW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8853 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8854 case 'i': // ":ilist" and ":dlist"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8855 action = ACTION_SHOW_ALL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8856 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8857 case 'u': // ":ijump" and ":djump"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8858 action = ACTION_GOTO;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8859 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8860 default: // ":isplit" and ":dsplit"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8861 action = ACTION_SPLIT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8862 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8865 n = 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8866 if (vim_isdigit(*eap->arg)) // get count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8867 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8868 n = getdigits(&eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8869 eap->arg = skipwhite(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8870 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8871 if (*eap->arg == '/') // Match regexp, not just whole words
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8873 whole = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8874 ++eap->arg;
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 23239
diff changeset
8875 p = skip_regexp(eap->arg, '/', magic_isset());
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8876 if (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8878 *p++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8879 p = skipwhite(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8880
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8881 // Check for trailing illegal characters
20111
f40231487a49 patch 8.2.0611: Vim9: no check for space before #comment
Bram Moolenaar <Bram@vim.org>
parents: 20097
diff changeset
8882 if (!ends_excmd2(eap->arg, p))
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
8883 eap->errmsg = ex_errmsg(e_trailing_characters_str, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8884 else
25521
2063b858cad9 patch 8.2.3297: cannot use all commands inside a {} block
Bram Moolenaar <Bram@vim.org>
parents: 25469
diff changeset
8885 set_nextcmd(eap, p);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8888 if (!eap->skip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8889 find_pattern_in_path(eap->arg, 0, (int)STRLEN(eap->arg),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8890 whole, !eap->forceit,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8891 *eap->cmd == 'd' ? FIND_DEFINE : FIND_ANY,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8892 n, action, eap->line1, eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8893 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8894 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8895
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8896
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8897 #ifdef FEAT_QUICKFIX
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8898 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8899 * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8900 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8901 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8902 ex_ptag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8903 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8904 g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8905 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8906 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8907
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8908 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8909 * ":pedit"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8910 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8911 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8912 ex_pedit(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8914 win_T *curwin_save = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8915
19621
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8916 if (ERROR_IF_ANY_POPUP_WINDOW)
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8917 return;
0d677257e35d patch 8.2.0367: can use :pedit in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 19575
diff changeset
8918
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8919 // Open the preview window or popup and make it the current window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8920 g_do_tagpreview = p_pvh;
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17746
diff changeset
8921 prepare_tagpreview(TRUE, TRUE, FALSE);
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8922
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8923 // Edit the file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8924 do_exedit(eap, NULL);
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8925
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8926 if (curwin != curwin_save && win_valid(curwin_save))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8927 {
17746
a4e488a6655c patch 8.1.1870: using :pedit from a help file sets help filetype
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
8928 // Return cursor to where we were
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8929 validate_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8930 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8931 win_enter(curwin_save, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8932 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18715
diff changeset
8933 # ifdef FEAT_PROP_POPUP
17644
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8934 else if (WIN_IS_POPUP(curwin))
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8935 {
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8936 // can't keep focus in popup window
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8937 win_enter(firstwin, TRUE);
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8938 }
daa1dea1c1b3 patch 8.1.1819: :pedit does not work with a popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17622
diff changeset
8939 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8940 g_do_tagpreview = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8941 }
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12459
diff changeset
8942 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8943
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8944 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8945 * ":stag", ":stselect" and ":stjump".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8946 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8947 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8948 ex_stag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8950 postponed_split = -1;
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
8951 postponed_split_flags = cmdmod.cmod_split;
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22697
diff changeset
8952 postponed_split_tab = cmdmod.cmod_tab;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8953 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8954 postponed_split_flags = 0;
1090
9a3b65713280 updated for version 7.0-216
vimboss
parents: 1088
diff changeset
8955 postponed_split_tab = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8956 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8957
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8958 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8959 * ":tag", ":tselect", ":tjump", ":tnext", etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8960 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8961 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8962 ex_tag(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8964 ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8967 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
8968 ex_tag_cmd(exarg_T *eap, char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8969 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8970 int cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8972 switch (name[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8973 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8974 case 'j': cmd = DT_JUMP; // ":tjump"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8975 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8976 case 's': cmd = DT_SELECT; // ":tselect"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8977 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8978 case 'p': cmd = DT_PREV; // ":tprevious"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8979 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8980 case 'N': cmd = DT_PREV; // ":tNext"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8981 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8982 case 'n': cmd = DT_NEXT; // ":tnext"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8983 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8984 case 'o': cmd = DT_POP; // ":pop"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8985 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8986 case 'f': // ":tfirst"
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8987 case 'r': cmd = DT_FIRST; // ":trewind"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8988 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8989 case 'l': cmd = DT_LAST; // ":tlast"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8990 break;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8991 default: // ":tag"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8992 #ifdef FEAT_CSCOPE
1603
694e8715dce6 updated for version 7.1-316
vimboss
parents: 1570
diff changeset
8993 if (p_cst && *eap->arg != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8994 {
10373
bd674706408a commit https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4
Christian Brabandt <cb@256bit.org>
parents: 10361
diff changeset
8995 ex_cstag(eap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8996 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8997 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8998 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8999 cmd = DT_TAG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9000 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9002
649
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9003 if (name[0] == 'l')
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9004 {
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9005 #ifndef FEAT_QUICKFIX
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9006 ex_ni(eap);
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9007 return;
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9008 #else
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9009 cmd = DT_LTAG;
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9010 #endif
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9011 }
8157079cea85 updated for version 7.0191
vimboss
parents: 635
diff changeset
9012
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9013 do_tag(eap->arg, cmd, eap->addr_count > 0 ? (int)eap->line2 : 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9014 eap->forceit, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9015 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9017 /*
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9018 * Check "str" for starting with a special cmdline variable.
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9019 * If found return one of the SPEC_ values and set "*usedlen" to the length of
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9020 * the variable. Otherwise return -1 and "*usedlen" is unchanged.
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9021 */
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9022 int
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9023 find_cmdline_var(char_u *src, int *usedlen)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9024 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9025 int len;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9026 int i;
1879
e8eeeff19eae updated for version 7.2-176
vimboss
parents: 1877
diff changeset
9027 static char *(spec_str[]) = {
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9028 "%",
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9029 #define SPEC_PERC 0
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9030 "#",
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9031 #define SPEC_HASH (SPEC_PERC + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9032 "<cword>", // cursor word
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9033 #define SPEC_CWORD (SPEC_HASH + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9034 "<cWORD>", // cursor WORD
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9035 #define SPEC_CCWORD (SPEC_CWORD + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9036 "<cexpr>", // expr under cursor
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9037 #define SPEC_CEXPR (SPEC_CCWORD + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9038 "<cfile>", // cursor path name
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9039 #define SPEC_CFILE (SPEC_CEXPR + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9040 "<sfile>", // ":so" file name
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9041 #define SPEC_SFILE (SPEC_CFILE + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9042 "<slnum>", // ":so" file line number
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9043 #define SPEC_SLNUM (SPEC_SFILE + 1)
21493
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
9044 "<stack>", // call stack
7449921216bc patch 8.2.1297: when a test fails it's often not easy to see where
Bram Moolenaar <Bram@vim.org>
parents: 21487
diff changeset
9045 #define SPEC_STACK (SPEC_SLNUM + 1)
28403
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9046 "<script>", // script file name
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9047 #define SPEC_SCRIPT (SPEC_STACK + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9048 "<afile>", // autocommand file name
28403
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9049 #define SPEC_AFILE (SPEC_SCRIPT + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9050 "<abuf>", // autocommand buffer number
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9051 #define SPEC_ABUF (SPEC_AFILE + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9052 "<amatch>", // autocommand match name
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13288
diff changeset
9053 #define SPEC_AMATCH (SPEC_ABUF + 1)
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9054 "<sflnum>", // script file line number
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9055 #define SPEC_SFLNUM (SPEC_AMATCH + 1)
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9056 "<SID>", // script ID: <SNR>123_
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9057 #define SPEC_SID (SPEC_SFLNUM + 1)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9058 #ifdef FEAT_CLIENTSERVER
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9059 "<client>"
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9060 # define SPEC_CLIENT (SPEC_SID + 1)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9061 #endif
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9062 };
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1868
diff changeset
9063
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24723
diff changeset
9064 for (i = 0; i < (int)ARRAY_LENGTH(spec_str); ++i)
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9065 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9066 len = (int)STRLEN(spec_str[i]);
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9067 if (STRNCMP(src, spec_str[i], len) == 0)
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9068 {
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9069 *usedlen = len;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9070 return i;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9071 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9072 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9073 return -1;
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9074 }
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9075
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9076 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9077 * Evaluate cmdline variables.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9078 *
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9079 * change "%" to curbuf->b_ffname
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9080 * "#" to curwin->w_alt_fnum
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9081 * "%%" to curwin->w_alt_fnum in Vim9 script
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9082 * "<cword>" to word under the cursor
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9083 * "<cWORD>" to WORD under the cursor
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9084 * "<cexpr>" to C-expression under the cursor
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9085 * "<cfile>" to path name under the cursor
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9086 * "<sfile>" to sourced file name
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9087 * "<stack>" to call stack
28433
367439b95aba patch 8.2.4741: startup test fails
Bram Moolenaar <Bram@vim.org>
parents: 28403
diff changeset
9088 * "<script>" to current script name
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9089 * "<slnum>" to sourced file line number
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9090 * "<afile>" to file name for autocommand
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9091 * "<abuf>" to buffer number for autocommand
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9092 * "<amatch>" to matching name for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9093 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9094 * When an error is detected, "errormsg" is set to a non-NULL pointer (may be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9095 * "" for error without a message) and NULL is returned.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9096 * Returns an allocated string if a valid match was found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9097 * Returns NULL if no match was found. "usedlen" then still contains the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9098 * number of characters to skip.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9099 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9100 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9101 eval_vars(
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9102 char_u *src, // pointer into commandline
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9103 char_u *srcstart, // beginning of valid memory for src
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9104 int *usedlen, // characters after src that are used
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9105 linenr_T *lnump, // line number for :e command, or NULL
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9106 char **errormsg, // pointer to error message
28635
dfe18756f2ad patch 8.2.4841: empty string considered an error for expand()
Bram Moolenaar <Bram@vim.org>
parents: 28530
diff changeset
9107 int *escaped, // return value has escaped white space (can
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9108 // be NULL)
28635
dfe18756f2ad patch 8.2.4841: empty string considered an error for expand()
Bram Moolenaar <Bram@vim.org>
parents: 28530
diff changeset
9109 int empty_is_error) // empty result is considered an error
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9111 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9112 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9113 char_u *result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9114 char_u *resultbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9115 int resultlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9116 buf_T *buf;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9117 int valid = VALID_HEAD + VALID_PATH; // assume valid result
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9118 int spec_idx;
14405
289b850d2cbf patch 8.1.0217: compiler warning for variable set but not used
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
9119 int tilde_file = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9120 int skip_mod = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9121 char_u strbuf[30];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9122
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9123 *errormsg = NULL;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
9124 if (escaped != NULL)
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
9125 *escaped = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9128 * Check if there is something to do.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9129 */
1661
5bbc2d6658ad updated for version 7.2a-013
vimboss
parents: 1619
diff changeset
9130 spec_idx = find_cmdline_var(src, usedlen);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9131 if (spec_idx < 0) // no match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9133 *usedlen = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9134 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9137 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9138 * Skip when preceded with a backslash "\%" and "\#".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9139 * Note: In "\\%" the % is also not recognized!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9140 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9141 if (src > srcstart && src[-1] == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9143 *usedlen = 0;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9144 STRMOVE(src - 1, src); // remove backslash
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9145 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9146 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9148 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9149 * word or WORD under cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9150 */
12421
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9151 if (spec_idx == SPEC_CWORD || spec_idx == SPEC_CCWORD
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9152 || spec_idx == SPEC_CEXPR)
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9153 {
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9154 resultlen = find_ident_under_cursor(&result,
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9155 spec_idx == SPEC_CWORD ? (FIND_IDENT | FIND_STRING)
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9156 : spec_idx == SPEC_CEXPR ? (FIND_IDENT | FIND_STRING | FIND_EVAL)
da55ea30842c patch 8.0.1090: cannot get the text under the cursor like v:beval_text
Christian Brabandt <cb@256bit.org>
parents: 12419
diff changeset
9157 : FIND_STRING);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9158 if (resultlen == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9159 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9160 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9161 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9163 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9165 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9166 * '#': Alternate file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9167 * '%': Current file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9168 * File name under the cursor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9169 * File name for autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9170 * and following modifiers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9172 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9173 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9174 int off = 0;
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9175
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9176 switch (spec_idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9177 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9178 case SPEC_PERC:
23372
86d155b29dd7 patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 23370
diff changeset
9179 #ifdef FEAT_EVAL
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9180 if (!in_vim9script() || src[1] != '%')
23372
86d155b29dd7 patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 23370
diff changeset
9181 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9182 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9183 // '%': current file
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9184 if (curbuf->b_fname == NULL)
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9185 {
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9186 result = (char_u *)"";
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9187 valid = 0; // Must have ":p:h" to be valid
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9188 }
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9189 else
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9190 {
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9191 result = curbuf->b_fname;
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9192 tilde_file = STRCMP(result, "~") == 0;
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9193 }
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9194 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9195 }
23372
86d155b29dd7 patch 8.2.2229: build failure without the +eval feature
Bram Moolenaar <Bram@vim.org>
parents: 23370
diff changeset
9196 #ifdef FEAT_EVAL
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9197 // "%%" alternate file
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9198 off = 1;
23378
8e956ea07bb2 patch 8.2.2232: compiler error for falling through into next case
Bram Moolenaar <Bram@vim.org>
parents: 23372
diff changeset
9199 #endif
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9200 // FALLTHROUGH
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9201 case SPEC_HASH: // '#' or "#99": alternate file
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9202 if (off == 0 ? src[1] == '#' : src[2] == '%')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9203 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9204 // "##" or "%%%": the argument list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9205 result = arg_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9206 resultbuf = result;
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9207 *usedlen = off + 2;
1098
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
9208 if (escaped != NULL)
5a1d8468d1fa updated for version 7.0-224
vimboss
parents: 1090
diff changeset
9209 *escaped = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9210 skip_mod = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9211 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9212 }
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9213 s = src + off + 1;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9214 if (*s == '<') // "#<99" uses v:oldfiles
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9215 ++s;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9216 i = (int)getdigits(&s);
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9217 if (s == src + off + 2 && src[off + 1] == '-')
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9218 // just a minus sign, don't skip over it
12706
9b882316aa63 patch 8.0.1231: expanding file name drops dash
Christian Brabandt <cb@256bit.org>
parents: 12674
diff changeset
9219 s--;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9220 *usedlen = (int)(s - src); // length of what we expand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9221
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9222 if (src[off + 1] == '<' && i != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9223 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9224 if (*usedlen < off + 2)
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9225 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9226 // Should we give an error message for #<text?
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9227 *usedlen = off + 1;
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9228 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9229 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9230 #ifdef FEAT_EVAL
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9231 result = list_find_str(get_vim_var_list(VV_OLDFILES),
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9232 (long)i);
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9233 if (result == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9234 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9235 *errormsg = "";
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9236 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9237 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9238 #else
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26960
diff changeset
9239 *errormsg = _(e_hashsmall_is_not_available_without_the_eval_feature);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9240 return NULL;
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9241 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9243 else
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9244 {
23370
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9245 if (i == 0 && src[off + 1] == '<' && *usedlen > off + 1)
622e90acea5d patch 8.2.2228: Vim9: cannot use ":e #" because # starts a comment
Bram Moolenaar <Bram@vim.org>
parents: 23358
diff changeset
9246 *usedlen = off + 1;
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9247 buf = buflist_findnr(i);
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9248 if (buf == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9249 {
26861
df2de1e63de0 patch 8.2.3959: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26857
diff changeset
9250 *errormsg = _(e_no_alternate_file_name_to_substitute_for_hash);
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9251 return NULL;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9252 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9253 if (lnump != NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9254 *lnump = ECMD_LAST;
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9255 if (buf->b_fname == NULL)
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9256 {
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9257 result = (char_u *)"";
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9258 valid = 0; // Must have ":p:h" to be valid
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9259 }
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9260 else
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
9261 {
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9262 result = buf->b_fname;
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
9263 tilde_file = STRCMP(result, "~") == 0;
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
9264 }
1733
5a7384b9ca66 updated for version 7.2-031
vimboss
parents: 1731
diff changeset
9265 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9266 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9268 #ifdef FEAT_SEARCHPATH
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9269 case SPEC_CFILE: // file name under cursor
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 678
diff changeset
9270 result = file_name_at_cursor(FNAME_MESS|FNAME_HYP, 1L, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9271 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9272 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9273 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9274 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9275 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9276 resultbuf = result; // remember allocated string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9277 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9278 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9279
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9280 case SPEC_AFILE: // file name for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9281 result = autocmd_fname;
1723
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9282 if (result != NULL && !autocmd_fname_full)
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9283 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9284 // Still need to turn the fname into a full path. It is
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9285 // postponed to avoid a delay when <afile> is not used.
1723
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9286 autocmd_fname_full = TRUE;
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9287 result = FullName_save(autocmd_fname, FALSE);
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9288 vim_free(autocmd_fname);
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9289 autocmd_fname = result;
2e42153b37f1 updated for version 7.2-021
vimboss
parents: 1721
diff changeset
9290 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9291 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9292 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
9293 *errormsg = _(e_no_autocommand_file_name_to_substitute_for_afile);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9294 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9295 }
1471
e980e93d2ac2 updated for version 7.1-186
vimboss
parents: 1467
diff changeset
9296 result = shorten_fname1(result);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9297 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9298
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9299 case SPEC_ABUF: // buffer number for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9300 if (autocmd_bufnr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9301 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
9302 *errormsg = _(e_no_autocommand_buffer_name_to_substitute_for_abuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9303 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9305 sprintf((char *)strbuf, "%d", autocmd_bufnr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9306 result = strbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9307 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9308
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9309 case SPEC_AMATCH: // match name for autocommand
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9310 result = autocmd_match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9311 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9312 {
26915
3631d2deb36c patch 8.2.3986: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26909
diff changeset
9313 *errormsg = _(e_no_autocommand_match_name_to_substitute_for_amatch);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9314 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9316 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9317
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9318 case SPEC_SFILE: // file name for ":so" command
28403
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9319 result = estack_sfile(ESTACK_SFILE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9320 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9321 {
28403
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9322 *errormsg = _(e_no_source_file_name_to_substitute_for_sfile);
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9323 return NULL;
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9324 }
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9325 resultbuf = result; // remember allocated string
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9326 break;
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9327 case SPEC_STACK: // call stack
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9328 result = estack_sfile(ESTACK_STACK);
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9329 if (result == NULL)
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9330 {
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9331 *errormsg = _(e_no_call_stack_to_substitute_for_stack);
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9332 return NULL;
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9333 }
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9334 resultbuf = result; // remember allocated string
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9335 break;
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9336 case SPEC_SCRIPT: // script file name
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9337 result = estack_sfile(ESTACK_SCRIPT);
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9338 if (result == NULL)
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9339 {
2655935b5ccc patch 8.2.4726: cannot use expand() to get the script name
Bram Moolenaar <Bram@vim.org>
parents: 28397
diff changeset
9340 *errormsg = _(e_no_script_file_name_to_substitute_for_script);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9341 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9342 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
9343 resultbuf = result; // remember allocated string
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9344 break;
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9345
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9346 case SPEC_SLNUM: // line in file for ":so" command
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
9347 if (SOURCING_NAME == NULL || SOURCING_LNUM == 0)
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
9348 {
26962
85866e069c24 patch 8.2.4010: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26960
diff changeset
9349 *errormsg = _(e_no_line_number_to_use_for_slnum);
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
9350 return NULL;
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
9351 }
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
9352 sprintf((char *)strbuf, "%ld", SOURCING_LNUM);
2645
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
9353 result = strbuf;
a2271decbce5 updated for version 7.3.065
Bram Moolenaar <bram@vim.org>
parents: 2635
diff changeset
9354 break;
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9355
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9356 #ifdef FEAT_EVAL
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9357 case SPEC_SFLNUM: // line in script file
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
9358 if (current_sctx.sc_lnum + SOURCING_LNUM == 0)
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9359 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26962
diff changeset
9360 *errormsg = _(e_no_line_number_to_use_for_sflnum);
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9361 return NULL;
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9362 }
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9363 sprintf((char *)strbuf, "%ld",
18991
847cc7932c42 patch 8.2.0056: execution stack is incomplete and inefficient
Bram Moolenaar <Bram@vim.org>
parents: 18904
diff changeset
9364 (long)(current_sctx.sc_lnum + SOURCING_LNUM));
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9365 result = strbuf;
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9366 break;
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9367
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9368 case SPEC_SID:
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9369 if (current_sctx.sc_sid <= 0)
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9370 {
26439
b18f3b0f317c patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents: 26420
diff changeset
9371 *errormsg = _(e_using_sid_not_in_script_context);
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9372 return NULL;
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9373 }
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9374 sprintf((char *)strbuf, "<SNR>%d_", current_sctx.sc_sid);
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9375 result = strbuf;
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9376 break;
21596
c18d00494b60 patch 8.2.1348: build failure without the eval feature
Bram Moolenaar <Bram@vim.org>
parents: 21594
diff changeset
9377 #endif
21594
5daca8504c63 patch 8.2.1347: cannot easily get the script ID
Bram Moolenaar <Bram@vim.org>
parents: 21592
diff changeset
9378
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9379 #ifdef FEAT_CLIENTSERVER
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9380 case SPEC_CLIENT: // Source of last submitted input
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
9381 sprintf((char *)strbuf, PRINTF_HEX_LONG_U,
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 838
diff changeset
9382 (long_u)clientWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9383 result = strbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9384 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9385 #endif
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14677
diff changeset
9386
11428
346168f2a6cb patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents: 11374
diff changeset
9387 default:
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9388 result = (char_u *)""; // avoid gcc warning
11428
346168f2a6cb patch 8.0.0598: building with gcc 7.1 yields new warnings
Christian Brabandt <cb@256bit.org>
parents: 11374
diff changeset
9389 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9390 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9391
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9392 resultlen = (int)STRLEN(result); // length of new string
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9393 if (src[*usedlen] == '<') // remove the file name extension
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9395 ++*usedlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9396 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9397 resultlen = (int)(s - result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9399 else if (!skip_mod)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9400 {
14393
c62601adad69 patch 8.1.0211: expanding a file name "~" results in $HOME
Christian Brabandt <cb@256bit.org>
parents: 14286
diff changeset
9401 valid |= modify_fname(src, tilde_file, usedlen, &result, &resultbuf,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9402 &resultlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9403 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9404 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9405 *errormsg = "";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9406 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9410
28637
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9411 if (resultlen == 0 || valid != VALID_HEAD + VALID_PATH)
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9412 {
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9413 if (empty_is_error)
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9414 {
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9415 if (valid != VALID_HEAD + VALID_PATH)
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9416 *errormsg = _(e_empty_file_name_for_percent_or_hash_only_works_with_ph);
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9417 else
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9418 *errormsg = _(e_evaluates_to_an_empty_string);
5cf6dee0f305 patch 8.2.4842: expand("%:p") is not empty when there is no buffer name
Bram Moolenaar <Bram@vim.org>
parents: 28635
diff changeset
9419 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9420 result = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9422 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9423 result = vim_strnsave(result, resultlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9424 vim_free(resultbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9425 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9426 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9428 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9429 * Expand the <sfile> string in "arg".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9430 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9431 * Returns an allocated string, or NULL for any error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9432 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9433 char_u *
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9434 expand_sfile(char_u *arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9435 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9436 char *errormsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9437 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9438 char_u *result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9439 char_u *newres;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9440 char_u *repl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9441 int srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9442 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9444 result = vim_strsave(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9445 if (result == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9446 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9448 for (p = result; *p; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9450 if (STRNCMP(p, "<sfile>", 7) != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9451 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9452 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9453 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9454 // replace "<sfile>" with the sourced file name, and do ":" stuff
28635
dfe18756f2ad patch 8.2.4841: empty string considered an error for expand()
Bram Moolenaar <Bram@vim.org>
parents: 28530
diff changeset
9455 repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9456 if (errormsg != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9458 if (*errormsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9459 emsg(errormsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9460 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9461 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9462 }
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9463 if (repl == NULL) // no match (cannot happen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9465 p += srclen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9466 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9467 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9468 len = (int)STRLEN(result) - srclen + (int)STRLEN(repl) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9469 newres = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9470 if (newres == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9472 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9473 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9474 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9476 mch_memmove(newres, result, (size_t)(p - result));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9477 STRCPY(newres + (p - result), repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9478 len = (int)STRLEN(newres);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9479 STRCAT(newres, p + srclen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9480 vim_free(repl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9481 vim_free(result);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9482 result = newres;
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9483 p = newres + len; // continue after the match
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9487 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9488 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9490 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO)
272
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
9491 /*
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
9492 * Make a dialog message in "buff[DIALOG_MSG_SIZE]".
310
04bf54c587f4 updated for version 7.0082
vimboss
parents: 296
diff changeset
9493 * "format" must contain "%s".
272
ddada568db54 updated for version 7.0073
vimboss
parents: 268
diff changeset
9494 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9495 void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9496 dialog_msg(char_u *buff, char *format, char_u *fname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9497 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9498 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9499 fname = (char_u *)_("Untitled");
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2768
diff changeset
9500 vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9502 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9504 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9505 * ":behave {mswin,xterm}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9506 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9507 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9508 ex_behave(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9510 if (STRCMP(eap->arg, "mswin") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9511 {
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9512 set_option_value_give_err((char_u *)"selection",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9513 0L, (char_u *)"exclusive", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9514 set_option_value_give_err((char_u *)"selectmode",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9515 0L, (char_u *)"mouse,key", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9516 set_option_value_give_err((char_u *)"mousemodel",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9517 0L, (char_u *)"popup", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9518 set_option_value_give_err((char_u *)"keymodel",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9519 0L, (char_u *)"startsel,stopsel", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9521 else if (STRCMP(eap->arg, "xterm") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9522 {
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9523 set_option_value_give_err((char_u *)"selection",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9524 0L, (char_u *)"inclusive", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9525 set_option_value_give_err((char_u *)"selectmode", 0L, (char_u *)"", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9526 set_option_value_give_err((char_u *)"mousemodel",
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9527 0L, (char_u *)"extend", 0);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9528 set_option_value_give_err((char_u *)"keymodel", 0L, (char_u *)"", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9530 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
9531 semsg(_(e_invalid_argument_str), eap->arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9534 static int filetype_detect = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9535 static int filetype_plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9536 static int filetype_indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9538 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9539 * ":filetype [plugin] [indent] {on,off,detect}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9540 * on: Load the filetype.vim file to install autocommands for file types.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9541 * off: Load the ftoff.vim file to remove all autocommands for file types.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9542 * plugin on: load filetype.vim and ftplugin.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9543 * plugin off: load ftplugof.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9544 * indent on: load filetype.vim and indent.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9545 * indent off: load indoff.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9546 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9547 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9548 ex_filetype(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9549 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9550 char_u *arg = eap->arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9551 int plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9552 int indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9554 if (*eap->arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9555 {
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9556 // Print current status.
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15452
diff changeset
9557 smsg("filetype detection:%s plugin:%s indent:%s",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9558 filetype_detect ? "ON" : "OFF",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9559 filetype_plugin ? (filetype_detect ? "ON" : "(on)") : "OFF",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9560 filetype_indent ? (filetype_detect ? "ON" : "(on)") : "OFF");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9561 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9562 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9563
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9564 // Accept "plugin" and "indent" in any order.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9565 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9566 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9567 if (STRNCMP(arg, "plugin", 6) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9568 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9569 plugin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9570 arg = skipwhite(arg + 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9571 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9573 if (STRNCMP(arg, "indent", 6) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9575 indent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9576 arg = skipwhite(arg + 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9577 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9579 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9581 if (STRCMP(arg, "on") == 0 || STRCMP(arg, "detect") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9583 if (*arg == 'o' || !filetype_detect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9584 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9585 source_runtime((char_u *)FILETYPE_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9586 filetype_detect = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9587 if (plugin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9588 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9589 source_runtime((char_u *)FTPLUGIN_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9590 filetype_plugin = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9592 if (indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9593 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9594 source_runtime((char_u *)INDENT_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9595 filetype_indent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9596 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9598 if (*arg == 'd')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9599 {
9260
ac8180818504 commit https://github.com/vim/vim/commit/1610d052413e0ed664498853a47acc2d677a22d1
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
9600 (void)do_doautocmd((char_u *)"filetypedetect BufRead", TRUE, NULL);
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 715
diff changeset
9601 do_modelines(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9603 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9604 else if (STRCMP(arg, "off") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9605 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9606 if (plugin || indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9608 if (plugin)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9609 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9610 source_runtime((char_u *)FTPLUGOF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9611 filetype_plugin = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9613 if (indent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9614 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9615 source_runtime((char_u *)INDOFF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9616 filetype_indent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9619 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9620 {
8524
2f57bbe870ea commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents: 8402
diff changeset
9621 source_runtime((char_u *)FTOFF_FILE, DIP_ALL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9622 filetype_detect = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9624 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9625 else
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26861
diff changeset
9626 semsg(_(e_invalid_argument_str), arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9627 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9628
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9629 /*
11459
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9630 * ":setfiletype [FALLBACK] {name}"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9631 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9632 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9633 ex_setfiletype(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9634 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9635 if (!did_filetype)
11459
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9636 {
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9637 char_u *arg = eap->arg;
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9638
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9639 if (STRNCMP(arg, "FALLBACK ", 9) == 0)
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9640 arg += 9;
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9641
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28433
diff changeset
9642 set_option_value_give_err((char_u *)"filetype", 0L, arg, OPT_LOCAL);
11459
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9643 if (arg != eap->arg)
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9644 did_filetype = FALSE;
561b76ed9d12 patch 8.0.0613: the conf filetype is used before ftdetect from packages
Christian Brabandt <cb@256bit.org>
parents: 11428
diff changeset
9645 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9646 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9647
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9648 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9649 ex_digraphs(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9650 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9651 #ifdef FEAT_DIGRAPHS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9652 if (*eap->arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9653 putdigraph(eap->arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9654 else
15152
1ef429366fd4 patch 8.1.0586: :digraph output is not easy to read
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
9655 listdigraphs(eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9656 #else
25294
c626fd34b66f patch 8.2.3184: cannot add a digraph with a leading space
Bram Moolenaar <Bram@vim.org>
parents: 25064
diff changeset
9657 emsg(_(e_no_digraphs_version));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9658 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9660
13792
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9661 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9662 void
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9663 set_no_hlsearch(int flag)
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9664 {
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9665 no_hlsearch = flag;
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9666 # ifdef FEAT_EVAL
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9667 set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls);
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9668 # endif
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9669 }
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9670
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9671 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9672 * ":nohlsearch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9673 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9674 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9675 ex_nohlsearch(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9676 {
13792
0e9b2971d7c3 patch 8.0.1768: SET_NO_HLSEARCH() used in a wrong way
Christian Brabandt <cb@256bit.org>
parents: 13581
diff changeset
9677 set_no_hlsearch(TRUE);
737
59971e227f8c updated for version 7.0222
vimboss
parents: 727
diff changeset
9678 redraw_all_later(SOME_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9679 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9680 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9681
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9682 #ifdef FEAT_CRYPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9683 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9684 * ":X": Get crypt key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9685 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9686 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9687 ex_X(exarg_T *eap UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9688 {
6353
60659773c73b updated for version 7.4.509
Bram Moolenaar <bram@vim.org>
parents: 6322
diff changeset
9689 crypt_check_current_method();
6122
18ac55444b37 updated for version 7.4.399
Bram Moolenaar <bram@vim.org>
parents: 6116
diff changeset
9690 (void)crypt_get_key(TRUE, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9692 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9694 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9695 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9696 ex_fold(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9697 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9698 if (foldManualAllowed(TRUE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9699 foldCreate(eap->line1, eap->line2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9702 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9703 ex_foldopen(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9705 opFoldRange(eap->line1, eap->line2, eap->cmdidx == CMD_foldopen,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9706 eap->forceit, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9709 static void
7819
f86adafb28d4 commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents: 7799
diff changeset
9710 ex_folddo(exarg_T *eap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9712 linenr_T lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9713
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9714 # ifdef FEAT_CLIPBOARD
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9715 start_global_changes();
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9716 # endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9717
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9718 // First set the marks for all lines closed/open.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9719 for (lnum = eap->line1; lnum <= eap->line2; ++lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9720 if (hasFolding(lnum, NULL, NULL) == (eap->cmdidx == CMD_folddoclosed))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9721 ml_setmarked(lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9722
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9723 // Execute the command on the marked lines.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9724 global_exe(eap->arg);
18779
8f05b3cf8557 patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
9725 ml_clearmarked(); // clear rest of the marks
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9726 # ifdef FEAT_CLIPBOARD
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9727 end_global_changes();
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9728 # endif
6116
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9729 }
7766142fc7d3 updated for version 7.4.396
Bram Moolenaar <bram@vim.org>
parents: 5979
diff changeset
9730 #endif
12459
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9731
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents: 19137
diff changeset
9732 #if defined(FEAT_QUICKFIX) || defined(PROTO)
14550
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9733 /*
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9734 * Returns TRUE if the supplied Ex cmdidx is for a location list command
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9735 * instead of a quickfix command.
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9736 */
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9737 int
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9738 is_loclist_cmd(int cmdidx)
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9739 {
14621
89cc3e7ecb68 patch 8.1.0324: off-by-one error in cmdidx check
Christian Brabandt <cb@256bit.org>
parents: 14591
diff changeset
9740 if (cmdidx < 0 || cmdidx >= CMD_SIZE)
14550
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9741 return FALSE;
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9742 return cmdnames[cmdidx].cmd_name[0] == 'l';
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9743 }
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9744 #endif
60b9b6196644 patch 8.1.0288: quickfix code uses cmdidx too often
Christian Brabandt <cb@256bit.org>
parents: 14538
diff changeset
9745
18297
b0b37bd807ba patch 8.1.2143: cannot see each command even when 'verbose' is set
Bram Moolenaar <Bram@vim.org>
parents: 18139
diff changeset
9746 #if defined(FEAT_TIMERS) || defined(PROTO)
12459
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9747 int
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9748 get_pressedreturn(void)
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9749 {
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9750 return ex_pressedreturn;
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9751 }
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9752
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9753 void
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9754 set_pressedreturn(int val)
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9755 {
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9756 ex_pressedreturn = val;
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9757 }
937356f8f8d6 patch 8.0.1109: timer causes error on exit from Ex mode
Christian Brabandt <cb@256bit.org>
parents: 12457
diff changeset
9758 #endif