comparison src/quickfix.c @ 13380:69517d67421f v8.0.1564

patch 8.0.1564: too many #ifdefs commit https://github.com/vim/vim/commit/f2bd8ef2b4507d02c6043affff8f7e85e3414d5f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 4 18:08:14 2018 +0100 patch 8.0.1564: too many #ifdefs Problem: Too many #ifdefs. Solution: Graduate the +autocmd feature. Takes away 450 #ifdefs and increases code size of tiny Vim by only 40 Kbyte.
author Christian Brabandt <cb@256bit.org>
date Sun, 04 Mar 2018 18:15:08 +0100
parents 66b8b29854d9
children d0afc9aa7a43
comparison
equal deleted inserted replaced
13379:0f9dd1b43244 13380:69517d67421f
3624 if (old_last == NULL) 3624 if (old_last == NULL)
3625 { 3625 {
3626 /* Set the 'filetype' to "qf" each time after filling the buffer. 3626 /* Set the 'filetype' to "qf" each time after filling the buffer.
3627 * This resembles reading a file into a buffer, it's more logical when 3627 * This resembles reading a file into a buffer, it's more logical when
3628 * using autocommands. */ 3628 * using autocommands. */
3629 #ifdef FEAT_AUTOCMD
3630 ++curbuf_lock; 3629 ++curbuf_lock;
3631 #endif
3632 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL); 3630 set_option_value((char_u *)"ft", 0L, (char_u *)"qf", OPT_LOCAL);
3633 curbuf->b_p_ma = FALSE; 3631 curbuf->b_p_ma = FALSE;
3634 3632
3635 #ifdef FEAT_AUTOCMD
3636 keep_filetype = TRUE; /* don't detect 'filetype' */ 3633 keep_filetype = TRUE; /* don't detect 'filetype' */
3637 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL, 3634 apply_autocmds(EVENT_BUFREADPOST, (char_u *)"quickfix", NULL,
3638 FALSE, curbuf); 3635 FALSE, curbuf);
3639 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL, 3636 apply_autocmds(EVENT_BUFWINENTER, (char_u *)"quickfix", NULL,
3640 FALSE, curbuf); 3637 FALSE, curbuf);
3641 keep_filetype = FALSE; 3638 keep_filetype = FALSE;
3642 --curbuf_lock; 3639 --curbuf_lock;
3643 #endif 3640
3644 /* make sure it will be redrawn */ 3641 /* make sure it will be redrawn */
3645 redraw_curbuf_later(NOT_VALID); 3642 redraw_curbuf_later(NOT_VALID);
3646 } 3643 }
3647 3644
3648 /* Restore KeyTyped, setting 'filetype' may reset it. */ 3645 /* Restore KeyTyped, setting 'filetype' may reset it. */
3680 char_u *enc = NULL; 3677 char_u *enc = NULL;
3681 unsigned len; 3678 unsigned len;
3682 win_T *wp = NULL; 3679 win_T *wp = NULL;
3683 qf_info_T *qi = &ql_info; 3680 qf_info_T *qi = &ql_info;
3684 int res; 3681 int res;
3685 #ifdef FEAT_AUTOCMD
3686 char_u *au_name = NULL; 3682 char_u *au_name = NULL;
3687 3683
3688 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ 3684 /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */
3689 if (grep_internal(eap->cmdidx)) 3685 if (grep_internal(eap->cmdidx))
3690 { 3686 {
3703 default: break; 3699 default: break;
3704 } 3700 }
3705 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, 3701 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
3706 curbuf->b_fname, TRUE, curbuf)) 3702 curbuf->b_fname, TRUE, curbuf))
3707 { 3703 {
3708 # ifdef FEAT_EVAL 3704 #ifdef FEAT_EVAL
3709 if (aborting()) 3705 if (aborting())
3710 return; 3706 return;
3711 # endif
3712 }
3713 #endif 3707 #endif
3708 }
3714 #ifdef FEAT_MBYTE 3709 #ifdef FEAT_MBYTE
3715 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; 3710 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
3716 #endif 3711 #endif
3717 3712
3718 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep 3713 if (eap->cmdidx == CMD_lmake || eap->cmdidx == CMD_lgrep
3764 *eap->cmdlinep, enc); 3759 *eap->cmdlinep, enc);
3765 if (wp != NULL) 3760 if (wp != NULL)
3766 qi = GET_LOC_LIST(wp); 3761 qi = GET_LOC_LIST(wp);
3767 if (res >= 0 && qi != NULL) 3762 if (res >= 0 && qi != NULL)
3768 qf_list_changed(qi, qi->qf_curlist); 3763 qf_list_changed(qi, qi->qf_curlist);
3769 #ifdef FEAT_AUTOCMD
3770 if (au_name != NULL) 3764 if (au_name != NULL)
3771 { 3765 {
3772 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 3766 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
3773 curbuf->b_fname, TRUE, curbuf); 3767 curbuf->b_fname, TRUE, curbuf);
3774 if (qi != NULL && qi->qf_curlist < qi->qf_listcount) 3768 if (qi != NULL && qi->qf_curlist < qi->qf_listcount)
3775 res = qi->qf_lists[qi->qf_curlist].qf_count; 3769 res = qi->qf_lists[qi->qf_curlist].qf_count;
3776 else 3770 else
3777 res = 0; 3771 res = 0;
3778 } 3772 }
3779 #endif
3780 if (res > 0 && !eap->forceit) 3773 if (res > 0 && !eap->forceit)
3781 qf_jump(qi, 0, 0, FALSE); /* display first error */ 3774 qf_jump(qi, 0, 0, FALSE); /* display first error */
3782 3775
3783 mch_remove(fname); 3776 mch_remove(fname);
3784 vim_free(fname); 3777 vim_free(fname);
4103 ex_cfile(exarg_T *eap) 4096 ex_cfile(exarg_T *eap)
4104 { 4097 {
4105 char_u *enc = NULL; 4098 char_u *enc = NULL;
4106 win_T *wp = NULL; 4099 win_T *wp = NULL;
4107 qf_info_T *qi = &ql_info; 4100 qf_info_T *qi = &ql_info;
4108 #ifdef FEAT_AUTOCMD
4109 char_u *au_name = NULL; 4101 char_u *au_name = NULL;
4110 int save_qfid; 4102 int save_qfid;
4111 #endif
4112 int res; 4103 int res;
4113 4104
4114 #ifdef FEAT_AUTOCMD
4115 switch (eap->cmdidx) 4105 switch (eap->cmdidx)
4116 { 4106 {
4117 case CMD_cfile: au_name = (char_u *)"cfile"; break; 4107 case CMD_cfile: au_name = (char_u *)"cfile"; break;
4118 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break; 4108 case CMD_cgetfile: au_name = (char_u *)"cgetfile"; break;
4119 case CMD_caddfile: au_name = (char_u *)"caddfile"; break; 4109 case CMD_caddfile: au_name = (char_u *)"caddfile"; break;
4122 case CMD_laddfile: au_name = (char_u *)"laddfile"; break; 4112 case CMD_laddfile: au_name = (char_u *)"laddfile"; break;
4123 default: break; 4113 default: break;
4124 } 4114 }
4125 if (au_name != NULL) 4115 if (au_name != NULL)
4126 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf); 4116 apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, NULL, FALSE, curbuf);
4127 #endif
4128 #ifdef FEAT_MBYTE 4117 #ifdef FEAT_MBYTE
4129 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; 4118 enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc;
4130 #endif 4119 #endif
4131 #ifdef FEAT_BROWSE 4120 #ifdef FEAT_BROWSE
4132 if (cmdmod.browse) 4121 if (cmdmod.browse)
4162 && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc); 4151 && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc);
4163 if (wp != NULL) 4152 if (wp != NULL)
4164 qi = GET_LOC_LIST(wp); 4153 qi = GET_LOC_LIST(wp);
4165 if (res >= 0 && qi != NULL) 4154 if (res >= 0 && qi != NULL)
4166 qf_list_changed(qi, qi->qf_curlist); 4155 qf_list_changed(qi, qi->qf_curlist);
4167 #ifdef FEAT_AUTOCMD
4168 if (qi != NULL) 4156 if (qi != NULL)
4169 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; 4157 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
4170 if (au_name != NULL) 4158 if (au_name != NULL)
4171 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf); 4159 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, NULL, FALSE, curbuf);
4172 4160
4173 /* An autocmd might have freed the quickfix/location list. Check whether it 4161 /* An autocmd might have freed the quickfix/location list. Check whether it
4174 * is still valid. */ 4162 * is still valid. */
4175 if (qi != NULL && !qflist_valid(wp, save_qfid)) 4163 if (qi != NULL && !qflist_valid(wp, save_qfid))
4176 return; 4164 return;
4177 #endif
4178 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)) 4165 if (res > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile))
4179 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 4166 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
4180 } 4167 }
4181 4168
4182 /* 4169 /*
4196 char_u *s; 4183 char_u *s;
4197 char_u *p; 4184 char_u *p;
4198 int fi; 4185 int fi;
4199 qf_info_T *qi = &ql_info; 4186 qf_info_T *qi = &ql_info;
4200 int loclist_cmd = FALSE; 4187 int loclist_cmd = FALSE;
4201 #ifdef FEAT_AUTOCMD
4202 int_u save_qfid; 4188 int_u save_qfid;
4203 qfline_T *cur_qf_start; 4189 qfline_T *cur_qf_start;
4204 win_T *wp; 4190 win_T *wp;
4205 #endif
4206 long lnum; 4191 long lnum;
4207 buf_T *buf; 4192 buf_T *buf;
4208 int duplicate_name = FALSE; 4193 int duplicate_name = FALSE;
4209 int using_dummy; 4194 int using_dummy;
4210 int redraw_for_dummy = FALSE; 4195 int redraw_for_dummy = FALSE;
4211 int found_match; 4196 int found_match;
4212 buf_T *first_match_buf = NULL; 4197 buf_T *first_match_buf = NULL;
4213 time_t seconds = 0; 4198 time_t seconds = 0;
4214 int save_mls; 4199 int save_mls;
4215 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) 4200 #if defined(FEAT_SYN_HL)
4216 char_u *save_ei = NULL; 4201 char_u *save_ei = NULL;
4217 #endif 4202 #endif
4218 aco_save_T aco; 4203 aco_save_T aco;
4219 int flags = 0; 4204 int flags = 0;
4220 colnr_T col; 4205 colnr_T col;
4221 long tomatch; 4206 long tomatch;
4222 char_u *dirname_start = NULL; 4207 char_u *dirname_start = NULL;
4223 char_u *dirname_now = NULL; 4208 char_u *dirname_now = NULL;
4224 char_u *target_dir = NULL; 4209 char_u *target_dir = NULL;
4225 #ifdef FEAT_AUTOCMD
4226 char_u *au_name = NULL; 4210 char_u *au_name = NULL;
4227 4211
4228 switch (eap->cmdidx) 4212 switch (eap->cmdidx)
4229 { 4213 {
4230 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break; 4214 case CMD_vimgrep: au_name = (char_u *)"vimgrep"; break;
4238 default: break; 4222 default: break;
4239 } 4223 }
4240 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, 4224 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
4241 curbuf->b_fname, TRUE, curbuf)) 4225 curbuf->b_fname, TRUE, curbuf))
4242 { 4226 {
4243 # ifdef FEAT_EVAL 4227 #ifdef FEAT_EVAL
4244 if (aborting()) 4228 if (aborting())
4245 return; 4229 return;
4246 # endif
4247 }
4248 #endif 4230 #endif
4231 }
4249 4232
4250 if (eap->cmdidx == CMD_lgrep 4233 if (eap->cmdidx == CMD_lgrep
4251 || eap->cmdidx == CMD_lvimgrep 4234 || eap->cmdidx == CMD_lvimgrep
4252 || eap->cmdidx == CMD_lgrepadd 4235 || eap->cmdidx == CMD_lgrepadd
4253 || eap->cmdidx == CMD_lvimgrepadd) 4236 || eap->cmdidx == CMD_lvimgrepadd)
4323 4306
4324 /* Remember the current directory, because a BufRead autocommand that does 4307 /* Remember the current directory, because a BufRead autocommand that does
4325 * ":lcd %:p:h" changes the meaning of short path names. */ 4308 * ":lcd %:p:h" changes the meaning of short path names. */
4326 mch_dirname(dirname_start, MAXPATHL); 4309 mch_dirname(dirname_start, MAXPATHL);
4327 4310
4328 #ifdef FEAT_AUTOCMD
4329 /* Remember the current values of the quickfix list and qf_start, so that 4311 /* Remember the current values of the quickfix list and qf_start, so that
4330 * we can check for autocommands changing the current quickfix list. */ 4312 * we can check for autocommands changing the current quickfix list. */
4331 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id; 4313 save_qfid = qi->qf_lists[qi->qf_curlist].qf_id;
4332 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; 4314 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
4333 #endif
4334 4315
4335 seconds = (time_t)0; 4316 seconds = (time_t)0;
4336 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi) 4317 for (fi = 0; fi < fcount && !got_int && tomatch > 0; ++fi)
4337 { 4318 {
4338 fname = shorten_fname1(fnames[fi]); 4319 fname = shorten_fname1(fnames[fi]);
4363 /* Remember that a buffer with this name already exists. */ 4344 /* Remember that a buffer with this name already exists. */
4364 duplicate_name = (buf != NULL); 4345 duplicate_name = (buf != NULL);
4365 using_dummy = TRUE; 4346 using_dummy = TRUE;
4366 redraw_for_dummy = TRUE; 4347 redraw_for_dummy = TRUE;
4367 4348
4368 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) 4349 #if defined(FEAT_SYN_HL)
4369 /* Don't do Filetype autocommands to avoid loading syntax and 4350 /* Don't do Filetype autocommands to avoid loading syntax and
4370 * indent scripts, a great speed improvement. */ 4351 * indent scripts, a great speed improvement. */
4371 save_ei = au_event_disable(",Filetype"); 4352 save_ei = au_event_disable(",Filetype");
4372 #endif 4353 #endif
4373 /* Don't use modelines here, it's useless. */ 4354 /* Don't use modelines here, it's useless. */
4377 /* Load file into a buffer, so that 'fileencoding' is detected, 4358 /* Load file into a buffer, so that 'fileencoding' is detected,
4378 * autocommands applied, etc. */ 4359 * autocommands applied, etc. */
4379 buf = load_dummy_buffer(fname, dirname_start, dirname_now); 4360 buf = load_dummy_buffer(fname, dirname_start, dirname_now);
4380 4361
4381 p_mls = save_mls; 4362 p_mls = save_mls;
4382 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) 4363 #if defined(FEAT_SYN_HL)
4383 au_event_restore(save_ei); 4364 au_event_restore(save_ei);
4384 #endif 4365 #endif
4385 } 4366 }
4386 else 4367 else
4387 /* Use existing, loaded buffer. */ 4368 /* Use existing, loaded buffer. */
4388 using_dummy = FALSE; 4369 using_dummy = FALSE;
4389 4370
4390 #ifdef FEAT_AUTOCMD
4391 if (loclist_cmd) 4371 if (loclist_cmd)
4392 { 4372 {
4393 /* 4373 /*
4394 * Verify that the location list is still valid. An autocmd might 4374 * Verify that the location list is still valid. An autocmd might
4395 * have freed the location list. 4375 * have freed the location list.
4417 /* List cannot be found, create a new one. */ 4397 /* List cannot be found, create a new one. */
4418 qf_new_list(qi, *eap->cmdlinep); 4398 qf_new_list(qi, *eap->cmdlinep);
4419 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; 4399 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
4420 } 4400 }
4421 } 4401 }
4422 #endif
4423 4402
4424 if (buf == NULL) 4403 if (buf == NULL)
4425 { 4404 {
4426 if (!got_int) 4405 if (!got_int)
4427 smsg((char_u *)_("Cannot open file \"%s\""), fname); 4406 smsg((char_u *)_("Cannot open file \"%s\""), fname);
4473 } 4452 }
4474 line_breakcheck(); 4453 line_breakcheck();
4475 if (got_int) 4454 if (got_int)
4476 break; 4455 break;
4477 } 4456 }
4478 #ifdef FEAT_AUTOCMD
4479 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start; 4457 cur_qf_start = qi->qf_lists[qi->qf_curlist].qf_start;
4480 #endif
4481 4458
4482 if (using_dummy) 4459 if (using_dummy)
4483 { 4460 {
4484 if (found_match && first_match_buf == NULL) 4461 if (found_match && first_match_buf == NULL)
4485 first_match_buf = buf; 4462 first_match_buf = buf;
4530 /* The buffer is still loaded, the Filetype autocommands 4507 /* The buffer is still loaded, the Filetype autocommands
4531 * need to be done now, in that buffer. And the modelines 4508 * need to be done now, in that buffer. And the modelines
4532 * need to be done (again). But not the window-local 4509 * need to be done (again). But not the window-local
4533 * options! */ 4510 * options! */
4534 aucmd_prepbuf(&aco, buf); 4511 aucmd_prepbuf(&aco, buf);
4535 #if defined(FEAT_AUTOCMD) && defined(FEAT_SYN_HL) 4512 #if defined(FEAT_SYN_HL)
4536 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, 4513 apply_autocmds(EVENT_FILETYPE, buf->b_p_ft,
4537 buf->b_fname, TRUE, buf); 4514 buf->b_fname, TRUE, buf);
4538 #endif 4515 #endif
4539 do_modelines(OPT_NOWIN); 4516 do_modelines(OPT_NOWIN);
4540 aucmd_restbuf(&aco); 4517 aucmd_restbuf(&aco);
4550 qi->qf_lists[qi->qf_curlist].qf_index = 1; 4527 qi->qf_lists[qi->qf_curlist].qf_index = 1;
4551 qf_list_changed(qi, qi->qf_curlist); 4528 qf_list_changed(qi, qi->qf_curlist);
4552 4529
4553 qf_update_buffer(qi, NULL); 4530 qf_update_buffer(qi, NULL);
4554 4531
4555 #ifdef FEAT_AUTOCMD
4556 if (au_name != NULL) 4532 if (au_name != NULL)
4557 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 4533 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
4558 curbuf->b_fname, TRUE, curbuf); 4534 curbuf->b_fname, TRUE, curbuf);
4559 /* 4535 /*
4560 * The QuickFixCmdPost autocmd may free the quickfix list. Check the list 4536 * The QuickFixCmdPost autocmd may free the quickfix list. Check the list
4561 * is still valid. 4537 * is still valid.
4562 */ 4538 */
4563 wp = loclist_cmd ? curwin : NULL; 4539 wp = loclist_cmd ? curwin : NULL;
4564 if (!qflist_valid(wp, save_qfid)) 4540 if (!qflist_valid(wp, save_qfid))
4565 goto theend; 4541 goto theend;
4566 #endif
4567 4542
4568 /* Jump to first match. */ 4543 /* Jump to first match. */
4569 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) 4544 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
4570 { 4545 {
4571 if ((flags & VGR_NOJUMP) == 0) 4546 if ((flags & VGR_NOJUMP) == 0)
4746 static void 4721 static void
4747 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start) 4722 wipe_dummy_buffer(buf_T *buf, char_u *dirname_start)
4748 { 4723 {
4749 if (curbuf != buf) /* safety check */ 4724 if (curbuf != buf) /* safety check */
4750 { 4725 {
4751 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4726 #if defined(FEAT_EVAL)
4752 cleanup_T cs; 4727 cleanup_T cs;
4753 4728
4754 /* Reset the error/interrupt/exception state here so that aborting() 4729 /* Reset the error/interrupt/exception state here so that aborting()
4755 * returns FALSE when wiping out the buffer. Otherwise it doesn't 4730 * returns FALSE when wiping out the buffer. Otherwise it doesn't
4756 * work when got_int is set. */ 4731 * work when got_int is set. */
4757 enter_cleanup(&cs); 4732 enter_cleanup(&cs);
4758 #endif 4733 #endif
4759 4734
4760 wipe_buffer(buf, FALSE); 4735 wipe_buffer(buf, FALSE);
4761 4736
4762 #if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL) 4737 #if defined(FEAT_EVAL)
4763 /* Restore the error/interrupt/exception state if not discarded by a 4738 /* Restore the error/interrupt/exception state if not discarded by a
4764 * new aborting error, interrupt, or uncaught exception. */ 4739 * new aborting error, interrupt, or uncaught exception. */
4765 leave_cleanup(&cs); 4740 leave_cleanup(&cs);
4766 #endif 4741 #endif
4767 /* When autocommands/'autochdir' option changed directory: go back. */ 4742 /* When autocommands/'autochdir' option changed directory: go back. */
5596 void 5571 void
5597 ex_cbuffer(exarg_T *eap) 5572 ex_cbuffer(exarg_T *eap)
5598 { 5573 {
5599 buf_T *buf = NULL; 5574 buf_T *buf = NULL;
5600 qf_info_T *qi = &ql_info; 5575 qf_info_T *qi = &ql_info;
5601 #ifdef FEAT_AUTOCMD
5602 char_u *au_name = NULL; 5576 char_u *au_name = NULL;
5603 #endif
5604 int res; 5577 int res;
5605 5578
5606 #ifdef FEAT_AUTOCMD
5607 switch (eap->cmdidx) 5579 switch (eap->cmdidx)
5608 { 5580 {
5609 case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break; 5581 case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break;
5610 case CMD_cgetbuffer: au_name = (char_u *)"cgetbuffer"; break; 5582 case CMD_cgetbuffer: au_name = (char_u *)"cgetbuffer"; break;
5611 case CMD_caddbuffer: au_name = (char_u *)"caddbuffer"; break; 5583 case CMD_caddbuffer: au_name = (char_u *)"caddbuffer"; break;
5615 default: break; 5587 default: break;
5616 } 5588 }
5617 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, 5589 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
5618 curbuf->b_fname, TRUE, curbuf)) 5590 curbuf->b_fname, TRUE, curbuf))
5619 { 5591 {
5620 # ifdef FEAT_EVAL 5592 #ifdef FEAT_EVAL
5621 if (aborting()) 5593 if (aborting())
5622 return; 5594 return;
5623 # endif
5624 }
5625 #endif 5595 #endif
5596 }
5626 5597
5627 /* Must come after autocommands. */ 5598 /* Must come after autocommands. */
5628 if (eap->cmdidx == CMD_lbuffer 5599 if (eap->cmdidx == CMD_lbuffer
5629 || eap->cmdidx == CMD_lgetbuffer 5600 || eap->cmdidx == CMD_lgetbuffer
5630 || eap->cmdidx == CMD_laddbuffer) 5601 || eap->cmdidx == CMD_laddbuffer)
5668 && eap->cmdidx != CMD_laddbuffer), 5639 && eap->cmdidx != CMD_laddbuffer),
5669 eap->line1, eap->line2, 5640 eap->line1, eap->line2,
5670 qf_title, NULL); 5641 qf_title, NULL);
5671 if (res >= 0) 5642 if (res >= 0)
5672 qf_list_changed(qi, qi->qf_curlist); 5643 qf_list_changed(qi, qi->qf_curlist);
5673 #ifdef FEAT_AUTOCMD
5674 if (au_name != NULL) 5644 if (au_name != NULL)
5675 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 5645 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5676 curbuf->b_fname, TRUE, curbuf); 5646 curbuf->b_fname, TRUE, curbuf);
5677 #endif
5678 if (res > 0 && (eap->cmdidx == CMD_cbuffer || 5647 if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
5679 eap->cmdidx == CMD_lbuffer)) 5648 eap->cmdidx == CMD_lbuffer))
5680 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 5649 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
5681 } 5650 }
5682 } 5651 }
5690 void 5659 void
5691 ex_cexpr(exarg_T *eap) 5660 ex_cexpr(exarg_T *eap)
5692 { 5661 {
5693 typval_T *tv; 5662 typval_T *tv;
5694 qf_info_T *qi = &ql_info; 5663 qf_info_T *qi = &ql_info;
5695 #ifdef FEAT_AUTOCMD
5696 char_u *au_name = NULL; 5664 char_u *au_name = NULL;
5697 #endif
5698 int res; 5665 int res;
5699 5666
5700 #ifdef FEAT_AUTOCMD
5701 switch (eap->cmdidx) 5667 switch (eap->cmdidx)
5702 { 5668 {
5703 case CMD_cexpr: au_name = (char_u *)"cexpr"; break; 5669 case CMD_cexpr: au_name = (char_u *)"cexpr"; break;
5704 case CMD_cgetexpr: au_name = (char_u *)"cgetexpr"; break; 5670 case CMD_cgetexpr: au_name = (char_u *)"cgetexpr"; break;
5705 case CMD_caddexpr: au_name = (char_u *)"caddexpr"; break; 5671 case CMD_caddexpr: au_name = (char_u *)"caddexpr"; break;
5709 default: break; 5675 default: break;
5710 } 5676 }
5711 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, 5677 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
5712 curbuf->b_fname, TRUE, curbuf)) 5678 curbuf->b_fname, TRUE, curbuf))
5713 { 5679 {
5714 # ifdef FEAT_EVAL 5680 #ifdef FEAT_EVAL
5715 if (aborting()) 5681 if (aborting())
5716 return; 5682 return;
5717 # endif
5718 }
5719 #endif 5683 #endif
5684 }
5720 5685
5721 if (eap->cmdidx == CMD_lexpr 5686 if (eap->cmdidx == CMD_lexpr
5722 || eap->cmdidx == CMD_lgetexpr 5687 || eap->cmdidx == CMD_lgetexpr
5723 || eap->cmdidx == CMD_laddexpr) 5688 || eap->cmdidx == CMD_laddexpr)
5724 { 5689 {
5740 && eap->cmdidx != CMD_laddexpr), 5705 && eap->cmdidx != CMD_laddexpr),
5741 (linenr_T)0, (linenr_T)0, *eap->cmdlinep, 5706 (linenr_T)0, (linenr_T)0, *eap->cmdlinep,
5742 NULL); 5707 NULL);
5743 if (res >= 0) 5708 if (res >= 0)
5744 qf_list_changed(qi, qi->qf_curlist); 5709 qf_list_changed(qi, qi->qf_curlist);
5745 #ifdef FEAT_AUTOCMD
5746 if (au_name != NULL) 5710 if (au_name != NULL)
5747 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 5711 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5748 curbuf->b_fname, TRUE, curbuf); 5712 curbuf->b_fname, TRUE, curbuf);
5749 #endif
5750 if (res > 0 && (eap->cmdidx == CMD_cexpr || 5713 if (res > 0 && (eap->cmdidx == CMD_cexpr ||
5751 eap->cmdidx == CMD_lexpr)) 5714 eap->cmdidx == CMD_lexpr))
5752 qf_jump(qi, 0, 0, eap->forceit); /* display first error */ 5715 qf_jump(qi, 0, 0, eap->forceit); /* display first error */
5753 } 5716 }
5754 else 5717 else
5777 #endif 5740 #endif
5778 qf_info_T *qi = &ql_info; 5741 qf_info_T *qi = &ql_info;
5779 qf_info_T *save_qi; 5742 qf_info_T *save_qi;
5780 int new_qi = FALSE; 5743 int new_qi = FALSE;
5781 win_T *wp; 5744 win_T *wp;
5782 #ifdef FEAT_AUTOCMD
5783 char_u *au_name = NULL; 5745 char_u *au_name = NULL;
5784 #endif
5785 5746
5786 #ifdef FEAT_MULTI_LANG 5747 #ifdef FEAT_MULTI_LANG
5787 /* Check for a specified language */ 5748 /* Check for a specified language */
5788 lang = check_help_lang(eap->arg); 5749 lang = check_help_lang(eap->arg);
5789 #endif 5750 #endif
5790 5751
5791 #ifdef FEAT_AUTOCMD
5792 switch (eap->cmdidx) 5752 switch (eap->cmdidx)
5793 { 5753 {
5794 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break; 5754 case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break;
5795 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break; 5755 case CMD_lhelpgrep: au_name = (char_u *)"lhelpgrep"; break;
5796 default: break; 5756 default: break;
5797 } 5757 }
5798 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name, 5758 if (au_name != NULL && apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
5799 curbuf->b_fname, TRUE, curbuf)) 5759 curbuf->b_fname, TRUE, curbuf))
5800 { 5760 {
5801 # ifdef FEAT_EVAL 5761 #ifdef FEAT_EVAL
5802 if (aborting()) 5762 if (aborting())
5803 return; 5763 return;
5804 # endif
5805 }
5806 #endif 5764 #endif
5765 }
5807 5766
5808 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ 5767 /* Make 'cpoptions' empty, the 'l' flag should not be used here. */
5809 save_cpo = p_cpo; 5768 save_cpo = p_cpo;
5810 p_cpo = empty_option; 5769 p_cpo = empty_option;
5811 5770
5963 free_string_option(save_cpo); 5922 free_string_option(save_cpo);
5964 5923
5965 qf_list_changed(qi, qi->qf_curlist); 5924 qf_list_changed(qi, qi->qf_curlist);
5966 qf_update_buffer(qi, NULL); 5925 qf_update_buffer(qi, NULL);
5967 5926
5968 #ifdef FEAT_AUTOCMD
5969 if (au_name != NULL) 5927 if (au_name != NULL)
5970 { 5928 {
5971 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, 5929 apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
5972 curbuf->b_fname, TRUE, curbuf); 5930 curbuf->b_fname, TRUE, curbuf);
5973 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL) 5931 if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL)
5974 /* autocommands made "qi" invalid */ 5932 /* autocommands made "qi" invalid */
5975 return; 5933 return;
5976 } 5934 }
5977 #endif
5978 5935
5979 /* Jump to first match. */ 5936 /* Jump to first match. */
5980 if (qi->qf_lists[qi->qf_curlist].qf_count > 0) 5937 if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
5981 qf_jump(qi, 0, 0, FALSE); 5938 qf_jump(qi, 0, 0, FALSE);
5982 else 5939 else