Skip to content

Commit

Permalink
refs #11 fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tell-k committed May 23, 2014
1 parent 3bf411d commit 7dc456f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion doc/autopep8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Author: tell-k (ffk2005 AT gmail DOT com)
For Vim version 7 and above
Last change: 2014 May 15
Last change: 2014 May 23

1. Overview |autopep8-overview|
2. Required |autopep8-required|
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# built documents.
#
# The short X.Y version.
version = '1.0.5'
version = '1.0.6'
# The full version, including alpha/beta/rc tags.
release = '1.0.5'

Expand Down
70 changes: 35 additions & 35 deletions ftplugin/python_autopep8.vim
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"=========================================================
" File: python_autopep8.vim
" Author: tell-k <ffk2005[at]gmail.com>
" Last Change: 15-May-2014.
" Version: 1.0.5
" Last Change: 23-May-2014.
" Version: 1.0.6
" WebPage: https://github.com/tell-k/vim-autopep8
" License: MIT Licence
"==========================================================
Expand All @@ -20,82 +20,82 @@ if !exists("*Autopep8(...)")
let l:args = get(a:, 1, '')

if exists("g:autopep8_cmd")
let s:autopep8_cmd=g:autopep8_cmd
let autopep8_cmd=g:autopep8_cmd
else
let s:autopep8_cmd="autopep8"
let autopep8_cmd="autopep8"
endif

if !executable(s:autopep8_cmd)
echoerr "File " . s:autopep8_cmd . " not found. Please install it first."
if !executable(autopep8_cmd)
echoerr "File " . autopep8_cmd . " not found. Please install it first."
return
endif

if exists("g:autopep8_ignore")
let s:autopep8_ignores=" --ignore=".g:autopep8_ignore
let autopep8_ignores=" --ignore=".g:autopep8_ignore
else
let s:autopep8_ignores=""
let autopep8_ignores=""
endif

if exists("g:autopep8_select")
let s:autopep8_selects=" --select=".g:autopep8_select
let autopep8_selects=" --select=".g:autopep8_select
else
let s:autopep8_selects=""
let autopep8_selects=""
endif

if exists("g:autopep8_pep8_passes")
let s:autopep8_pep8_passes=" --pep8-passes=".g:autopep8_pep8_passes
let autopep8_pep8_passes=" --pep8-passes=".g:autopep8_pep8_passes
else
let s:autopep8_pep8_passes=""
let autopep8_pep8_passes=""
endif

if exists("g:autopep8_max_line_length")
let s:autopep8_max_line_length=" --max-line-length=".g:autopep8_max_line_length
let autopep8_max_line_length=" --max-line-length=".g:autopep8_max_line_length
else
let s:autopep8_max_line_length=""
let autopep8_max_line_length=""
endif

if exists("g:autopep8_aggressive")
let s:autopep8_aggressive=" --aggressive "
let autopep8_aggressive=" --aggressive "
else
let s:autopep8_aggressive=""
let autopep8_aggressive=""
endif

if exists("g:autopep8_indent_size")
let s:autopep8_indent_size=" --indent-size=".g:autopep8_indent_size
let autopep8_indent_size=" --indent-size=".g:autopep8_indent_size
else
let s:autopep8_indent_size=""
let autopep8_indent_size=""
endif

let s:execmdline=s:autopep8_cmd.s:autopep8_pep8_passes.s:autopep8_selects.s:autopep8_ignores.s:autopep8_max_line_length.s:autopep8_aggressive.s:autopep8_indent_size.l:args
let s:tmpfile = tempname()
let s:tmpdiff = tempname()
let s:index = 0
let execmdline=autopep8_cmd.autopep8_pep8_passes.autopep8_selects.autopep8_ignores.autopep8_max_line_length.autopep8_aggressive.autopep8_indent_size.l:args
let tmpfile = tempname()
let tmpdiff = tempname()
let index = 0
try
" current cursor
let s:current_cursor = getpos(".")
let current_cursor = getpos(".")
" write to temporary file
silent execute "!". s:execmdline . " \"" . expand('%:p') . "\" > " . s:tmpfile
silent execute "!". execmdline . " \"" . expand('%:p') . "\" > " . tmpfile
if !exists("g:autopep8_disable_show_diff")
silent execute "!". s:execmdline . " --diff \"" . expand('%:p') . "\" > " . s:tmpdiff
silent execute "!". execmdline . " --diff \"" . expand('%:p') . "\" > " . tmpdiff
endif

" current buffer all delete
silent execute "%d"
" read temp file. and write to current buffer.
for line in readfile(s:tmpfile)
call append(s:index, line)
let s:index = s:index + 1
for line in readfile(tmpfile)
call append(index, line)
let index = index + 1
endfor
" remove last linebreak.
silent execute ":" . s:index . "," . s:index . "s/\\n$//g"
silent execute ":" . index . "," . index . "s/\\n$//g"
" restore cursor
call setpos('.', s:current_cursor)
call setpos('.', current_cursor)

" show diff
if !exists("g:autopep8_disable_show_diff")
botright new autopep8
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
silent execute '$read ' . s:tmpdiff
silent execute '$read ' . tmpdiff
setlocal nomodifiable
setlocal nu
setlocal filetype=diff
Expand All @@ -108,11 +108,11 @@ if !exists("*Autopep8(...)")

finally
" file close
if filewritable(s:tmpfile)
call delete(s:tmpfile)
if filewritable(tmpfile)
call delete(tmpfile)
endif
if filewritable(s:tmpdiff)
call delete(s:tmpdiff)
if filewritable(tmpdiff)
call delete(tmpdiff)
endif
endtry

Expand Down

0 comments on commit 7dc456f

Please sign in to comment.