Skip to content

Commit a04b3ab

Browse files
committed
Improvements on pull request #16
See pull request #16 on GitHub: #16
1 parent 1382495 commit a04b3ab

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ Note that on UNIX if the environment variable `$DISPLAY` is empty the plug-in wi
4848

4949
### The `:MakeWithShell` command
5050

51-
This command is a very simple replacement for the [:make] [make] command that does not pop up a console window on Windows. It doesn't come with all of the bells and whistles that Vim's built-in make command does but it should work.
51+
This command is a very simple replacement for the [:make] [] command that does not pop up a console window on Windows. It doesn't come with all of the bells and whistles that Vim's built-in make command does but it should work. It properly triggers the [QuickFixCmdPre] [] and [QuickFixCmdPost] [] events, although it does so using [:silent] [] to avoid printing two "No matching autocommands" messages.
5252

53-
Because Vim's [v:shell_error] [shell_error] variable is read only (which means it cannot be set by a Vim plug-in) the vim-shell plug-in defines its own variable with the exit code of the `make` process executed by `:MakeWithShell`. This variable is called `g:xolox#shell#make_exit_code`. The semantics are exactly the same as for [v:shell_error] [shell_error].
53+
Because Vim's [v:shell_error] [] variable is read only (which means it cannot be set by a Vim plug-in) the vim-shell plug-in defines its own variable with the exit code of the `make` process executed by `:MakeWithShell`. This variable is called `g:xolox#shell#make_exit_code`. The semantics are exactly the same as for [v:shell_error] [].
54+
55+
The `:MakeWithShell` command uses Vim's [quickfix window] []. To make the shell plug-in use the [location-list] [] instead you can use the command `:LMakeWithShell` instead.
5456

5557
### The `xolox#misc#os#exec()` function
5658

@@ -136,6 +138,8 @@ This software is licensed under the [MIT license] [mit].
136138
© 2013 Peter Odding &lt;<peter@peterodding.com>&gt;.
137139

138140

141+
[:make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make
142+
[:silent]: http://vimdoc.sourceforge.net/htmldoc/various.html#:silent
139143
[ctags]: http://en.wikipedia.org/wiki/Ctags
140144
[dll]: http://en.wikipedia.org/wiki/Dynamic-link_library
141145
[download-misc]: http://peterodding.com/code/vim/downloads/misc.zip
@@ -149,16 +153,19 @@ This software is licensed under the [MIT license] [mit].
149153
[gui]: http://vimdoc.sourceforge.net/htmldoc/gui.html#GUI
150154
[gvimfullscreen_win32]: http://www.vim.org/scripts/script.php?script_id=2596
151155
[libcall]: http://vimdoc.sourceforge.net/htmldoc/eval.html#libcall()
152-
[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make
156+
[location-list]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#location-list
153157
[mit]: http://en.wikipedia.org/wiki/MIT_License
154158
[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
159+
[quickfix window]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
160+
[QuickFixCmdPost]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#QuickFixCmdPost
161+
[QuickFixCmdPre]: http://vimdoc.sourceforge.net/htmldoc/autocmd.html#QuickFixCmdPre
155162
[screenshots]: http://peterodding.com/code/vim/shell/screenshots/
156163
[sh_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shell%27
157164
[shcf_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shellcmdflag%27
158-
[shell_error]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:shell_error
159165
[stal]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27showtabline%27
160166
[system]: http://vimdoc.sourceforge.net/htmldoc/eval.html#system()
161167
[taskbars]: http://en.wikipedia.org/wiki/Taskbar
168+
[v:shell_error]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:shell_error
162169
[vim-session]: http://peterodding.com/code/vim/session/
163170
[vim]: http://www.vim.org/
164171
[vim_scripts_entry]: http://www.vim.org/scripts/script.php?script_id=3123

autoload/xolox/shell.vim

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 3, 2013
3+
" Last Change: June , 2013
44
" URL: http://peterodding.com/code/vim/shell/
55

6-
let g:xolox#shell#version = '0.12.10'
6+
let g:xolox#shell#version = '0.13'
77

88
if !exists('s:fullscreen_enabled')
99
let s:enoimpl = "%s() hasn't been implemented on your platform! %s"
@@ -146,28 +146,29 @@ function! xolox#shell#execute_with_dll(cmd, async) " {{{1
146146
endif
147147
endfunction
148148

149-
function! xolox#shell#make(bang, args) " {{{1
149+
function! xolox#shell#make(mode, bang, args) " {{{1
150150
" Run :make silent (without a console window).
151151
let command = &makeprg
152152
if a:args =~ '\S'
153153
let command .= ' ' . a:args
154154
endif
155-
call xolox#misc#msg#info("shell.vim %s: Running make command %s ..", g:xolox#shell#version, command)
155+
call xolox#misc#msg#info("shell.vim %s: Running make command: %s", g:xolox#shell#version, command)
156156
if a:bang == '!'
157-
cgetexpr s:make_cmd(command)
157+
execute printf('%sgetexpr s:make_cmd(a:mode, command)', a:mode)
158158
else
159-
cexpr s:make_cmd(command)
159+
execute printf('%sexpr s:make_cmd(a:mode, command)', a:mode)
160160
endif
161-
cwindow
161+
execute a:mode . 'window'
162162
endfunction
163163

164-
function! s:make_cmd(command)
165-
doautocmd QuickFixCmdPre make,lmake
164+
function! s:make_cmd(mode, command)
165+
let event = (a:mode == 'l') ? 'lmake' : 'make'
166+
execute 'silent doautocmd QuickFixCmdPre' event
166167
let command = a:command . ' 2>&1'
167168
let result = xolox#misc#os#exec({'command': command, 'check': 0})
168169
let g:xolox#shell#make_exit_code = result['exit_code']
170+
execute 'silent doautocmd QuickFixCmdPost' event
169171
return join(result['stdout'], "\n")
170-
doautocmd QuickFixCmdPost make,lmake
171172
endfunction
172173

173174
if !exists('g:xolox#shell#make_exit_code')

doc/shell.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,20 @@ The *:MakeWithShell* command
121121

122122
This command is a very simple replacement for the |:make| command that does not
123123
pop up a console window on Windows. It doesn't come with all of the bells and
124-
whistles that Vim's built-in make command does but it should work.
124+
whistles that Vim's built-in make command does but it should work. It properly
125+
triggers the |QuickFixCmdPre| and |QuickFixCmdPost| events, although it does so
126+
using |:silent| to avoid printing two "No matching autocommands" messages.
125127

126128
Because Vim's |v:shell_error| variable is read only (which means it cannot be
127129
set by a Vim plug-in) the vim-shell plug-in defines its own variable with the
128130
exit code of the 'make' process executed by |:MakeWithShell|. This variable is
129131
called 'g:xolox#shell#make_exit_code'. The semantics are exactly the same as
130132
for |v:shell_error|.
131133

134+
The |:MakeWithShell| command uses Vim's |quickfix| window. To make the shell
135+
plug-in use the |location-list| instead you can use the command
136+
':LMakeWithShell' instead.
137+
132138
-------------------------------------------------------------------------------
133139
The *xolox#misc#os#exec()* function
134140

plugin/shell.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: May 2, 2013
3+
" Last Change: June 12, 2013
44
" URL: http://peterodding.com/code/vim/shell/
55

66
" Support for automatic update using the GLVS plug-in.
@@ -42,7 +42,8 @@ augroup END
4242
command! -bar -nargs=? -complete=file Open call xolox#shell#open_cmd(<q-args>)
4343
command! -bar Maximize call xolox#shell#maximize()
4444
command! -bar Fullscreen call xolox#shell#fullscreen()
45-
command! -bar -bang -nargs=? MakeWithShell :call xolox#shell#make(<q-bang>, <q-args>)
45+
command! -bar -bang -nargs=? MakeWithShell :call xolox#shell#make('c', <q-bang>, <q-args>)
46+
command! -bar -bang -nargs=? LMakeWithShell :call xolox#shell#make('l', <q-bang>, <q-args>)
4647

4748
" Default key mappings. {{{1
4849

0 commit comments

Comments
 (0)