Mercurial > vim
annotate src/ex_cmds2.c @ 28860:3942ea75b4c0 v8.2.4953
patch 8.2.4953: with 'si' inserting '}' after completion goes wrong
Commit: https://github.com/vim/vim/commit/2e444bbef0f36535bf941f007f2961f3f66bbe87
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 14 12:54:23 2022 +0100
patch 8.2.4953: with 'si' inserting '}' after completion goes wrong
Problem: With 'smartindent' inserting '}' after completion goes wrong.
Solution: Check the cursor is in indent. (closes https://github.com/vim/vim/issues/10420)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 14 May 2022 14:00:03 +0200 |
parents | 4dcccb2673fe |
children | 6c7eddcce52c |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9812
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * ex_cmds2.c: some more functions for command line commands | |
12 */ | |
13 | |
14 #include "vim.h" | |
15 #include "version.h" | |
16 | |
17 /* | |
18 * If 'autowrite' option set, try to write the file. | |
19 * Careful: autocommands may make "buf" invalid! | |
20 * | |
21 * return FAIL for failure, OK otherwise | |
22 */ | |
23 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
24 autowrite(buf_T *buf, int forceit) |
7 | 25 { |
1069 | 26 int r; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
27 bufref_T bufref; |
1069 | 28 |
7 | 29 if (!(p_aw || p_awa) || !p_write |
30 #ifdef FEAT_QUICKFIX | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
31 // never autowrite a "nofile" or "nowrite" buffer |
1069 | 32 || bt_dontwrite(buf) |
7 | 33 #endif |
1069 | 34 || (!forceit && buf->b_p_ro) || buf->b_ffname == NULL) |
7 | 35 return FAIL; |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
36 set_bufref(&bufref, buf); |
1069 | 37 r = buf_write_all(buf, forceit); |
38 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
39 // Writing may succeed but the buffer still changed, e.g., when there is a |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
40 // conversion error. We do want to return FAIL then. |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
41 if (bufref_valid(&bufref) && bufIsChanged(buf)) |
1069 | 42 r = FAIL; |
43 return r; | |
7 | 44 } |
45 | |
46 /* | |
14642
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
47 * Flush all buffers, except the ones that are readonly or are never written. |
7 | 48 */ |
49 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
50 autowrite_all(void) |
7 | 51 { |
52 buf_T *buf; | |
53 | |
54 if (!(p_aw || p_awa) || !p_write) | |
55 return; | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
56 FOR_ALL_BUFFERS(buf) |
14642
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
14303
diff
changeset
|
57 if (bufIsChanged(buf) && !buf->b_p_ro && !bt_dontwrite(buf)) |
7 | 58 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
59 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
60 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
61 set_bufref(&bufref, buf); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
62 |
7 | 63 (void)buf_write_all(buf, FALSE); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
64 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
65 // an autocommand may have deleted the buffer |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
66 if (!bufref_valid(&bufref)) |
7 | 67 buf = firstbuf; |
68 } | |
69 } | |
70 | |
71 /* | |
5464 | 72 * Return TRUE if buffer was changed and cannot be abandoned. |
73 * For flags use the CCGD_ values. | |
7 | 74 */ |
75 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
76 check_changed(buf_T *buf, int flags) |
7 | 77 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
78 int forceit = (flags & CCGD_FORCEIT); |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
79 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
80 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
81 set_bufref(&bufref, buf); |
5464 | 82 |
7 | 83 if ( !forceit |
84 && bufIsChanged(buf) | |
5464 | 85 && ((flags & CCGD_MULTWIN) || buf->b_nwindows <= 1) |
86 && (!(flags & CCGD_AW) || autowrite(buf, forceit) == FAIL)) | |
7 | 87 { |
88 #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:
21437
diff
changeset
|
89 if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && p_write) |
7 | 90 { |
91 buf_T *buf2; | |
92 int count = 0; | |
93 | |
5464 | 94 if (flags & CCGD_ALLBUF) |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
95 FOR_ALL_BUFFERS(buf2) |
7 | 96 if (bufIsChanged(buf2) |
97 && (buf2->b_ffname != NULL | |
98 # ifdef FEAT_BROWSE | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21437
diff
changeset
|
99 || (cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 100 # endif |
101 )) | |
102 ++count; | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
103 if (!bufref_valid(&bufref)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
104 // Autocommand deleted buffer, oops! It's not changed now. |
7 | 105 return FALSE; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
106 |
7 | 107 dialog_changed(buf, count > 1); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
108 |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
109 if (!bufref_valid(&bufref)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
110 // Autocommand deleted buffer, oops! It's not changed now. |
7 | 111 return FALSE; |
112 return bufIsChanged(buf); | |
113 } | |
114 #endif | |
5464 | 115 if (flags & CCGD_EXCMD) |
12146
59c1e09cf1a9
patch 8.0.0953: get "no write since last change" error in terminal window
Christian Brabandt <cb@256bit.org>
parents:
12039
diff
changeset
|
116 no_write_message(); |
5464 | 117 else |
13302
b5806be0b36d
patch 8.0.1525: using :wqa exits even if a job runs in a terminal window
Christian Brabandt <cb@256bit.org>
parents:
13274
diff
changeset
|
118 no_write_message_nobang(curbuf); |
7 | 119 return TRUE; |
120 } | |
121 return FALSE; | |
122 } | |
123 | |
124 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) | |
125 | |
126 #if defined(FEAT_BROWSE) || defined(PROTO) | |
127 /* | |
128 * When wanting to write a file without a file name, ask the user for a name. | |
129 */ | |
130 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
131 browse_save_fname(buf_T *buf) |
7 | 132 { |
133 if (buf->b_fname == NULL) | |
134 { | |
135 char_u *fname; | |
136 | |
29 | 137 fname = do_browse(BROWSE_SAVE, (char_u *)_("Save As"), |
138 NULL, NULL, NULL, NULL, buf); | |
7 | 139 if (fname != NULL) |
140 { | |
141 if (setfname(buf, fname, NULL, TRUE) == OK) | |
142 buf->b_flags |= BF_NOTEDITED; | |
143 vim_free(fname); | |
144 } | |
145 } | |
146 } | |
147 #endif | |
148 | |
149 /* | |
2849 | 150 * Ask the user what to do when abandoning a changed buffer. |
7 | 151 * Must check 'write' option first! |
152 */ | |
153 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
154 dialog_changed( |
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
155 buf_T *buf, |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
156 int checkall) // may abandon all changed buffers |
7 | 157 { |
2770 | 158 char_u buff[DIALOG_MSG_SIZE]; |
7 | 159 int ret; |
160 buf_T *buf2; | |
3486 | 161 exarg_T ea; |
7 | 162 |
12206
bd8d767fb36f
patch 8.0.0983: unnecessary check for NULL pointer
Christian Brabandt <cb@256bit.org>
parents:
12146
diff
changeset
|
163 dialog_msg(buff, _("Save changes to \"%s\"?"), buf->b_fname); |
7 | 164 if (checkall) |
165 ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1); | |
166 else | |
167 ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); | |
168 | |
16619
8f0ea605ec96
patch 8.1.1312: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16594
diff
changeset
|
169 // Init ea pseudo-structure, this is needed for the check_overwrite() |
8f0ea605ec96
patch 8.1.1312: Coverity warning for using uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16594
diff
changeset
|
170 // function. |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
171 CLEAR_FIELD(ea); |
3486 | 172 |
7 | 173 if (ret == VIM_YES) |
174 { | |
175 #ifdef FEAT_BROWSE | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
176 // May get file name, when there is none |
7 | 177 browse_save_fname(buf); |
178 #endif | |
3486 | 179 if (buf->b_fname != NULL && check_overwrite(&ea, buf, |
180 buf->b_fname, buf->b_ffname, FALSE) == OK) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
181 // didn't hit Cancel |
7 | 182 (void)buf_write_all(buf, FALSE); |
183 } | |
184 else if (ret == VIM_NO) | |
185 { | |
16996
d5e1e09a829f
patch 8.1.1498: ":write" increments b:changedtick even though nothing changed
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
186 unchanged(buf, TRUE, FALSE); |
7 | 187 } |
188 else if (ret == VIM_ALL) | |
189 { | |
190 /* | |
191 * Write all modified files that can be written. | |
192 * Skip readonly buffers, these need to be confirmed | |
193 * individually. | |
194 */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
195 FOR_ALL_BUFFERS(buf2) |
7 | 196 { |
197 if (bufIsChanged(buf2) | |
198 && (buf2->b_ffname != NULL | |
199 #ifdef FEAT_BROWSE | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21437
diff
changeset
|
200 || (cmdmod.cmod_flags & CMOD_BROWSE) |
7 | 201 #endif |
202 ) | |
203 && !buf2->b_p_ro) | |
204 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
205 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
206 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
207 set_bufref(&bufref, buf2); |
7 | 208 #ifdef FEAT_BROWSE |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
209 // May get file name, when there is none |
7 | 210 browse_save_fname(buf2); |
211 #endif | |
3486 | 212 if (buf2->b_fname != NULL && check_overwrite(&ea, buf2, |
213 buf2->b_fname, buf2->b_ffname, FALSE) == OK) | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
214 // didn't hit Cancel |
7 | 215 (void)buf_write_all(buf2, FALSE); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
216 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
217 // an autocommand may have deleted the buffer |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
218 if (!bufref_valid(&bufref)) |
7 | 219 buf2 = firstbuf; |
220 } | |
221 } | |
222 } | |
223 else if (ret == VIM_DISCARDALL) | |
224 { | |
225 /* | |
226 * mark all buffers as unchanged | |
227 */ | |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
228 FOR_ALL_BUFFERS(buf2) |
16996
d5e1e09a829f
patch 8.1.1498: ":write" increments b:changedtick even though nothing changed
Bram Moolenaar <Bram@vim.org>
parents:
16874
diff
changeset
|
229 unchanged(buf2, TRUE, FALSE); |
7 | 230 } |
231 } | |
232 #endif | |
233 | |
234 /* | |
235 * Return TRUE if the buffer "buf" can be abandoned, either by making it | |
236 * hidden, autowriting it or unloading it. | |
237 */ | |
238 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
239 can_abandon(buf_T *buf, int forceit) |
7 | 240 { |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
241 return ( buf_hide(buf) |
7 | 242 || !bufIsChanged(buf) |
243 || buf->b_nwindows > 1 | |
244 || autowrite(buf, forceit) == OK | |
245 || forceit); | |
246 } | |
247 | |
3429 | 248 /* |
249 * Add a buffer number to "bufnrs", unless it's already there. | |
250 */ | |
251 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
252 add_bufnum(int *bufnrs, int *bufnump, int nr) |
3429 | 253 { |
254 int i; | |
255 | |
256 for (i = 0; i < *bufnump; ++i) | |
257 if (bufnrs[i] == nr) | |
258 return; | |
259 bufnrs[*bufnump] = nr; | |
260 *bufnump = *bufnump + 1; | |
261 } | |
262 | |
7 | 263 /* |
264 * Return TRUE if any buffer was changed and cannot be abandoned. | |
265 * That changed buffer becomes the current buffer. | |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
266 * When "unload" is TRUE the current buffer is unloaded instead of making it |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7107
diff
changeset
|
267 * hidden. This is used for ":q!". |
7 | 268 */ |
269 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
270 check_changed_any( |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
271 int hidden, // Only check hidden buffers |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
272 int unload) |
7 | 273 { |
3429 | 274 int ret = FALSE; |
7 | 275 buf_T *buf; |
276 int save; | |
3429 | 277 int i; |
278 int bufnum = 0; | |
279 int bufcount = 0; | |
280 int *bufnrs; | |
281 tabpage_T *tp; | |
7 | 282 win_T *wp; |
283 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
284 // Make a list of all buffers, with the most important ones first. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
285 FOR_ALL_BUFFERS(buf) |
3429 | 286 ++bufcount; |
287 | |
288 if (bufcount == 0) | |
289 return FALSE; | |
290 | |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
291 bufnrs = ALLOC_MULT(int, bufcount); |
3429 | 292 if (bufnrs == NULL) |
293 return FALSE; | |
294 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
295 // curbuf |
3429 | 296 bufnrs[bufnum++] = curbuf->b_fnum; |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
297 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
298 // buffers in current tab |
3429 | 299 FOR_ALL_WINDOWS(wp) |
300 if (wp->w_buffer != curbuf) | |
301 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); | |
302 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
303 // buffers in other tabs |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
304 FOR_ALL_TABPAGES(tp) |
3429 | 305 if (tp != curtab) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19396
diff
changeset
|
306 FOR_ALL_WINDOWS_IN_TAB(tp, wp) |
3429 | 307 add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum); |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
308 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
309 // any other buffer |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
310 FOR_ALL_BUFFERS(buf) |
3429 | 311 add_bufnum(bufnrs, &bufnum, buf->b_fnum); |
312 | |
313 for (i = 0; i < bufnum; ++i) | |
7 | 314 { |
3429 | 315 buf = buflist_findnr(bufnrs[i]); |
316 if (buf == NULL) | |
317 continue; | |
318 if ((!hidden || buf->b_nwindows == 0) && bufIsChanged(buf)) | |
7 | 319 { |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
320 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
321 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
322 set_bufref(&bufref, buf); |
13438
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
323 #ifdef FEAT_TERMINAL |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
324 if (term_job_running(buf->b_term)) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
325 { |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
326 if (term_try_stop_job(buf) == FAIL) |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
327 break; |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
328 } |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
329 else |
33eea5ce5415
patch 8.0.1593: :qall never exits with an active terminal window
Christian Brabandt <cb@256bit.org>
parents:
13384
diff
changeset
|
330 #endif |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
331 // Try auto-writing the buffer. If this fails but the buffer no |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
332 // longer exists it's not changed, that's OK. |
5464 | 333 if (check_changed(buf, (p_awa ? CCGD_AW : 0) |
334 | CCGD_MULTWIN | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
335 | CCGD_ALLBUF) && bufref_valid(&bufref)) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
336 break; // didn't save - still changes |
7 | 337 } |
338 } | |
339 | |
3429 | 340 if (i >= bufnum) |
341 goto theend; | |
342 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
343 // Get here if "buf" cannot be abandoned. |
3429 | 344 ret = TRUE; |
7 | 345 exiting = FALSE; |
346 #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) | |
347 /* | |
348 * When ":confirm" used, don't give an error message. | |
349 */ | |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21437
diff
changeset
|
350 if (!(p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM))) |
7 | 351 #endif |
352 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
353 // There must be a wait_return for this message, do_buffer() |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
354 // may cause a redraw. But wait_return() is a no-op when vgetc() |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
355 // is busy (Quit used from window menu), then make sure we don't |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
356 // cause a scroll up. |
823 | 357 if (vgetc_busy > 0) |
7 | 358 { |
359 msg_row = cmdline_row; | |
360 msg_col = 0; | |
361 msg_didout = FALSE; | |
362 } | |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
363 if ( |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
364 #ifdef FEAT_TERMINAL |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
365 term_job_running(buf->b_term) |
26966
ac75c145f0a9
patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26952
diff
changeset
|
366 ? semsg(_(e_job_still_running_in_buffer_str), buf->b_fname) |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
367 : |
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
368 #endif |
26857
2aeea8611342
patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26103
diff
changeset
|
369 semsg(_(e_no_write_since_last_change_for_buffer_str), |
3839 | 370 buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) |
7 | 371 { |
372 save = no_wait_return; | |
373 no_wait_return = FALSE; | |
374 wait_return(FALSE); | |
375 no_wait_return = save; | |
376 } | |
377 } | |
378 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
379 // Try to find a window that contains the buffer. |
7 | 380 if (buf != curbuf) |
3429 | 381 FOR_ALL_TAB_WINDOWS(tp, wp) |
7 | 382 if (wp->w_buffer == buf) |
383 { | |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
384 bufref_T bufref; |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
385 |
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
386 set_bufref(&bufref, buf); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
387 |
3429 | 388 goto_tabpage_win(tp, wp); |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
389 |
15967
ddd82b1c9e9d
patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents:
15868
diff
changeset
|
390 // Paranoia: did autocmd wipe out the buffer with changes? |
9487
69ed2c9d34a6
commit https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Christian Brabandt <cb@256bit.org>
parents:
9410
diff
changeset
|
391 if (!bufref_valid(&bufref)) |
3429 | 392 goto theend; |
393 goto buf_found; | |
7 | 394 } |
3429 | 395 buf_found: |
7 | 396 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
397 // Open the changed buffer in the current window. |
7 | 398 if (buf != curbuf) |
7469
15eefe1b0dad
commit https://github.com/vim/vim/commit/027387f70c671f62e3e08e0bdd09ec05b0232735
Christian Brabandt <cb@256bit.org>
parents:
7107
diff
changeset
|
399 set_curbuf(buf, unload ? DOBUF_UNLOAD : DOBUF_GOTO); |
7 | 400 |
3429 | 401 theend: |
402 vim_free(bufnrs); | |
403 return ret; | |
7 | 404 } |
405 | |
406 /* | |
407 * return FAIL if there is no file name, OK if there is one | |
408 * give error message for FAIL | |
409 */ | |
410 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
411 check_fname(void) |
7 | 412 { |
413 if (curbuf->b_ffname == NULL) | |
414 { | |
25306
078edc1821bf
patch 8.2.3190: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
22699
diff
changeset
|
415 emsg(_(e_no_file_name)); |
7 | 416 return FAIL; |
417 } | |
418 return OK; | |
419 } | |
420 | |
421 /* | |
422 * flush the contents of a buffer, unless it has no file name | |
423 * | |
424 * return FAIL for failure, OK otherwise | |
425 */ | |
426 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
427 buf_write_all(buf_T *buf, int forceit) |
7 | 428 { |
429 int retval; | |
430 buf_T *old_curbuf = curbuf; | |
431 | |
432 retval = (buf_write(buf, buf->b_ffname, buf->b_fname, | |
433 (linenr_T)1, buf->b_ml.ml_line_count, NULL, | |
434 FALSE, forceit, TRUE, FALSE)); | |
435 if (curbuf != old_curbuf) | |
16 | 436 { |
11158
501f46f7644c
patch 8.0.0466: still macros that should be all-caps
Christian Brabandt <cb@256bit.org>
parents:
11129
diff
changeset
|
437 msg_source(HL_ATTR(HLF_W)); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
438 msg(_("Warning: Entered other buffer unexpectedly (check autocommands)")); |
16 | 439 } |
7 | 440 return retval; |
441 } | |
442 | |
443 /* | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
444 * ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo" |
7 | 445 */ |
446 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
447 ex_listdo(exarg_T *eap) |
7 | 448 { |
449 int i; | |
685 | 450 win_T *wp; |
451 tabpage_T *tp; | |
6641 | 452 buf_T *buf = curbuf; |
7 | 453 int next_fnum = 0; |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
454 #if defined(FEAT_SYN_HL) |
7 | 455 char_u *save_ei = NULL; |
456 #endif | |
39 | 457 char_u *p_shm_save; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
458 #ifdef FEAT_QUICKFIX |
7107
84efaf06f195
commit https://github.com/vim/vim/commit/ed84b76021df763619cabaedddc44eb5ee849136
Christian Brabandt <cb@256bit.org>
parents:
7092
diff
changeset
|
459 int qf_size = 0; |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
460 int qf_idx; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
461 #endif |
7 | 462 |
8220
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
463 #ifndef FEAT_QUICKFIX |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
464 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo || |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
465 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
466 { |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
467 ex_ni(eap); |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
468 return; |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
469 } |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
470 #endif |
ad9edad64d22
commit https://github.com/vim/vim/commit/0106e3d0bf8a38351af45331cbf3b9172a6bb90b
Christian Brabandt <cb@256bit.org>
parents:
8212
diff
changeset
|
471 |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
472 #if defined(FEAT_SYN_HL) |
819 | 473 if (eap->cmdidx != CMD_windo && eap->cmdidx != CMD_tabdo) |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
474 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
475 // Don't do syntax HL autocommands. Skipping the syntax file is a |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
476 // great speed improvement. |
123 | 477 save_ei = au_event_disable(",Syntax"); |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
478 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19396
diff
changeset
|
479 FOR_ALL_BUFFERS(buf) |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
480 buf->b_flags &= ~BF_SYN_SET; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
481 buf = curbuf; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
482 } |
7 | 483 #endif |
6116 | 484 #ifdef FEAT_CLIPBOARD |
485 start_global_changes(); | |
486 #endif | |
7 | 487 |
488 if (eap->cmdidx == CMD_windo | |
685 | 489 || eap->cmdidx == CMD_tabdo |
11957
bc0fee081e1e
patch 8.0.0858: can exit while a terminal is still running a job
Christian Brabandt <cb@256bit.org>
parents:
11935
diff
changeset
|
490 || buf_hide(curbuf) |
5464 | 491 || !check_changed(curbuf, CCGD_AW |
492 | (eap->forceit ? CCGD_FORCEIT : 0) | |
493 | CCGD_EXCMD)) | |
7 | 494 { |
495 i = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
496 // start at the eap->line1 argument/window/buffer |
685 | 497 wp = firstwin; |
498 tp = first_tabpage; | |
6474 | 499 switch (eap->cmdidx) |
500 { | |
501 case CMD_windo: | |
502 for ( ; wp != NULL && i + 1 < eap->line1; wp = wp->w_next) | |
503 i++; | |
504 break; | |
505 case CMD_tabdo: | |
506 for( ; tp != NULL && i + 1 < eap->line1; tp = tp->tp_next) | |
507 i++; | |
508 break; | |
509 case CMD_argdo: | |
510 i = eap->line1 - 1; | |
511 break; | |
512 default: | |
513 break; | |
514 } | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
515 // set pcmark now |
7 | 516 if (eap->cmdidx == CMD_bufdo) |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
517 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
518 // Advance to the first listed buffer after "eap->line1". |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
519 for (buf = firstbuf; buf != NULL && (buf->b_fnum < eap->line1 |
6641 | 520 || !buf->b_p_bl); buf = buf->b_next) |
521 if (buf->b_fnum > eap->line2) | |
522 { | |
523 buf = NULL; | |
524 break; | |
525 } | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
526 if (buf != NULL) |
6641 | 527 goto_buffer(eap, DOBUF_FIRST, FORWARD, buf->b_fnum); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
528 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
529 #ifdef FEAT_QUICKFIX |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
530 else if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
531 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
532 { |
16515
6e87a69b8e0c
patch 8.1.1261: no error for quickfix commands with negative range
Bram Moolenaar <Bram@vim.org>
parents:
16381
diff
changeset
|
533 qf_size = qf_get_valid_size(eap); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
534 if (qf_size <= 0 || eap->line1 > qf_size) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
535 buf = NULL; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
536 else |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
537 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
538 ex_cc(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
539 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
540 buf = curbuf; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
541 i = eap->line1 - 1; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
542 if (eap->addr_count <= 0) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
543 // default is all the quickfix/location list entries |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
544 eap->line2 = qf_size; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
545 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
546 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
547 #endif |
7 | 548 else |
549 setpcmark(); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
550 listcmd_busy = TRUE; // avoids setting pcmark below |
7 | 551 |
6641 | 552 while (!got_int && buf != NULL) |
7 | 553 { |
554 if (eap->cmdidx == CMD_argdo) | |
555 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
556 // go to argument "i" |
7 | 557 if (i == ARGCOUNT) |
558 break; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
559 // Don't call do_argfile() when already there, it will try |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
560 // reloading the file. |
22 | 561 if (curwin->w_arg_idx != i || !editing_arg_idx(curwin)) |
39 | 562 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
563 // Clear 'shm' to avoid that the file message overwrites |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
564 // any output from the command. |
39 | 565 p_shm_save = vim_strsave(p_shm); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
566 set_option_value_give_err((char_u *)"shm", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
567 0L, (char_u *)"", 0); |
7 | 568 do_argfile(eap, i); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
569 set_option_value_give_err((char_u *)"shm", |
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
570 0L, p_shm_save, 0); |
39 | 571 vim_free(p_shm_save); |
572 } | |
7 | 573 if (curwin->w_arg_idx != i) |
574 break; | |
575 } | |
576 else if (eap->cmdidx == CMD_windo) | |
577 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
578 // go to window "wp" |
685 | 579 if (!win_valid(wp)) |
7 | 580 break; |
685 | 581 win_goto(wp); |
1115 | 582 if (curwin != wp) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
583 break; // something must be wrong |
685 | 584 wp = curwin->w_next; |
585 } | |
586 else if (eap->cmdidx == CMD_tabdo) | |
587 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
588 // go to window "tp" |
685 | 589 if (!valid_tabpage(tp)) |
590 break; | |
4354 | 591 goto_tabpage_tp(tp, TRUE, TRUE); |
685 | 592 tp = tp->tp_next; |
7 | 593 } |
594 else if (eap->cmdidx == CMD_bufdo) | |
595 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
596 // Remember the number of the next listed buffer, in case |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
597 // ":bwipe" is used or autocommands do something strange. |
7 | 598 next_fnum = -1; |
599 for (buf = curbuf->b_next; buf != NULL; buf = buf->b_next) | |
600 if (buf->b_p_bl) | |
601 { | |
602 next_fnum = buf->b_fnum; | |
603 break; | |
604 } | |
605 } | |
606 | |
6474 | 607 ++i; |
608 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
609 // execute the command |
7 | 610 do_cmdline(eap->arg, eap->getline, eap->cookie, |
611 DOCMD_VERBOSE + DOCMD_NOWAIT); | |
612 | |
613 if (eap->cmdidx == CMD_bufdo) | |
614 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
615 // Done? |
6474 | 616 if (next_fnum < 0 || next_fnum > eap->line2) |
7 | 617 break; |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
618 // Check if the buffer still exists. |
9649
fd9727ae3c49
commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents:
9626
diff
changeset
|
619 FOR_ALL_BUFFERS(buf) |
7 | 620 if (buf->b_fnum == next_fnum) |
621 break; | |
622 if (buf == NULL) | |
623 break; | |
39 | 624 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
625 // Go to the next buffer. Clear 'shm' to avoid that the file |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
626 // message overwrites any output from the command. |
39 | 627 p_shm_save = vim_strsave(p_shm); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
628 set_option_value_give_err((char_u *)"shm", 0L, (char_u *)"", 0); |
7 | 629 goto_buffer(eap, DOBUF_FIRST, FORWARD, next_fnum); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
630 set_option_value_give_err((char_u *)"shm", 0L, p_shm_save, 0); |
39 | 631 vim_free(p_shm_save); |
632 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
633 // If autocommands took us elsewhere, quit here. |
7 | 634 if (curbuf->b_fnum != next_fnum) |
635 break; | |
636 } | |
637 | |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
638 #ifdef FEAT_QUICKFIX |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
639 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
640 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
641 { |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
642 if (i >= qf_size || i >= eap->line2) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
643 break; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
644 |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
645 qf_idx = qf_get_cur_idx(eap); |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
646 |
20565
5788b78a1af0
patch 8.2.0836: not all :cdo output is visible
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
647 // Clear 'shm' to avoid that the file message overwrites |
5788b78a1af0
patch 8.2.0836: not all :cdo output is visible
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
648 // any output from the command. |
5788b78a1af0
patch 8.2.0836: not all :cdo output is visible
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
649 p_shm_save = vim_strsave(p_shm); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
650 set_option_value_give_err((char_u *)"shm", 0L, (char_u *)"", 0); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
651 ex_cnext(eap); |
28457
4dcccb2673fe
patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents:
26966
diff
changeset
|
652 set_option_value_give_err((char_u *)"shm", 0L, p_shm_save, 0); |
20565
5788b78a1af0
patch 8.2.0836: not all :cdo output is visible
Bram Moolenaar <Bram@vim.org>
parents:
20007
diff
changeset
|
653 vim_free(p_shm_save); |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
654 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
655 // If jumping to the next quickfix entry fails, quit here |
7092
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
656 if (qf_get_cur_idx(eap) == qf_idx) |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
657 break; |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
658 } |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
659 #endif |
64e30831fa42
commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents:
7009
diff
changeset
|
660 |
7 | 661 if (eap->cmdidx == CMD_windo) |
662 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
663 validate_cursor(); // cursor may have moved |
13384
6740c499de13
patch 8.0.1566: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13380
diff
changeset
|
664 |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
665 // required when 'scrollbind' has been set |
7 | 666 if (curwin->w_p_scb) |
667 do_check_scrollbind(TRUE); | |
668 } | |
6474 | 669 |
670 if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo) | |
671 if (i+1 > eap->line2) | |
672 break; | |
673 if (eap->cmdidx == CMD_argdo && i >= eap->line2) | |
674 break; | |
7 | 675 } |
676 listcmd_busy = FALSE; | |
677 } | |
678 | |
13380
69517d67421f
patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents:
13302
diff
changeset
|
679 #if defined(FEAT_SYN_HL) |
154 | 680 if (save_ei != NULL) |
681 { | |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
682 buf_T *bnext; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
683 aco_save_T aco; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
684 |
154 | 685 au_event_restore(save_ei); |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
686 |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
687 for (buf = firstbuf; buf != NULL; buf = bnext) |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
688 { |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
689 bnext = buf->b_next; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
690 if (buf->b_nwindows > 0 && (buf->b_flags & BF_SYN_SET)) |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
691 { |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
692 buf->b_flags &= ~BF_SYN_SET; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
693 |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
694 // buffer was opened while Syntax autocommands were disabled, |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
695 // need to trigger them now. |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
696 if (buf == curbuf) |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
697 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, |
154 | 698 curbuf->b_fname, TRUE, curbuf); |
17596
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
699 else |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
700 { |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
701 aucmd_prepbuf(&aco, buf); |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
702 apply_autocmds(EVENT_SYNTAX, buf->b_p_syn, |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
703 buf->b_fname, TRUE, buf); |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
704 aucmd_restbuf(&aco); |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
705 } |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
706 |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
707 // start over, in case autocommands messed things up. |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
708 bnext = firstbuf; |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
709 } |
892b4ea3bad6
patch 8.1.1795: no syntax HL after splitting windows with :bufdo
Bram Moolenaar <Bram@vim.org>
parents:
17381
diff
changeset
|
710 } |
154 | 711 } |
7 | 712 #endif |
6116 | 713 #ifdef FEAT_CLIPBOARD |
714 end_global_changes(); | |
715 #endif | |
7 | 716 } |
717 | |
718 #ifdef FEAT_EVAL | |
719 /* | |
720 * ":compiler[!] {name}" | |
721 */ | |
722 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
723 ex_compiler(exarg_T *eap) |
7 | 724 { |
725 char_u *buf; | |
726 char_u *old_cur_comp = NULL; | |
727 char_u *p; | |
728 | |
729 if (*eap->arg == NUL) | |
730 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
731 // List all compiler scripts. |
7 | 732 do_cmdline_cmd((char_u *)"echo globpath(&rtp, 'compiler/*.vim')"); |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
733 // ) keep the indenter happy... |
7 | 734 } |
735 else | |
736 { | |
16764
ef00b6bc186b
patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
16738
diff
changeset
|
737 buf = alloc(STRLEN(eap->arg) + 14); |
7 | 738 if (buf != NULL) |
739 { | |
740 if (eap->forceit) | |
741 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
742 // ":compiler! {name}" sets global options |
7 | 743 do_cmdline_cmd((char_u *) |
744 "command -nargs=* CompilerSet set <args>"); | |
745 } | |
746 else | |
747 { | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
748 // ":compiler! {name}" sets local options. |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
749 // To remain backwards compatible "current_compiler" is always |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
750 // used. A user's compiler plugin may set it, the distributed |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
751 // plugin will then skip the settings. Afterwards set |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
752 // "b:current_compiler" and restore "current_compiler". |
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
753 // Explicitly prepend "g:" to make it work in a function. |
2051
ef2890033e88
updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents:
1882
diff
changeset
|
754 old_cur_comp = get_var_value((char_u *)"g:current_compiler"); |
7 | 755 if (old_cur_comp != NULL) |
756 old_cur_comp = vim_strsave(old_cur_comp); | |
757 do_cmdline_cmd((char_u *) | |
26103
d079ab2ba260
patch 8.2.3584: "verbose set efm" reports location of the :compiler command
Bram Moolenaar <Bram@vim.org>
parents:
25306
diff
changeset
|
758 "command -nargs=* -keepscript CompilerSet setlocal <args>"); |
7 | 759 } |
2051
ef2890033e88
updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents:
1882
diff
changeset
|
760 do_unlet((char_u *)"g:current_compiler", TRUE); |
148 | 761 do_unlet((char_u *)"b:current_compiler", TRUE); |
7 | 762 |
763 sprintf((char *)buf, "compiler/%s.vim", eap->arg); | |
8524
2f57bbe870ea
commit https://github.com/vim/vim/commit/7f8989dd8a627af2185df381195351a913f3777f
Christian Brabandt <cb@256bit.org>
parents:
8522
diff
changeset
|
764 if (source_runtime(buf, DIP_ALL) == FAIL) |
26952
b34ddbca305c
patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26857
diff
changeset
|
765 semsg(_(e_compiler_not_supported_str), eap->arg); |
7 | 766 vim_free(buf); |
767 | |
768 do_cmdline_cmd((char_u *)":delcommand CompilerSet"); | |
769 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
770 // Set "b:current_compiler" from "current_compiler". |
2051
ef2890033e88
updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents:
1882
diff
changeset
|
771 p = get_var_value((char_u *)"g:current_compiler"); |
7 | 772 if (p != NULL) |
773 set_internal_string_var((char_u *)"b:current_compiler", p); | |
774 | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
775 // Restore "current_compiler" for ":compiler {name}". |
7 | 776 if (!eap->forceit) |
777 { | |
778 if (old_cur_comp != NULL) | |
779 { | |
2051
ef2890033e88
updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents:
1882
diff
changeset
|
780 set_internal_string_var((char_u *)"g:current_compiler", |
7 | 781 old_cur_comp); |
782 vim_free(old_cur_comp); | |
783 } | |
784 else | |
2051
ef2890033e88
updated for version 7.2.337
Bram Moolenaar <bram@zimbu.org>
parents:
1882
diff
changeset
|
785 do_unlet((char_u *)"g:current_compiler", TRUE); |
7 | 786 } |
787 } | |
788 } | |
789 } | |
790 #endif | |
791 | |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
792 #if defined(FEAT_PYTHON3) || defined(FEAT_PYTHON) || defined(PROTO) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
793 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
794 # if (defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)) || defined(PROTO) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
795 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
796 * Detect Python 3 or 2, and initialize 'pyxversion'. |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
797 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
798 void |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
799 init_pyxversion(void) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
800 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
801 if (p_pyx == 0) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
802 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
803 if (python3_enabled(FALSE)) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
804 p_pyx = 3; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
805 else if (python_enabled(FALSE)) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
806 p_pyx = 2; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
807 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
808 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
809 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
810 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
811 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
812 * Does a file contain one of the following strings at the beginning of any |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
813 * line? |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
814 * "#!(any string)python2" => returns 2 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
815 * "#!(any string)python3" => returns 3 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
816 * "# requires python 2.x" => returns 2 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
817 * "# requires python 3.x" => returns 3 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
818 * otherwise return 0. |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
819 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
820 static int |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
821 requires_py_version(char_u *filename) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
822 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
823 FILE *file; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
824 int requires_py_version = 0; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
825 int i, lines; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
826 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
827 lines = (int)p_mls; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
828 if (lines < 0) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
829 lines = 5; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
830 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
831 file = mch_fopen((char *)filename, "r"); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
832 if (file != NULL) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
833 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
834 for (i = 0; i < lines; i++) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
835 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
836 if (vim_fgets(IObuff, IOSIZE, file)) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
837 break; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
838 if (i == 0 && IObuff[0] == '#' && IObuff[1] == '!') |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
839 { |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
840 // Check shebang. |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
841 if (strstr((char *)IObuff + 2, "python2") != NULL) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
842 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
843 requires_py_version = 2; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
844 break; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
845 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
846 if (strstr((char *)IObuff + 2, "python3") != NULL) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
847 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
848 requires_py_version = 3; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
849 break; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
850 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
851 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
852 IObuff[21] = '\0'; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
853 if (STRCMP("# requires python 2.x", IObuff) == 0) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
854 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
855 requires_py_version = 2; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
856 break; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
857 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
858 if (STRCMP("# requires python 3.x", IObuff) == 0) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
859 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
860 requires_py_version = 3; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
861 break; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
862 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
863 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
864 fclose(file); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
865 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
866 return requires_py_version; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
867 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
868 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
869 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
870 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
871 * Source a python file using the requested python version. |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
872 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
873 static void |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
874 source_pyx_file(exarg_T *eap, char_u *fname) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
875 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
876 exarg_T ex; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
877 int v = requires_py_version(fname); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
878 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
879 # 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:
10569
diff
changeset
|
880 init_pyxversion(); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
881 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
882 if (v == 0) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
883 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
884 # if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3) |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
885 // user didn't choose a preference, 'pyx' is used |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
886 v = p_pyx; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
887 # elif defined(FEAT_PYTHON) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
888 v = 2; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
889 # elif defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
890 v = 3; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
891 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
892 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
893 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
894 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
895 * now source, if required python version is not supported show |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
896 * unobtrusive message. |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
897 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
898 if (eap == NULL) |
20007
aadd1cae2ff5
patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
899 CLEAR_FIELD(ex); |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
900 else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
901 ex = *eap; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
902 ex.arg = fname; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
903 ex.cmd = (char_u *)(v == 2 ? "pyfile" : "pyfile3"); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
904 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
905 if (v == 2) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
906 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
907 # ifdef FEAT_PYTHON |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
908 ex_pyfile(&ex); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
909 # else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
910 vim_snprintf((char *)IObuff, IOSIZE, |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
911 _("W20: Required python version 2.x not supported, ignoring file: %s"), |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
912 fname); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
913 msg((char *)IObuff); |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
914 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
915 return; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
916 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
917 else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
918 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
919 # ifdef FEAT_PYTHON3 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
920 ex_py3file(&ex); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
921 # else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
922 vim_snprintf((char *)IObuff, IOSIZE, |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
923 _("W21: Required python version 3.x not supported, ignoring file: %s"), |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
924 fname); |
15543
dd725a8ab112
patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
925 msg((char *)IObuff); |
10722
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
926 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
927 return; |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
928 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
929 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
930 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
931 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
932 * ":pyxfile {fname}" |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
933 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
934 void |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
935 ex_pyxfile(exarg_T *eap) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
936 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
937 source_pyx_file(eap, eap->arg); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
938 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
939 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
940 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
941 * ":pyx" |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
942 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
943 void |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
944 ex_pyx(exarg_T *eap) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
945 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
946 # 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:
10569
diff
changeset
|
947 init_pyxversion(); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
948 if (p_pyx == 2) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
949 ex_python(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
950 else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
951 ex_py3(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
952 # elif defined(FEAT_PYTHON) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
953 ex_python(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
954 # elif defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
955 ex_py3(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
956 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
957 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
958 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
959 /* |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
960 * ":pyxdo" |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
961 */ |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
962 void |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
963 ex_pyxdo(exarg_T *eap) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
964 { |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
965 # 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:
10569
diff
changeset
|
966 init_pyxversion(); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
967 if (p_pyx == 2) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
968 ex_pydo(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
969 else |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
970 ex_py3do(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
971 # elif defined(FEAT_PYTHON) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
972 ex_pydo(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
973 # elif defined(FEAT_PYTHON3) |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
974 ex_py3do(eap); |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
975 # endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
976 } |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
977 |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
978 #endif |
7598ce51bf2a
patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents:
10569
diff
changeset
|
979 |
7 | 980 /* |
981 * ":checktime [buffer]" | |
982 */ | |
983 void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7807
diff
changeset
|
984 ex_checktime(exarg_T *eap) |
7 | 985 { |
986 buf_T *buf; | |
987 int save_no_check_timestamps = no_check_timestamps; | |
988 | |
989 no_check_timestamps = 0; | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
990 if (eap->addr_count == 0) // default is all buffers |
7 | 991 check_timestamps(FALSE); |
992 else | |
993 { | |
994 buf = buflist_findnr((int)eap->line2); | |
18779
8f05b3cf8557
patch 8.1.2379: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18051
diff
changeset
|
995 if (buf != NULL) // cannot happen? |
7 | 996 (void)buf_check_timestamp(buf, FALSE); |
997 } | |
998 no_check_timestamps = save_no_check_timestamps; | |
999 } |