Mercurial > vim
annotate src/arglist.c @ 36569:2824209e628e draft default tip
Added tag v9.1.0867 for changeset cc5630ef54698f10bd6eeddd36591ba22f784719
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 15 Nov 2024 20:15:04 +0100 |
parents | 1857846f9152 |
children |
rev | line source |
---|---|
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * arglist.c: functions for dealing with the argument list |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 #define AL_SET 1 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #define AL_ADD 2 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 #define AL_DEL 3 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
20 // This flag is set whenever the argument list is being changed and calling a |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
21 // function that might trigger an autocommand. |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
22 static int arglist_locked = FALSE; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
23 |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
24 static int |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
25 check_arglist_locked(void) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
26 { |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
27 if (arglist_locked) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
28 { |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
29 emsg(_(e_cannot_change_arglist_recursively)); |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
30 return FAIL; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
31 } |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
32 return OK; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
33 } |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
34 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 * Clear an argument list: free all file names and reset it to zero entries. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 alist_clear(alist_T *al) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 { |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
41 if (check_arglist_locked() == FAIL) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
42 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 while (--al->al_ga.ga_len >= 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 vim_free(AARGLIST(al)[al->al_ga.ga_len].ae_fname); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 ga_clear(&al->al_ga); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 * Init an argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 alist_init(alist_T *al) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 { |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
54 ga_init2(&al->al_ga, sizeof(aentry_T), 5); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 * Remove a reference from an argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 * Ignored when the argument list is the global one. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 * If the argument list is no longer used by any window, free it. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 alist_unlink(alist_T *al) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 if (al != &global_alist && --al->al_refcount <= 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 alist_clear(al); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 vim_free(al); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 * Create a new argument list and use it for the current window. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 alist_new(void) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 curwin->w_alist = ALLOC_ONE(alist_T); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 if (curwin->w_alist == NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 curwin->w_alist = &global_alist; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 ++global_alist.al_refcount; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 curwin->w_alist->al_refcount = 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 curwin->w_alist->id = ++max_alist_id; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 alist_init(curwin->w_alist); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 #if !defined(UNIX) || defined(PROTO) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 * Expand the file names in the global argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 * If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 * numbers to be re-used. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 alist_expand(int *fnum_list, int fnum_len) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 char_u **old_arg_files; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 int old_arg_count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 char_u **new_arg_files; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 int new_arg_file_count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 char_u *save_p_su = p_su; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
108 old_arg_files = ALLOC_MULT(char_u *, GARGCOUNT); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
109 if (old_arg_files == NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
110 return; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
111 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 // Don't use 'suffixes' here. This should work like the shell did the |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 // expansion. Also, the vimrc file isn't read yet, thus the user |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 // can't set the options. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 p_su = empty_option; |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
116 for (i = 0; i < GARGCOUNT; ++i) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
117 old_arg_files[i] = vim_strsave(GARGLIST[i].ae_fname); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
118 old_arg_count = GARGCOUNT; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
119 if (expand_wildcards(old_arg_count, old_arg_files, |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
120 &new_arg_file_count, &new_arg_files, |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
121 EW_FILE|EW_NOTFOUND|EW_ADDSLASH|EW_NOERROR) == OK |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
122 && new_arg_file_count > 0) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 { |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
124 alist_set(&global_alist, new_arg_file_count, new_arg_files, |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
125 TRUE, fnum_list, fnum_len); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
126 FreeWild(old_arg_count, old_arg_files); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 p_su = save_p_su; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 #endif |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 * Set the argument list for the current window. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 * Takes over the allocated files[] and the allocated fnames in it. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 alist_set( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 alist_T *al, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 int count, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 char_u **files, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 int use_curbuf, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 int *fnum_list, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 int fnum_len) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
147 if (check_arglist_locked() == FAIL) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 return; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 alist_clear(al); |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
151 if (GA_GROW_OK(&al->al_ga, count)) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 for (i = 0; i < count; ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 if (got_int) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 // When adding many buffers this can take a long time. Allow |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 // interrupting here. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 while (i < count) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 vim_free(files[i++]); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 // May set buffer name of a buffer previously used for the |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 // argument list, so that it's re-used by alist_add. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 if (fnum_list != NULL && i < fnum_len) |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
167 { |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
168 arglist_locked = TRUE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 buf_set_name(fnum_list[i], files[i]); |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
170 arglist_locked = FALSE; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
171 } |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 alist_add(al, files[i], use_curbuf ? 2 : 1); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 ui_breakcheck(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 vim_free(files); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 FreeWild(count, files); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 if (al == &global_alist) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 arg_had_last = FALSE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 * Add file "fname" to argument list "al". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 * "fname" must have been allocated and "al" must have been checked for room. |
35975
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
187 * |
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
188 * May trigger Buf* autocommands |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 alist_add( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 alist_T *al, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 char_u *fname, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 int set_fnum) // 1: set buffer number; 2: re-use curbuf |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 if (fname == NULL) // don't add NULL file names |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 return; |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
198 if (check_arglist_locked() == FAIL) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
199 return; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
200 arglist_locked = TRUE; |
35975
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
201 curwin->w_locked = TRUE; |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
202 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 #ifdef BACKSLASH_IN_FILENAME |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 slash_adjust(fname); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 #endif |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 if (set_fnum > 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 AARGLIST(al)[al->al_ga.ga_len].ae_fnum = |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0)); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 ++al->al_ga.ga_len; |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
211 |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
212 arglist_locked = FALSE; |
35975
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
213 curwin->w_locked = FALSE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 * Adjust slashes in file names. Called after 'shellslash' was set. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 alist_slash_adjust(void) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 win_T *wp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 tabpage_T *tp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 for (i = 0; i < GARGCOUNT; ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 if (GARGLIST[i].ae_fname != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 slash_adjust(GARGLIST[i].ae_fname); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 FOR_ALL_TAB_WINDOWS(tp, wp) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 if (wp->w_alist != &global_alist) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 for (i = 0; i < WARGCOUNT(wp); ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 if (WARGLIST(wp)[i].ae_fname != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 slash_adjust(WARGLIST(wp)[i].ae_fname); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 #endif |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 * Isolate one argument, taking backticks. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 * Changes the argument in-place, puts a NUL after it. Backticks remain. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 * Return a pointer to the start of the next argument. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 static char_u * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 do_one_arg(char_u *str) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 char_u *p; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 int inbacktick; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 inbacktick = FALSE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 for (p = str; *str; ++str) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 // When the backslash is used for escaping the special meaning of a |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 // character we need to keep it until wildcard expansion. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 if (rem_backslash(str)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 *p++ = *str++; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 *p++ = *str; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 // An item ends at a space not in backticks |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 if (!inbacktick && vim_isspace(*str)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 if (*str == '`') |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 inbacktick ^= TRUE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 *p++ = *str; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 str = skipwhite(str); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 *p = NUL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 return str; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 * Separate the arguments in "str" and return a list of pointers in the |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 * growarray "gap". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 static int |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 get_arglist(garray_T *gap, char_u *str, int escaped) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 { |
27028
c9474ae175f4
patch 8.2.4043: using int for second argument of ga_init2()
Bram Moolenaar <Bram@vim.org>
parents:
26877
diff
changeset
|
282 ga_init2(gap, sizeof(char_u *), 20); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 while (*str != NUL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 if (ga_grow(gap, 1) == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 ga_clear(gap); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 return FAIL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 ((char_u **)gap->ga_data)[gap->ga_len++] = str; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 // If str is escaped, don't handle backslashes or spaces |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 if (!escaped) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 return OK; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 // Isolate one argument, change it in-place, put a NUL after it. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 str = do_one_arg(str); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 return OK; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 |
30825
c7983f593fa7
patch 9.0.0747: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
30645
diff
changeset
|
302 #if defined(FEAT_QUICKFIX) || defined(FEAT_SYN_HL) || defined(FEAT_SPELL) || defined(PROTO) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 * Parse a list of arguments (file names), expand them and return in |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 * "fnames[fcountp]". When "wig" is TRUE, removes files matching 'wildignore'. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 * Return FAIL or OK. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 int |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 get_arglist_exp( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 char_u *str, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 int *fcountp, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 char_u ***fnamesp, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 int wig) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 garray_T ga; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 if (get_arglist(&ga, str, TRUE) == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 return FAIL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 if (wig == TRUE) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 i = expand_wildcards(ga.ga_len, (char_u **)ga.ga_data, |
23778
8b682f6f3709
patch 8.2.2430: :vimgrep expands wildcards twice
Bram Moolenaar <Bram@vim.org>
parents:
23760
diff
changeset
|
322 fcountp, fnamesp, EW_FILE|EW_NOTFOUND|EW_NOTWILD); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 i = gen_expand_wildcards(ga.ga_len, (char_u **)ga.ga_data, |
23778
8b682f6f3709
patch 8.2.2430: :vimgrep expands wildcards twice
Bram Moolenaar <Bram@vim.org>
parents:
23760
diff
changeset
|
325 fcountp, fnamesp, EW_FILE|EW_NOTFOUND|EW_NOTWILD); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 ga_clear(&ga); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 return i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 #endif |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 * Check the validity of the arg_idx for each other window. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 static void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 alist_check_arg_idx(void) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 win_T *win; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 tabpage_T *tp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 FOR_ALL_TAB_WINDOWS(tp, win) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 if (win->w_alist == curwin->w_alist) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 check_arg_idx(win); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 * Add files[count] to the arglist of the current window after arg "after". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 * The file names in files[count] must have been allocated and are taken over. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 * Files[] itself is not taken over. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 static void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 alist_add_list( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 int count, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 char_u **files, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 int after, // where to add: 0 = before first one |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 int will_edit) // will edit adding argument |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 int old_argcount = ARGCOUNT; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
361 if (check_arglist_locked() != FAIL |
25477
a8f526c9b172
patch 8.2.3275: optimizer can use hints about ga_grow() normally succeeding
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
362 && GA_GROW_OK(&ALIST(curwin)->al_ga, count)) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 if (after < 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 after = 0; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 if (after > ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 after = ARGCOUNT; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 if (after < ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 mch_memmove(&(ARGLIST[after + count]), &(ARGLIST[after]), |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 (ARGCOUNT - after) * sizeof(aentry_T)); |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
371 arglist_locked = TRUE; |
35975
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
372 curwin->w_locked = TRUE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 for (i = 0; i < count; ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 int flags = BLN_LISTED | (will_edit ? BLN_CURBUF : 0); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 ARGLIST[after + i].ae_fname = files[i]; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 ARGLIST[after + i].ae_fnum = buflist_add(files[i], flags); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 } |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
380 arglist_locked = FALSE; |
35975
1857846f9152
patch 9.1.0678: [security]: use-after-free in alist_add()
Christian Brabandt <cb@256bit.org>
parents:
34470
diff
changeset
|
381 curwin->w_locked = FALSE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 ALIST(curwin)->al_ga.ga_len += count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 if (old_argcount > 0 && curwin->w_arg_idx >= after) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 curwin->w_arg_idx += count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 return; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 for (i = 0; i < count; ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 vim_free(files[i]); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 /* |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
393 * Delete the file names in 'alist_ga' from the argument list. |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
394 */ |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
395 static void |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
396 arglist_del_files(garray_T *alist_ga) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
397 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
398 regmatch_T regmatch; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
399 int didone; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
400 int i; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
401 char_u *p; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
402 int match; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
403 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
404 // Delete the items: use each item as a regexp and find a match in the |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
405 // argument list. |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
406 regmatch.rm_ic = p_fic; // ignore case when 'fileignorecase' is set |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
407 for (i = 0; i < alist_ga->ga_len && !got_int; ++i) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
408 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
409 p = ((char_u **)alist_ga->ga_data)[i]; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
410 p = file_pat_to_reg_pat(p, NULL, NULL, FALSE); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
411 if (p == NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
412 break; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
413 regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
414 if (regmatch.regprog == NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
415 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
416 vim_free(p); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
417 break; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
418 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
419 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
420 didone = FALSE; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
421 for (match = 0; match < ARGCOUNT; ++match) |
31201
b1c66bff0a66
patch 9.0.0934: various code formatting issues
Bram Moolenaar <Bram@vim.org>
parents:
31061
diff
changeset
|
422 if (vim_regexec(®match, alist_name(&ARGLIST[match]), (colnr_T)0)) |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
423 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
424 didone = TRUE; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
425 vim_free(ARGLIST[match].ae_fname); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
426 mch_memmove(ARGLIST + match, ARGLIST + match + 1, |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
427 (ARGCOUNT - match - 1) * sizeof(aentry_T)); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
428 --ALIST(curwin)->al_ga.ga_len; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
429 if (curwin->w_arg_idx > match) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
430 --curwin->w_arg_idx; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
431 --match; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
432 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
433 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
434 vim_regfree(regmatch.regprog); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
435 vim_free(p); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
436 if (!didone) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
437 semsg(_(e_no_match_str_2), ((char_u **)alist_ga->ga_data)[i]); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
438 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
439 ga_clear(alist_ga); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
440 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
441 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
442 /* |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 * "what" == AL_SET: Redefine the argument list to 'str'. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 * "what" == AL_ADD: add files in 'str' to the argument list after "after". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 * "what" == AL_DEL: remove files in 'str' from the argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 * Return FAIL for failure, OK otherwise. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 static int |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 do_arglist( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 char_u *str, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 int what, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 int after UNUSED, // 0 means before first one |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 int will_edit) // will edit added argument |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 garray_T new_ga; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 int exp_count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 char_u **exp_files; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 int arg_escaped = TRUE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
462 if (check_arglist_locked() == FAIL) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
463 return FAIL; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
464 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 // Set default argument for ":argadd" command. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 if (what == AL_ADD && *str == NUL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 if (curbuf->b_ffname == NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 return FAIL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 str = curbuf->b_fname; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 arg_escaped = FALSE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 // Collect all file name arguments in "new_ga". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 if (get_arglist(&new_ga, str, arg_escaped) == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 return FAIL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 if (what == AL_DEL) |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
479 arglist_del_files(&new_ga); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 i = expand_wildcards(new_ga.ga_len, (char_u **)new_ga.ga_data, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 &exp_count, &exp_files, EW_DIR|EW_FILE|EW_ADDSLASH|EW_NOTFOUND); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 ga_clear(&new_ga); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 if (i == FAIL || exp_count == 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 { |
26877
06a137af96f8
patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26865
diff
changeset
|
487 emsg(_(e_no_match)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 return FAIL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 if (what == AL_ADD) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 alist_add_list(exp_count, exp_files, after, will_edit); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 vim_free(exp_files); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 else // what == AL_SET |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 alist_set(ALIST(curwin), exp_count, exp_files, will_edit, NULL, 0); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 alist_check_arg_idx(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 return OK; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 * Redefine the argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 set_arglist(char_u *str) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 { |
34190
4f8b57f8b07a
patch 9.1.0046: :drop does not re-use empty buffer
Christian Brabandt <cb@256bit.org>
parents:
33947
diff
changeset
|
511 do_arglist(str, AL_SET, 0, TRUE); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 * Return TRUE if window "win" is editing the file at the current argument |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 * index. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 int |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 editing_arg_idx(win_T *win) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 return !(win->w_arg_idx >= WARGCOUNT(win) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 || (win->w_buffer->b_fnum |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 != WARGLIST(win)[win->w_arg_idx].ae_fnum |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 && (win->w_buffer->b_ffname == NULL |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 || !(fullpathcmp( |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 alist_name(&WARGLIST(win)[win->w_arg_idx]), |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 win->w_buffer->b_ffname, TRUE, TRUE) & FPC_SAME)))); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 * Check if window "win" is editing the w_arg_idx file in its argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 check_arg_idx(win_T *win) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 if (WARGCOUNT(win) > 1 && !editing_arg_idx(win)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 // We are not editing the current entry in the argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 // Set "arg_had_last" if we are editing the last one. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 win->w_arg_idx_invalid = TRUE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 if (win->w_arg_idx != WARGCOUNT(win) - 1 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 && arg_had_last == FALSE |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 && ALIST(win) == &global_alist |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 && GARGCOUNT > 0 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 && win->w_arg_idx < GARGCOUNT |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 && (win->w_buffer->b_fnum == GARGLIST[GARGCOUNT - 1].ae_fnum |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 || (win->w_buffer->b_ffname != NULL |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 && (fullpathcmp(alist_name(&GARGLIST[GARGCOUNT - 1]), |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 win->w_buffer->b_ffname, TRUE, TRUE) & FPC_SAME)))) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 arg_had_last = TRUE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 // We are editing the current entry in the argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 // Set "arg_had_last" if it's also the last one |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 win->w_arg_idx_invalid = FALSE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 if (win->w_arg_idx == WARGCOUNT(win) - 1 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 && win->w_alist == &global_alist) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 arg_had_last = TRUE; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 * ":args", ":argslocal" and ":argsglobal". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 ex_args(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 if (eap->cmdidx != CMD_args) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 { |
23843
d97258eca25d
patch 8.2.2463: using :arglocal in an autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23778
diff
changeset
|
573 if (check_arglist_locked() == FAIL) |
d97258eca25d
patch 8.2.2463: using :arglocal in an autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23778
diff
changeset
|
574 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 alist_unlink(ALIST(curwin)); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 if (eap->cmdidx == CMD_argglobal) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 ALIST(curwin) = &global_alist; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 else // eap->cmdidx == CMD_arglocal |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 alist_new(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
582 // ":args file ..": define new argument list, handle like ":next" |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
583 // Also for ":argslocal file .." and ":argsglobal file ..". |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 if (*eap->arg != NUL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 { |
23843
d97258eca25d
patch 8.2.2463: using :arglocal in an autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23778
diff
changeset
|
586 if (check_arglist_locked() == FAIL) |
d97258eca25d
patch 8.2.2463: using :arglocal in an autocommand may use freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23778
diff
changeset
|
587 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 ex_next(eap); |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
589 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
591 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
592 // ":args": list arguments. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
593 if (eap->cmdidx == CMD_args) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 { |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
595 char_u **items; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
596 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
597 if (ARGCOUNT <= 0) |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
598 return; // empty argument list |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
600 items = ALLOC_MULT(char_u *, ARGCOUNT); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
601 if (items == NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
602 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
604 // Overwrite the command, for a short list there is no scrolling |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
605 // required and no wait_return(). |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
606 gotocmdline(TRUE); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
607 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
608 for (i = 0; i < ARGCOUNT; ++i) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
609 items[i] = alist_name(&ARGLIST[i]); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
610 list_in_columns(items, ARGCOUNT, curwin->w_arg_idx); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
611 vim_free(items); |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
612 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
613 return; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
615 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
616 // ":argslocal": make a local copy of the global argument list. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
617 if (eap->cmdidx == CMD_arglocal) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 garray_T *gap = &curwin->w_alist->al_ga; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
621 if (GA_GROW_FAILS(gap, GARGCOUNT)) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
622 return; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
623 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
624 for (i = 0; i < GARGCOUNT; ++i) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
625 if (GARGLIST[i].ae_fname != NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
626 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
627 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fname = |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
628 vim_strsave(GARGLIST[i].ae_fname); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
629 AARGLIST(curwin->w_alist)[gap->ga_len].ae_fnum = |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
630 GARGLIST[i].ae_fnum; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
631 ++gap->ga_len; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
632 } |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 * ":previous", ":sprevious", ":Next" and ":sNext". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 ex_previous(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 // If past the last one already, go to the last one. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 if (curwin->w_arg_idx - (int)eap->line2 >= ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 do_argfile(eap, ARGCOUNT - 1); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 do_argfile(eap, curwin->w_arg_idx - (int)eap->line2); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 * ":rewind", ":first", ":sfirst" and ":srewind". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 ex_rewind(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 do_argfile(eap, 0); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 * ":last" and ":slast". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 ex_last(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 do_argfile(eap, ARGCOUNT - 1); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 * ":argument" and ":sargument". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 ex_argument(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 if (eap->addr_count > 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 i = eap->line2 - 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 i = curwin->w_arg_idx; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 do_argfile(eap, i); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 * Edit file "argn" of the argument lists. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 do_argfile(exarg_T *eap, int argn) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 int other; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 char_u *p; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 int old_arg_idx = curwin->w_arg_idx; |
34470
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
691 int is_split_cmd = *eap->cmd == 's'; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 |
19271
ebeeb4b4a1fa
patch 8.2.0194: some commands can cause problems in terminal popup
Bram Moolenaar <Bram@vim.org>
parents:
19112
diff
changeset
|
693 if (ERROR_IF_ANY_POPUP_WINDOW) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 return; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 if (argn < 0 || argn >= ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 if (ARGCOUNT <= 1) |
26857
2aeea8611342
patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26719
diff
changeset
|
698 emsg(_(e_there_is_only_one_file_to_edit)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 else if (argn < 0) |
26857
2aeea8611342
patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26719
diff
changeset
|
700 emsg(_(e_cannot_go_before_first_file)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 else |
26857
2aeea8611342
patch 8.2.3957: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26719
diff
changeset
|
702 emsg(_(e_cannot_go_beyond_last_file)); |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
703 |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
704 return; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
705 } |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
706 |
34470
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
707 if (!is_split_cmd |
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
708 && (&ARGLIST[argn])->ae_fnum != curbuf->b_fnum |
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
709 && !check_can_set_curbuf_forceit(eap->forceit)) |
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
710 return; |
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
711 |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
712 setpcmark(); |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
713 #ifdef FEAT_GUI |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
714 need_mouse_correct = TRUE; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
715 #endif |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
716 |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
717 // split window or create new tab page first |
34470
dd8f5311cee5
patch 9.1.0147: Cannot keep a buffer focused in a window
Christian Brabandt <cb@256bit.org>
parents:
34305
diff
changeset
|
718 if (is_split_cmd || cmdmod.cmod_tab != 0) |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
719 { |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
720 if (win_split(0, 0) == FAIL) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
721 return; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
722 RESET_BINDING(curwin); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 { |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
726 // if 'hidden' set, only check for changed file when re-editing |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
727 // the same buffer |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
728 other = TRUE; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
729 if (buf_hide(curbuf)) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 { |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
731 p = fix_fname(alist_name(&ARGLIST[argn])); |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
732 other = otherfile(p); |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
733 vim_free(p); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 } |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
735 if ((!buf_hide(curbuf) || !other) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
736 && check_changed(curbuf, CCGD_AW |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
737 | (other ? 0 : CCGD_MULTWIN) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
738 | (eap->forceit ? CCGD_FORCEIT : 0) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
739 | CCGD_EXCMD)) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
740 return; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
741 } |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
743 curwin->w_arg_idx = argn; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
744 if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
745 arg_had_last = TRUE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 |
31600
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
747 // Edit the file; always use the last known line number. |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
748 // When it fails (e.g. Abort for already edited file) restore the |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
749 // argument index. |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
750 if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL, |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
751 eap, ECMD_LAST, |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
752 (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
753 + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
754 curwin->w_arg_idx = old_arg_idx; |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
755 // like Vi: set the mark where the cursor is in the file. |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
756 else if (eap->cmdidx != CMD_argdo) |
f1d5ad2b978e
patch 9.0.1132: code is indented more than needed
Bram Moolenaar <Bram@vim.org>
parents:
31201
diff
changeset
|
757 setmark('\''); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 * ":next", and commands that behave like it. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 ex_next(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 // check for changed buffer now, if this fails the argument list is not |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 // redefined. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 if ( buf_hide(curbuf) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 || eap->cmdidx == CMD_snext |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 || !check_changed(curbuf, CCGD_AW |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 | (eap->forceit ? CCGD_FORCEIT : 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 | CCGD_EXCMD)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 if (*eap->arg != NUL) // redefine file list |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 if (do_arglist(eap->arg, AL_SET, 0, TRUE) == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 return; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 i = 0; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 i = curwin->w_arg_idx + (int)eap->line2; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 do_argfile(eap, i); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 /* |
26719
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
789 * ":argdedupe" |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
790 */ |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
791 void |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
792 ex_argdedupe(exarg_T *eap UNUSED) |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
793 { |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
794 int i; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
795 int j; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
796 |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
797 for (i = 0; i < ARGCOUNT; ++i) |
31061
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
798 { |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
799 // Expand each argument to a full path to catch different paths leading |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
800 // to the same file. |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
801 char_u *firstFullname = FullName_save(ARGLIST[i].ae_fname, FALSE); |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
802 if (firstFullname == NULL) |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
803 return; // out of memory |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
804 |
26719
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
805 for (j = i + 1; j < ARGCOUNT; ++j) |
31061
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
806 { |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
807 char_u *secondFullname = FullName_save(ARGLIST[j].ae_fname, FALSE); |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
808 if (secondFullname == NULL) |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
809 break; // out of memory |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
810 int areNamesDuplicate = |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
811 fnamecmp(firstFullname, secondFullname) == 0; |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
812 vim_free(secondFullname); |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
813 |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
814 if (areNamesDuplicate) |
26719
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
815 { |
31061
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
816 // remove one duplicate argument |
26719
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
817 vim_free(ARGLIST[j].ae_fname); |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
818 mch_memmove(ARGLIST + j, ARGLIST + j + 1, |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
819 (ARGCOUNT - j - 1) * sizeof(aentry_T)); |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
820 --ARGCOUNT; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
821 |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
822 if (curwin->w_arg_idx == j) |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
823 curwin->w_arg_idx = i; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
824 else if (curwin->w_arg_idx > j) |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
825 --curwin->w_arg_idx; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
826 |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
827 --j; |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
828 } |
31061
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
829 } |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
830 |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
831 vim_free(firstFullname); |
2606fcb01157
patch 9.0.0865: duplicate arguments are not always detected
Bram Moolenaar <Bram@vim.org>
parents:
30825
diff
changeset
|
832 } |
26719
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
833 } |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
834 |
2bdcce61a4e4
patch 8.2.3888: the argument list may contain duplicates
Bram Moolenaar <Bram@vim.org>
parents:
26711
diff
changeset
|
835 /* |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 * ":argedit" |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 ex_argedit(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 int i = eap->addr_count ? (int)eap->line2 : curwin->w_arg_idx + 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 // Whether curbuf will be reused, curbuf->b_ffname will be set. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 int curbuf_is_reusable = curbuf_reusable(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 if (do_arglist(eap->arg, AL_ADD, i, TRUE) == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 return; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 maketitle(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 if (curwin->w_arg_idx == 0 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 && (curbuf->b_ml.ml_flags & ML_EMPTY) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 && (curbuf->b_ffname == NULL || curbuf_is_reusable)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 i = 0; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 // Edit the argument. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 if (i < ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 do_argfile(eap, i); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 * ":argadd" |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 ex_argadd(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 do_arglist(eap->arg, AL_ADD, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 eap->addr_count > 0 ? (int)eap->line2 : curwin->w_arg_idx + 1, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 FALSE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 maketitle(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 * ":argdelete" |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 ex_argdelete(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 int i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 int n; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 |
23760
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
879 if (check_arglist_locked() == FAIL) |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
880 return; |
bb2afcad503b
patch 8.2.2421: double free when using autocommand with "argdel"
Bram Moolenaar <Bram@vim.org>
parents:
23744
diff
changeset
|
881 |
21845
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
882 if (eap->addr_count > 0 || *eap->arg == NUL) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 { |
21996
808edde1e97d
patch 8.2.1547: various comment problems
Bram Moolenaar <Bram@vim.org>
parents:
21845
diff
changeset
|
884 // ":argdel" works like ":.argdel" |
21845
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
885 if (eap->addr_count == 0) |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
886 { |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
887 if (curwin->w_arg_idx >= ARGCOUNT) |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
888 { |
26863
6ee19c6ae8a2
patch 8.2.3960: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26857
diff
changeset
|
889 emsg(_(e_no_argument_to_delete)); |
21845
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
890 return; |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
891 } |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
892 eap->line1 = eap->line2 = curwin->w_arg_idx + 1; |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
893 } |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
894 else if (eap->line2 > ARGCOUNT) |
0e6ee11977b3
patch 8.2.1472: ":argdel" does not work like ":.argdel" as documented
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
895 // ":1,4argdel": Delete all arguments in the range. |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 eap->line2 = ARGCOUNT; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 n = eap->line2 - eap->line1 + 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 if (*eap->arg != NUL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 // Can't have both a range and an argument. |
26865
bce848ec8b1b
patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26863
diff
changeset
|
900 emsg(_(e_invalid_argument)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 else if (n <= 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 // Don't give an error for ":%argdel" if the list is empty. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 if (eap->line1 != 1 || eap->line2 != 0) |
25064
8f2262c72178
patch 8.2.3069: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
23843
diff
changeset
|
905 emsg(_(e_invalid_range)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 for (i = eap->line1; i <= eap->line2; ++i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 vim_free(ARGLIST[i - 1].ae_fname); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 mch_memmove(ARGLIST + eap->line1 - 1, ARGLIST + eap->line2, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 (size_t)((ARGCOUNT - eap->line2) * sizeof(aentry_T))); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 ALIST(curwin)->al_ga.ga_len -= n; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 if (curwin->w_arg_idx >= eap->line2) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 curwin->w_arg_idx -= n; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 else if (curwin->w_arg_idx > eap->line1) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 curwin->w_arg_idx = eap->line1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 if (ARGCOUNT == 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 curwin->w_arg_idx = 0; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 else if (curwin->w_arg_idx >= ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 curwin->w_arg_idx = ARGCOUNT - 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 do_arglist(eap->arg, AL_DEL, 0, FALSE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 maketitle(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 * Function given to ExpandGeneric() to obtain the possible arguments of the |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 * argedit and argdelete commands. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 char_u * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 get_arglist_name(expand_T *xp UNUSED, int idx) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 if (idx >= ARGCOUNT) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 return NULL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 return alist_name(&ARGLIST[idx]); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 * Get the file name for an argument list entry. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 char_u * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 alist_name(aentry_T *aep) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 buf_T *bp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 // Use the name from the associated buffer if it exists. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 bp = buflist_findnr(aep->ae_fnum); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 if (bp == NULL || bp->b_fname == NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 return aep->ae_fname; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 return bp->b_fname; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 /* |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
958 * State used by the :all command to open all the files in the argument list in |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
959 * separate windows. |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 */ |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
961 typedef struct { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
962 alist_T *alist; // argument list to be used |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
963 int had_tab; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
964 int keep_tabs; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
965 int forceit; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
966 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
967 int use_firstwin; // use first window for arglist |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 char_u *opened; // Array of weight for which args are open: |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 // 0: not opened |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 // 1: opened in other tab |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 // 2: opened in curtab |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 // 3: opened in curtab and curwin |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 int opened_len; // length of opened[] |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
974 win_T *new_curwin; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
975 tabpage_T *new_curtab; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
976 } arg_all_state_T; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
978 /* |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
979 * Close all the windows containing files which are not in the argument list. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
980 * Used by the ":all" command. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
981 */ |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
982 static void |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
983 arg_all_close_unused_windows(arg_all_state_T *aall) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
984 { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
985 win_T *wp; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
986 win_T *wpnext; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
987 tabpage_T *tpnext; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
988 buf_T *buf; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
989 int i; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
990 win_T *old_curwin; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
991 tabpage_T *old_curtab; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 old_curwin = curwin; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 old_curtab = curtab; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
996 if (aall->had_tab > 0) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 goto_tabpage_tp(first_tabpage, TRUE, TRUE); |
33947
f4d88db48a63
patch 9.0.2168: Moving tabpages on :drop may cause an endless loop
Christian Brabandt <cb@256bit.org>
parents:
32282
diff
changeset
|
998 |
f4d88db48a63
patch 9.0.2168: Moving tabpages on :drop may cause an endless loop
Christian Brabandt <cb@256bit.org>
parents:
32282
diff
changeset
|
999 // moving tabpages around in an autocommand may cause an endless loop |
f4d88db48a63
patch 9.0.2168: Moving tabpages on :drop may cause an endless loop
Christian Brabandt <cb@256bit.org>
parents:
32282
diff
changeset
|
1000 tabpage_move_disallowed++; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 for (;;) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 tpnext = curtab->tp_next; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 for (wp = firstwin; wp != NULL; wp = wpnext) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 wpnext = wp->w_next; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 buf = wp->w_buffer; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 if (buf->b_ffname == NULL |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1009 || (!aall->keep_tabs && (buf->b_nwindows > 1 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 || wp->w_width != Columns))) |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1011 i = aall->opened_len; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 // check if the buffer in this window is in the arglist |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1015 for (i = 0; i < aall->opened_len; ++i) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1017 if (i < aall->alist->al_ga.ga_len |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1018 && (AARGLIST(aall->alist)[i].ae_fnum == buf->b_fnum |
30325
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30104
diff
changeset
|
1019 || fullpathcmp(alist_name( |
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30104
diff
changeset
|
1020 &AARGLIST(aall->alist)[i]), |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 buf->b_ffname, TRUE, TRUE) & FPC_SAME)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 int weight = 1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 if (old_curtab == curtab) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 ++weight; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 if (old_curwin == wp) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 ++weight; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1032 if (weight > (int)aall->opened[i]) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1034 aall->opened[i] = (char_u)weight; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 if (i == 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1037 if (aall->new_curwin != NULL) |
30325
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30104
diff
changeset
|
1038 aall->new_curwin->w_arg_idx = |
58fb880f3607
patch 9.0.0498: various small issues
Bram Moolenaar <Bram@vim.org>
parents:
30104
diff
changeset
|
1039 aall->opened_len; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1040 aall->new_curwin = wp; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1041 aall->new_curtab = curtab; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1044 else if (aall->keep_tabs) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1045 i = aall->opened_len; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1047 if (wp->w_alist != aall->alist) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 // Use the current argument list for all windows |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 // containing a file from it. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 alist_unlink(wp->w_alist); |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1052 wp->w_alist = aall->alist; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 ++wp->w_alist->al_refcount; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 wp->w_arg_idx = i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1061 if (i == aall->opened_len && !aall->keep_tabs)// close this window |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1063 if (buf_hide(buf) || aall->forceit || buf->b_nwindows > 1 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 || !bufIsChanged(buf)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 // If the buffer was changed, and we would like to hide it, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 // try autowriting. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 if (!buf_hide(buf) && buf->b_nwindows <= 1 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 && bufIsChanged(buf)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 bufref_T bufref; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 set_bufref(&bufref, buf); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 (void)autowrite(buf, FALSE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 // check if autocommands removed the window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 if (!win_valid(wp) || !bufref_valid(&bufref)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 wpnext = firstwin; // start all over... |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 continue; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 // don't close last window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 if (ONE_WINDOW |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1086 && (first_tabpage->tp_next == NULL |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1087 || !aall->had_tab)) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1088 aall->use_firstwin = TRUE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 win_close(wp, !buf_hide(buf) && !bufIsChanged(buf)); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 // check if autocommands removed the next window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 if (!win_valid(wpnext)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 wpnext = firstwin; // start all over... |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 // Without the ":tab" modifier only do the current tab page. |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1102 if (aall->had_tab == 0 || tpnext == NULL) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 // check if autocommands removed the next tab page |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 if (!valid_tabpage(tpnext)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 tpnext = first_tabpage; // start all over... |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 goto_tabpage_tp(tpnext, TRUE, TRUE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 } |
33947
f4d88db48a63
patch 9.0.2168: Moving tabpages on :drop may cause an endless loop
Christian Brabandt <cb@256bit.org>
parents:
32282
diff
changeset
|
1111 tabpage_move_disallowed--; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1112 } |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1114 /* |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1115 * Open upto "count" windows for the files in the argument list 'aall->alist'. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1116 */ |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1117 static void |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1118 arg_all_open_windows(arg_all_state_T *aall, int count) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1119 { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1120 win_T *wp; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1121 int tab_drop_empty_window = FALSE; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1122 int i; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1123 int split_ret = OK; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1124 int p_ea_save; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1125 |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1126 // ":tab drop file" should re-use an empty window to avoid "--remote-tab" |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 // leaving an empty tab page when executed locally. |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1128 if (aall->keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 && curbuf->b_ffname == NULL && !curbuf->b_changed) |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1130 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1131 aall->use_firstwin = TRUE; |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1132 tab_drop_empty_window = TRUE; |
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1133 } |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1135 for (i = 0; i < count && !got_int; ++i) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1137 if (aall->alist == &global_alist && i == global_alist.al_ga.ga_len - 1) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 arg_had_last = TRUE; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1139 if (aall->opened[i] > 0) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 // Move the already present window to below the current window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 if (curwin->w_arg_idx != i) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1144 FOR_ALL_WINDOWS(wp) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1146 if (wp->w_arg_idx == i) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1148 if (aall->keep_tabs) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1150 aall->new_curwin = wp; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1151 aall->new_curtab = curtab; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1153 else if (wp->w_frame->fr_parent |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1154 != curwin->w_frame->fr_parent) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 { |
26863
6ee19c6ae8a2
patch 8.2.3960: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
26857
diff
changeset
|
1156 emsg(_(e_window_layout_changed_unexpectedly)); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 i = count; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 else |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1161 win_move_after(wp, curwin); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 else if (split_ret == OK) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 { |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1169 // trigger events for tab drop |
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1170 if (tab_drop_empty_window && i == count - 1) |
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1171 --autocmd_no_enter; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1172 if (!aall->use_firstwin) // split current window |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 p_ea_save = p_ea; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 p_ea = TRUE; // use space from all windows |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 split_ret = win_split(0, WSP_ROOM | WSP_BELOW); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 p_ea = p_ea_save; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 if (split_ret == FAIL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 continue; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 else // first window: do autocmd for leaving this buffer |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 --autocmd_no_leave; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 // edit file "i" |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 curwin->w_arg_idx = i; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 if (i == 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 { |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1188 aall->new_curwin = curwin; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1189 aall->new_curtab = curtab; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1191 (void)do_ecmd(0, alist_name(&AARGLIST(aall->alist)[i]), NULL, NULL, |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1192 ECMD_ONE, |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1193 ((buf_hide(curwin->w_buffer) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1194 || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1195 + ECMD_OLDBUF, curwin); |
19112
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1196 if (tab_drop_empty_window && i == count - 1) |
0b337617877e
patch 8.2.0116: BufEnter autocmd not triggered on ":tab drop"
Bram Moolenaar <Bram@vim.org>
parents:
17781
diff
changeset
|
1197 ++autocmd_no_enter; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1198 if (aall->use_firstwin) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 ++autocmd_no_leave; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1200 aall->use_firstwin = FALSE; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 ui_breakcheck(); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 // When ":tab" was used open a new tab for a new window repeatedly. |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1205 if (aall->had_tab > 0 && tabpage_index(NULL) <= p_tpm) |
22699
e82579016863
patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents:
21996
diff
changeset
|
1206 cmdmod.cmod_tab = 9999; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 } |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1208 } |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1209 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1210 /* |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1211 * do_arg_all(): Open up to "count" windows, one for each argument. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1212 */ |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1213 static void |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1214 do_arg_all( |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1215 int count, |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1216 int forceit, // hide buffers in current windows |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1217 int keep_tabs) // keep current tabs, for ":tab drop file" |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1218 { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1219 arg_all_state_T aall; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1220 win_T *last_curwin; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1221 tabpage_T *last_curtab; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1222 int prev_arglist_locked = arglist_locked; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1223 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1224 if (cmdwin_type != 0) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1225 { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1226 emsg(_(e_invalid_in_cmdline_window)); |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1227 return; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1228 } |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1229 if (ARGCOUNT <= 0) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1230 { |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1231 // Don't give an error message. We don't want it when the ":all" |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1232 // command is in the .vimrc. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1233 return; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1234 } |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1235 setpcmark(); |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1236 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1237 aall.use_firstwin = FALSE; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1238 aall.had_tab = cmdmod.cmod_tab; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1239 aall.new_curwin = NULL; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1240 aall.new_curtab = NULL; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1241 aall.forceit = forceit; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1242 aall.keep_tabs = keep_tabs; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1243 aall.opened_len = ARGCOUNT; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1244 aall.opened = alloc_clear(aall.opened_len); |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1245 if (aall.opened == NULL) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1246 return; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1247 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1248 // Autocommands may do anything to the argument list. Make sure it's not |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1249 // freed while we are working here by "locking" it. We still have to |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1250 // watch out for its size being changed. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1251 aall.alist = curwin->w_alist; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1252 ++aall.alist->al_refcount; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1253 arglist_locked = TRUE; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1254 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1255 #ifdef FEAT_GUI |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1256 need_mouse_correct = TRUE; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1257 #endif |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1258 |
32282
e47739c49487
patch 9.0.1472: ":drop fname" may change the last used tab page
Bram Moolenaar <Bram@vim.org>
parents:
31600
diff
changeset
|
1259 tabpage_T *new_lu_tp = curtab; |
e47739c49487
patch 9.0.1472: ":drop fname" may change the last used tab page
Bram Moolenaar <Bram@vim.org>
parents:
31600
diff
changeset
|
1260 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1261 // Try closing all windows that are not in the argument list. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1262 // Also close windows that are not full width; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1263 // When 'hidden' or "forceit" set the buffer becomes hidden. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1264 // Windows that have a changed buffer and can't be hidden won't be closed. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1265 // When the ":tab" modifier was used do this for all tab pages. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1266 arg_all_close_unused_windows(&aall); |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1267 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1268 // Open a window for files in the argument list that don't have one. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1269 // ARGCOUNT may change while doing this, because of autocommands. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1270 if (count > aall.opened_len || count <= 0) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1271 count = aall.opened_len; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1272 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1273 // Don't execute Win/Buf Enter/Leave autocommands here. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1274 ++autocmd_no_enter; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1275 ++autocmd_no_leave; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1276 last_curwin = curwin; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1277 last_curtab = curtab; |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1278 win_enter(lastwin, FALSE); |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1279 |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1280 /* |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1281 * Open upto "count" windows. |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1282 */ |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1283 arg_all_open_windows(&aall, count); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 // Remove the "lock" on the argument list. |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1286 alist_unlink(aall.alist); |
26711
5860bd619d30
patch 8.2.3884: crash when clearing the argument list while using it
Bram Moolenaar <Bram@vim.org>
parents:
26336
diff
changeset
|
1287 arglist_locked = prev_arglist_locked; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 --autocmd_no_enter; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 // restore last referenced tabpage's curwin |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1292 if (last_curtab != aall.new_curtab) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 if (valid_tabpage(last_curtab)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 goto_tabpage_tp(last_curtab, TRUE, TRUE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 if (win_valid(last_curwin)) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 win_enter(last_curwin, FALSE); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 // to window with first arg |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1300 if (valid_tabpage(aall.new_curtab)) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1301 goto_tabpage_tp(aall.new_curtab, TRUE, TRUE); |
34305
9335b3e58558
patch 9.1.0087: Restoring lastused_tabpage too early in do_arg_all()
Christian Brabandt <cb@256bit.org>
parents:
34190
diff
changeset
|
1302 |
9335b3e58558
patch 9.1.0087: Restoring lastused_tabpage too early in do_arg_all()
Christian Brabandt <cb@256bit.org>
parents:
34190
diff
changeset
|
1303 // Now set the last used tabpage to where we started. |
9335b3e58558
patch 9.1.0087: Restoring lastused_tabpage too early in do_arg_all()
Christian Brabandt <cb@256bit.org>
parents:
34190
diff
changeset
|
1304 if (valid_tabpage(new_lu_tp)) |
9335b3e58558
patch 9.1.0087: Restoring lastused_tabpage too early in do_arg_all()
Christian Brabandt <cb@256bit.org>
parents:
34190
diff
changeset
|
1305 lastused_tabpage = new_lu_tp; |
9335b3e58558
patch 9.1.0087: Restoring lastused_tabpage too early in do_arg_all()
Christian Brabandt <cb@256bit.org>
parents:
34190
diff
changeset
|
1306 |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1307 if (win_valid(aall.new_curwin)) |
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1308 win_enter(aall.new_curwin, FALSE); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 --autocmd_no_leave; |
30104
dd97e797fffb
patch 9.0.0388: the do_arg_all() function is too long
Bram Moolenaar <Bram@vim.org>
parents:
30100
diff
changeset
|
1311 vim_free(aall.opened); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 * ":all" and ":sall". |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 * Also used for ":tab drop file ..." after setting the argument list. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 ex_all(exarg_T *eap) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 if (eap->addr_count == 0) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 eap->line2 = 9999; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 do_arg_all((int)eap->line2, eap->forceit, eap->cmdidx == CMD_drop); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 * Concatenate all files in the argument list, separated by spaces, and return |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 * it in one allocated string. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 * Spaces and backslashes in the file names are escaped with a backslash. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 * Returns NULL when out of memory. |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 char_u * |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 arg_all(void) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 int len; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1336 int idx; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1337 char_u *retval = NULL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 char_u *p; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 // Do this loop two times: |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 // first time: compute the total length |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 // second time: concatenate the names |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 for (;;) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 len = 0; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 for (idx = 0; idx < ARGCOUNT; ++idx) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 p = alist_name(&ARGLIST[idx]); |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1349 if (p == NULL) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1350 continue; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1351 if (len > 0) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1353 // insert a space in between names |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1354 if (retval != NULL) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1355 retval[len] = ' '; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1356 ++len; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1357 } |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1358 for ( ; *p != NUL; ++p) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1359 { |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1360 if (*p == ' ' |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1361 #ifndef BACKSLASH_IN_FILENAME |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1362 || *p == '\\' |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1363 #endif |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1364 || *p == '`') |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 { |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1366 // insert a backslash |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 if (retval != NULL) |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1368 retval[len] = '\\'; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 ++len; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 } |
29566
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1371 if (retval != NULL) |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1372 retval[len] = *p; |
99e3763cbd34
patch 9.0.0124: code has more indent than needed
Bram Moolenaar <Bram@vim.org>
parents:
27521
diff
changeset
|
1373 ++len; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 // second time: break here |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 if (retval != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 retval[len] = NUL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 // allocate memory |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 retval = alloc(len + 1); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 if (retval == NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 break; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 return retval; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 #if defined(FEAT_EVAL) || defined(PROTO) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 * "argc([window id])" function |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 f_argc(typval_T *argvars, typval_T *rettv) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 win_T *wp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1402 if (in_vim9script() && check_for_opt_number_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1403 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1404 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 if (argvars[0].v_type == VAR_UNKNOWN) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 // use the current window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 rettv->vval.v_number = ARGCOUNT; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 else if (argvars[0].v_type == VAR_NUMBER |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 && tv_get_number(&argvars[0]) == -1) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 // use the global argument list |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 rettv->vval.v_number = GARGCOUNT; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 // use the argument list of the specified window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 wp = find_win_by_nr_or_id(&argvars[0]); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 if (wp != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 rettv->vval.v_number = WARGCOUNT(wp); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 else |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 rettv->vval.v_number = -1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 * "argidx()" function |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 f_argidx(typval_T *argvars UNUSED, typval_T *rettv) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 rettv->vval.v_number = curwin->w_arg_idx; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 * "arglistid()" function |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 f_arglistid(typval_T *argvars, typval_T *rettv) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 win_T *wp; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1440 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1441 && (check_for_opt_number_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1442 || (argvars[0].v_type != VAR_UNKNOWN |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1443 && check_for_opt_number_arg(argvars, 1) == FAIL))) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1444 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1445 |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 rettv->vval.v_number = -1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 wp = find_tabwin(&argvars[0], &argvars[1], NULL); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 if (wp != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 rettv->vval.v_number = wp->w_alist->id; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 * Get the argument list for a given window |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 static void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 get_arglist_as_rettv(aentry_T *arglist, int argcount, typval_T *rettv) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 int idx; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 if (rettv_list_alloc(rettv) == OK && arglist != NULL) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 for (idx = 0; idx < argcount; ++idx) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 list_append_string(rettv->vval.v_list, |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 alist_name(&arglist[idx]), -1); |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 /* |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 * "argv(nr)" function |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 */ |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 void |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 f_argv(typval_T *argvars, typval_T *rettv) |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 { |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 int idx; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 aentry_T *arglist = NULL; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 int argcount = -1; |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1476 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1477 && (check_for_opt_number_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1478 || (argvars[0].v_type != VAR_UNKNOWN |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1479 && check_for_opt_number_arg(argvars, 1) == FAIL))) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1480 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25064
diff
changeset
|
1481 |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1482 if (argvars[0].v_type == VAR_UNKNOWN) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1483 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1484 get_arglist_as_rettv(ARGLIST, ARGCOUNT, rettv); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1485 return; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1486 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1487 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1488 if (argvars[1].v_type == VAR_UNKNOWN) |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 { |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1490 arglist = ARGLIST; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1491 argcount = ARGCOUNT; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1492 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1493 else if (argvars[1].v_type == VAR_NUMBER |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1494 && tv_get_number(&argvars[1]) == -1) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1495 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1496 arglist = GARGLIST; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1497 argcount = GARGCOUNT; |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 else |
30100
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1500 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1501 win_T *wp = find_win_by_nr_or_id(&argvars[1]); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1502 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1503 if (wp != NULL) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1504 { |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1505 // Use the argument list of the specified window |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1506 arglist = WARGLIST(wp); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1507 argcount = WARGCOUNT(wp); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1508 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1509 } |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1510 |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1511 rettv->v_type = VAR_STRING; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1512 rettv->vval.v_string = NULL; |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1513 idx = tv_get_number_chk(&argvars[0], NULL); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1514 if (arglist != NULL && idx >= 0 && idx < argcount) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1515 rettv->vval.v_string = vim_strsave(alist_name(&arglist[idx])); |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1516 else if (idx == -1) |
84c18beec6bc
patch 9.0.0386: some code blocks are nested too deep
Bram Moolenaar <Bram@vim.org>
parents:
29566
diff
changeset
|
1517 get_arglist_as_rettv(arglist, argcount, rettv); |
17744
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 } |
4a3dca734d36
patch 8.1.1869: code for the argument list is spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 #endif |