Skip to content

Commit

Permalink
Make integration (:make without console window, closes issue #8)
Browse files Browse the repository at this point in the history
Issue #8 on GitHub: #8
  • Loading branch information
xolox committed May 1, 2013
1 parent 614fbf0 commit 52c9b24
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -36,6 +36,10 @@ This will launch your preferred (or the best available) web browser. Likewise th

Note that on UNIX if the environment variable `$DISPLAY` is empty the plug-in will fall back to a command-line web browser. Because such web browsers are executed in front of Vim you have to quit the web browser to return to Vim.

### The `:MakeWithShell` command

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.

### The `xolox#shell#execute()` function

This function enables other Vim plug-ins to execute external commands in the background (i.e. asynchronously) *without opening a command prompt window on Windows*. For example try to execute the following command on Windows ([vimrun.exe][vimrun] is only included with Vim for Windows because it isn't needed on other platforms):
Expand Down Expand Up @@ -117,6 +121,7 @@ This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/M
[easytags]: http://peterodding.com/code/vim/easytags/
[gui]: http://vimdoc.sourceforge.net/htmldoc/gui.html#GUI
[libcall]: http://vimdoc.sourceforge.net/htmldoc/eval.html#libcall()
[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make
[sh_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shell%27
[shcf_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shellcmdflag%27
[system]: http://vimdoc.sourceforge.net/htmldoc/eval.html#system()
Expand Down
18 changes: 16 additions & 2 deletions autoload/xolox/shell.vim
@@ -1,9 +1,9 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
" Last Change: April 30, 2013
" Last Change: May 2, 2013
" URL: http://peterodding.com/code/vim/shell/

let g:xolox#shell#version = '0.9.26'
let g:xolox#shell#version = '0.10'

call xolox#misc#compat#check('shell', 2)

Expand Down Expand Up @@ -164,6 +164,20 @@ function! xolox#shell#execute(command, synchronous, ...) " -- execute external c
endtry
endfunction

function! xolox#shell#make(bang, args) " -- run :make silent (without a console window) {{{1
let command = &makeprg
if a:args =~ '\S'
let command .= ' ' . a:args
endif
call xolox#misc#msg#info("shell.vim %s: Running make command %s ..", g:xolox#shell#version, command)
if a:bang == '!'
cgetexpr xolox#shell#execute(command, 1)
else
cexpr xolox#shell#execute(command, 1)
endif
cwindow
endfunction

function! xolox#shell#maximize(...) " -- show/hide Vim's menu, tool bar and/or tab line {{{1
let new_state = a:0 == 0 ? !s:maximized : a:1
if new_state && !s:maximized
Expand Down
24 changes: 18 additions & 6 deletions doc/shell.txt
Expand Up @@ -9,12 +9,14 @@ Contents ~
1. The |:Maximize| command
2. The |:Fullscreen| command
3. The |:Open| command
4. The |xolox#shell#execute()| function
5. The |xolox#shell#fullscreen()| function
6. The |xolox#shell#is_fullscreen()| function
7. The |g:shell_fullscreen_items| option
8. The |g:shell_mappings_enabled| option
9. The |g:shell_verify_urls| option
4. The |:MakeWithShell| command
5. The |xolox#shell#execute()| function
6. The |xolox#shell#fullscreen()| function
7. The |xolox#shell#is_fullscreen()| function
8. The |g:shell_fullscreen_items| option
9. The |g:shell_mappings_enabled| option
10. The |g:shell_make_override| option
11. The |g:shell_verify_urls| option
3. Background |shell-background|
4. Other full-screen implementations |shell-other-full-screen-implementations|
5. Contact |shell-contact|
Expand Down Expand Up @@ -98,6 +100,13 @@ Note that on UNIX if the environment variable '$DISPLAY' is empty the plug-in
will fall back to a command-line web browser. Because such web browsers are
executed in front of Vim you have to quit the web browser to return to Vim.

-------------------------------------------------------------------------------
The *:MakeWithShell* command

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.

-------------------------------------------------------------------------------
The *xolox#shell#execute()* function

Expand Down Expand Up @@ -179,6 +188,9 @@ to your |vimrc| script:
:inoremap <Leader>op <C-o>:Open<CR>
:nnoremap <Leader>op :Open<CR>
-------------------------------------------------------------------------------
The *g:shell_make_override* option

-------------------------------------------------------------------------------
The *g:shell_verify_urls* option

Expand Down
3 changes: 2 additions & 1 deletion plugin/shell.vim
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
" Last Change: October 28, 2011
" Last Change: May 2, 2013
" URL: http://peterodding.com/code/vim/shell/

" Support for automatic update using the GLVS plug-in.
Expand Down Expand Up @@ -37,6 +37,7 @@ augroup END
command! -bar -nargs=? -complete=file Open call xolox#shell#open_cmd(<q-args>)
command! -bar Maximize call xolox#shell#maximize()
command! -bar Fullscreen call xolox#shell#fullscreen()
command! -bar -bang -nargs=? MakeWithShell :call xolox#shell#make(<q-bang>, <q-args>)

" Default key mappings. {{{1

Expand Down

0 comments on commit 52c9b24

Please sign in to comment.