annotate src/quickfix.c @ 7391:4761fed349ed v7.4.1000

commit https://github.com/vim/vim/commit/c06624661a3aa6642304c06db9cebe553a4cab17 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 30 15:49:05 2015 +0100 patch 7.4.1000 Problem: Test 49 is slow and doesn't work on MS-Windows. Solution: Start moving parts of test 49 to test_viml.
author Christian Brabandt <cb@256bit.org>
date Wed, 30 Dec 2015 16:00:05 +0100
parents 64e30831fa42
children e7874551bb34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * quickfix.c: functions for quickfix mode, using a file with error messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 #if defined(FEAT_QUICKFIX) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 struct dir_stack_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 struct dir_stack_T *next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 char_u *dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 static struct dir_stack_T *dir_stack = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 /*
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
27 * For each error the next struct is allocated and linked in a list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
29 typedef struct qfline_S qfline_T;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
30 struct qfline_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
32 qfline_T *qf_next; /* pointer to next error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
33 qfline_T *qf_prev; /* pointer to previous error in the list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
34 linenr_T qf_lnum; /* line number where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
35 int qf_fnum; /* file number for the line */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
36 int qf_col; /* column where the error occurred */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
37 int qf_nr; /* error number */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
38 char_u *qf_pattern; /* search pattern for the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
39 char_u *qf_text; /* description of the error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
40 char_u qf_viscol; /* set to TRUE if qf_col is screen column */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
41 char_u qf_cleared; /* set to TRUE if line has been deleted */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
42 char_u qf_type; /* type of the error (mostly 'E'); 1 for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 :helpgrep */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
44 char_u qf_valid; /* valid error message detected */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 * There is a stack of error lists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 #define LISTCOUNT 10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
52 typedef struct qf_list_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
54 qfline_T *qf_start; /* pointer to the first error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
55 qfline_T *qf_ptr; /* pointer to the current error */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
56 int qf_count; /* number of errors (0 means no error list) */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
57 int qf_index; /* current index in the error list */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
58 int qf_nonevalid; /* TRUE if not a single valid entry found */
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
59 char_u *qf_title; /* title derived from the command that created
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
60 * the error list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
61 } qf_list_T;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
62
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
63 struct qf_info_S
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
64 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
65 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
66 * Count of references to this list. Used only for location lists.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
67 * When a location list window reference this list, qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
68 * will be 2. Otherwise, qf_refcount will be 1. When qf_refcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
69 * reaches 0, the list is freed.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
70 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
71 int qf_refcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
72 int qf_listcount; /* current number of lists */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
73 int qf_curlist; /* current error list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
74 qf_list_T qf_lists[LISTCOUNT];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
75 };
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
76
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
77 static qf_info_T ql_info; /* global quickfix list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
79 #define FMT_PATTERNS 10 /* maximum number of % recognized */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 * Structure used to hold the info of one part of 'errorformat'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
84 typedef struct efm_S efm_T;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
85 struct efm_S
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 regprog_T *prog; /* pre-formatted part of 'errorformat' */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
88 efm_T *next; /* pointer to next (NULL if last) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 char_u addr[FMT_PATTERNS]; /* indices of used % patterns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 char_u prefix; /* prefix of this format line: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 /* 'D' enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 /* 'X' leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 /* 'A' start of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 /* 'E' error message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 /* 'W' warning message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 /* 'I' informational message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 /* 'C' continuation line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 /* 'Z' end of multi-line message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 /* 'G' general, unspecific message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 /* 'P' push file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 /* 'Q' pop/quit file (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 /* 'O' overread (partial) message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 char_u flags; /* additional flags given in prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 /* '-' do not include this line */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
105 /* '+' include whole line in message */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
106 int conthere; /* %> used */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
109 static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast, char_u *qf_title));
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
110 static void qf_store_title __ARGS((qf_info_T *qi, char_u *title));
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
111 static void qf_new_list __ARGS((qf_info_T *qi, char_u *qf_title));
1571
26d879bcab3a updated for version 7.1-284
vimboss
parents: 1521
diff changeset
112 static void ll_free_all __ARGS((qf_info_T **pqi));
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
113 static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
1571
26d879bcab3a updated for version 7.1-284
vimboss
parents: 1521
diff changeset
114 static qf_info_T *ll_new_list __ARGS((void));
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
115 static void qf_msg __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
116 static void qf_free __ARGS((qf_info_T *qi, int idx));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 static char_u *qf_types __ARGS((int, int));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 static int qf_get_fnum __ARGS((char_u *, char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 static char_u *qf_push_dir __ARGS((char_u *, struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 static char_u *qf_pop_dir __ARGS((struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 static char_u *qf_guess_filepath __ARGS((char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 static void qf_fmt_text __ARGS((char_u *text, char_u *buf, int bufsize));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 static void qf_clean_dir_stack __ARGS((struct dir_stack_T **));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
125 static int qf_win_pos_update __ARGS((qf_info_T *qi, int old_qf_index));
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
126 static int is_qf_win __ARGS((win_T *win, qf_info_T *qi));
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
127 static win_T *qf_find_win __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
128 static buf_T *qf_find_buf __ARGS((qf_info_T *qi));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
129 static void qf_update_buffer __ARGS((qf_info_T *qi));
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
130 static void qf_set_title_var __ARGS((qf_info_T *qi));
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
131 static void qf_fill_buffer __ARGS((qf_info_T *qi));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 static char_u *get_mef_name __ARGS((void));
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
134 static void restore_start_dir __ARGS((char_u *dirname_start));
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
135 static buf_T *load_dummy_buffer __ARGS((char_u *fname, char_u *dirname_start, char_u *resulting_dir));
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
136 static void wipe_dummy_buffer __ARGS((buf_T *buf, char_u *dirname_start));
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
137 static void unload_dummy_buffer __ARGS((buf_T *buf, char_u *dirname_start));
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
138 static qf_info_T *ll_get_or_alloc_list __ARGS((win_T *));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
140 /* Quickfix window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
141 #define IS_QF_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
142 /* Location list window check helper macro */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
143 #define IS_LL_WINDOW(wp) (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
144 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
145 * Return location list for window 'wp'
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
146 * For location list window, return the referenced location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
147 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
148 #define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
149
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
151 * Read the errorfile "efile" into memory, line by line, building the error
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
152 * list. Set the error list's title to qf_title.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 * Return -1 for error, number of errors for success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 int
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
156 qf_init(wp, efile, errorformat, newlist, qf_title)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
157 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 char_u *efile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 char_u *errorformat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 int newlist; /* TRUE: start a new error list */
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
161 char_u *qf_title;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
163 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
164
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
165 if (efile == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
166 return FAIL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
167
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
168 if (wp != NULL)
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
169 {
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
170 qi = ll_get_or_alloc_list(wp);
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
171 if (qi == NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
172 return FAIL;
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
173 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
174
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
175 return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist,
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
176 (linenr_T)0, (linenr_T)0,
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
177 qf_title);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
178 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
179
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
180 /*
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
181 * Read the errorfile "efile" into memory, line by line, building the error
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
182 * list.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
183 * Alternative: when "efile" is null read errors from buffer "buf".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
184 * Always use 'errorformat' from "buf" if there is a local value.
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
185 * Then "lnumfirst" and "lnumlast" specify the range of lines to use.
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
186 * Set the title of the list to "qf_title".
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
187 * Return -1 for error, number of errors for success.
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
188 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
189 static int
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
190 qf_init_ext(qi, efile, buf, tv, errorformat, newlist, lnumfirst, lnumlast,
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
191 qf_title)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
192 qf_info_T *qi;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
193 char_u *efile;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
194 buf_T *buf;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
195 typval_T *tv;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
196 char_u *errorformat;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
197 int newlist; /* TRUE: start a new error list */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
198 linenr_T lnumfirst; /* first line number to use */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
199 linenr_T lnumlast; /* last line number to use */
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
200 char_u *qf_title;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
201 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 char_u *namebuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 char_u *errmsg;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
204 char_u *pattern;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 char_u *fmtstr = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 int col = 0;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
207 char_u use_viscol = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 int type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 int valid;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
210 linenr_T buflnum = lnumfirst;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 long lnum = 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 int enr = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
213 FILE *fd = NULL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
214 qfline_T *qfprev = NULL; /* init to make SASC shut up */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 char_u *efmp;
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
216 efm_T *fmt_first = NULL;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
217 efm_T *fmt_last = NULL;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
218 efm_T *fmt_ptr;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
219 efm_T *fmt_start = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 char_u *efm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 char_u *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 char_u *srcptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 int round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 int idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 int multiline = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 int multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 int multiscan = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 int retval = -1; /* default: return error flag */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 char_u *directory = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 char_u *currfile = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 char_u *tail = NULL;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
234 char_u *p_str = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
235 listitem_T *p_li = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 struct dir_stack_T *file_stack = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 static struct fmtpattern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 char_u convchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 char *pattern;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 } fmt_pat[FMT_PATTERNS] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
244 {'f', ".\\+"}, /* only used when at end */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {'n', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 {'l', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {'c', "\\d\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {'t', "."},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 {'m', ".\\+"},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 {'r', ".*"},
3555
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
251 {'p', "[- .]*"},
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
252 {'v', "\\d\\+"},
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
253 {'s', ".\\+"}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 namebuf = alloc(CMDBUFFSIZE + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 errmsg = alloc(CMDBUFFSIZE + 1);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
258 pattern = alloc(CMDBUFFSIZE + 1);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
259 if (namebuf == NULL || errmsg == NULL || pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
262 if (efile != NULL && (fd = mch_fopen((char *)efile, "r")) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 EMSG2(_(e_openerrf), efile);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 goto qf_init_end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
268 if (newlist || qi->qf_curlist == qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
270 qf_new_list(qi, qf_title);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
271 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
273 for (qfprev = qi->qf_lists[qi->qf_curlist].qf_start;
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
274 qfprev->qf_next != qfprev; qfprev = qfprev->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 * Each part of the format string is copied and modified from errorformat to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 * regex prog. Only a few % characters are allowed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 /* Use the local value of 'errorformat' if it's set. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
282 if (errorformat == p_efm && tv == NULL && *buf->b_p_efm != NUL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
283 efm = buf->b_p_efm;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 efm = errorformat;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 * Get some space to modify the format string into.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 i = (FMT_PATTERNS * 3) + ((int)STRLEN(efm) << 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 for (round = FMT_PATTERNS; round > 0; )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 i += (int)STRLEN(fmt_pat[--round].pattern);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 #ifdef COLON_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 i += 12; /* "%f" can become twelve chars longer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 i += 2; /* "%f" can become two chars longer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 if ((fmtstr = alloc(i)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
300 while (efm[0] != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 * Allocate a new eformat structure and put it at the end of the list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 */
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
305 fmt_ptr = (efm_T *)alloc_clear((unsigned)sizeof(efm_T));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 if (fmt_ptr == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 if (fmt_first == NULL) /* first one */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 fmt_first = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 fmt_last->next = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 fmt_last = fmt_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 * Isolate one part in the 'errorformat' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 for (len = 0; efm[len] != NUL && efm[len] != ','; ++len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 if (efm[len] == '\\' && efm[len + 1] != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 ++len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 * Build regexp pattern from current 'errorformat' option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 ptr = fmtstr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 *ptr++ = '^';
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
326 round = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 for (efmp = efm; efmp < efm + len; ++efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 if (*efmp == '%')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 ++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 for (idx = 0; idx < FMT_PATTERNS; ++idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 if (fmt_pat[idx].convchar == *efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 if (idx < FMT_PATTERNS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 if (fmt_ptr->addr[idx])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 _("E372: Too many %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 if ((idx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 && idx < 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 && vim_strchr((char_u *)"DXOPQ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 fmt_ptr->prefix) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 || (idx == 6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 && vim_strchr((char_u *)"OPQ",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 fmt_ptr->prefix) == NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 _("E373: Unexpected %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 fmt_ptr->addr[idx] = (char_u)++round;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 *ptr++ = '(';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 #ifdef BACKSLASH_IN_FILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 if (*efmp == 'f')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 /* Also match "c:" in the file name, even when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 * checking for a colon next: "%f:".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 * "\%(\a:\)\=" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 STRCPY(ptr, "\\%(\\a:\\)\\=");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 ptr += 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
370 if (*efmp == 'f' && efmp[1] != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 {
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
372 if (efmp[1] != '\\' && efmp[1] != '%')
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
373 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
374 /* A file name may contain spaces, but this isn't
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
375 * in "\f". For "%f:%l:%m" there may be a ":" in
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
376 * the file name. Use ".\{-1,}x" instead (x is
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
377 * the next character), the requirement that :999:
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
378 * follows should work. */
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
379 STRCPY(ptr, ".\\{-1,}");
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
380 ptr += 7;
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
381 }
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
382 else
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
383 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
384 /* File name followed by '\\' or '%': include as
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
385 * many file name chars as possible. */
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
386 STRCPY(ptr, "\\f\\+");
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
387 ptr += 4;
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 461
diff changeset
388 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 srcptr = (char_u *)fmt_pat[idx].pattern;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 while ((*ptr = *srcptr++) != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 ++ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 *ptr++ = ')';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 else if (*efmp == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 if (*++efmp == '[' || *efmp == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 if ((*ptr++ = *efmp) == '[') /* %*[^a-z0-9] etc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 if (efmp[1] == '^')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 *ptr++ = *++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 if (efmp < efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 *ptr++ = *++efmp; /* could be ']' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 while (efmp < efm + len
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 && (*ptr++ = *++efmp) != ']')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 /* skip */;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 if (efmp == efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 EMSG(_("E374: Missing ] in format string"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 else if (efmp < efm + len) /* %*\D, %*\s etc. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 *ptr++ = *++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 *ptr++ = '\\';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 *ptr++ = '+';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 /* TODO: scanf()-like: %*ud, %*3c, %*f, ... ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 _("E375: Unsupported %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 else if (vim_strchr((char_u *)"%\\.^$~[", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 *ptr++ = *efmp; /* regexp magic characters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 else if (*efmp == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 *ptr++ = '*';
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
438 else if (*efmp == '>')
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
439 fmt_ptr->conthere = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 else if (efmp == efm + 1) /* analyse prefix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 if (vim_strchr((char_u *)"+-", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 fmt_ptr->flags = *efmp++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 if (vim_strchr((char_u *)"DXAEWICZGOPQ", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 fmt_ptr->prefix = *efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 _("E376: Invalid %%%c in format string prefix"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 sprintf((char *)errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 _("E377: Invalid %%%c in format string"), *efmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 EMSG(errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 else /* copy normal character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 if (*efmp == '\\' && efmp + 1 < efm + len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 ++efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 else if (vim_strchr((char_u *)".*^$~[", *efmp) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 *ptr++ = '\\'; /* escape regexp atoms */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 if (*efmp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 *ptr++ = *efmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 *ptr++ = '$';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 *ptr = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 if ((fmt_ptr->prog = vim_regcomp(fmtstr, RE_MAGIC + RE_STRING)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 * Advance to next part
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 efm = skip_to_option_part(efm + len); /* skip comma and spaces */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 if (fmt_first == NULL) /* nothing found */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 EMSG(_("E378: 'errorformat' contains no pattern"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 * got_int is reset here, because it was probably set when killing the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 * ":make" command, but we still want to read the errorfile then.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 got_int = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 /* Always ignore case when looking for a matching error. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 regmatch.rm_ic = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
496 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
497 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
498 if (tv->v_type == VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
499 p_str = tv->vval.v_string;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
500 else if (tv->v_type == VAR_LIST)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
501 p_li = tv->vval.v_list->lv_first;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
502 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
503
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 * Read the lines in the error file one by one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 * Try to recognize one of the error formats in each line.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
508 while (!got_int)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 {
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
510 /* Get the next line. */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
511 if (fd == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
512 {
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
513 if (tv != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
514 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
515 if (tv->v_type == VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
516 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
517 /* Get the next line from the supplied string */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
518 char_u *p;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
519
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
520 if (!*p_str) /* Reached the end of the string */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
521 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
522
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
523 p = vim_strchr(p_str, '\n');
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
524 if (p)
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 798
diff changeset
525 len = (int)(p - p_str + 1);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
526 else
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 798
diff changeset
527 len = (int)STRLEN(p_str);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
528
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
529 if (len > CMDBUFFSIZE - 2)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
530 vim_strncpy(IObuff, p_str, CMDBUFFSIZE - 2);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
531 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
532 vim_strncpy(IObuff, p_str, len);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
533
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
534 p_str += len;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
535 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
536 else if (tv->v_type == VAR_LIST)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
537 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
538 /* Get the next line from the supplied list */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
539 while (p_li && p_li->li_tv.v_type != VAR_STRING)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
540 p_li = p_li->li_next; /* Skip non-string items */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
541
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
542 if (!p_li) /* End of the list */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
543 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
544
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 798
diff changeset
545 len = (int)STRLEN(p_li->li_tv.vval.v_string);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
546 if (len > CMDBUFFSIZE - 2)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
547 len = CMDBUFFSIZE - 2;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
548
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
549 vim_strncpy(IObuff, p_li->li_tv.vval.v_string, len);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
550
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
551 p_li = p_li->li_next; /* next item */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
552 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
553 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
554 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
555 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
556 /* Get the next line from the supplied buffer */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
557 if (buflnum > lnumlast)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
558 break;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
559 vim_strncpy(IObuff, ml_get_buf(buf, buflnum++, FALSE),
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
560 CMDBUFFSIZE - 2);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
561 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
562 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
563 else if (fgets((char *)IObuff, CMDBUFFSIZE - 2, fd) == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
564 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
565
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 IObuff[CMDBUFFSIZE - 2] = NUL; /* for very long lines */
3002
7d4e5e31d8c1 updated for version 7.3.273
Bram Moolenaar <bram@vim.org>
parents: 2847
diff changeset
567 #ifdef FEAT_MBYTE
7d4e5e31d8c1 updated for version 7.3.273
Bram Moolenaar <bram@vim.org>
parents: 2847
diff changeset
568 remove_bom(IObuff);
7d4e5e31d8c1 updated for version 7.3.273
Bram Moolenaar <bram@vim.org>
parents: 2847
diff changeset
569 #endif
7d4e5e31d8c1 updated for version 7.3.273
Bram Moolenaar <bram@vim.org>
parents: 2847
diff changeset
570
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 if ((efmp = vim_strrchr(IObuff, '\n')) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 *efmp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 #ifdef USE_CRNL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 if ((efmp = vim_strrchr(IObuff, '\r')) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 *efmp = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
578 /* If there was no %> item start at the first pattern */
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
579 if (fmt_start == NULL)
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
580 fmt_ptr = fmt_first;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
581 else
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
582 {
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
583 fmt_ptr = fmt_start;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
584 fmt_start = NULL;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
585 }
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
586
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 * Try to match each part of 'errorformat' until we find a complete
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 * match or no match.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 valid = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 restofline:
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
593 for ( ; fmt_ptr != NULL; fmt_ptr = fmt_ptr->next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
6450
7e4c22ecc679 updated for version 7.4.554
Bram Moolenaar <bram@vim.org>
parents: 6081
diff changeset
595 int r;
7e4c22ecc679 updated for version 7.4.554
Bram Moolenaar <bram@vim.org>
parents: 6081
diff changeset
596
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 idx = fmt_ptr->prefix;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 if (multiscan && vim_strchr((char_u *)"OPQ", idx) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 namebuf[0] = NUL;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
601 pattern[0] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 if (!multiscan)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 errmsg[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 lnum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 col = 0;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
606 use_viscol = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 enr = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 tail = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 regmatch.regprog = fmt_ptr->prog;
6450
7e4c22ecc679 updated for version 7.4.554
Bram Moolenaar <bram@vim.org>
parents: 6081
diff changeset
612 r = vim_regexec(&regmatch, IObuff, (colnr_T)0);
7e4c22ecc679 updated for version 7.4.554
Bram Moolenaar <bram@vim.org>
parents: 6081
diff changeset
613 fmt_ptr->prog = regmatch.regprog;
7e4c22ecc679 updated for version 7.4.554
Bram Moolenaar <bram@vim.org>
parents: 6081
diff changeset
614 if (r)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 if ((idx == 'C' || idx == 'Z') && !multiline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 if (vim_strchr((char_u *)"EWI", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 type = idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 /*
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
623 * Extract error message data from matched line.
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
624 * We check for an actual submatch, because "\[" and "\]" in
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
625 * the 'errorformat' may cause the wrong submatch to be used.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 if ((i = (int)fmt_ptr->addr[0]) > 0) /* %f */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 {
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
629 int c;
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
630
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
631 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
632 continue;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
633
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
634 /* Expand ~/file and $HOME/file to full path. */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
635 c = *regmatch.endp[i];
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
636 *regmatch.endp[i] = NUL;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
637 expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE);
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
638 *regmatch.endp[i] = c;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
639
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 if (vim_strchr((char_u *)"OPQ", idx) != NULL
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
641 && mch_getperm(namebuf) == -1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 if ((i = (int)fmt_ptr->addr[1]) > 0) /* %n */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
645 {
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
646 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
647 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 enr = (int)atol((char *)regmatch.startp[i]);
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
649 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 if ((i = (int)fmt_ptr->addr[2]) > 0) /* %l */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
651 {
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
652 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
653 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 lnum = atol((char *)regmatch.startp[i]);
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
655 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 if ((i = (int)fmt_ptr->addr[3]) > 0) /* %c */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
657 {
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
658 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
659 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 col = (int)atol((char *)regmatch.startp[i]);
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
661 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 if ((i = (int)fmt_ptr->addr[4]) > 0) /* %t */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
663 {
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
664 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
665 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 type = *regmatch.startp[i];
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
667 }
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
668 if (fmt_ptr->flags == '+' && !multiscan) /* %+ */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 STRCPY(errmsg, IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 else if ((i = (int)fmt_ptr->addr[5]) > 0) /* %m */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 {
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
672 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
673 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 410
diff changeset
675 vim_strncpy(errmsg, regmatch.startp[i], len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 if ((i = (int)fmt_ptr->addr[6]) > 0) /* %r */
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
678 {
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
679 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
680 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 tail = regmatch.startp[i];
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
682 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 if ((i = (int)fmt_ptr->addr[7]) > 0) /* %p */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 {
3555
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
685 char_u *match_ptr;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
686
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
687 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
688 continue;
3555
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
689 col = 0;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
690 for (match_ptr = regmatch.startp[i];
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
691 match_ptr != regmatch.endp[i]; ++match_ptr)
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
692 {
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
693 ++col;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
694 if (*match_ptr == TAB)
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
695 {
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
696 col += 7;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
697 col -= col % 8;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
698 }
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
699 }
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
700 ++col;
bbf1fbbe4ab4 updated for version 7.3.538
Bram Moolenaar <bram@vim.org>
parents: 3490
diff changeset
701 use_viscol = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 if ((i = (int)fmt_ptr->addr[8]) > 0) /* %v */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 {
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
705 if (regmatch.startp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
706 continue;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 col = (int)atol((char *)regmatch.startp[i]);
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
708 use_viscol = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
710 if ((i = (int)fmt_ptr->addr[9]) > 0) /* %s */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
711 {
895
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
712 if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
4ec4c53046b5 updated for version 7.0-021
vimboss
parents: 859
diff changeset
713 continue;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
714 len = (int)(regmatch.endp[i] - regmatch.startp[i]);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
715 if (len > CMDBUFFSIZE - 5)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
716 len = CMDBUFFSIZE - 5;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
717 STRCPY(pattern, "^\\V");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
718 STRNCAT(pattern, regmatch.startp[i], len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
719 pattern[len + 3] = '\\';
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
720 pattern[len + 4] = '$';
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
721 pattern[len + 5] = NUL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
722 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 multiscan = FALSE;
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
727
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
728 if (fmt_ptr == NULL || idx == 'D' || idx == 'X')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 {
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
730 if (fmt_ptr != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 if (idx == 'D') /* enter directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 if (*namebuf == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 EMSG(_("E379: Missing or empty directory name"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 if ((directory = qf_push_dir(namebuf, &dir_stack)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 else if (idx == 'X') /* leave directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 directory = qf_pop_dir(&dir_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 namebuf[0] = NUL; /* no match found, remove file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 lnum = 0; /* don't jump to this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 STRCPY(errmsg, IObuff); /* copy whole line to error message */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
749 if (fmt_ptr == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 multiline = multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 }
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
752 else if (fmt_ptr != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 {
789
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
754 /* honor %> item */
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
755 if (fmt_ptr->conthere)
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
756 fmt_start = fmt_ptr;
b29b006d52d2 updated for version 7.0230
vimboss
parents: 729
diff changeset
757
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 if (vim_strchr((char_u *)"AEWI", idx) != NULL)
5716
fb24b025c7cf updated for version 7.4.203
Bram Moolenaar <bram@vim.org>
parents: 5084
diff changeset
759 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 multiline = TRUE; /* start of a multi-line message */
5716
fb24b025c7cf updated for version 7.4.203
Bram Moolenaar <bram@vim.org>
parents: 5084
diff changeset
761 multiignore = FALSE; /* reset continuation */
fb24b025c7cf updated for version 7.4.203
Bram Moolenaar <bram@vim.org>
parents: 5084
diff changeset
762 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 else if (vim_strchr((char_u *)"CZ", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 { /* continuation of multi-line msg */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 if (qfprev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 if (*errmsg && !multiignore)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 len = (int)STRLEN(qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 if ((ptr = alloc((unsigned)(len + STRLEN(errmsg) + 2)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 STRCPY(ptr, qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774 vim_free(qfprev->qf_text);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 qfprev->qf_text = ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 *(ptr += len) = '\n';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 STRCPY(++ptr, errmsg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 if (qfprev->qf_nr == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 qfprev->qf_nr = enr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 if (vim_isprintc(type) && !qfprev->qf_type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 qfprev->qf_type = type; /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 if (!qfprev->qf_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 qfprev->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 if (!qfprev->qf_col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 qfprev->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
787 qfprev->qf_viscol = use_viscol;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 if (!qfprev->qf_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 qfprev->qf_fnum = qf_get_fnum(directory,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 *namebuf || directory ? namebuf
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 : currfile && valid ? currfile : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 if (idx == 'Z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 multiline = multiignore = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 else if (vim_strchr((char_u *)"OPQ", idx) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 /* global file names */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 if (*namebuf == NUL || mch_getperm(namebuf) >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 if (*namebuf && idx == 'P')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 currfile = qf_push_dir(namebuf, &file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 else if (idx == 'Q')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 currfile = qf_pop_dir(&file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 *namebuf = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 if (tail && *tail)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 {
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1621
diff changeset
810 STRMOVE(IObuff, skipwhite(tail));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 multiscan = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 goto restofline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 if (fmt_ptr->flags == '-') /* generally exclude this line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 if (multiline)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 multiignore = TRUE; /* also exclude continuation lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
824 if (qf_add_entry(qi, &qfprev,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 directory,
129
2983cde45542 updated for version 7.0044
vimboss
parents: 123
diff changeset
826 (*namebuf || directory)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 ? namebuf
129
2983cde45542 updated for version 7.0044
vimboss
parents: 123
diff changeset
828 : ((currfile && valid) ? currfile : (char_u *)NULL),
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
829 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 errmsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 lnum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 col,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
833 use_viscol,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
834 pattern,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 enr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 valid) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 goto error2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
841 if (fd == NULL || !ferror(fd))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
843 if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
845 /* no valid entry found */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
846 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
847 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
848 qi->qf_lists[qi->qf_curlist].qf_index = 1;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
849 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
853 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
854 if (qi->qf_lists[qi->qf_curlist].qf_ptr == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
855 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
856 qi->qf_lists[qi->qf_curlist].qf_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
858 /* return number of matches */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
859 retval = qi->qf_lists[qi->qf_curlist].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 goto qf_init_ok;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 EMSG(_(e_readerrf));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 error2:
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
864 qf_free(qi, qi->qf_curlist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
865 qi->qf_listcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
866 if (qi->qf_curlist > 0)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
867 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 qf_init_ok:
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
869 if (fd != NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
870 fclose(fd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 for (fmt_ptr = fmt_first; fmt_ptr != NULL; fmt_ptr = fmt_first)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 fmt_first = fmt_ptr->next;
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
874 vim_regfree(fmt_ptr->prog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 vim_free(fmt_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 qf_clean_dir_stack(&dir_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 qf_clean_dir_stack(&file_stack);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 qf_init_end:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 vim_free(namebuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 vim_free(errmsg);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
882 vim_free(pattern);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 vim_free(fmtstr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
886 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
892 static void
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
893 qf_store_title(qi, title)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
894 qf_info_T *qi;
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
895 char_u *title;
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
896 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
897 if (title != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
898 {
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
899 char_u *p = alloc((int)STRLEN(title) + 2);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
900
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
901 qi->qf_lists[qi->qf_curlist].qf_title = p;
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
902 if (p != NULL)
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
903 sprintf((char *)p, ":%s", (char *)title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
904 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
905 }
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
906
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 * Prepare for adding a new quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 static void
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
911 qf_new_list(qi, qf_title)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
912 qf_info_T *qi;
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
913 char_u *qf_title;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 /*
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
918 * If the current entry is not the last entry, delete entries beyond
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 * the current entry. This makes it possible to browse in a tree-like
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 * way with ":grep'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
922 while (qi->qf_listcount > qi->qf_curlist + 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
923 qf_free(qi, --qi->qf_listcount);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926 * When the stack is full, remove to oldest entry
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 * Otherwise, add a new entry.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
929 if (qi->qf_listcount == LISTCOUNT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
931 qf_free(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 for (i = 1; i < LISTCOUNT; ++i)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
933 qi->qf_lists[i - 1] = qi->qf_lists[i];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
934 qi->qf_curlist = LISTCOUNT - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 else
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
937 qi->qf_curlist = qi->qf_listcount++;
3259
9eb7fdfb5e63 updated for version 7.3.398
Bram Moolenaar <bram@vim.org>
parents: 3257
diff changeset
938 vim_memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T)));
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
939 qf_store_title(qi, qf_title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
942 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
943 * Free a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
944 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
945 static void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
946 ll_free_all(pqi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
947 qf_info_T **pqi;
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
948 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
949 int i;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
950 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
951
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
952 qi = *pqi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
953 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
954 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
955 *pqi = NULL; /* Remove reference to this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
956
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
957 qi->qf_refcount--;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
958 if (qi->qf_refcount < 1)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
959 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
960 /* No references to this location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
961 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
962 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
963 vim_free(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
964 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
965 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
966
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
967 void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
968 qf_free_all(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
969 win_T *wp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
970 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
971 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
972 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
973
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
974 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
975 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
976 /* location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
977 ll_free_all(&wp->w_llist);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
978 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
979 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
980 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
981 /* quickfix list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
982 for (i = 0; i < qi->qf_listcount; ++i)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
983 qf_free(qi, i);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
984 }
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 297
diff changeset
985
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 * Add an entry to the end of the list of errors.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988 * Returns OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 static int
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
991 qf_add_entry(qi, prevp, dir, fname, bufnum, mesg, lnum, col, vis_col, pattern,
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
992 nr, type, valid)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
993 qf_info_T *qi; /* quickfix list */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
994 qfline_T **prevp; /* pointer to previously added entry or NULL */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 char_u *dir; /* optional directory name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 char_u *fname; /* file name or NULL */
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
997 int bufnum; /* buffer number or zero */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 char_u *mesg; /* message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 long lnum; /* line number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 int col; /* column */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1001 int vis_col; /* using visual column */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1002 char_u *pattern; /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 int nr; /* error number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 int type; /* type character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 int valid; /* valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1007 qfline_T *qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1009 if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 return FAIL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1011 if (bufnum != 0)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1012 qfp->qf_fnum = bufnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1013 else
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1014 qfp->qf_fnum = qf_get_fnum(dir, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 vim_free(qfp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 qfp->qf_lnum = lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 qfp->qf_col = col;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
1022 qfp->qf_viscol = vis_col;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1023 if (pattern == NULL || *pattern == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1024 qfp->qf_pattern = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1025 else if ((qfp->qf_pattern = vim_strsave(pattern)) == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1026 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1027 vim_free(qfp->qf_text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1028 vim_free(qfp);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1029 return FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1030 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 qfp->qf_nr = nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 if (type != 1 && !vim_isprintc(type)) /* only printable chars allowed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 qfp->qf_type = type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 qfp->qf_valid = valid;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1037 if (qi->qf_lists[qi->qf_curlist].qf_count == 0)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1038 /* first element in the list */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1040 qi->qf_lists[qi->qf_curlist].qf_start = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 qfp->qf_prev = qfp; /* first element points to itself */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 qfp->qf_prev = *prevp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 (*prevp)->qf_next = qfp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 qfp->qf_next = qfp; /* last element points to itself */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 qfp->qf_cleared = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 *prevp = qfp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1051 ++qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1052 if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1053 /* first valid entry */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1055 qi->qf_lists[qi->qf_curlist].qf_index =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1056 qi->qf_lists[qi->qf_curlist].qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1057 qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 /*
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1064 * Allocate a new location list
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1065 */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1066 static qf_info_T *
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1067 ll_new_list()
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1068 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1069 qf_info_T *qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1070
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1071 qi = (qf_info_T *)alloc((unsigned)sizeof(qf_info_T));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1072 if (qi != NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1073 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1074 vim_memset(qi, 0, (size_t)(sizeof(qf_info_T)));
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1075 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1076 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1077
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1078 return qi;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1079 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1080
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1081 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1082 * Return the location list for window 'wp'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1083 * If not present, allocate a location list
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1084 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1085 static qf_info_T *
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1086 ll_get_or_alloc_list(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1087 win_T *wp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1088 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1089 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1090 /* For a location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1091 return wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1092
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1093 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1094 * For a non-location list window, w_llist_ref should not point to a
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1095 * location list.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1096 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1097 ll_free_all(&wp->w_llist_ref);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1098
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1099 if (wp->w_llist == NULL)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1100 wp->w_llist = ll_new_list(); /* new location list */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1101 return wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1102 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1103
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1104 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1105 * Copy the location list from window "from" to window "to".
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1106 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1107 void
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1108 copy_loclist(from, to)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1109 win_T *from;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1110 win_T *to;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1111 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1112 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1113 int idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1114 int i;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1115
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1116 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1117 * When copying from a location list window, copy the referenced
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1118 * location list. For other windows, copy the location list for
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1119 * that window.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1120 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1121 if (IS_LL_WINDOW(from))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1122 qi = from->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1123 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1124 qi = from->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1125
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1126 if (qi == NULL) /* no location list to copy */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1127 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1128
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1129 /* allocate a new location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1130 if ((to->w_llist = ll_new_list()) == NULL)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1131 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1132
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1133 to->w_llist->qf_listcount = qi->qf_listcount;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1134
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1135 /* Copy the location lists one at a time */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1136 for (idx = 0; idx < qi->qf_listcount; idx++)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1137 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1138 qf_list_T *from_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1139 qf_list_T *to_qfl;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1140
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1141 to->w_llist->qf_curlist = idx;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1142
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1143 from_qfl = &qi->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1144 to_qfl = &to->w_llist->qf_lists[idx];
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1145
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1146 /* Some of the fields are populated by qf_add_entry() */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1147 to_qfl->qf_nonevalid = from_qfl->qf_nonevalid;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1148 to_qfl->qf_count = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1149 to_qfl->qf_index = 0;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1150 to_qfl->qf_start = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1151 to_qfl->qf_ptr = NULL;
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1152 if (from_qfl->qf_title != NULL)
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1153 to_qfl->qf_title = vim_strsave(from_qfl->qf_title);
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1154 else
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
1155 to_qfl->qf_title = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1156
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1157 if (from_qfl->qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1158 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1159 qfline_T *from_qfp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1160 qfline_T *prevp = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1161
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1162 /* copy all the location entries in this list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1163 for (i = 0, from_qfp = from_qfl->qf_start; i < from_qfl->qf_count;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1164 ++i, from_qfp = from_qfp->qf_next)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1165 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1166 if (qf_add_entry(to->w_llist, &prevp,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1167 NULL,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1168 NULL,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
1169 0,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1170 from_qfp->qf_text,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1171 from_qfp->qf_lnum,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1172 from_qfp->qf_col,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1173 from_qfp->qf_viscol,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1174 from_qfp->qf_pattern,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1175 from_qfp->qf_nr,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1176 0,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1177 from_qfp->qf_valid) == FAIL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1178 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1179 qf_free_all(to);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1180 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1181 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1182 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1183 * qf_add_entry() will not set the qf_num field, as the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1184 * directory and file names are not supplied. So the qf_fnum
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1185 * field is copied here.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1186 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1187 prevp->qf_fnum = from_qfp->qf_fnum; /* file number */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1188 prevp->qf_type = from_qfp->qf_type; /* error type */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1189 if (from_qfl->qf_ptr == from_qfp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1190 to_qfl->qf_ptr = prevp; /* current location */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1191 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1192 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1193
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1194 to_qfl->qf_index = from_qfl->qf_index; /* current index in the list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1195
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1196 /* When no valid entries are present in the list, qf_ptr points to
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1197 * the first item in the list */
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
1198 if (to_qfl->qf_nonevalid)
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1199 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1200 to_qfl->qf_ptr = to_qfl->qf_start;
5060
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1201 to_qfl->qf_index = 1;
30910831e5b0 updated for version 7.3.1273
Bram Moolenaar <bram@vim.org>
parents: 4805
diff changeset
1202 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1203 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1204
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1205 to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1206 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1207
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1208 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 * get buffer number for file "dir.name"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 qf_get_fnum(directory, fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 char_u *directory;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 if (fname == NULL || *fname == NUL) /* no file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 char_u *ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 int fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1222 #ifdef VMS
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 vms_remove_version(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1224 #endif
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1225 #ifdef BACKSLASH_IN_FILENAME
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 if (directory != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 slash_adjust(directory);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 slash_adjust(fname);
2823
8bd38abda314 updated for version 7.3.187
Bram Moolenaar <bram@vim.org>
parents: 2795
diff changeset
1229 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 if (directory != NULL && !vim_isAbsName(fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 * Here we check if the file really exists.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 * This should normally be true, but if make works without
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 * "leaving directory"-messages we might have missed a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 * directory change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 if (mch_getperm(ptr) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 vim_free(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 directory = qf_guess_filepath(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 if (directory)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 ptr = concat_fnames(directory, fname, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 ptr = vim_strsave(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 /* Use concatenated directory name and file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 fnum = buflist_add(ptr, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 vim_free(ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 return fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 return buflist_add(fname, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 * push dirbuf onto the directory stack and return pointer to actual dir or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 * NULL on error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 qf_push_dir(dirbuf, stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 char_u *dirbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 struct dir_stack_T *ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 /* allocate new stack element and hook it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 ds_new = (struct dir_stack_T *)alloc((unsigned)sizeof(struct dir_stack_T));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 ds_new->next = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 *stackptr = ds_new;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 /* store directory on the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 if (vim_isAbsName(dirbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 || (*stackptr)->next == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 || (*stackptr && dir_stack != *stackptr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 /* Okay we don't have an absolute path.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 * dirbuf must be a subdir of one of the directories on the stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 * Let's search...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 ds_new = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 (*stackptr)->dirname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 while (ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 (*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 if (mch_isdir((*stackptr)->dirname) == TRUE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 ds_new = ds_new->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 while ((*stackptr)->next != ds_new)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 ds_ptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 (*stackptr)->next = (*stackptr)->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 /* Nothing found -> it must be on top level */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 if (ds_new == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 vim_free((*stackptr)->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 (*stackptr)->dirname = vim_strsave(dirbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 if ((*stackptr)->dirname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 return (*stackptr)->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 * pop dirbuf from the directory stack and return previous directory or NULL if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 * stack is empty
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 qf_pop_dir(stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 /* TODO: Should we check if dirbuf is the directory on top of the stack?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 * What to do if it isn't? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 /* pop top element and free it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 if (*stackptr != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 ds_ptr = *stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 /* return NEW top element as current dir or NULL if stack is empty*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 return *stackptr ? (*stackptr)->dirname : NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 * clean up directory stack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 qf_clean_dir_stack(stackptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 struct dir_stack_T **stackptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 while ((ds_ptr = *stackptr) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 *stackptr = (*stackptr)->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 vim_free(ds_ptr->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 vim_free(ds_ptr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 * Check in which directory of the directory stack the given file can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * found.
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
1376 * Returns a pointer to the directory name or NULL if not found.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 * Cleans up intermediate directory entries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 * TODO: How to solve the following problem?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 * If we have the this directory tree:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 * ./
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 * ./aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 * ./aa/bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 * ./bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 * ./bb/x.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 * and make says:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 * making all in aa
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 * making all in bb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 * x.c:9: Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 * Then qf_push_dir thinks we are in ./aa/bb, but we are in ./bb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 * qf_guess_filepath will return NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 qf_guess_filepath(filename)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 char_u *filename;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 struct dir_stack_T *ds_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398 struct dir_stack_T *ds_tmp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 char_u *fullname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 /* no dirs on the stack - there's nothing we can do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 if (dir_stack == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 ds_ptr = dir_stack->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 fullname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 while (ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 fullname = concat_fnames(ds_ptr->dirname, filename, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 /* If concat_fnames failed, just go on. The worst thing that can happen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 * is that we delete the entire stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 if ((fullname != NULL) && (mch_getperm(fullname) >= 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 ds_ptr = ds_ptr->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 vim_free(fullname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 /* clean up all dirs we already left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 while (dir_stack->next != ds_ptr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 ds_tmp = dir_stack->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 dir_stack->next = dir_stack->next->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 vim_free(ds_tmp->dirname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 vim_free(ds_tmp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 return ds_ptr==NULL? NULL: ds_ptr->dirname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 * jump to a quickfix line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 * if dir == FORWARD go "errornr" valid entries forward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 * if dir == BACKWARD go "errornr" valid entries backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 * if dir == FORWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 * if dir == BACKWARD_FILE go "errornr" valid entries files backward
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 * else if "errornr" is zero, redisplay the same line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 * else go to entry "errornr"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 void
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1446 qf_jump(qi, dir, errornr, forceit)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1447 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 int dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 int errornr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 int forceit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1452 qf_info_T *ll_ref;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1453 qfline_T *qf_ptr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1454 qfline_T *old_qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 int qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 int old_qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 int old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 int prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 static char_u *e_no_more_items = (char_u *)N_("E553: No more items");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 char_u *err = e_no_more_items;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 linenr_T i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 buf_T *old_curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 linenr_T old_lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 colnr_T screen_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 colnr_T char_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 #ifdef FEAT_WINDOWS
639
c79d4df4686e updated for version 7.0185
vimboss
parents: 634
diff changeset
1468 char_u *old_swb = p_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1469 unsigned old_swb_flags = swb_flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 int opened_window = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 win_T *altwin;
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1473 int flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 #endif
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
1475 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 int print_message = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 int old_KeyTyped = KeyTyped; /* getting file may reset it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1481 int ok = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1482 int usable_win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1483
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1484 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1485 qi = &ql_info;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1486
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1487 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1488 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1494 qf_ptr = qi->qf_lists[qi->qf_curlist].qf_ptr;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 old_qf_ptr = qf_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1496 qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 old_qf_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 if (dir == FORWARD || dir == FORWARD_FILE) /* next valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1507 if (qf_index == qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 || qf_ptr->qf_next == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 qf_ptr = qf_ptr->qf_next;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1522 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1523 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 || (dir == FORWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 else if (dir == BACKWARD || dir == BACKWARD_FILE) /* prev. valid entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 while (errornr--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 old_qf_ptr = qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 prev_index = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 old_qf_fnum = qf_ptr->qf_fnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 if (qf_index == 1 || qf_ptr->qf_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 qf_index = prev_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 if (err != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 EMSG(_(err));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 errornr = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 qf_ptr = qf_ptr->qf_prev;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1551 } while ((!qi->qf_lists[qi->qf_curlist].qf_nonevalid
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1552 && !qf_ptr->qf_valid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 || (dir == BACKWARD_FILE && qf_ptr->qf_fnum == old_qf_fnum));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 err = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 else if (errornr != 0) /* go to specified number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 while (errornr < qf_index && qf_index > 1 && qf_ptr->qf_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 --qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 qf_ptr = qf_ptr->qf_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1564 while (errornr > qf_index && qf_index <
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1565 qi->qf_lists[qi->qf_curlist].qf_count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 && qf_ptr->qf_next != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 ++qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 qf_ptr = qf_ptr->qf_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1574 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1575 if (qf_win_pos_update(qi, old_qf_index))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 /* No need to print the error message if it's visible in the error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 * window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 print_message = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 /*
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1581 * For ":helpgrep" find a help window or open one.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1582 */
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1583 if (qf_ptr->qf_type == 1 && (!curwin->w_buffer->b_help || cmdmod.tab != 0))
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1584 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1585 win_T *wp;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1586
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1587 if (cmdmod.tab != 0)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1588 wp = NULL;
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1589 else
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1590 for (wp = firstwin; wp != NULL; wp = wp->w_next)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1591 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
1592 break;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1593 if (wp != NULL && wp->w_buffer->b_nwindows > 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1594 win_enter(wp, TRUE);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1595 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1596 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1597 /*
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1598 * Split off help window; put it at far top if no position
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1599 * specified, the current window is vertically split and narrow.
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1600 */
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1601 flags = WSP_HELP;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1602 # ifdef FEAT_VERTSPLIT
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1603 if (cmdmod.split == 0 && curwin->w_width != Columns
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1604 && curwin->w_width < 80)
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1605 flags |= WSP_TOP;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1606 # endif
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1607 if (qi != &ql_info)
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1608 flags |= WSP_NEWLOC; /* don't copy the location list */
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1609
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1610 if (win_split(0, flags) == FAIL)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1611 goto theend;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
1612 opened_window = TRUE; /* close it when fail */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1613
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1614 if (curwin->w_height < p_hh)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1615 win_setheight((int)p_hh);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1616
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1617 if (qi != &ql_info) /* not a quickfix list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1618 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1619 /* The new window should use the supplied location list */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1620 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1621 qi->qf_refcount++;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
1622 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1623 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1624
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1625 if (!p_im)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1626 restart_edit = 0; /* don't want insert mode in help file */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1627 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1628
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1629 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 * If currently in the quickfix window, find another window to show the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 * file in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 17
diff changeset
1633 if (bt_quickfix(curbuf) && !opened_window)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 {
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1635 win_T *usable_win_ptr = NULL;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1636
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 * If there is no file specified, we don't know where to go.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 * But do advance, otherwise ":cn" gets stuck.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 if (qf_ptr->qf_fnum == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 goto theend;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1644 usable_win = 0;
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1645
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1646 ll_ref = curwin->w_llist_ref;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1647 if (ll_ref != NULL)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1648 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1649 /* Find a window using the same location list that is not a
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1650 * quickfix window. */
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1651 FOR_ALL_WINDOWS(usable_win_ptr)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1652 if (usable_win_ptr->w_llist == ll_ref
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1653 && usable_win_ptr->w_buffer->b_p_bt[0] != 'q')
5084
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
1654 {
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
1655 usable_win = 1;
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1656 break;
5084
14e7a115d54d updated for version 7.3.1285
Bram Moolenaar <bram@vim.org>
parents: 5062
diff changeset
1657 }
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1658 }
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1659
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1660 if (!usable_win)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1661 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1662 /* Locate a window showing a normal buffer */
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1663 FOR_ALL_WINDOWS(win)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1664 if (win->w_buffer->b_p_bt[0] == NUL)
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1665 {
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1666 usable_win = 1;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1667 break;
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1668 }
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1669 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1670
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 /*
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1672 * If no usable window is found and 'switchbuf' contains "usetab"
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1673 * then search in other tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1675 if (!usable_win && (swb_flags & SWB_USETAB))
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1676 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1677 tabpage_T *tp;
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1678 win_T *wp;
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1679
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1680 FOR_ALL_TAB_WINDOWS(tp, wp)
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1681 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1682 if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum)
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1683 {
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1684 goto_tabpage_win(tp, wp);
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1685 usable_win = 1;
1819
15130d4dfea1 updated for version 7.2-117
vimboss
parents: 1743
diff changeset
1686 goto win_found;
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1687 }
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1688 }
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1689 }
1819
15130d4dfea1 updated for version 7.2-117
vimboss
parents: 1743
diff changeset
1690 win_found:
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1691
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1692 /*
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
1693 * If there is only one window and it is the quickfix window, create a
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
1694 * new one above the quickfix window.
1020
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1695 */
be9fbf8b0cdb updated for version 7.0-146
vimboss
parents: 960
diff changeset
1696 if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 {
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1698 flags = WSP_ABOVE;
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1699 if (ll_ref != NULL)
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1700 flags |= WSP_NEWLOC;
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
1701 if (win_split(0, flags) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 goto failed; /* not enough room for window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 opened_window = TRUE; /* close it when fail */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 p_swb = empty_option; /* don't split again */
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1705 swb_flags = 0;
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
1706 RESET_BINDING(curwin);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1707 if (ll_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1708 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1709 /* The new window should use the location list from the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1710 * location list window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1711 curwin->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1712 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1713 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1717 if (curwin->w_llist_ref != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1718 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1719 /* In a location window */
5062
761cef8f5d1d updated for version 7.3.1274
Bram Moolenaar <bram@vim.org>
parents: 5060
diff changeset
1720 win = usable_win_ptr;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1721 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1722 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1723 /* Find the window showing the selected file */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1724 FOR_ALL_WINDOWS(win)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1725 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1726 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1727 if (win == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1728 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1729 /* Find a previous usable window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1730 win = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1731 do
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1732 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1733 if (win->w_buffer->b_p_bt[0] == NUL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1734 break;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1735 if (win->w_prev == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1736 win = lastwin; /* wrap around the top */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1737 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1738 win = win->w_prev; /* go to previous window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1739 } while (win != curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1740 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1741 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1742 win_goto(win);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1743
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1744 /* If the location list for the window is not set, then set it
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1745 * to the location list from the location window */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1746 if (win->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1747 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1748 win->w_llist = ll_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1749 ll_ref->qf_refcount++;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1750 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1751 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1752 else
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1753 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1754
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 * Try to find a window that shows the right buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 * Default to the window just above the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 altwin = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 if (win->w_prev == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 win = lastwin; /* wrap around the top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 win = win->w_prev; /* go to previous window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1770 if (IS_QF_WINDOW(win))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 /* Didn't find it, go to the window before the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 * window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 if (altwin != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 win = altwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 else if (curwin->w_prev != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 win = curwin->w_prev;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 win = curwin->w_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 /* Remember a usable window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 if (altwin == NULL && !win->w_p_pvw
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 && win->w_buffer->b_p_bt[0] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 altwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 win_goto(win);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1790 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 * If there is a file name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 * read the wanted file if needed, and check autowrite etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 old_curbuf = curbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 old_lnum = curwin->w_cursor.lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1801
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1802 if (qf_ptr->qf_fnum != 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1803 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1804 if (qf_ptr->qf_type == 1)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1805 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1806 /* Open help file (do_ecmd() will set b_help flag, readfile() will
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1807 * set b_p_ro flag). */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1808 if (!can_abandon(curbuf, forceit))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1809 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1810 EMSG(_(e_nowrtmsg));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1811 ok = FALSE;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1812 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1813 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1814 ok = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
1815 ECMD_HIDE + ECMD_SET_HELP,
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
1816 oldwin == curwin ? curwin : NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1817 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1818 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1819 ok = buflist_getfile(qf_ptr->qf_fnum,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1820 (linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1821 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1822
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1823 if (ok == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 /* When not switched to another buffer, still need to set pc mark */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 if (curbuf == old_curbuf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 setpcmark();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1829 if (qf_ptr->qf_pattern == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1831 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1832 * Go to line with error, unless qf_lnum is 0.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1833 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1834 i = qf_ptr->qf_lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1835 if (i > 0)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1836 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1837 if (i > curbuf->b_ml.ml_line_count)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1838 i = curbuf->b_ml.ml_line_count;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1839 curwin->w_cursor.lnum = i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1840 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1841 if (qf_ptr->qf_col > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1843 curwin->w_cursor.col = qf_ptr->qf_col - 1;
6853
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
1844 #ifdef FEAT_VIRTUALEDIT
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
1845 curwin->w_cursor.coladd = 0;
d1a87b307a50 patch 7.4.747
Bram Moolenaar <bram@vim.org>
parents: 6793
diff changeset
1846 #endif
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1847 if (qf_ptr->qf_viscol == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1849 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1850 * Check each character from the beginning of the error
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1851 * line up to the error column. For each tab character
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1852 * found, reduce the error column value by the length of
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1853 * a tab character.
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1854 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1855 line = ml_get_curline();
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1856 screen_col = 0;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1857 for (char_col = 0; char_col < curwin->w_cursor.col; ++char_col)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1859 if (*line == NUL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1860 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1861 if (*line++ == '\t')
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1862 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1863 curwin->w_cursor.col -= 7 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1864 screen_col += 8 - (screen_col % 8);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1865 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1866 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1867 ++screen_col;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1870 check_cursor();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1872 else
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1873 beginline(BL_WHITE | BL_FIX);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 else
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1876 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1877 pos_T save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1878
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1879 /* Move the cursor to the first line in the buffer */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1880 save_cursor = curwin->w_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1881 curwin->w_cursor.lnum = 0;
1521
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
1882 if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1,
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
1883 SEARCH_KEEP, NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1884 curwin->w_cursor = save_cursor;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1885 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 if ((fdo_flags & FDO_QUICKFIX) && old_KeyTyped)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 foldOpenCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 if (print_message)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 {
3267
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
1893 /* Update the screen before showing the message, unless the screen
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
1894 * scrolled up. */
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
1895 if (!msg_scrolled)
4eda43e1fce0 updated for version 7.3.402
Bram Moolenaar <bram@vim.org>
parents: 3259
diff changeset
1896 update_topline_redraw();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 sprintf((char *)IObuff, _("(%d of %d)%s%s: "), qf_index,
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1898 qi->qf_lists[qi->qf_curlist].qf_count,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 qf_ptr->qf_cleared ? _(" (line deleted)") : "",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 (char *)qf_types(qf_ptr->qf_type, qf_ptr->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 /* Add the message, skipping leading whitespace and newlines. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 qf_fmt_text(skipwhite(qf_ptr->qf_text), IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 /* Output the message. Overwrite to avoid scrolling when the 'O'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 * flag is present in 'shortmess'; But when not jumping, print the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 * whole message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 i = msg_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 msg_scroll = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 else if (!msg_scrolled && shortmess(SHM_OVERALL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 msg_attr_keep(IObuff, 0, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 msg_scroll = i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 if (opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 win_close(curwin, TRUE); /* Close opened window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 if (qf_ptr->qf_fnum != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 * Couldn't open file, so put index back where it was. This could
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 * happen if the file was readonly and we changed something.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 failed:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 qf_ptr = old_qf_ptr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 qf_index = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 theend:
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1937 qi->qf_lists[qi->qf_curlist].qf_ptr = qf_ptr;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1938 qi->qf_lists[qi->qf_curlist].qf_index = qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 if (p_swb != old_swb && opened_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 /* Restore old 'switchbuf' value, but not when an autocommand or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 * modeline has changed the value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 if (p_swb == empty_option)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1945 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 p_swb = old_swb;
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1947 swb_flags = old_swb_flags;
82b5078be2dd updated for version 7.2a
vimboss
parents: 1571
diff changeset
1948 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 free_string_option(old_swb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 * ":clist": list all errors
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1957 * ":llist": list all locations
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 qf_list(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1963 buf_T *buf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1964 char_u *fname;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1965 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1966 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1967 int idx1 = 1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1968 int idx2 = -1;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1969 char_u *arg = eap->arg;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
1970 int all = eap->forceit; /* if not :cl!, only show
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 recognised errors */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1972 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1973
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1974 if (eap->cmdidx == CMD_llist)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1975 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1976 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1977 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1978 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1979 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1980 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1981 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1982 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1983
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1984 if (qi->qf_curlist >= qi->qf_listcount
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1985 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 EMSG(_(e_quickfix));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 if (!get_list_range(&arg, &idx1, &idx2) || *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 EMSG(_(e_trailing));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
1995 i = qi->qf_lists[qi->qf_curlist].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 if (idx1 < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 idx1 = (-idx1 > i) ? 0 : idx1 + i + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 if (idx2 < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 idx2 = (-idx2 > i) ? 0 : idx2 + i + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2001 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 all = TRUE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2003 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2004 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 if ((qfp->qf_valid || all) && idx1 <= i && i <= idx2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 {
2047
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2008 msg_putchar('\n');
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2009 if (got_int)
85da03763130 updated for version 7.2.333
Bram Moolenaar <bram@zimbu.org>
parents: 1918
diff changeset
2010 break;
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2011
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2012 fname = NULL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2013 if (qfp->qf_fnum != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 && (buf = buflist_findnr(qfp->qf_fnum)) != NULL)
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2015 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2016 fname = buf->b_fname;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2017 if (qfp->qf_type == 1) /* :helpgrep */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2018 fname = gettail(fname);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2019 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2020 if (fname == NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2021 sprintf((char *)IObuff, "%2d", i);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2022 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2023 vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 236
diff changeset
2024 i, (char *)fname);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2025 msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2026 ? hl_attr(HLF_L) : hl_attr(HLF_D));
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2027 if (qfp->qf_lnum == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2028 IObuff[0] = NUL;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2029 else if (qfp->qf_col == 0)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2030 sprintf((char *)IObuff, ":%ld", qfp->qf_lnum);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2031 else
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2032 sprintf((char *)IObuff, ":%ld col %d",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 qfp->qf_lnum, qfp->qf_col);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2034 sprintf((char *)IObuff + STRLEN(IObuff), "%s:",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2036 msg_puts_attr(IObuff, hl_attr(HLF_N));
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2037 if (qfp->qf_pattern != NULL)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2038 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2039 qf_fmt_text(qfp->qf_pattern, IObuff, IOSIZE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2040 STRCAT(IObuff, ":");
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2041 msg_puts(IObuff);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2042 }
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2043 msg_puts((char_u *)" ");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2044
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2045 /* Remove newlines and leading whitespace from the text. For an
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2046 * unrecognized line keep the indent, the compiler may mark a word
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2047 * with ^^^^. */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2048 qf_fmt_text((fname != NULL || qfp->qf_lnum != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 IObuff, IOSIZE);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2051 msg_prt_line(IObuff, FALSE);
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2052 out_flush(); /* show one line at a time */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2054
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2055 qfp = qfp->qf_next;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
2056 ++i;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 * Remove newlines and leading whitespace from an error message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 * Put the result in "buf[bufsize]".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 qf_fmt_text(text, buf, bufsize)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 char_u *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 int bufsize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 char_u *p = text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 for (i = 0; *p != NUL && i < bufsize - 1; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 if (*p == '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 buf[i] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 while (*++p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 if (!vim_iswhite(*p) && *p != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 buf[i] = *p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 buf[i] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 * ":colder [count]": Up in the quickfix stack.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 * ":cnewer [count]": Down in the quickfix stack.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2092 * ":lolder [count]": Up in the location list stack.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2093 * ":lnewer [count]": Down in the location list stack.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 qf_age(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2099 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2102 if (eap->cmdidx == CMD_lolder || eap->cmdidx == CMD_lnewer)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2103 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2104 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2105 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2106 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2107 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2108 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2109 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2110 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2111
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 count = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 while (count--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2118 if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2120 if (qi->qf_curlist == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 EMSG(_("E380: At bottom of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2123 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2125 --qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2129 if (qi->qf_curlist >= qi->qf_listcount - 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 EMSG(_("E381: At top of quickfix stack"));
4371
000bb500208d updated for version 7.3.934
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
2132 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2134 ++qi->qf_curlist;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2137 qf_msg(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2141 qf_msg(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2142 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 smsg((char_u *)_("error list %d of %d; %d errors"),
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2145 qi->qf_curlist + 1, qi->qf_listcount,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2146 qi->qf_lists[qi->qf_curlist].qf_count);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2148 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 /*
581
ec04f19aed55 updated for version 7.0165
vimboss
parents: 532
diff changeset
2153 * Free error list "idx".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2156 qf_free(qi, idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2157 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2160 qfline_T *qfp;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2161 int stop = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2163 while (qi->qf_lists[idx].qf_count)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2165 qfp = qi->qf_lists[idx].qf_start->qf_next;
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2166 if (qi->qf_lists[idx].qf_title != NULL && !stop)
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2167 {
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2168 vim_free(qi->qf_lists[idx].qf_start->qf_text);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2169 stop = (qi->qf_lists[idx].qf_start == qfp);
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2170 vim_free(qi->qf_lists[idx].qf_start->qf_pattern);
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2171 vim_free(qi->qf_lists[idx].qf_start);
3982
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2172 if (stop)
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2173 /* Somehow qf_count may have an incorrect value, set it to 1
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2174 * to avoid crashing when it's wrong.
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2175 * TODO: Avoid qf_count being incorrect. */
4934eb2e22dc updated for version 7.3.746
Bram Moolenaar <bram@vim.org>
parents: 3974
diff changeset
2176 qi->qf_lists[idx].qf_count = 1;
3949
37a4cacd2051 updated for version 7.3.730
Bram Moolenaar <bram@vim.org>
parents: 3939
diff changeset
2177 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2178 qi->qf_lists[idx].qf_start = qfp;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2179 --qi->qf_lists[idx].qf_count;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 }
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
2181 vim_free(qi->qf_lists[idx].qf_title);
2576
2a8bf2ba504f updated for version 7.3.003
Bram Moolenaar <bram@vim.org>
parents: 2530
diff changeset
2182 qi->qf_lists[idx].qf_title = NULL;
6081
16cfdf28be40 updated for version 7.4.379
Bram Moolenaar <bram@vim.org>
parents: 6079
diff changeset
2183 qi->qf_lists[idx].qf_index = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 * qf_mark_adjust: adjust marks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2190 qf_mark_adjust(wp, line1, line2, amount, amount_after)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2191 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 linenr_T line1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 linenr_T line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 long amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195 long amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2197 int i;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2198 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2199 int idx;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2200 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2201
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2202 if (wp != NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2203 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2204 if (wp->w_llist == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2205 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2206 qi = wp->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2207 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2208
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2209 for (idx = 0; idx < qi->qf_listcount; ++idx)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2210 if (qi->qf_lists[idx].qf_count)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2211 for (i = 0, qfp = qi->qf_lists[idx].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2212 i < qi->qf_lists[idx].qf_count; ++i, qfp = qfp->qf_next)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 if (qfp->qf_fnum == curbuf->b_fnum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 if (qfp->qf_lnum >= line1 && qfp->qf_lnum <= line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 if (amount == MAXLNUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 qfp->qf_cleared = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 qfp->qf_lnum += amount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 else if (amount_after && qfp->qf_lnum > line2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 qfp->qf_lnum += amount_after;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 * Make a nice message out of the error character and the error number:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 * char number message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 * e or E 0 " error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 * w or W 0 " warning"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 * i or I 0 " info"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 * 0 0 ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 * other 0 " c"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 * e or E n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 * w or W n " warning n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 * i or I n " info n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 * 0 n " error n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 * other n " c n"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 * 1 x "" :helpgrep
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 qf_types(c, nr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 int c, nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 static char_u buf[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 static char_u cc[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 if (c == 'W' || c == 'w')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 p = (char_u *)" warning";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 else if (c == 'I' || c == 'i')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 p = (char_u *)" info";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 else if (c == 'E' || c == 'e' || (c == 0 && nr > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 p = (char_u *)" error";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 else if (c == 0 || c == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 p = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 cc[0] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 cc[1] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 cc[2] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 p = cc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 if (nr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 return p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 sprintf((char *)buf, "%s %3d", (char *)p, nr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 * ":cwindow": open the quickfix window if we have errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 * close it if not.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2277 * ":lwindow": open the location list window if we have locations to display,
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2278 * close it if not.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 ex_cwindow(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2284 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 win_T *win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2287 if (eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2288 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2289 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2290 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2291 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2292 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2293
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2294 /* Look for an existing quickfix window. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2295 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 * If a quickfix window is open but we have no errors to display,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 * close the window. If a quickfix window is not open, then open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 * it if we have errors; otherwise, leave it closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2302 if (qi->qf_lists[qi->qf_curlist].qf_nonevalid
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
2303 || qi->qf_lists[qi->qf_curlist].qf_count == 0
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
2304 || qi->qf_curlist >= qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 ex_cclose(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 else if (win == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 ex_copen(eap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 * ":cclose": close the window showing the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2315 * ":lclose": close the window showing the location list
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 ex_cclose(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2321 win_T *win = NULL;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2322 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2323
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2324 if (eap->cmdidx == CMD_lclose || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2325 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2326 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2327 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2328 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2329 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2330
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2331 /* Find existing quickfix window and close it. */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2332 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 if (win != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 win_close(win, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 * ":copen": open a window that shows the list of errors.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2339 * ":lopen": open a window that shows the location list.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 ex_copen(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2345 qf_info_T *qi = &ql_info;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 win_T *win;
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2348 tabpage_T *prevtab = curtab;
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2349 buf_T *qf_buf;
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2350 win_T *oldwin = curwin;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2352 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2353 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2354 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2355 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2356 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2357 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2358 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2359 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2360 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2361
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 if (eap->addr_count != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 height = eap->line2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 height = QF_WINHEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 reset_VIsual_and_resel(); /* stop Visual mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 need_mouse_correct = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373 * Find existing quickfix window, or open a new one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2375 win = qf_find_win(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2376
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2377 if (win != NULL && cmdmod.tab == 0)
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2378 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 win_goto(win);
5753
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2380 if (eap->addr_count != 0)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2381 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2382 #ifdef FEAT_VERTSPLIT
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2383 if (cmdmod.split & WSP_VERT)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2384 {
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2385 if (height != W_WIDTH(win))
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2386 win_setwidth(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2387 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2388 else
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2389 #endif
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2390 if (height != win->w_height)
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2391 win_setheight(height);
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2392 }
a548aae15b3a updated for version 7.4.221
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
2393 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2396 qf_buf = qf_find_buf(qi);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2397
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 /* The current window becomes the previous window afterwards. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 win = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400
3939
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2401 if ((eap->cmdidx == CMD_copen || eap->cmdidx == CMD_cwindow)
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2402 && cmdmod.split == 0)
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2403 /* Create the new window at the very bottom, except when
f4aa43d952f5 updated for version 7.3.725
Bram Moolenaar <bram@vim.org>
parents: 3918
diff changeset
2404 * :belowright or :aboveleft is used. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2405 win_goto(lastwin);
1822
cda8f3aceb85 updated for version 7.2-120
vimboss
parents: 1819
diff changeset
2406 if (win_split(height, WSP_BELOW | WSP_NEWLOC) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 return; /* not enough room for window */
2583
7c2e6ba1d702 updated for version 7.3.008
Bram Moolenaar <bram@vim.org>
parents: 2576
diff changeset
2408 RESET_BINDING(curwin);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2410 if (eap->cmdidx == CMD_lopen || eap->cmdidx == CMD_lwindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2412 /*
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2413 * For the location list window, create a reference to the
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2414 * location list from the window 'win'.
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2415 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2416 curwin->w_llist_ref = win->w_llist;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2417 win->w_llist->qf_refcount++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418 }
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2419
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2420 if (oldwin != curwin)
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2421 oldwin = NULL; /* don't store info when in another window */
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2422 if (qf_buf != NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2423 /* Use the existing quickfix buffer */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2424 (void)do_ecmd(qf_buf->b_fnum, NULL, NULL, NULL, ECMD_ONE,
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2425 ECMD_HIDE + ECMD_OLDBUF, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2426 else
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2427 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2428 /* Create a new quickfix buffer */
1743
734d5bdae499 updated for version 7.2-041
vimboss
parents: 1683
diff changeset
2429 (void)do_ecmd(0, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, oldwin);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2430 /* switch off 'swapfile' */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2431 set_option_value((char_u *)"swf", 0L, NULL, OPT_LOCAL);
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2432 set_option_value((char_u *)"bt", 0L, (char_u *)"quickfix",
729
3d0ca316efab updated for version 7.0221
vimboss
parents: 717
diff changeset
2433 OPT_LOCAL);
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2434 set_option_value((char_u *)"bh", 0L, (char_u *)"wipe", OPT_LOCAL);
2651
b254cfdd7405 updated for version 7.3.071
Bram Moolenaar <bram@vim.org>
parents: 2646
diff changeset
2435 RESET_BINDING(curwin);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2436 #ifdef FEAT_DIFF
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2437 curwin->w_p_diff = FALSE;
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2438 #endif
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2439 #ifdef FEAT_FOLDING
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2440 set_option_value((char_u *)"fdm", 0L, (char_u *)"manual",
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2441 OPT_LOCAL);
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2442 #endif
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2443 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2445 /* Only set the height when still in the same tab page and there is no
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2446 * window to the side. */
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2447 if (curtab == prevtab
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 95
diff changeset
2448 #ifdef FEAT_VERTSPLIT
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2449 && curwin->w_width == Columns
119
e8f07016e34d updated for version 7.0042
vimboss
parents: 95
diff changeset
2450 #endif
682
f1b013312711 updated for version 7.0205
vimboss
parents: 681
diff changeset
2451 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 win_setheight(height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 curwin->w_p_wfh = TRUE; /* set 'winfixheight' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 if (win_valid(win))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 prevwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2458 qf_set_title_var(qi);
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2459
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 * Fill the buffer with the quickfix list.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2463 qf_fill_buffer(qi);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2464
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2465 curwin->w_cursor.lnum = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 check_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 * Return the number of the current entry (line number in the quickfix
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473 * window).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 linenr_T
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2476 qf_current_entry(wp)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2477 win_T *wp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2479 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2480
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2481 if (IS_LL_WINDOW(wp))
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2482 /* In the location list window, use the referenced location list */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2483 qi = wp->w_llist_ref;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2484
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2485 return qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 * Update the cursor position in the quickfix window to the current error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 * Return TRUE if there is a quickfix window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 static int
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2493 qf_win_pos_update(qi, old_qf_index)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2494 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 int old_qf_index; /* previous qf_index or zero */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 win_T *win;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2498 int qf_index = qi->qf_lists[qi->qf_curlist].qf_index;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 * Put the cursor on the current error in the quickfix window, so that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 * it's viewable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2504 win = qf_find_win(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 if (win != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 && qf_index <= win->w_buffer->b_ml.ml_line_count
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 && old_qf_index != qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 win_T *old_curwin = curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 curwin = win;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 curbuf = win->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 if (qf_index > old_qf_index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 curwin->w_redraw_top = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 curwin->w_redraw_bot = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 curwin->w_redraw_top = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 curwin->w_redraw_bot = old_qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 curwin->w_cursor.lnum = qf_index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 curwin->w_cursor.col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 update_topline(); /* scroll to show the line */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 redraw_later(VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 curwin->w_redr_status = TRUE; /* update ruler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 curwin = old_curwin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 curbuf = curwin->w_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 return win != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2535 * Check whether the given window is displaying the specified quickfix/location
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2536 * list buffer
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2537 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2538 static int
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2539 is_qf_win(win, qi)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2540 win_T *win;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2541 qf_info_T *qi;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2542 {
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2543 /*
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2544 * A window displaying the quickfix buffer will have the w_llist_ref field
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2545 * set to NULL.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2546 * A window displaying a location list buffer will have the w_llist_ref
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2547 * pointing to the location list.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2548 */
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2549 if (bt_quickfix(win->w_buffer))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2550 if ((qi == &ql_info && win->w_llist_ref == NULL)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2551 || (qi != &ql_info && win->w_llist_ref == qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2552 return TRUE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2553
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2554 return FALSE;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2555 }
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2556
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2557 /*
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2558 * Find a window displaying the quickfix/location list 'qi'
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2559 * Searches in only the windows opened in the current tab.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2560 */
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2561 static win_T *
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2562 qf_find_win(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2563 qf_info_T *qi;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2564 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2565 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2566
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2567 FOR_ALL_WINDOWS(win)
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2568 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2569 break;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2570
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2571 return win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2572 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2573
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2574 /*
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2575 * Find a quickfix buffer.
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2576 * Searches in windows opened in all the tabs.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 static buf_T *
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2579 qf_find_buf(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2580 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 {
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2582 tabpage_T *tp;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2583 win_T *win;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2584
859
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2585 FOR_ALL_TAB_WINDOWS(tp, win)
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2586 if (is_qf_win(win, qi))
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2587 return win->w_buffer;
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2588
99305c4c42d4 updated for version 7.0g02
vimboss
parents: 857
diff changeset
2589 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 * Find the quickfix buffer. If it exists, update the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2596 qf_update_buffer(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2597 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 buf_T *buf;
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2600 win_T *win;
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2601 win_T *curwin_save;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 aco_save_T aco;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 /* Check if a buffer for the quickfix list exists. Update it. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2605 buf = qf_find_buf(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 if (buf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 /* set curwin/curbuf to buf and save a few things */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609 aucmd_prepbuf(&aco, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2611 qf_fill_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2613 if ((win = qf_find_win(qi)) != NULL)
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2614 {
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2615 curwin_save = curwin;
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2616 curwin = win;
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
2617 qf_set_title_var(qi);
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2618 curwin = curwin_save;
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2619
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2620 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2621
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 /* restore curwin/curbuf and a few other things */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623 aucmd_restbuf(&aco);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2625 (void)qf_win_pos_update(qi, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2629 /*
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2630 * Set "w:quickfix_title" if "qi" has a title.
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2631 */
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2632 static void
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
2633 qf_set_title_var(qi)
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2634 qf_info_T *qi;
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2635 {
6793
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2636 if (qi->qf_lists[qi->qf_curlist].qf_title != NULL)
e1d59836eecc patch 7.4.718
Bram Moolenaar <bram@vim.org>
parents: 6721
diff changeset
2637 set_internal_string_var((char_u *)"w:quickfix_title",
3016
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2638 qi->qf_lists[qi->qf_curlist].qf_title);
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2639 }
58bba69b3371 updated for version 7.3.280
Bram Moolenaar <bram@vim.org>
parents: 3002
diff changeset
2640
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 * Fill current buffer with quickfix errors, replacing any previous contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 * curbuf must be the quickfix buffer!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 static void
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2646 qf_fill_buffer(qi)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2647 qf_info_T *qi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 {
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2649 linenr_T lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2650 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2651 buf_T *errbuf;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2652 int len;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2653 int old_KeyTyped = KeyTyped;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 /* delete all existing lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 (void)ml_delete((linenr_T)1, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 /* Check if there is anything to display */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2660 if (qi->qf_curlist < qi->qf_listcount)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 /* Add one line for each error */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2663 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
2664 for (lnum = 0; lnum < qi->qf_lists[qi->qf_curlist].qf_count; ++lnum)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 if (qfp->qf_fnum != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668 && errbuf->b_fname != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 if (qfp->qf_type == 1) /* :helpgrep */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 STRCPY(IObuff, gettail(errbuf->b_fname));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 STRCPY(IObuff, errbuf->b_fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 len = (int)STRLEN(IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 if (qfp->qf_lnum > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 sprintf((char *)IObuff + len, "%ld", qfp->qf_lnum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 if (qfp->qf_col > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 sprintf((char *)IObuff + len, " col %d", qfp->qf_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 sprintf((char *)IObuff + len, "%s",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 (char *)qf_types(qfp->qf_type, qfp->qf_nr));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 len += (int)STRLEN(IObuff + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2695 else if (qfp->qf_pattern != NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2696 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2697 qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2698 len += (int)STRLEN(IObuff + len);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
2699 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 IObuff[len++] = '|';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 IObuff[len++] = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703 /* Remove newlines and leading whitespace from the text.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 * For an unrecognized line keep the indent, the compiler may
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 * mark a word with ^^^^. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 IObuff + len, IOSIZE - len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 if (ml_append(lnum, IObuff, (colnr_T)STRLEN(IObuff) + 1, FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 qfp = qfp->qf_next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 /* Delete the empty line which is now at the end */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 (void)ml_delete(lnum + 1, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 /* correct cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 check_lnums(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 /* Set the 'filetype' to "qf" each time after filling the buffer. This
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 * resembles reading a file into a buffer, it's more logical when using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 * autocommands. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 curbuf->b_p_ma = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 #ifdef FEAT_AUTOCMD
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2728 keep_filetype = TRUE; /* don't detect 'filetype' */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 FALSE, curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 FALSE, curbuf);
1864
05c8ff7f1284 updated for version 7.2-162
vimboss
parents: 1822
diff changeset
2733 keep_filetype = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 /* make sure it will be redrawn */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 redraw_curbuf_later(NOT_VALID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 /* Restore KeyTyped, setting 'filetype' may reset it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 KeyTyped = old_KeyTyped;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 #endif /* FEAT_WINDOWS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 * Return TRUE if "buf" is the quickfix buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 bt_quickfix(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
2752 return buf != NULL && buf->b_p_bt[0] == 'q';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 /*
17
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2756 * Return TRUE if "buf" is a "nofile" or "acwrite" buffer.
9be87deaeb52 updated for version 7.0009
vimboss
parents: 9
diff changeset
2757 * This means the buffer name is not a file name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 bt_nofile(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
2763 return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
2764 || buf->b_p_bt[0] == 'a');
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 * Return TRUE if "buf" is a "nowrite" or "nofile" buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 bt_dontwrite(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 {
3242
48252b5fd170 updated for version 7.3.390
Bram Moolenaar <bram@vim.org>
parents: 3016
diff changeset
2774 return buf != NULL && buf->b_p_bt[0] == 'n';
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 bt_dontwrite_msg(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 if (bt_dontwrite(buf))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 EMSG(_("E382: Cannot write, 'buftype' option is set"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 * Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 * and 'bufhidden'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 buf_hide(buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 /* 'bufhidden' overrules 'hidden' and ":hide", check it first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 switch (buf->b_p_bh[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 case 'u': /* "unload" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 case 'w': /* "wipe" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 case 'd': return FALSE; /* "delete" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 case 'h': return TRUE; /* "hide" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 return (p_hid || cmdmod.hide);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2809 * Return TRUE when using ":vimgrep" for ":grep".
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2810 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2811 int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2812 grep_internal(cmdidx)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
2813 cmdidx_T cmdidx;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2814 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2815 return ((cmdidx == CMD_grep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2816 || cmdidx == CMD_lgrep
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2817 || cmdidx == CMD_grepadd
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2818 || cmdidx == CMD_lgrepadd)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2819 && STRCMP("internal",
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2820 *curbuf->b_p_gp == NUL ? p_gp : curbuf->b_p_gp) == 0);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2821 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2822
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
2823 /*
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2824 * Used for ":make", ":lmake", ":grep", ":lgrep", ":grepadd", and ":lgrepadd"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 ex_make(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 {
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2830 char_u *fname;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 unsigned len;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2833 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2834 qf_info_T *qi = &ql_info;
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2835 int res;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2836 #ifdef FEAT_AUTOCMD
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2837 char_u *au_name = NULL;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2838
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2839 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2840 if (grep_internal(eap->cmdidx))
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2841 {
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2842 ex_vimgrep(eap);
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2843 return;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2844 }
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
2845
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2846 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2847 {
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2848 case CMD_make: au_name = (char_u *)"make"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2849 case CMD_lmake: au_name = (char_u *)"lmake"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2850 case CMD_grep: au_name = (char_u *)"grep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2851 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2852 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
2853 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2854 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2855 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2856 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2857 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2858 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2859 curbuf->b_fname, TRUE, curbuf);
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
2860 # ifdef FEAT_EVAL
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2861 if (did_throw || force_abort)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2862 return;
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
2863 # endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2864 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2865 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2867 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2868 || eap->cmdidx == CMD_lgrepadd)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2869 wp = curwin;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2870
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 autowrite_all();
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2872 fname = get_mef_name();
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2873 if (fname == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 return;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2875 mch_remove(fname); /* in case it's not unique */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 * If 'shellpipe' empty: don't redirect to 'errorfile'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 if (*p_sp != NUL)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2882 len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 cmd = alloc(len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 if (cmd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 (char *)p_shq);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 if (*p_sp != NUL)
1872
f13849167330 updated for version 7.2-169
vimboss
parents: 1864
diff changeset
2889 append_redir(cmd, len, p_sp, fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 * Output a newline if there's something else than the :make command that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892 * was typed (in which case the cursor is in column 0).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 if (msg_col == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 msg_didout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 msg_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 MSG_PUTS(":!");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 msg_outtrans(cmd); /* show what we are doing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 /* let the shell know if we are redirecting output or not */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901 do_shell(cmd, *p_sp != NUL ? SHELL_DOOUT : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 #ifdef AMIGA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 /* read window status report and redraw before message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 (void)char_avail();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2909 res = qf_init(wp, fname, (eap->cmdidx != CMD_make
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2910 && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm,
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
2911 (eap->cmdidx != CMD_grepadd
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
2912 && eap->cmdidx != CMD_lgrepadd),
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
2913 *eap->cmdlinep);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2914 if (wp != NULL)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2915 qi = GET_LOC_LIST(wp);
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2916 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2917 if (au_name != NULL)
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2918 {
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2919 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2920 curbuf->b_fname, TRUE, curbuf);
2847
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2921 if (qi->qf_curlist < qi->qf_listcount)
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2922 res = qi->qf_lists[qi->qf_curlist].qf_count;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2923 else
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2924 res = 0;
45c536fe48db updated for version 7.3.197
Bram Moolenaar <bram@vim.org>
parents: 2823
diff changeset
2925 }
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2926 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
2927 if (res > 0 && !eap->forceit)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
2928 qf_jump(qi, 0, 0, FALSE); /* display first error */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2930 mch_remove(fname);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
2931 vim_free(fname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 vim_free(cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936 * Return the name for the errorfile, in allocated memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 * Find a new unique name when 'makeef' contains "##".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 * Returns NULL for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 get_mef_name()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2942 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 static int start = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 static int off = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947 #ifdef HAVE_LSTAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 struct stat sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 if (*p_mef == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 {
6721
7347229a646a updated for version 7.4.684
Bram Moolenaar <bram@vim.org>
parents: 6450
diff changeset
2953 name = vim_tempname('e', FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 EMSG(_(e_notmp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 for (p = p_mef; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 if (p[0] == '#' && p[1] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 return vim_strsave(p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 /* Keep trying until the name doesn't exist yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 if (start == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 start = mch_get_pid();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 off += 19;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 name = alloc((unsigned)STRLEN(p_mef) + 30);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 STRCPY(name, p_mef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 STRCAT(name, p + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 if (mch_getperm(name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 #ifdef HAVE_LSTAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 /* Don't accept a symbolic link, its a security risk. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 && mch_lstat((char *)name, &sb) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 vim_free(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 return name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 /*
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2993 * Returns the number of valid entries in the current quickfix/location list.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2994 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2995 int
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2996 qf_get_size(eap)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2997 exarg_T *eap;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2998 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
2999 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3000 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3001 int i, sz = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3002 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3003
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3004 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3005 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3006 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3007 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3008 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3009 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3010 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3011
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3012 for (i = 0, qfp = qi->qf_lists[qi->qf_curlist].qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3013 (i < qi->qf_lists[qi->qf_curlist].qf_count) && (qfp != NULL);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3014 ++i, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3015 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3016 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3017 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3018 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3019 sz++; /* Count all valid entries */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3020 else if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3021 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3022 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3023 sz++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3024 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3025 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3026 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3027 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3028
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3029 return sz;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3030 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3031
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3032 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3033 * Returns the current index of the quickfix/location list.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3034 * Returns 0 if there is an error.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3035 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3036 int
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3037 qf_get_cur_idx(eap)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3038 exarg_T *eap;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3039 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3040 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3041
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3042 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3043 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3044 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3045 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3046 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3047 return 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3048 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3049
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3050 return qi->qf_lists[qi->qf_curlist].qf_index;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3051 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3052
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3053 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3054 * Returns the current index in the quickfix/location list (counting only valid
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3055 * entries). If no valid entries are in the list, then returns 1.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3056 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3057 int
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3058 qf_get_cur_valid_idx(eap)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3059 exarg_T *eap;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3060 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3061 qf_info_T *qi = &ql_info;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3062 qf_list_T *qfl;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3063 qfline_T *qfp;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3064 int i, eidx = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3065 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3066
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3067 if (eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3068 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3069 /* Location list */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3070 qi = GET_LOC_LIST(curwin);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3071 if (qi == NULL)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3072 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3073 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3074
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3075 qfl = &qi->qf_lists[qi->qf_curlist];
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3076 qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3077
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3078 /* check if the list has valid errors */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3079 if (qfl->qf_count <= 0 || qfl->qf_nonevalid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3080 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3081
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3082 for (i = 1; i <= qfl->qf_index && qfp!= NULL; i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3083 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3084 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3085 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3086 if (eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3087 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3088 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3089 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3090 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3091 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3092 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3093 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3094 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3095 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3096 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3097 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3098 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3099
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3100 return eidx ? eidx : 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3101 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3102
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3103 /*
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3104 * Get the 'n'th valid error entry in the quickfix or location list.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3105 * Used by :cdo, :ldo, :cfdo and :lfdo commands.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3106 * For :cdo and :ldo returns the 'n'th valid error entry.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3107 * For :cfdo and :lfdo returns the 'n'th valid file entry.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3108 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3109 static int
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3110 qf_get_nth_valid_entry(qi, n, fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3111 qf_info_T *qi;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3112 int n;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3113 int fdo;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3114 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3115 qf_list_T *qfl = &qi->qf_lists[qi->qf_curlist];
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3116 qfline_T *qfp = qfl->qf_start;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3117 int i, eidx;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3118 int prev_fnum = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3119
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3120 /* check if the list has valid errors */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3121 if (qfl->qf_count <= 0 || qfl->qf_nonevalid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3122 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3123
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3124 for (i = 1, eidx = 0; i <= qfl->qf_count && qfp!= NULL;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3125 i++, qfp = qfp->qf_next)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3126 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3127 if (qfp->qf_valid)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3128 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3129 if (fdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3130 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3131 if (qfp->qf_fnum > 0 && qfp->qf_fnum != prev_fnum)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3132 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3133 /* Count the number of files */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3134 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3135 prev_fnum = qfp->qf_fnum;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3136 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3137 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3138 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3139 eidx++;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3140 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3141
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3142 if (eidx == n)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3143 break;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3144 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3145
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3146 if (i <= qfl->qf_count)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3147 return i;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3148 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3149 return 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3150 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3151
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3152 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 * ":cc", ":crewind", ":cfirst" and ":clast".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3154 * ":ll", ":lrewind", ":lfirst" and ":llast".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3155 * ":cdo", ":ldo", ":cfdo" and ":lfdo"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 ex_cc(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3161 qf_info_T *qi = &ql_info;
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3162 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3163
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3164 if (eap->cmdidx == CMD_ll
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3165 || eap->cmdidx == CMD_lrewind
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3166 || eap->cmdidx == CMD_lfirst
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3167 || eap->cmdidx == CMD_llast
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3168 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3169 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3170 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3171 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3172 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3173 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3174 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3175 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3176 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3177 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3178
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3179 if (eap->addr_count > 0)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3180 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3181 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3182 {
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3183 if (eap->cmdidx == CMD_cc || eap->cmdidx == CMD_ll)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3184 errornr = 0;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3185 else if (eap->cmdidx == CMD_crewind || eap->cmdidx == CMD_lrewind
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3186 || eap->cmdidx == CMD_cfirst || eap->cmdidx == CMD_lfirst)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3187 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3188 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3189 errornr = 32767;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3190 }
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3191
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3192 /* For cdo and ldo commands, jump to the nth valid error.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3193 * For cfdo and lfdo commands, jump to the nth valid file entry.
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3194 */
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3195 if (eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo ||
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3196 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3197 errornr = qf_get_nth_valid_entry(qi,
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3198 eap->addr_count > 0 ? (int)eap->line1 : 1,
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3199 eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo);
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3200
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3201 qf_jump(qi, 0, errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3204 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3205 * ":cnext", ":cnfile", ":cNext" and ":cprevious".
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3206 * ":lnext", ":lNext", ":lprevious", ":lnfile", ":lNfile" and ":lpfile".
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3207 * Also, used by ":cdo", ":ldo", ":cfdo" and ":lfdo" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3208 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3210 ex_cnext(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3211 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3212 {
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3213 qf_info_T *qi = &ql_info;
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3214 int errornr;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3215
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3216 if (eap->cmdidx == CMD_lnext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3217 || eap->cmdidx == CMD_lNext
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3218 || eap->cmdidx == CMD_lprevious
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3219 || eap->cmdidx == CMD_lnfile
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3220 || eap->cmdidx == CMD_lNfile
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3221 || eap->cmdidx == CMD_lpfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3222 || eap->cmdidx == CMD_ldo
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3223 || eap->cmdidx == CMD_lfdo)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3224 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3225 qi = GET_LOC_LIST(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3226 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3227 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3228 EMSG(_(e_loclist));
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3229 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3230 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3231 }
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3232
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3233 if (eap->addr_count > 0 &&
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3234 (eap->cmdidx != CMD_cdo && eap->cmdidx != CMD_ldo &&
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3235 eap->cmdidx != CMD_cfdo && eap->cmdidx != CMD_lfdo))
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3236 errornr = (int)eap->line2;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3237 else
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3238 errornr = 1;
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3239
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3240 qf_jump(qi, (eap->cmdidx == CMD_cnext || eap->cmdidx == CMD_lnext
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3241 || eap->cmdidx == CMD_cdo || eap->cmdidx == CMD_ldo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 ? FORWARD
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3243 : (eap->cmdidx == CMD_cnfile || eap->cmdidx == CMD_lnfile
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3244 || eap->cmdidx == CMD_cfdo || eap->cmdidx == CMD_lfdo)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245 ? FORWARD_FILE
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3246 : (eap->cmdidx == CMD_cpfile || eap->cmdidx == CMD_lpfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3247 || eap->cmdidx == CMD_cNfile || eap->cmdidx == CMD_lNfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3248 ? BACKWARD_FILE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3249 : BACKWARD,
7092
64e30831fa42 commit https://github.com/vim/vim/commit/aa23b379421aa214e6543b06c974594a25799b09
Christian Brabandt <cb@256bit.org>
parents: 6853
diff changeset
3250 errornr, eap->forceit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 /*
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3254 * ":cfile"/":cgetfile"/":caddfile" commands.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3255 * ":lfile"/":lgetfile"/":laddfile" commands.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 ex_cfile(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3259 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3260 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3261 win_T *wp = NULL;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3262 qf_info_T *qi = &ql_info;
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3263 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3264 char_u *au_name = NULL;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3265 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3266
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3267 if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3268 || eap->cmdidx == CMD_laddfile)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3269 wp = curwin;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3270
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3271 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3272 switch (eap->cmdidx)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3273 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3274 case CMD_cfile: au_name = (char_u *)"cfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3275 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3276 case CMD_caddfile: au_name = (char_u *)"caddfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3277 case CMD_lfile: au_name = (char_u *)"lfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3278 case CMD_lgetfile: au_name = (char_u *)"lgetfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3279 case CMD_laddfile: au_name = (char_u *)"laddfile"; break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3280 default: break;
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3281 }
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3282 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3283 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3284 #endif
2296
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3285 #ifdef FEAT_BROWSE
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3286 if (cmdmod.browse)
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3287 {
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3288 char_u *browse_file = do_browse(0, (char_u *)_("Error file"), eap->arg,
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3289 NULL, NULL, BROWSE_FILTER_ALL_FILES, NULL);
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3290 if (browse_file == NULL)
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3291 return;
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3292 set_string_option_direct((char_u *)"ef", -1, browse_file, OPT_FREE, 0);
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3293 vim_free(browse_file);
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3294 }
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3295 else
eb7be7b075a6 Support :browse for commands that use an error file argument. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2146
diff changeset
3296 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 if (*eap->arg != NUL)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 682
diff changeset
3298 set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3299
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3300 /*
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3301 * This function is used by the :cfile, :cgetfile and :caddfile
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3302 * commands.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3303 * :cfile always creates a new quickfix list and jumps to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3304 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3305 * :cgetfile creates a new quickfix list but doesn't jump to the
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3306 * first error.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3307 * :caddfile adds to an existing quickfix list. If there is no
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3308 * quickfix list then a new list is created.
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
3309 */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3310 if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
3311 && eap->cmdidx != CMD_laddfile),
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
3312 *eap->cmdlinep) > 0
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3313 && (eap->cmdidx == CMD_cfile
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3314 || eap->cmdidx == CMD_lfile))
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3315 {
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3316 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3317 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3318 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3319 #endif
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3320 if (wp != NULL)
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3321 qi = GET_LOC_LIST(wp);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3322 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
665
21ab9abf0f08 updated for version 7.0196
vimboss
parents: 661
diff changeset
3323 }
3404
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3324
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3325 else
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3326 {
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3327 #ifdef FEAT_AUTOCMD
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3328 if (au_name != NULL)
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3329 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3330 #endif
38a135730423 updated for version 7.3.468
Bram Moolenaar <bram@vim.org>
parents: 3365
diff changeset
3331 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3335 * ":vimgrep {pattern} file(s)"
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3336 * ":vimgrepadd {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3337 * ":lvimgrep {pattern} file(s)"
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3338 * ":lvimgrepadd {pattern} file(s)"
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3339 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3340 void
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3341 ex_vimgrep(eap)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3342 exarg_T *eap;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3343 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3344 regmmatch_T regmatch;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3345 int fcount;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3346 char_u **fnames;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3347 char_u *fname;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3348 char_u *s;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3349 char_u *p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3350 int fi;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3351 qf_info_T *qi = &ql_info;
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3352 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3353 qfline_T *cur_qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3354 #endif
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3355 qfline_T *prevp = NULL;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3356 long lnum;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3357 buf_T *buf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3358 int duplicate_name = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3359 int using_dummy;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3360 int redraw_for_dummy = FALSE;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3361 int found_match;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3362 buf_T *first_match_buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3363 time_t seconds = 0;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3364 int save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3365 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3366 char_u *save_ei = NULL;
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3367 #endif
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3368 aco_save_T aco;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3369 int flags = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3370 colnr_T col;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3371 long tomatch;
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3372 char_u *dirname_start = NULL;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3373 char_u *dirname_now = NULL;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3374 char_u *target_dir = NULL;
1683
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
3375 #ifdef FEAT_AUTOCMD
75dbeedddaa9 updated for version 7.2b-016
vimboss
parents: 1672
diff changeset
3376 char_u *au_name = NULL;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3377
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3378 switch (eap->cmdidx)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3379 {
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3380 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3381 case CMD_lvimgrep: au_name = (char_u *)"lvimgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3382 case CMD_vimgrepadd: au_name = (char_u *)"vimgrepadd"; break;
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3383 case CMD_lvimgrepadd: au_name = (char_u *)"lvimgrepadd"; break;
2782
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3384 case CMD_grep: au_name = (char_u *)"grep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3385 case CMD_lgrep: au_name = (char_u *)"lgrep"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3386 case CMD_grepadd: au_name = (char_u *)"grepadd"; break;
0a0d7961b4fe updated for version 7.3.167
Bram Moolenaar <bram@vim.org>
parents: 2770
diff changeset
3387 case CMD_lgrepadd: au_name = (char_u *)"lgrepadd"; break;
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3388 default: break;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3389 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3390 if (au_name != NULL)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3391 {
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3392 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3393 curbuf->b_fname, TRUE, curbuf);
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3394 if (did_throw || force_abort)
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3395 return;
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3396 }
6df0106fc595 updated for version 7.0049
vimboss
parents: 153
diff changeset
3397 #endif
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3398
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3399 if (eap->cmdidx == CMD_lgrep
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3400 || eap->cmdidx == CMD_lvimgrep
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3401 || eap->cmdidx == CMD_lgrepadd
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3402 || eap->cmdidx == CMD_lvimgrepadd)
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3403 {
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3404 qi = ll_get_or_alloc_list(curwin);
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3405 if (qi == NULL)
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3406 return;
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3407 }
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3408
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3409 if (eap->addr_count > 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3410 tomatch = eap->line2;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3411 else
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3412 tomatch = MAXLNUM;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3413
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3414 /* Get the search pattern: either white-separated or enclosed in // */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3415 regmatch.regprog = NULL;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3416 p = skip_vimgrep_pat(eap->arg, &s, &flags);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3417 if (p == NULL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3418 {
282
33d9c918b8ab updated for version 7.0075
vimboss
parents: 277
diff changeset
3419 EMSG(_(e_invalpat));
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3420 goto theend;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3421 }
4197
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3422
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3423 if (s != NULL && *s == NUL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3424 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3425 /* Pattern is empty, use last search pattern. */
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3426 if (last_search_pat() == NULL)
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3427 {
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3428 EMSG(_(e_noprevre));
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3429 goto theend;
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3430 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3431 regmatch.regprog = vim_regcomp(last_search_pat(), RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3432 }
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3433 else
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3434 regmatch.regprog = vim_regcomp(s, RE_MAGIC);
07fef68eb018 updated for version 7.3.850
Bram Moolenaar <bram@vim.org>
parents: 4003
diff changeset
3435
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3436 if (regmatch.regprog == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3437 goto theend;
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 42
diff changeset
3438 regmatch.rmm_ic = p_ic;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 359
diff changeset
3439 regmatch.rmm_maxcol = 0;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3440
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3441 p = skipwhite(p);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3442 if (*p == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3443 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3444 EMSG(_("E683: File name missing or invalid pattern"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3445 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3446 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3447
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
3448 if ((eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd &&
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
3449 eap->cmdidx != CMD_vimgrepadd && eap->cmdidx != CMD_lvimgrepadd)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3450 || qi->qf_curlist == qi->qf_listcount)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3451 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
3452 qf_new_list(qi, *eap->cmdlinep);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3453 else if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3454 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3455 for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3456 prevp->qf_next != prevp; prevp = prevp->qf_next)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3457 ;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3458
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3459 /* parse the list of arguments */
3620
4f1c511e71f8 updated for version 7.3.570
Bram Moolenaar <bram@vim.org>
parents: 3555
diff changeset
3460 if (get_arglist_exp(p, &fcount, &fnames, TRUE) == FAIL)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3461 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3462 if (fcount == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3463 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3464 EMSG(_(e_nomatch));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3465 goto theend;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3466 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3467
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3468 dirname_start = alloc(MAXPATHL);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3469 dirname_now = alloc(MAXPATHL);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3470 if (dirname_start == NULL || dirname_now == NULL)
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3471 goto theend;
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3472
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3473 /* Remember the current directory, because a BufRead autocommand that does
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3474 * ":lcd %:p:h" changes the meaning of short path names. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3475 mch_dirname(dirname_start, MAXPATHL);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3476
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3477 #ifdef FEAT_AUTOCMD
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4197
diff changeset
3478 /* Remember the value of qf_start, so that we can check for autocommands
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3479 * changing the current quickfix list. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3480 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3481 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3482
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3483 seconds = (time_t)0;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3484 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3485 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3486 fname = shorten_fname1(fnames[fi]);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3487 if (time(NULL) > seconds)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3488 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3489 /* Display the file name every second or so, show the user we are
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3490 * working on it. */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3491 seconds = time(NULL);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3492 msg_start();
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3493 p = msg_strtrunc(fname, TRUE);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3494 if (p == NULL)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3495 msg_outtrans(fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3496 else
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3497 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3498 msg_outtrans(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3499 vim_free(p);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3500 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3501 msg_clr_eos();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3502 msg_didout = FALSE; /* overwrite this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3503 msg_nowait = TRUE; /* don't wait for this message */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3504 msg_col = 0;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3505 out_flush();
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3506 }
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3507
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3508 buf = buflist_findname_exp(fnames[fi]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3509 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3510 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3511 /* Remember that a buffer with this name already exists. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3512 duplicate_name = (buf != NULL);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3513 using_dummy = TRUE;
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3514 redraw_for_dummy = TRUE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3515
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3516 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3517 /* Don't do Filetype autocommands to avoid loading syntax and
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3518 * indent scripts, a great speed improvement. */
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3519 save_ei = au_event_disable(",Filetype");
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3520 #endif
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3521 /* Don't use modelines here, it's useless. */
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3522 save_mls = p_mls;
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3523 p_mls = 0;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3524
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3525 /* Load file into a buffer, so that 'fileencoding' is detected,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3526 * autocommands applied, etc. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3527 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3528
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3529 p_mls = save_mls;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3530 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3531 au_event_restore(save_ei);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3532 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3533 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3534 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3535 /* Use existing, loaded buffer. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3536 using_dummy = FALSE;
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3537
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3538 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3539 if (cur_qf_start != qi->qf_lists[qi->qf_curlist].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3540 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3541 int idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3542
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3543 /* Autocommands changed the quickfix list. Find the one we were
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3544 * using and restore it. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3545 for (idx = 0; idx < LISTCOUNT; ++idx)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3546 if (cur_qf_start == qi->qf_lists[idx].qf_start)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3547 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3548 qi->qf_curlist = idx;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3549 break;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3550 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3551 if (idx == LISTCOUNT)
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3552 {
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3553 /* List cannot be found, create a new one. */
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3554 qf_new_list(qi, *eap->cmdlinep);
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3555 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3556 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3557 }
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3558 #endif
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3559
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3560 if (buf == NULL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3561 {
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3562 if (!got_int)
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3563 smsg((char_u *)_("Cannot open file \"%s\""), fname);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3564 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3565 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3566 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3567 /* Try for a match in all lines of the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3568 * For ":1vimgrep" look for first match only. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3569 found_match = FALSE;
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3570 for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3571 ++lnum)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3572 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3573 col = 0;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3574 while (vim_regexec_multi(&regmatch, curwin, buf, lnum,
1521
cc4fe241baa3 updated for version 7.1-236
vimboss
parents: 1411
diff changeset
3575 col, NULL) > 0)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3576 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3577 ;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3578 if (qf_add_entry(qi, &prevp,
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3579 NULL, /* dir */
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3580 fname,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3581 0,
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3582 ml_get_buf(buf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3583 regmatch.startpos[0].lnum + lnum, FALSE),
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3584 regmatch.startpos[0].lnum + lnum,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3585 regmatch.startpos[0].col + 1,
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3586 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3587 NULL, /* search pattern */
856
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3588 0, /* nr */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3589 0, /* type */
8cd729851562 updated for version 7.0g
vimboss
parents: 842
diff changeset
3590 TRUE /* valid */
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3591 ) == FAIL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3592 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3593 got_int = TRUE;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3594 break;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3595 }
716
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3596 found_match = TRUE;
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3597 if (--tomatch == 0)
8ae24f338cab updated for version 7.0217
vimboss
parents: 712
diff changeset
3598 break;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3599 if ((flags & VGR_GLOBAL) == 0
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3600 || regmatch.endpos[0].lnum > 0)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3601 break;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3602 col = regmatch.endpos[0].col
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3603 + (col == regmatch.endpos[0].col);
1883
c8f343a465a2 updated for version 7.2-180
vimboss
parents: 1872
diff changeset
3604 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE)))
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3605 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3606 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3607 line_breakcheck();
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3608 if (got_int)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3609 break;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3610 }
4003
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3611 #ifdef FEAT_AUTOCMD
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3612 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
706c87d16d40 updated for version 7.3.756
Bram Moolenaar <bram@vim.org>
parents: 3982
diff changeset
3613 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3614
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3615 if (using_dummy)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3616 {
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3617 if (found_match && first_match_buf == NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3618 first_match_buf = buf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3619 if (duplicate_name)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3620 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3621 /* Never keep a dummy buffer if there is another buffer
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3622 * with the same name. */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3623 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3624 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3625 }
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3626 else if (!cmdmod.hide
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3627 || buf->b_p_bh[0] == 'u' /* "unload" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3628 || buf->b_p_bh[0] == 'w' /* "wipe" */
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3629 || buf->b_p_bh[0] == 'd') /* "delete" */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3630 {
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3631 /* When no match was found we don't need to remember the
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3632 * buffer, wipe it out. If there was a match and it
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3633 * wasn't the first one or we won't jump there: only
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3634 * unload the buffer.
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3635 * Ignore 'hidden' here, because it may lead to having too
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3636 * many swap files. */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3637 if (!found_match)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3638 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3639 wipe_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3640 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3641 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3642 else if (buf != first_match_buf || (flags & VGR_NOJUMP))
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3643 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3644 unload_dummy_buffer(buf, dirname_start);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3645 buf = NULL;
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3646 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3647 }
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3648
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3649 if (buf != NULL)
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3650 {
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3651 /* If the buffer is still loaded we need to use the
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3652 * directory we jumped to below. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3653 if (buf == first_match_buf
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3654 && target_dir == NULL
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3655 && STRCMP(dirname_start, dirname_now) != 0)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3656 target_dir = vim_strsave(dirname_now);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3657
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3658 /* The buffer is still loaded, the Filetype autocommands
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3659 * need to be done now, in that buffer. And the modelines
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3660 * need to be done (again). But not the window-local
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3661 * options! */
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3662 aucmd_prepbuf(&aco, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3663 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3664 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3665 buf->b_fname, TRUE, buf);
677
e649c78407e6 updated for version 7.0202
vimboss
parents: 665
diff changeset
3666 #endif
717
2fa8cb05b861 updated for version 7.0218
vimboss
parents: 716
diff changeset
3667 do_modelines(OPT_NOWIN);
123
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3668 aucmd_restbuf(&aco);
f67f8a8d81ba updated for version 7.0043
vimboss
parents: 119
diff changeset
3669 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3670 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3671 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3672 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3673
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3674 FreeWild(fcount, fnames);
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3675
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3676 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3677 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3678 qi->qf_lists[qi->qf_curlist].qf_index = 1;
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3679
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3680 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3681 qf_update_buffer(qi);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3682 #endif
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3683
842
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3684 #ifdef FEAT_AUTOCMD
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3685 if (au_name != NULL)
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3686 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3687 curbuf->b_fname, TRUE, curbuf);
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3688 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 835
diff changeset
3689
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3690 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3691 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3692 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3693 if ((flags & VGR_NOJUMP) == 0)
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3694 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3695 buf = curbuf;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
3696 qf_jump(qi, 0, 0, eap->forceit);
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3697 if (buf != curbuf)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3698 /* If we jumped to another buffer redrawing will already be
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3699 * taken care of. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3700 redraw_for_dummy = FALSE;
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3701
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3702 /* Jump to the directory used after loading the buffer. */
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3703 if (curbuf == first_match_buf && target_dir != NULL)
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3704 {
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3705 exarg_T ea;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3706
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3707 ea.arg = target_dir;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3708 ea.cmdidx = CMD_lcd;
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3709 ex_cd(&ea);
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3710 }
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3711 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3712 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3713 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3714 EMSG2(_(e_nomatch2), s);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3715
1396
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3716 /* If we loaded a dummy buffer into the current window, the autocommands
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3717 * may have messed up things, need to redraw and recompute folds. */
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3718 if (redraw_for_dummy)
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3719 {
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3720 #ifdef FEAT_FOLDING
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3721 foldUpdateAll(curwin);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3722 #else
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3723 redraw_later(NOT_VALID);
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3724 #endif
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3725 }
3e0f9984e98e updated for version 7.1-111
vimboss
parents: 1302
diff changeset
3726
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3727 theend:
2770
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3728 vim_free(dirname_now);
25672ad7f377 updated for version 7.3.161
Bram Moolenaar <bram@vim.org>
parents: 2651
diff changeset
3729 vim_free(dirname_start);
1411
0e6b369b9760 updated for version 7.1-126
vimboss
parents: 1396
diff changeset
3730 vim_free(target_dir);
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
3731 vim_regfree(regmatch.regprog);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3732 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3733
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
3734 /*
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3735 * Skip over the pattern argument of ":vimgrep /pat/[g][j]".
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3736 * Put the start of the pattern in "*s", unless "s" is NULL.
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3737 * If "flags" is not NULL put the flags in it: VGR_GLOBAL, VGR_NOJUMP.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3738 * If "s" is not NULL terminate the pattern with a NUL.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3739 * Return a pointer to the char just past the pattern plus flags.
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3740 */
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3741 char_u *
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3742 skip_vimgrep_pat(p, s, flags)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3743 char_u *p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3744 char_u **s;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3745 int *flags;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3746 {
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3747 int c;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3748
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3749 if (vim_isIDc(*p))
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3750 {
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3751 /* ":vimgrep pattern fname" */
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3752 if (s != NULL)
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3753 *s = p;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3754 p = skiptowhite(p);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3755 if (s != NULL && *p != NUL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3756 *p++ = NUL;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3757 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3758 else
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3759 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3760 /* ":vimgrep /pattern/[g][j] fname" */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3761 if (s != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3762 *s = p + 1;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3763 c = *p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3764 p = skip_regexp(p + 1, c, TRUE, NULL);
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3765 if (*p != c)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3766 return NULL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3767
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3768 /* Truncate the pattern. */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3769 if (s != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3770 *p = NUL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3771 ++p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3772
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3773 /* Find the flags */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3774 while (*p == 'g' || *p == 'j')
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3775 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3776 if (flags != NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3777 {
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3778 if (*p == 'g')
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3779 *flags |= VGR_GLOBAL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3780 else
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3781 *flags |= VGR_NOJUMP;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3782 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3783 ++p;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3784 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3785 }
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3786 return p;
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3787 }
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3788
19670b05ee32 updated for version 7.0047
vimboss
parents: 129
diff changeset
3789 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3790 * Restore current working directory to "dirname_start" if they differ, taking
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3791 * into account whether it is set locally or globally.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3792 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3793 static void
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3794 restore_start_dir(dirname_start)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3795 char_u *dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3796 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3797 char_u *dirname_now = alloc(MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3798
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3799 if (NULL != dirname_now)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3800 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3801 mch_dirname(dirname_now, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3802 if (STRCMP(dirname_start, dirname_now) != 0)
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3803 {
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3804 /* If the directory has changed, change it back by building up an
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3805 * appropriate ex command and executing it. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3806 exarg_T ea;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3807
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3808 ea.arg = dirname_start;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3809 ea.cmdidx = (curwin->w_localdir == NULL) ? CMD_cd : CMD_lcd;
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3810 ex_cd(&ea);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3811 }
3974
4d1753f3e85c updated for version 7.3.742
Bram Moolenaar <bram@vim.org>
parents: 3965
diff changeset
3812 vim_free(dirname_now);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3813 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3814 }
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3815
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3816 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3817 * Load file "fname" into a dummy buffer and return the buffer pointer,
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3818 * placing the directory resulting from the buffer load into the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3819 * "resulting_dir" pointer. "resulting_dir" must be allocated by the caller
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3820 * prior to calling this function. Restores directory to "dirname_start" prior
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3821 * to returning, if autocmds or the 'autochdir' option have changed it.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3822 *
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3823 * If creating the dummy buffer does not fail, must call unload_dummy_buffer()
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3824 * or wipe_dummy_buffer() later!
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3825 *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3826 * Returns NULL if it fails.
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3827 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3828 static buf_T *
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3829 load_dummy_buffer(fname, dirname_start, resulting_dir)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3830 char_u *fname;
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3831 char_u *dirname_start; /* in: old directory */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3832 char_u *resulting_dir; /* out: new directory */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3833 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3834 buf_T *newbuf;
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3835 buf_T *newbuf_to_wipe = NULL;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3836 int failed = TRUE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3837 aco_save_T aco;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3838
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3839 /* Allocate a buffer without putting it in the buffer list. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3840 newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3841 if (newbuf == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3842 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3843
177
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3844 /* Init the options. */
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3845 buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP);
84c21eb4fc40 updated for version 7.0054
vimboss
parents: 170
diff changeset
3846
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3847 /* need to open the memfile before putting the buffer in a window */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3848 if (ml_open(newbuf) == OK)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3849 {
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3850 /* set curwin/curbuf to buf and save a few things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3851 aucmd_prepbuf(&aco, newbuf);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3852
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3853 /* Need to set the filename for autocommands. */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3854 (void)setfname(curbuf, fname, NULL, FALSE);
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3855
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3856 /* Create swap file now to avoid the ATTENTION message. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3857 check_need_swap(TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3858
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3859 /* Remove the "dummy" flag, otherwise autocommands may not
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3860 * work. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3861 curbuf->b_flags &= ~BF_DUMMY;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3862
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3863 if (readfile(fname, NULL,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3864 (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3865 NULL, READ_NEW | READ_DUMMY) == OK
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3866 && !got_int
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3867 && !(curbuf->b_flags & BF_NEW))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3868 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3869 failed = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3870 if (curbuf != newbuf)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3871 {
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3872 /* Bloody autocommands changed the buffer! Can happen when
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3873 * using netrw and editing a remote file. Use the current
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3874 * buffer instead, delete the dummy one after restoring the
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3875 * window stuff. */
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3876 newbuf_to_wipe = newbuf;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3877 newbuf = curbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3878 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3879 }
1918
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3880
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3881 /* restore curwin/curbuf and a few other things */
eac2556d4620 updated for version 7.2-215
vimboss
parents: 1883
diff changeset
3882 aucmd_restbuf(&aco);
2646
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3883 if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe))
ff3a304b4ac2 updated for version 7.3.066
Bram Moolenaar <bram@vim.org>
parents: 2583
diff changeset
3884 wipe_buffer(newbuf_to_wipe, FALSE);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3885 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3886
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3887 /*
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3888 * When autocommands/'autochdir' option changed directory: go back.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3889 * Let the caller know what the resulting dir was first, in case it is
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3890 * important.
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3891 */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3892 mch_dirname(resulting_dir, MAXPATHL);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3893 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3894
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3895 if (!buf_valid(newbuf))
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3896 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3897 if (failed)
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3898 {
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3899 wipe_dummy_buffer(newbuf, dirname_start);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3900 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3901 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3902 return newbuf;
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3903 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3904
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3905 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3906 * Wipe out the dummy buffer that load_dummy_buffer() created. Restores
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3907 * directory to "dirname_start" prior to returning, if autocmds or the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3908 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3909 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3910 static void
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3911 wipe_dummy_buffer(buf, dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3912 buf_T *buf;
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3913 char_u *dirname_start;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3914 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3915 if (curbuf != buf) /* safety check */
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3916 {
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3917 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3918 cleanup_T cs;
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3919
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3920 /* Reset the error/interrupt/exception state here so that aborting()
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3921 * returns FALSE when wiping out the buffer. Otherwise it doesn't
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3922 * work when got_int is set. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3923 enter_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3924 #endif
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3925
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3926 wipe_buffer(buf, FALSE);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3927
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3928 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3929 /* Restore the error/interrupt/exception state if not discarded by a
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3930 * new aborting error, interrupt, or uncaught exception. */
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3931 leave_cleanup(&cs);
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3932 #endif
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3933 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3934 restore_start_dir(dirname_start);
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 856
diff changeset
3935 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3936 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3937
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3938 /*
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3939 * Unload the dummy buffer that load_dummy_buffer() created. Restores
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3940 * directory to "dirname_start" prior to returning, if autocmds or the
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3941 * 'autochdir' option have changed it.
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3942 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3943 static void
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3944 unload_dummy_buffer(buf, dirname_start)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3945 buf_T *buf;
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3946 char_u *dirname_start;
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3947 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3948 if (curbuf != buf) /* safety check */
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3949 {
3365
9ccdc4a69d8f updated for version 7.3.449
Bram Moolenaar <bram@vim.org>
parents: 3269
diff changeset
3950 close_buffer(NULL, buf, DOBUF_UNLOAD, FALSE);
3490
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3951
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3952 /* When autocommands/'autochdir' option changed directory: go back. */
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3953 restore_start_dir(dirname_start);
8101253704f6 updated for version 7.3.509
Bram Moolenaar <bram@vim.org>
parents: 3404
diff changeset
3954 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3955 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
3956
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3957 #if defined(FEAT_EVAL) || defined(PROTO)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3958 /*
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3959 * Add each quickfix error to list "list" as a dictionary.
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3960 */
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3961 int
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3962 get_errorlist(wp, list)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3963 win_T *wp;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3964 list_T *list;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3965 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3966 qf_info_T *qi = &ql_info;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3967 dict_T *dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3968 char_u buf[2];
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3969 qfline_T *qfp;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
3970 int i;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3971 int bufnum;
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3972
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3973 if (wp != NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3974 {
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3975 qi = GET_LOC_LIST(wp);
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3976 if (qi == NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3977 return FAIL;
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3978 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
3979
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3980 if (qi->qf_curlist >= qi->qf_listcount
712
2e887dfa8917 updated for version 7.0214
vimboss
parents: 694
diff changeset
3981 || qi->qf_lists[qi->qf_curlist].qf_count == 0)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3982 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3983
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3984 qfp = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
3985 for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i)
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3986 {
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3987 /* Handle entries with a non-existing buffer number. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3988 bufnum = qfp->qf_fnum;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3989 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3990 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3991
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3992 if ((dict = dict_alloc()) == NULL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3993 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3994 if (list_append_dict(list, dict) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3995 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3996
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3997 buf[0] = qfp->qf_type;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
3998 buf[1] = NUL;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
3999 if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4000 || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4001 || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4002 || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4003 || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
960
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4004 || dict_add_nr_str(dict, "pattern", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4005 qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4006 || dict_add_nr_str(dict, "text", 0L,
8c8d07318d8d updated for version 7.0-086
vimboss
parents: 944
diff changeset
4007 qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4008 || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4009 || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4010 return FAIL;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4011
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4012 qfp = qfp->qf_next;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4013 }
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4014 return OK;
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4015 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4016
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4017 /*
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4018 * Populate the quickfix list with the items supplied in the list
2530
9fe4164cb586 Fix: :ltag command did not set w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2416
diff changeset
4019 * of dictionaries. "title" will be copied to w:quickfix_title
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4020 */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4021 int
2530
9fe4164cb586 Fix: :ltag command did not set w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2416
diff changeset
4022 set_errorlist(wp, list, action, title)
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4023 win_T *wp;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4024 list_T *list;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4025 int action;
2530
9fe4164cb586 Fix: :ltag command did not set w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2416
diff changeset
4026 char_u *title;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4027 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4028 listitem_T *li;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4029 dict_T *d;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4030 char_u *filename, *pattern, *text, *type;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4031 int bufnum;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4032 long lnum;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4033 int col, nr;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4034 int vcol;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4035 qfline_T *prevp = NULL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4036 int valid, status;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4037 int retval = OK;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4038 qf_info_T *qi = &ql_info;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4039 int did_bufnr_emsg = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4040
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4041 if (wp != NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4042 {
648
9032e4668296 updated for version 7.0189
vimboss
parents: 647
diff changeset
4043 qi = ll_get_or_alloc_list(wp);
647
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4044 if (qi == NULL)
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4045 return FAIL;
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4046 }
19106f131c87 updated for version 7.0188
vimboss
parents: 644
diff changeset
4047
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4048 if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4049 /* make place for a new list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
4050 qf_new_list(qi, title);
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4051 else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0)
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4052 /* Adding to existing list, find last entry. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4053 for (prevp = qi->qf_lists[qi->qf_curlist].qf_start;
277
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4054 prevp->qf_next != prevp; prevp = prevp->qf_next)
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4055 ;
fe16c18c24a7 updated for version 7.0074
vimboss
parents: 273
diff changeset
4056 else if (action == 'r')
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4057 {
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4058 qf_free(qi, qi->qf_curlist);
6079
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4059 qf_store_title(qi, title);
75ae211df37d updated for version 7.4.378
Bram Moolenaar <bram@vim.org>
parents: 5753
diff changeset
4060 }
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4061
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4062 for (li = list->lv_first; li != NULL; li = li->li_next)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4063 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4064 if (li->li_tv.v_type != VAR_DICT)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4065 continue; /* Skip non-dict items */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4066
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4067 d = li->li_tv.vval.v_dict;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4068 if (d == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4069 continue;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4070
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4071 filename = get_dict_string(d, (char_u *)"filename", TRUE);
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4072 bufnum = get_dict_number(d, (char_u *)"bufnr");
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4073 lnum = get_dict_number(d, (char_u *)"lnum");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4074 col = get_dict_number(d, (char_u *)"col");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4075 vcol = get_dict_number(d, (char_u *)"vcol");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4076 nr = get_dict_number(d, (char_u *)"nr");
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4077 type = get_dict_string(d, (char_u *)"type", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4078 pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4079 text = get_dict_string(d, (char_u *)"text", TRUE);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4080 if (text == NULL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4081 text = vim_strsave((char_u *)"");
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4082
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4083 valid = TRUE;
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4084 if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4085 valid = FALSE;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4086
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4087 /* Mark entries with non-existing buffer number as not valid. Give the
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4088 * error message only once. */
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4089 if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4090 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4091 if (!did_bufnr_emsg)
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4092 {
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4093 did_bufnr_emsg = TRUE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4094 EMSGN(_("E92: Buffer %ld not found"), bufnum);
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4095 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4096 valid = FALSE;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4097 bufnum = 0;
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4098 }
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4099
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4100 status = qf_add_entry(qi, &prevp,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4101 NULL, /* dir */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4102 filename,
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4103 bufnum,
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4104 text,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4105 lnum,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4106 col,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4107 vcol, /* vis_col */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4108 pattern, /* search pattern */
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4109 nr,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4110 type == NULL ? NUL : *type,
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4111 valid);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4112
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4113 vim_free(filename);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4114 vim_free(pattern);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4115 vim_free(text);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4116 vim_free(type);
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4117
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4118 if (status == FAIL)
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4119 {
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4120 retval = FAIL;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4121 break;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4122 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4123 }
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4124
2146
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4125 if (qi->qf_lists[qi->qf_curlist].qf_index == 0)
2795
133d089f247e updated for version 7.3.173
Bram Moolenaar <bram@vim.org>
parents: 2782
diff changeset
4126 /* no valid entry */
2146
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4127 qi->qf_lists[qi->qf_curlist].qf_nonevalid = TRUE;
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4128 else
c17a42da3920 updated for version 7.2.428
Bram Moolenaar <bram@zimbu.org>
parents: 2047
diff changeset
4129 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4130 qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4131 qi->qf_lists[qi->qf_curlist].qf_index = 1;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4132
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4133 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4134 qf_update_buffer(qi);
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4135 #endif
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4136
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4137 return retval;
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4138 }
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4139 #endif
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4140
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4141 /*
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4142 * ":[range]cbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4143 * ":[range]caddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4144 * ":[range]cgetbuffer [bufnr]" command.
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4145 * ":[range]lbuffer [bufnr]" command.
657
b112ec5c73f0 updated for version 7.0193
vimboss
parents: 648
diff changeset
4146 * ":[range]laddbuffer [bufnr]" command.
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4147 * ":[range]lgetbuffer [bufnr]" command.
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4148 */
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4149 void
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4150 ex_cbuffer(eap)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4151 exarg_T *eap;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4152 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4153 buf_T *buf = NULL;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4154 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4155
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4156 if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4157 || eap->cmdidx == CMD_laddbuffer)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4158 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4159 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4160 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4161 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4162 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4163
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4164 if (*eap->arg == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4165 buf = curbuf;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4166 else if (*skipwhite(skipdigits(eap->arg)) == NUL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4167 buf = buflist_findnr(atoi((char *)eap->arg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4168 if (buf == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4169 EMSG(_(e_invarg));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4170 else if (buf->b_ml.ml_mfp == NULL)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4171 EMSG(_("E681: Buffer is not loaded"));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4172 else
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4173 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4174 if (eap->addr_count == 0)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4175 {
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4176 eap->line1 = 1;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4177 eap->line2 = buf->b_ml.ml_line_count;
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4178 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4179 if (eap->line1 < 1 || eap->line1 > buf->b_ml.ml_line_count
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4180 || eap->line2 < 1 || eap->line2 > buf->b_ml.ml_line_count)
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4181 EMSG(_(e_invrange));
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4182 else
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4183 {
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4184 char_u *qf_title = *eap->cmdlinep;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4185
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4186 if (buf->b_sfname)
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4187 {
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4188 vim_snprintf((char *)IObuff, IOSIZE, "%s (%s)",
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4189 (char *)qf_title, (char *)buf->b_sfname);
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4190 qf_title = IObuff;
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4191 }
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4192
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4193 if (qf_init_ext(qi, NULL, buf, NULL, p_efm,
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4194 (eap->cmdidx != CMD_caddbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4195 && eap->cmdidx != CMD_laddbuffer),
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4196 eap->line1, eap->line2,
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4197 qf_title) > 0
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4198 && (eap->cmdidx == CMD_cbuffer
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4199 || eap->cmdidx == CMD_lbuffer))
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4200 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4201 }
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4202 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4203 }
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4204
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
4205 #if defined(FEAT_EVAL) || defined(PROTO)
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 26
diff changeset
4206 /*
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4207 * ":cexpr {expr}", ":cgetexpr {expr}", ":caddexpr {expr}" command.
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4208 * ":lexpr {expr}", ":lgetexpr {expr}", ":laddexpr {expr}" command.
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4209 */
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4210 void
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4211 ex_cexpr(eap)
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4212 exarg_T *eap;
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4213 {
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4214 typval_T *tv;
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4215 qf_info_T *qi = &ql_info;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4216
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4217 if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4218 || eap->cmdidx == CMD_laddexpr)
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4219 {
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4220 qi = ll_get_or_alloc_list(curwin);
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4221 if (qi == NULL)
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4222 return;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4223 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4224
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4225 /* Evaluate the expression. When the result is a string or a list we can
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4226 * use it to fill the errorlist. */
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4227 tv = eval_expr(eap->arg, NULL);
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4228 if (tv != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4229 {
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4230 if ((tv->v_type == VAR_STRING && tv->vval.v_string != NULL)
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4231 || (tv->v_type == VAR_LIST && tv->vval.v_list != NULL))
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4232 {
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4233 if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4234 (eap->cmdidx != CMD_caddexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4235 && eap->cmdidx != CMD_laddexpr),
2411
68e394361ca3 Add "q" item for 'statusline'. Add w:quickfix_title. (Lech Lorens)
Bram Moolenaar <bram@vim.org>
parents: 2296
diff changeset
4236 (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0
798
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4237 && (eap->cmdidx == CMD_cexpr
95dac6af3b3a updated for version 7.0232
vimboss
parents: 789
diff changeset
4238 || eap->cmdidx == CMD_lexpr))
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4239 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4240 }
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4241 else
626
732c7ae5743e updated for version 7.0180
vimboss
parents: 625
diff changeset
4242 EMSG(_("E777: String or List expected"));
625
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4243 free_tv(tv);
81fe2ccc1207 updated for version 7.0179
vimboss
parents: 581
diff changeset
4244 }
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4245 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 531
diff changeset
4246 #endif
446
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4247
7472c565592a updated for version 7.0117
vimboss
parents: 418
diff changeset
4248 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249 * ":helpgrep {pattern}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4250 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4251 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4252 ex_helpgrep(eap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4253 exarg_T *eap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4254 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4255 regmatch_T regmatch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4256 char_u *save_cpo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4257 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4258 int fcount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4259 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4260 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4261 int fi;
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4262 qfline_T *prevp = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4263 long lnum;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4264 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4265 char_u *lang;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4266 #endif
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4267 qf_info_T *qi = &ql_info;
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4268 int new_qi = FALSE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4269 win_T *wp;
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4270 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4271 char_u *au_name = NULL;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4272 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4273
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4274 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4275 /* Check for a specified language */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4276 lang = check_help_lang(eap->arg);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4277 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4278
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4279 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4280 switch (eap->cmdidx)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4281 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4282 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4283 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4284 default: break;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4285 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4286 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4287 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4288 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4289 curbuf->b_fname, TRUE, curbuf);
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4290 if (did_throw || force_abort)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4291 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4292 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4293 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4294
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4295 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4296 save_cpo = p_cpo;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4297 p_cpo = empty_option;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4298
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4299 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4300 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4301 /* Find an existing help window */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4302 FOR_ALL_WINDOWS(wp)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4303 if (wp->w_buffer != NULL && wp->w_buffer->b_help)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4304 break;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4305
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4306 if (wp == NULL) /* Help window not found */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4307 qi = NULL;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4308 else
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4309 qi = wp->w_llist;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4310
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4311 if (qi == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4312 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4313 /* Allocate a new location list for help text matches */
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4314 if ((qi = ll_new_list()) == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4315 return;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4316 new_qi = TRUE;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4317 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4318 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4319
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4320 regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4321 regmatch.rm_ic = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4322 if (regmatch.regprog != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4323 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4324 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4325 vimconv_T vc;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4326
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4327 /* Help files are in utf-8 or latin1, convert lines when 'encoding'
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4328 * differs. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4329 vc.vc_type = CONV_NONE;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4330 if (!enc_utf8)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4331 convert_setup(&vc, (char_u *)"utf-8", p_enc);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4332 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4333
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4334 /* create a new quickfix list */
3965
eccae034465b updated for version 7.3.738
Bram Moolenaar <bram@vim.org>
parents: 3949
diff changeset
4335 qf_new_list(qi, *eap->cmdlinep);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4337 /* Go through all directories in 'runtimepath' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4338 p = p_rtp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4339 while (*p != NUL && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4340 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4341 copy_option_part(&p, NameBuff, MAXPATHL, ",");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4343 /* Find all "*.txt" and "*.??x" files in the "doc" directory. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4344 add_pathsep(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4345 STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4346 if (gen_expand_wildcards(1, &NameBuff, &fcount,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4347 &fnames, EW_FILE|EW_SILENT) == OK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4348 && fcount > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4350 for (fi = 0; fi < fcount && !got_int; ++fi)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4351 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4352 #ifdef FEAT_MULTI_LANG
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4353 /* Skip files for a different language. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4354 if (lang != NULL
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4355 && STRNICMP(lang, fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4356 + STRLEN(fnames[fi]) - 3, 2) != 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4357 && !(STRNICMP(lang, "en", 2) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4358 && STRNICMP("txt", fnames[fi]
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4359 + STRLEN(fnames[fi]) - 3, 3) == 0))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4360 continue;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4361 #endif
531
da9142bd190a updated for version 7.0149
vimboss
parents: 514
diff changeset
4362 fd = mch_fopen((char *)fnames[fi], "r");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4363 if (fd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4365 lnum = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366 while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4368 char_u *line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4369 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4370 /* Convert a line if 'encoding' is not utf-8 and
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4371 * the line contains a non-ASCII character. */
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4372 if (vc.vc_type != CONV_NONE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4373 && has_non_ascii(IObuff)) {
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4374 line = string_convert(&vc, IObuff, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4375 if (line == NULL)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4376 line = IObuff;
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4377 }
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4378 #endif
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4379
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4380 if (vim_regexec(&regmatch, line, (colnr_T)0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4381 {
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4382 int l = (int)STRLEN(line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4384 /* remove trailing CR, LF, spaces, etc. */
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4385 while (l > 0 && line[l - 1] <= ' ')
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4386 line[--l] = NUL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4387
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4388 if (qf_add_entry(qi, &prevp,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4389 NULL, /* dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390 fnames[fi],
1065
caa550fe4457 updated for version 7.0-191
vimboss
parents: 1020
diff changeset
4391 0,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4392 line,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393 lnum,
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4394 (int)(regmatch.startp[0] - line)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 41
diff changeset
4395 + 1, /* col */
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 167
diff changeset
4396 FALSE, /* vis_col */
230
9281a51ca7a2 updated for version 7.0064
vimboss
parents: 189
diff changeset
4397 NULL, /* search pattern */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 0, /* nr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 1, /* type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 TRUE /* valid */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 ) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403 got_int = TRUE;
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4404 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4405 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4406 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4407 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4408 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4411 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4412 if (line != IObuff)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4413 vim_free(line);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4414 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4415 ++lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4416 line_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4418 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4421 FreeWild(fcount, fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4423 }
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4424
4805
66803af09906 updated for version 7.3.1149
Bram Moolenaar <bram@vim.org>
parents: 4371
diff changeset
4425 vim_regfree(regmatch.regprog);
3257
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4426 #ifdef FEAT_MBYTE
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4427 if (vc.vc_type != CONV_NONE)
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4428 convert_setup(&vc, NULL, NULL);
75217982ea46 updated for version 7.3.397
Bram Moolenaar <bram@vim.org>
parents: 3242
diff changeset
4429 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4430
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4431 qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4432 qi->qf_lists[qi->qf_curlist].qf_ptr =
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4433 qi->qf_lists[qi->qf_curlist].qf_start;
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4434 qi->qf_lists[qi->qf_curlist].qf_index = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4436
1672
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
4437 if (p_cpo == empty_option)
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
4438 p_cpo = save_cpo;
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
4439 else
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
4440 /* Darn, some plugin changed the value. */
fddea6c03dee updated for version 7.2b-004
vimboss
parents: 1668
diff changeset
4441 free_string_option(save_cpo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4443 #ifdef FEAT_WINDOWS
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4444 qf_update_buffer(qi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4445 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4446
3269
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4447 #ifdef FEAT_AUTOCMD
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4448 if (au_name != NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4449 {
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4450 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4451 curbuf->b_fname, TRUE, curbuf);
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4452 if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL)
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4453 /* autocommands made "qi" invalid */
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4454 return;
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4455 }
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4456 #endif
5850b5827691 updated for version 7.3.403
Bram Moolenaar <bram@vim.org>
parents: 3267
diff changeset
4457
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 /* Jump to first match. */
644
e4fa26ce8769 updated for version 7.0187
vimboss
parents: 639
diff changeset
4459 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4460 qf_jump(qi, 0, 0, FALSE);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4461 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4462 EMSG2(_(e_nomatch2), eap->arg);
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4463
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4464 if (eap->cmdidx == CMD_lhelpgrep)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4465 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4466 /* If the help window is not opened or if it already points to the
661
e93a99ef31d0 updated for version 7.0195
vimboss
parents: 659
diff changeset
4467 * correct location list, then free the new location list. */
659
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4468 if (!curwin->w_buffer->b_help || curwin->w_llist == qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4469 {
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4470 if (new_qi)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4471 ll_free_all(&qi);
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4472 }
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4473 else if (curwin->w_llist == NULL)
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4474 curwin->w_llist = qi;
d6a69271cb9a updated for version 7.0194
vimboss
parents: 657
diff changeset
4475 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4478 #endif /* FEAT_QUICKFIX */