Patch 7.4.2299
Problem: QuickFixCmdPre and QuickFixCmdPost autocommands are not always
triggered.
Solution: Also trigger on ":expr", ":cbuffer", etc. (Yegappan Lakshmanan)
Files: src/quickfix.c, src/testdir/test_quickfix.vim
*** ../vim-7.4.2298/src/quickfix.c 2016-08-29 22:48:12.165106045 +0200
--- src/quickfix.c 2016-09-01 15:40:55.232951961 +0200
***************
*** 4845,4850 ****
--- 4845,4853 ----
{
buf_T *buf = NULL;
qf_info_T *qi = &ql_info;
+ #ifdef FEAT_AUTOCMD
+ char_u *au_name = NULL;
+ #endif
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
|| eap->cmdidx == CMD_laddbuffer)
***************
*** 4854,4859 ****
--- 4857,4884 ----
return;
}
+ #ifdef FEAT_AUTOCMD
+ switch (eap->cmdidx)
+ {
+ case CMD_cbuffer: au_name = (char_u *)"cbuffer"; break;
+ case CMD_cgetbuffer: au_name = (char_u *)"cgetbuffer"; break;
+ case CMD_caddbuffer: au_name = (char_u *)"caddbuffer"; break;
+ case CMD_lbuffer: au_name = (char_u *)"lbuffer"; break;
+ case CMD_lgetbuffer: au_name = (char_u *)"lgetbuffer"; break;
+ case CMD_laddbuffer: au_name = (char_u *)"laddbuffer"; break;
+ default: break;
+ }
+ if (au_name != NULL)
+ {
+ apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf);
+ # ifdef FEAT_EVAL
+ if (did_throw || force_abort)
+ return;
+ # endif
+ }
+ #endif
+
if (*eap->arg == NUL)
buf = curbuf;
else if (*skipwhite(skipdigits(eap->arg)) == NUL)
***************
*** 4887,4896 ****
(eap->cmdidx != CMD_caddbuffer
&& eap->cmdidx != CMD_laddbuffer),
eap->line1, eap->line2,
! qf_title) > 0
! && (eap->cmdidx == CMD_cbuffer
! || eap->cmdidx == CMD_lbuffer))
! qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
}
}
--- 4912,4927 ----
(eap->cmdidx != CMD_caddbuffer
&& eap->cmdidx != CMD_laddbuffer),
eap->line1, eap->line2,
! qf_title) > 0)
! {
! #ifdef FEAT_AUTOCMD
! if (au_name != NULL)
! apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
! curbuf->b_fname, TRUE, curbuf);
! #endif
! if (eap->cmdidx == CMD_cbuffer || eap->cmdidx == CMD_lbuffer)
! qf_jump(qi, 0, 0, eap->forceit); /* display first error */
! }
}
}
}
***************
*** 4905,4910 ****
--- 4936,4944 ----
{
typval_T *tv;
qf_info_T *qi = &ql_info;
+ #ifdef FEAT_AUTOCMD
+ char_u *au_name = NULL;
+ #endif
if (eap->cmdidx == CMD_lexpr || eap->cmdidx == CMD_lgetexpr
|| eap->cmdidx == CMD_laddexpr)
***************
*** 4914,4919 ****
--- 4948,4975 ----
return;
}
+ #ifdef FEAT_AUTOCMD
+ switch (eap->cmdidx)
+ {
+ case CMD_cexpr: au_name = (char_u *)"cexpr"; break;
+ case CMD_cgetexpr: au_name = (char_u *)"cgetexpr"; break;
+ case CMD_caddexpr: au_name = (char_u *)"caddexpr"; break;
+ case CMD_lexpr: au_name = (char_u *)"lexpr"; break;
+ case CMD_lgetexpr: au_name = (char_u *)"lgetexpr"; break;
+ case CMD_laddexpr: au_name = (char_u *)"laddexpr"; break;
+ default: break;
+ }
+ if (au_name != NULL)
+ {
+ apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,
+ curbuf->b_fname, TRUE, curbuf);
+ # ifdef FEAT_EVAL
+ if (did_throw || force_abort)
+ return;
+ # endif
+ }
+ #endif
+
/* Evaluate the expression. When the result is a string or a list we can
* use it to fill the errorlist. */
tv = eval_expr(eap->arg, NULL);
***************
*** 4925,4934 ****
if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
(eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr),
! (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0
! && (eap->cmdidx == CMD_cexpr
! || eap->cmdidx == CMD_lexpr))
! qf_jump(qi, 0, 0, eap->forceit); /* display first error */
}
else
EMSG(_("E777: String or List expected"));
--- 4981,4996 ----
if (qf_init_ext(qi, NULL, NULL, tv, p_efm,
(eap->cmdidx != CMD_caddexpr
&& eap->cmdidx != CMD_laddexpr),
! (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0)
! {
! #ifdef FEAT_AUTOCMD
! if (au_name != NULL)
! apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
! curbuf->b_fname, TRUE, curbuf);
! #endif
! if (eap->cmdidx == CMD_cexpr || eap->cmdidx == CMD_lexpr)
! qf_jump(qi, 0, 0, eap->forceit); /* display first error */
! }
}
else
EMSG(_("E777: String or List expected"));
*** ../vim-7.4.2298/src/testdir/test_quickfix.vim 2016-08-27
13:35:31.064015024 +0200
--- src/testdir/test_quickfix.vim 2016-09-01 15:39:30.389685556 +0200
***************
*** 1554,1556 ****
--- 1554,1591 ----
call Xproperty_tests('c')
call Xproperty_tests('l')
endfunction
+
+ " Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands
+ function QfAutoCmdHandler(loc, cmd)
+ call add(g:acmds, a:loc . a:cmd)
+ endfunction
+
+ function Test_Autocmd()
+ autocmd QuickFixCmdPre * call QfAutoCmdHandler('pre', expand('<amatch>'))
+ autocmd QuickFixCmdPost * call QfAutoCmdHandler('post', expand('<amatch>'))
+
+ let g:acmds = []
+ cexpr "F1:10:Line 10"
+ caddexpr "F1:20:Line 20"
+ cgetexpr "F1:30:Line 30"
+ enew! | call append(0, "F2:10:Line 10")
+ cbuffer!
+ enew! | call append(0, "F2:20:Line 20")
+ cgetbuffer
+ enew! | call append(0, "F2:30:Line 30")
+ caddbuffer
+
+ let l = ['precexpr',
+ \ 'postcexpr',
+ \ 'precaddexpr',
+ \ 'postcaddexpr',
+ \ 'precgetexpr',
+ \ 'postcgetexpr',
+ \ 'precbuffer',
+ \ 'postcbuffer',
+ \ 'precgetbuffer',
+ \ 'postcgetbuffer',
+ \ 'precaddbuffer',
+ \ 'postcaddbuffer']
+ call assert_equal(l, g:acmds)
+ endfunction
*** ../vim-7.4.2298/src/version.c 2016-09-01 15:11:13.548265402 +0200
--- src/version.c 2016-09-01 15:42:01.796376517 +0200
***************
*** 765,766 ****
--- 765,768 ----
{ /* Add new patch number below this line */
+ /**/
+ 2299,
/**/
--
I have a watch cat! Just break in and she'll watch.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.