annotate src/ex_cmds2.c @ 31263:d8e7d725a666 v9.0.0965

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