Skip to content
Browse files

Fix #133 add vexe insert option

  • Loading branch information...
1 parent 90abb7e commit 8cacf43550bf684c20f6279934fa2d40f575c65d @Shougo committed Feb 27, 2014
Showing with 34 additions and 4 deletions.
  1. +11 −2 autoload/vimshell/commands/vexe.vim
  2. +12 −1 autoload/vimshell/parser.vim
  3. +4 −0 doc/vimshell.txt
  4. +7 −1 vest/parser.vim
View
13 autoload/vimshell/commands/vexe.vim
@@ -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
@@ -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
@@ -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, _)
View
13 autoload/vimshell/parser.vim
@@ -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
@@ -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
View
4 doc/vimshell.txt
@@ -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
View
8 vest/parser.vim
@@ -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

0 comments on commit 8cacf43

Please sign in to comment.
Something went wrong with that request. Please try again.