Skip to content

Commit

Permalink
Fix #133 add vexe insert option
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Feb 27, 2014
1 parent 90abb7e commit 8cacf43
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
13 changes: 11 additions & 2 deletions autoload/vimshell/commands/vexe.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ let s:command = {
\}
function! s:command.execute(args, context) "{{{
" Execute vim command.
let [args, options] = vimshell#parser#getopt(a:args, {
\ 'noarg' : ['--insert'],
\ }, {
\ '--insert' : 0,
\ })

let context = a:context
let context.fd = a:context.fd
Expand All @@ -44,7 +49,7 @@ function! s:command.execute(args, context) "{{{
let &verbosefile = verbose
let &verbose = 0

for command in split(join(a:args), '\n')
for command in split(join(args), '\n')
silent! execute command
endfor
finally
Expand All @@ -62,7 +67,11 @@ function! s:command.execute(args, context) "{{{
if bufnr('%') != bufnr
call vimshell#next_prompt(a:context)
call vimshell#helpers#restore_pos(pos)
stopinsert
if options['--insert']
startinsert
else
stopinsert
endif
return 1
elseif _ != ''
call vimshell#print_line(a:context.fd, _)
Expand Down
13 changes: 12 additions & 1 deletion autoload/vimshell/parser.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: parser.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>
" Last Modified: 14 Feb 2014.
" Last Modified: 27 Feb 2014.
" License: MIT license {{{
" Permission is hereby granted, free of charge, to any person obtaining
" a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -445,6 +445,17 @@ function! vimshell#parser#getopt(args, optsyntax, ...) "{{{
for arg in a:args
let found = 0

for opt in optsyntax['noarg']
if arg ==# opt
let found = 1

" Get argument value.
let options[opt] = 1

break
endif
endfor

for opt in optsyntax['arg=']
if vimshell#util#head_match(arg, opt.'=')
let found = 1
Expand Down
4 changes: 4 additions & 0 deletions doc/vimshell.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,10 @@ vexe {expression} *vimshell-special-vexe*
You can use prefix ":" instead of vexe.
Note: If you use ":", vimshell do not parse anything.

--insert
Start insert mode after execute {expression}.
If omit the option, leave insert mode.

Example:
>
:ls
Expand Down
8 changes: 7 additions & 1 deletion vest/parser.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ Context Vesting.run()
VimShellCreate
call vimshell#set_alias('l2', 'll')
call vimshell#set_alias('ll', 'ls -l')
Should vimshell#parser#parse_alias('l2') ==# 'ls -l'
ShouldEqual vimshell#parser#parse_alias('l2'), 'ls -l'
VimShellCreate -toggle
End

It tests option parser.
ShouldEqual vimshell#parser#getopt(['foo', 'bar'], {
\ 'noarg' : ['--insert'],
\ }), [['foo', 'bar'], {}]
End
End

Fin
Expand Down

0 comments on commit 8cacf43

Please sign in to comment.