Skip to content

Commit a7b5e6e

Browse files
committed
Refactor buffer actions.
1 parent 68dbae1 commit a7b5e6e

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

autoload/pymode.vim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ fun! pymode#error(msg) "{{{
4343
endfunction "}}}
4444

4545
" DESC: Open quickfix window
46-
fun! pymode#quickfix_open(onlyRecognized, holdCursor, maxHeight, minHeight, jumpError) "{{{
46+
fun! pymode#quickfix_open(onlyRecognized, maxHeight, minHeight, jumpError) "{{{
4747
let numErrors = len(filter(getqflist(), 'v:val.valid'))
4848
let numOthers = len(getqflist()) - numErrors
4949
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
5050
botright copen
5151
exe max([min([line("$"), a:maxHeight]), a:minHeight]) . "wincmd _"
5252
if a:jumpError
5353
cc
54-
elseif !a:holdCursor
54+
else
5555
wincmd p
5656
endif
5757
else
@@ -103,3 +103,16 @@ fun! pymode#reload_buf_by_nr(nr) "{{{
103103
exe "e!"
104104
exe "buffer " . cur
105105
endfunction "}}}
106+
107+
fun! pymode#buffer_pre_write() "{{{
108+
let b:pymode_modified = &modified
109+
endfunction
110+
111+
fun! pymode#buffer_post_write() "{{{
112+
if b:pymode_modified && g:pymode_rope_regenerate_on_write
113+
call pymode#rope#regenerate()
114+
endif
115+
if b:pymode_modified && g:pymode_lint_on_write
116+
call pymode#lint#check()
117+
endif
118+
endfunction "}}}

ftplugin/python/pymode.vim

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ if !pymode#default('g:pymode_init', 1)
99
call pymode#breakpoint#init()
1010
endif
1111

12+
" Setup events for pymode
13+
au pymode BufWritePre <buffer> call pymode#buffer_pre_write()
14+
au pymode BufWritePost <buffer> call pymode#buffer_post_write()
15+
1216
" Run python code
1317
if g:pymode_run
1418

@@ -63,10 +67,6 @@ if g:pymode_lint
6367
let b:pymode_errors = {}
6468
let b:pymode_signs = []
6569

66-
if g:pymode_lint_on_write
67-
au pymode BufWritePost <buffer> PymodeLint
68-
endif
69-
7070
if g:pymode_lint_on_fly
7171
au pymode InsertLeave <buffer> PymodeLint
7272
endif
@@ -148,13 +148,12 @@ if g:pymode_rope
148148
inoremap <silent> <buffer> . .<C-R>=pymode#rope#complete_on_dot()<CR>
149149
end
150150

151-
au pymode BufWritePost <buffer> call pymode#rope#regenerate()
152-
153151
command! -buffer PymodeRopeNewProject call pymode#rope#new()
154152
command! -buffer PymodeRopeUndo call pymode#rope#undo()
155153
command! -buffer PymodeRopeRedo call pymode#rope#redo()
156154
command! -buffer PymodeRopeRenameModule call pymode#rope#rename_module()
157155
command! -buffer PymodeRopeModuleToPackage call pymode#rope#module_to_package()
156+
command! -buffer PymodeRopeRegenerate call pymode#rope#regenerate()
158157

159158
if g:pymode_rope_autoimport
160159
command! -buffer PymodeRopeAutoImport call pymode#rope#autoimport(expand('<cword>'))

0 commit comments

Comments
 (0)