Fix temporary open erl
This commit is contained in:
parent
a07657a58d
commit
348a96fc7d
@ -7,7 +7,7 @@ set cpo&vim
|
|||||||
|
|
||||||
function! s:echo_error(msg)
|
function! s:echo_error(msg)
|
||||||
echohl Error
|
echohl Error
|
||||||
echo a:msg
|
echomsg a:msg
|
||||||
echohl None
|
echohl None
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -107,13 +107,29 @@ endfunction
|
|||||||
|
|
||||||
function! repl#start_erlang()
|
function! repl#start_erlang()
|
||||||
" FIXME: this function messes current directly with a .bean file.
|
" FIXME: this function messes current directly with a .bean file.
|
||||||
|
let l:pwd = getcwd()
|
||||||
|
|
||||||
" Setting up the file for the current file
|
" Setting up the file for the current file
|
||||||
if &modified
|
if &modified
|
||||||
" Create new file temporary
|
" Create new file temporary
|
||||||
let l:module_file = tempname() . '.erl'
|
" -module don't allow module name number start
|
||||||
call writefile(getline(1, expand('$')), l:module_file)
|
let l:tempname = tempname()
|
||||||
|
let l:filename = 't' . fnamemodify(l:tempname, ':t') . '.erl'
|
||||||
|
let l:dirpath = fnamemodify(l:tempname, ':h')
|
||||||
|
let l:module_file = l:dirpath . '/' . l:filename
|
||||||
|
try
|
||||||
|
call s:writefile_with_erlang_module(getline(1, expand('$')), l:module_file)
|
||||||
|
catch /^REPL_VIM/
|
||||||
|
call s:echo_error('REPL_VIM: fatal error')
|
||||||
|
call s:echo_error(v:exception)
|
||||||
|
return
|
||||||
|
endtry
|
||||||
|
" Change current directory temporary
|
||||||
|
execute 'cd' l:dirpath
|
||||||
else
|
else
|
||||||
let l:module_file = expand('%:p')
|
let l:module_file = expand('%:p')
|
||||||
|
" Change current directory temporary
|
||||||
|
cd %:p:h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:repl = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['repl']
|
let l:repl = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['repl']
|
||||||
@ -126,9 +142,6 @@ function! repl#start_erlang()
|
|||||||
endif
|
endif
|
||||||
let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file)
|
let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file)
|
||||||
|
|
||||||
" Change current directory temporary
|
|
||||||
let l:pwd = getcwd()
|
|
||||||
cd %:p:h
|
|
||||||
execute ':VimShellInteractive' l:args
|
execute ':VimShellInteractive' l:args
|
||||||
call vimshell#interactive#send(printf('c(%s).', fnamemodify(l:module_file, ':t:r')))
|
call vimshell#interactive#send(printf('c(%s).', fnamemodify(l:module_file, ':t:r')))
|
||||||
execute 'cd' l:pwd
|
execute 'cd' l:pwd
|
||||||
@ -146,6 +159,17 @@ endfunction
|
|||||||
" call s:CallVimShell(l:args)
|
" call s:CallVimShell(l:args)
|
||||||
"endfunction
|
"endfunction
|
||||||
|
|
||||||
|
"-------------------"
|
||||||
|
|
||||||
|
function! s:writefile_with_erlang_module(lines, filepath)
|
||||||
|
let l:module_defined_line = match(a:lines, '-module')
|
||||||
|
if l:module_defined_line is -1
|
||||||
|
throw "REPL_VIM: repl.vim couldn't -module difinition !"
|
||||||
|
endif
|
||||||
|
let a:lines[l:module_defined_line] = printf('-module(%s).', fnamemodify(a:filepath, ':t:r'))
|
||||||
|
call writefile(a:lines, a:filepath)
|
||||||
|
endfunction
|
||||||
|
|
||||||
"-------------------"
|
"-------------------"
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
|
Reference in New Issue
Block a user