Skip to content

Commit

Permalink
* Added vimshell#version().
Browse files Browse the repository at this point in the history
- vimshell#execute returns exit status.
- Improved prompt check.
  • Loading branch information
Shougo committed Apr 25, 2010
1 parent 6fb9874 commit af3b3c4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
49 changes: 30 additions & 19 deletions autoload/vimshell.vim
Expand Up @@ -2,7 +2,7 @@
" FILE: vimshell.vim
" AUTHOR: Janakiraman .S <prince@india.ti.com>(Original)
" Shougo Matsushita <Shougo.Matsu@gmail.com>(Modified)
" Last Modified: 20 Apr 2010
" Last Modified: 25 Apr 2010
" 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 @@ -30,10 +30,36 @@ let s:is_vimproc = exists('*vimproc#system')
let s:is_version = exists('*vimproc#version')
if !s:is_vimproc
echoerr 'vimproc is not installed. Please install vimproc Ver.4.0 or above.'
finish
elseif !s:is_version
echoerr 'Please install vimproc Ver.4.0 or above.'
finish
endif

function! vimshell#version()"{{{
return '7.0'
endfunction"}}}
function! vimshell#head_match(checkstr, headstr)"{{{
return a:headstr == '' || a:checkstr ==# a:headstr
\|| a:checkstr[: len(a:headstr)-1] ==# a:headstr
endfunction"}}}
function! vimshell#tail_match(checkstr, tailstr)"{{{
return a:tailstr == '' || a:checkstr ==# a:tailstr
\|| a:checkstr[: -len(a:tailstr)-1] ==# a:tailstr
endfunction"}}}

" Check prompt value."{{{
if vimshell#head_match(s:prompt, s:secondary_prompt) || vimshell#head_match(s:secondary_prompt, s:prompt)
echoerr printf('Head matched g:VimShell_Prompt("%s") and your g:VimShell_SecondaryPrompt("%s").', s:prompt, s:secondary_prompt)
finish
elseif vimshell#head_match(s:prompt, '[%] ') || vimshell#head_match('[%] ', s:prompt)
echoerr printf('Head matched g:VimShell_Prompt("%s") and your g:VimShell_UserPrompt("[%] ").', s:prompt)
finish
elseif vimshell#head_match('[%] ', s:secondary_prompt) || vimshell#head_match(s:secondary_prompt, '[%] ')
echoerr printf('Head matched g:VimShell_UserPrompt("[%] ") and your g:VimShell_SecondaryPrompt("%s").', s:secondary_prompt)
finish
endif"}}}

" Initialize."{{{
let s:prompt = exists('g:VimShell_Prompt') ? g:VimShell_Prompt : 'vimshell% '
let s:secondary_prompt = exists('g:VimShell_SecondaryPrompt') ? g:VimShell_SecondaryPrompt : '%% '
Expand Down Expand Up @@ -636,14 +662,6 @@ function! vimshell#check_secondary_prompt(...)"{{{
let l:line = a:0 == 0 ? getline('.') : getline(a:1)
return vimshell#head_match(l:line, vimshell#get_secondary_prompt())
endfunction"}}}
function! vimshell#head_match(checkstr, headstr)"{{{
return a:headstr == '' || a:checkstr ==# a:headstr
\|| a:checkstr[: len(a:headstr)-1] ==# a:headstr
endfunction"}}}
function! vimshell#tail_match(checkstr, tailstr)"{{{
return a:tailstr == '' || a:checkstr ==# a:tailstr
\|| a:checkstr[: -len(a:tailstr)-1] ==# a:tailstr
endfunction"}}}
function! vimshell#set_execute_file(exts, program)"{{{
for ext in split(a:exts, ',')
let g:VimShell_ExecuteFileList[ext] = a:program
Expand Down Expand Up @@ -688,8 +706,10 @@ function! vimshell#execute(cmdline, ...)"{{{
catch /.*/
let l:message = v:exception . ' ' . v:throwpoint
call vimshell#error_line(l:context.fd, l:message)
return
return 1
endtry

return b:vimshell.system_variables.status
endfunction"}}}
function! vimshell#set_context(context)"{{{
let s:context = a:context
Expand Down Expand Up @@ -743,13 +763,4 @@ function! s:restore_current_dir()"{{{
lcd `=fnamemodify(b:vimshell.save_dir, ':p')`
endfunction"}}}

" Check prompt value."{{{
if vimshell#head_match(s:prompt, s:secondary_prompt) || vimshell#head_match(s:secondary_prompt, s:prompt)
echoerr printf('Head matched g:VimShell_Prompt("%s") and your g:VimShell_SecondaryPrompt("%s").', s:prompt, s:secondary_prompt)
elseif vimshell#head_match(s:prompt, '[%] ') || vimshell#head_match('[%] ', s:prompt)
echoerr printf('Head matched g:VimShell_Prompt("%s") and your g:VimShell_UserPrompt("[%] ").', s:prompt)
elseif vimshell#head_match('[%] ', s:secondary_prompt) || vimshell#head_match(s:secondary_prompt, '[%] ')
echoerr printf('Head matched g:VimShell_UserPrompt("[%] ") and your g:VimShell_SecondaryPrompt("%s").', s:secondary_prompt)
endif"}}}

" vim: foldmethod=marker
4 changes: 2 additions & 2 deletions autoload/vimshell/parser.vim
@@ -1,7 +1,7 @@
"=============================================================================
" FILE: parser.vim
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com>(Modified)
" Last Modified: 13 Apr 2010
" Last Modified: 25 Apr 2010
" 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 @@ -700,7 +700,7 @@ function! s:parse_redirection(script)"{{{
return [l:fd, l:script]
endfunction"}}}

function! s:parse_single_quote(script, i)"{{{
function! parse_single_quote(script, i)"{{{
if a:script[a:i] != "'"
return ['', a:i]
endif
Expand Down
5 changes: 5 additions & 0 deletions doc/vimshell.txt
Expand Up @@ -153,6 +153,11 @@ BUGS *vimshell-bugs*
==============================================================================
CHANGELOG *vimshell-changelog*

2010-04-25
* vimshell#execute returns exit status.
* Improved prompt check.
* Added vimshell#version().

2010-04-24
* Fixed prompt check error.
* Fixed mapping <CR>.
Expand Down

0 comments on commit af3b3c4

Please sign in to comment.