vim make 后不回显消息
vim not echoing message after make
考虑以下最小 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 中看到的,来自函数 EchoLatexMessage()
的消息 This message is not shown
未显示(另一方面,消息 compiling latex file...
始终显示在屏幕上)。为什么会这样?我希望在 :make
完成后回显新消息。
这是因为您的函数中的 silent make!
。 :silent
显然不仅适用于 :make
本身,还适用于它调用的 autocmd(这是有道理的)。如果你想静音编译输出本身,而不是来自 autocmd 的消息,你可以在 EchoLatexMessage()
函数中将 :unsilent
添加到 :echo
之前。
考虑以下最小 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 中看到的,来自函数 EchoLatexMessage()
的消息 This message is not shown
未显示(另一方面,消息 compiling latex file...
始终显示在屏幕上)。为什么会这样?我希望在 :make
完成后回显新消息。
这是因为您的函数中的 silent make!
。 :silent
显然不仅适用于 :make
本身,还适用于它调用的 autocmd(这是有道理的)。如果你想静音编译输出本身,而不是来自 autocmd 的消息,你可以在 EchoLatexMessage()
函数中将 :unsilent
添加到 :echo
之前。