vim不会在make之后回显消息

时间:2015-03-29 21:41:53

标签: vim

考虑以下最小的vimrc:

set nocompatible

filetype plugin indent on
let g:tex_flavor = 'latex'

function! CompileLatex()
    let save_pwd = getcwd()
    lcd %:p:h
    let compiler = 'pdflatex '
    let mainfile = expand('%:p:r')
    let &l:makeprg = compiler . mainfile . '.tex'
    echon "compiling latex file..."
    silent make!
    execute 'lcd ' . save_pwd
endfunction

function! EchoLatexMessage()
    redraw
    echo 'This message is not shown'
endfunction

augroup echo_message
    au!
    au QuickFixCmdPost make call EchoLatexMessage()
augroup END

foo.tex文件中,如:

\documentclass{article}
\begin{document}
Foo
\end{document}

运行:call CompileLatex()。如在GIF中所见,未显示来自函数This message is not shown的消息EchoLatexMessage()(另一方面,消息compiling latex file...始终在屏幕上)。为什么会这样?我希望在:make完成后回显新消息。

enter image description here

1 个答案:

答案 0 :(得分:1)

这是因为你的函数中有silent make!:silent显然不仅适用于:make本身,也适用于由它调用的autocmds(哪种有意义)。如果要使编译输出本身静音,而不是来自autocmd的消息,则可以在:unsilent函数中将:echo添加到EchoLatexMessage()