annotate src/ex_cmds2.c @ 30709:223865a5f0f0 v9.0.0689

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