comparison src/quickfix.c @ 123:f67f8a8d81ba

updated for version 7.0043
author vimboss
date Fri, 21 Jan 2005 11:55:25 +0000
parents e8f07016e34d
children 2983cde45542
comparison
equal deleted inserted replaced
122:56eb9755174b 123:f67f8a8d81ba
2267 garray_T ga; 2267 garray_T ga;
2268 buf_T *buf; 2268 buf_T *buf;
2269 int duplicate_name = FALSE; 2269 int duplicate_name = FALSE;
2270 int using_dummy; 2270 int using_dummy;
2271 int found_match; 2271 int found_match;
2272 int first_match = TRUE; 2272 buf_T *first_match_buf = NULL;
2273 time_t seconds = 0;
2274 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
2275 char_u *save_ei = NULL;
2276 aco_save_T aco;
2277 #endif
2273 2278
2274 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ 2279 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
2275 save_cpo = p_cpo; 2280 save_cpo = p_cpo;
2276 p_cpo = empty_option; 2281 p_cpo = empty_option;
2277 2282
2328 { 2333 {
2329 EMSG(_(e_nomatch)); 2334 EMSG(_(e_nomatch));
2330 goto theend; 2335 goto theend;
2331 } 2336 }
2332 2337
2338 seconds = (time_t)0;
2333 for (fi = 0; fi < fcount && !got_int; ++fi) 2339 for (fi = 0; fi < fcount && !got_int; ++fi)
2334 { 2340 {
2341 if (time(NULL) > seconds)
2342 {
2343 /* Display the file name every second or so. */
2344 seconds = time(NULL);
2345 msg_start();
2346 p = msg_strtrunc(fnames[fi]);
2347 if (p == NULL)
2348 msg_outtrans(fnames[fi]);
2349 else
2350 {
2351 msg_outtrans(p);
2352 vim_free(p);
2353 }
2354 msg_clr_eos();
2355 msg_didout = FALSE; /* overwrite this message */
2356 msg_nowait = TRUE; /* don't wait for this message */
2357 msg_col = 0;
2358 out_flush();
2359 }
2360
2335 buf = buflist_findname_exp(fnames[fi]); 2361 buf = buflist_findname_exp(fnames[fi]);
2336 if (buf == NULL || buf->b_ml.ml_mfp == NULL) 2362 if (buf == NULL || buf->b_ml.ml_mfp == NULL)
2337 { 2363 {
2338 /* Remember that a buffer with this name already exists. */ 2364 /* Remember that a buffer with this name already exists. */
2339 duplicate_name = (buf != NULL); 2365 duplicate_name = (buf != NULL);
2366 using_dummy = TRUE;
2367
2368 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
2369 /* Don't do Filetype autocommands to avoid loading syntax and
2370 * indent scripts, a great speed improvement. */
2371 save_ei = au_event_disable(",Filetype");
2372 #endif
2340 2373
2341 /* Load file into a buffer, so that 'fileencoding' is detected, 2374 /* Load file into a buffer, so that 'fileencoding' is detected,
2342 * autocommands applied, etc. */ 2375 * autocommands applied, etc. */
2343 buf = load_dummy_buffer(fnames[fi]); 2376 buf = load_dummy_buffer(fnames[fi]);
2344 using_dummy = TRUE; 2377
2378 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
2379 au_event_restore(save_ei);
2380 #endif
2345 } 2381 }
2346 else 2382 else
2347 /* Use existing, loaded buffer. */ 2383 /* Use existing, loaded buffer. */
2348 using_dummy = FALSE; 2384 using_dummy = FALSE;
2385
2349 if (buf == NULL) 2386 if (buf == NULL)
2350 smsg((char_u *)_("Cannot open file \"%s\""), fnames[fi]); 2387 {
2388 if (!got_int)
2389 smsg((char_u *)_("Cannot open file \"%s\""), fnames[fi]);
2390 }
2351 else 2391 else
2352 { 2392 {
2353 found_match = FALSE; 2393 found_match = FALSE;
2354 for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum) 2394 for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
2355 { 2395 {
2380 break; 2420 break;
2381 } 2421 }
2382 2422
2383 if (using_dummy) 2423 if (using_dummy)
2384 { 2424 {
2425 if (found_match && first_match_buf == NULL)
2426 first_match_buf = buf;
2385 if (duplicate_name) 2427 if (duplicate_name)
2428 {
2386 /* Never keep a dummy buffer if there is another buffer 2429 /* Never keep a dummy buffer if there is another buffer
2387 * with the same name. */ 2430 * with the same name. */
2388 wipe_dummy_buffer(buf); 2431 wipe_dummy_buffer(buf);
2432 buf = NULL;
2433 }
2389 else if (!buf_hide(buf)) 2434 else if (!buf_hide(buf))
2390 { 2435 {
2391 /* When not hiding the buffer and no match was found we 2436 /* When not hiding the buffer and no match was found we
2392 * don't need to remember the buffer, wipe it out. If 2437 * don't need to remember the buffer, wipe it out. If
2393 * there was a match and it wasn't the first one: only 2438 * there was a match and it wasn't the first one: only
2394 * unload the buffer. */ 2439 * unload the buffer. */
2395 if (!found_match) 2440 if (!found_match)
2441 {
2396 wipe_dummy_buffer(buf); 2442 wipe_dummy_buffer(buf);
2397 else if (!first_match) 2443 buf = NULL;
2444 }
2445 else if (buf != first_match_buf)
2446 {
2398 unload_dummy_buffer(buf); 2447 unload_dummy_buffer(buf);
2448 buf = NULL;
2449 }
2399 } 2450 }
2451
2452 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL)
2453 if (buf != NULL)
2454 {
2455 /* The buffer is still loaded, the Filetype autocommands
2456 * need to be done now, in that buffer. */
2457 aucmd_prepbuf(&aco, buf);
2458 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
2459 buf->b_fname, TRUE, buf);
2460 aucmd_restbuf(&aco);
2461 }
2462 #endif
2400 } 2463 }
2401 if (found_match)
2402 first_match = FALSE;
2403 } 2464 }
2404 } 2465 }
2405 2466
2406 FreeWild(fcount, fnames); 2467 FreeWild(fcount, fnames);
2407 2468