Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4a72d7

Browse files
committed
Merge branch 'release/0.6.8'
2 parents49ae47e +e1311f5 commite4a72d7

File tree

8 files changed

+232
-50
lines changed

8 files changed

+232
-50
lines changed

‎Changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
## 2012-09-06 0.6.8
5+
-------------------
6+
* Add PEP8 indentation ":help 'pymode_indent'"
7+
48
## 2012-08-15 0.6.7
59
-------------------
610
* Fix documentation. Thanks (c) bgrant;

‎README.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@ Default values: ::
287287
" Autoremove unused whitespaces
288288
let g:pymode_utils_whitespaces = 1
289289

290-
"Set defaultpymodepython indent options
291-
let g:pymode_options_indent = 1
290+
"Enablepymodeindentation
291+
let g:pymode_indent = 1
292292

293-
" Set default pymode pythonotheroptions
294-
let g:pymode_options_other = 1
293+
" Set default pymode python options
294+
let g:pymode_options = 1
295295

296296

297297
Syntax highlight
@@ -478,6 +478,10 @@ Copyright (C) 2012 Kirill Klenov (klen_)
478478
Copyright (c) 2010 Dmitry Vasiliev
479479
http://www.hlabs.spb.ru/vim/python.vim
480480

481+
**PEP8 VIM indentation**
482+
Copyright (c) 2012 Hynek Schlawack <hs@ox.cx>
483+
http://github.com/hynek/vim-python-pep8-indent
484+
481485

482486
License
483487
=======
@@ -488,8 +492,6 @@ If you like this plugin, you can send me postcard :)
488492
My address is here: "Russia, 143401, Krasnogorsk, Shkolnaya 1-19" to "Kirill Klenov".
489493
**Thanks for support!**
490494

491-
Version 0.6.5: I still haven't received any postcard, guys :(
492-
493495

494496
.. _GNU lesser general public license:http://www.gnu.org/copyleft/lesser.html
495497
.. _klen:http://klen.github.com/

‎after/indent/python.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ifpymode#Default('b:pymode_indent',1)||!g:pymode_indent
2+
finish
3+
endif
4+
5+
6+
setlocalnolisp
7+
setlocaltabstop=4
8+
setlocalsofttabstop=4
9+
setlocalshiftwidth=4
10+
setlocalshiftround
11+
setlocalexpandtab
12+
setlocalautoindent
13+
setlocalindentexpr=pymode#indent#Indent(v:lnum)
14+
setlocalindentkeys=!^F,o,O,<:>,0),0],0},=elif,=except

‎autoload/pymode/indent.vim

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
" PEP8 compatible Python indent file
2+
" Language: Python
3+
" Maintainer: Hynek Schlawack <hs@ox.cx>
4+
" Prev Maintainer: Eric Mc Sween <em@tomcom.de> (address invalid)
5+
" Original Author: David Bustos <bustos@caltech.edu> (address invalid)
6+
" Last Change: 2012-06-21
7+
" License: Public Domainlet
8+
9+
10+
function!pymode#indent#Indent(lnum)
11+
12+
" First line has indent 0
13+
ifa:lnum==1
14+
return0
15+
endif
16+
17+
" If we can find an open parenthesis/bracket/brace, line up with it.
18+
callcursor(a:lnum,1)
19+
let parlnum=s:SearchParensPair()
20+
if parlnum >0
21+
let parcol=col('.')
22+
let closing_paren=match(getline(a:lnum),'^\s*[])}]')!=-1
23+
ifmatch(getline(parlnum),'[([{]\s*$', parcol-1)!=-1
24+
if closing_paren
25+
returnindent(parlnum)
26+
else
27+
returnindent(parlnum)+ &shiftwidth
28+
endif
29+
else
30+
return parcol
31+
endif
32+
endif
33+
34+
" Examine this line
35+
let thisline=getline(a:lnum)
36+
let thisindent=indent(a:lnum)
37+
38+
" If the line starts with 'elif' or 'else', line up with 'if' or 'elif'
39+
if thisline=~'^\s*\(elif\|else\)\>'
40+
let bslnum=s:BlockStarter(a:lnum,'^\s*\(if\|elif\)\>')
41+
if bslnum >0
42+
returnindent(bslnum)
43+
else
44+
return-1
45+
endif
46+
endif
47+
48+
" If the line starts with 'except' or 'finally', line up with 'try'
49+
" or 'except'
50+
if thisline=~'^\s*\(except\|finally\)\>'
51+
let bslnum=s:BlockStarter(a:lnum,'^\s*\(try\|except\)\>')
52+
if bslnum >0
53+
returnindent(bslnum)
54+
else
55+
return-1
56+
endif
57+
endif
58+
59+
" Examine previous line
60+
let plnum=a:lnum-1
61+
let pline=getline(plnum)
62+
let sslnum=s:StatementStart(plnum)
63+
64+
" If the previous line is blank, keep the same indentation
65+
if pline=~'^\s*$'
66+
return-1
67+
endif
68+
69+
" If this line is explicitly joined, try to find an indentation that looks
70+
" good.
71+
if pline=~'\\$'
72+
let compound_statement='^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
73+
let maybe_indent=matchend(getline(sslnum), compound_statement)
74+
if maybe_indent!=-1
75+
return maybe_indent
76+
else
77+
returnindent(sslnum)+ &sw*2
78+
endif
79+
endif
80+
81+
" If the previous line ended with a colon and is not a comment, indent
82+
" relative to statement start.
83+
if pline=~':\s*$'&& pline!~'^\s*#'
84+
returnindent(sslnum)+ &sw
85+
endif
86+
87+
" If the previous line was a stop-execution statement or a pass
88+
ifgetline(sslnum)=~'^\s*\(break\|continue\|raise\|return\|pass\)\>'
89+
" See if the user has already dedented
90+
ifindent(a:lnum) >indent(sslnum)- &sw
91+
" If not, recommend one dedent
92+
returnindent(sslnum)- &sw
93+
endif
94+
" Otherwise, trust the user
95+
return-1
96+
endif
97+
98+
" In all other cases, line up with the start of the previous statement.
99+
returnindent(sslnum)
100+
endfunction
101+
102+
103+
" Find backwards the closest open parenthesis/bracket/brace.
104+
function!s:SearchParensPair()
105+
letline=line('.')
106+
letcol=col('.')
107+
108+
" Skip strings and comments and don't look too far
109+
letskip="line('.') <" . (line-50) ." ? dummy :" .
110+
\'synIDattr(synID(line("."), col("."), 0), "name") =~?' .
111+
\'"string\\|comment"'
112+
113+
" Search for parentheses
114+
callcursor(line,col)
115+
let parlnum=searchpair('(','',')','bW',skip)
116+
let parcol=col('.')
117+
118+
" Search for brackets
119+
callcursor(line,col)
120+
let par2lnum=searchpair('\[','','\]','bW',skip)
121+
let par2col=col('.')
122+
123+
" Search for braces
124+
callcursor(line,col)
125+
let par3lnum=searchpair('{','','}','bW',skip)
126+
let par3col=col('.')
127+
128+
" Get the closest match
129+
if par2lnum >parlnum|| (par2lnum== parlnum&& par2col >parcol)
130+
let parlnum= par2lnum
131+
let parcol= par2col
132+
endif
133+
if par3lnum >parlnum|| (par3lnum== parlnum&& par3col >parcol)
134+
let parlnum= par3lnum
135+
let parcol= par3col
136+
endif
137+
138+
" Put the cursor on the match
139+
if parlnum >0
140+
callcursor(parlnum, parcol)
141+
endif
142+
return parlnum
143+
endfunction
144+
145+
146+
" Find the start of a multi-line statement
147+
function!s:StatementStart(lnum)
148+
let lnum=a:lnum
149+
while1
150+
ifgetline(lnum-1)=~'\\$'
151+
let lnum= lnum-1
152+
else
153+
callcursor(lnum,1)
154+
let maybe_lnum=s:SearchParensPair()
155+
if maybe_lnum <1
156+
return lnum
157+
else
158+
let lnum= maybe_lnum
159+
endif
160+
endif
161+
endwhile
162+
endfunction
163+
164+
165+
" Find the block starter that matches the current line
166+
function!s:BlockStarter(lnum, block_start_re)
167+
let lnum=a:lnum
168+
let maxindent=10000" whatever
169+
while lnum >1
170+
let lnum=prevnonblank(lnum-1)
171+
ifindent(lnum) <maxindent
172+
ifgetline(lnum)=~a:block_start_re
173+
return lnum
174+
else
175+
let maxindent=indent(lnum)
176+
" It's not worth going further if we reached the top level
177+
if maxindent==0
178+
return-1
179+
endif
180+
endif
181+
endif
182+
endwhile
183+
return-1
184+
endfunction

‎doc/pymode.txt

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(__) (__) (__) (_) (_)(_____)(_)\_) (_/\/\_)(_____)(____/(____)~
77

88

9-
Version: 0.6.7
9+
Version: 0.6.8
1010

1111
==============================================================================
1212
CONTENTS*Python-mode-contents*
@@ -100,10 +100,9 @@ PythonMode. These options should be set in your vimrc.
100100

101101
|'pymode_syntax'| Turns off the custom syntax highlighting
102102

103-
|'pymode_options_indent'| Set default pymode options for
104-
python indentation
103+
|'pymode_indent'| Enable/Disable pymode PEP8 indentation
105104

106-
|'pymode_options_other'| Set default pymode options for
105+
|'pymode_options'| Set default pymode options for
107106
python codding
108107

109108
|'pymode_motion'| Enable pymode motion stuff
@@ -346,24 +345,12 @@ If this option is set to 0 then the custom syntax highlighting will
346345
not be used.
347346

348347
------------------------------------------------------------------------------
349-
*'pymode_options_indent'*
348+
*'pymode_indent'*
350349
Values: 0 or 1.
351350
Default: 1.
352351

353-
If this option is set to 1, pymode will enable the following options for python
354-
buffers:>
352+
If this option is set to 1, pymode will enable python indentation support
355353

356-
setlocal cinwords=if,elif,else,for,while,try,except,finally,def,class
357-
setlocal cindent
358-
setlocal tabstop=4
359-
setlocal softtabstop=4
360-
setlocal shiftwidth=4
361-
setlocal shiftround
362-
setlocal smartindent
363-
setlocal smarttab
364-
setlocal expandtab
365-
setlocal autoindent
366-
<
367354
------------------------------------------------------------------------------
368355
*'pymode_folding'*
369356
Values: 0 or 1.
@@ -372,7 +359,7 @@ Default: 1.
372359
If this option is set to 1, pymode will enable python-folding.
373360

374361
------------------------------------------------------------------------------
375-
*'pymode_options_other'*
362+
*'pymode_options'*
376363
Values: 0 or 1.
377364
Default: 1.
378365

@@ -535,6 +522,10 @@ from `.vimrc` from your projects directories.
535522
Copyright (c) 2010 Dmitry Vasiliev
536523
http://www.hlabs.spb.ru/vim/python.vim
537524

525+
PEP8 VIM indentation
526+
Copyright (c) 2012 Hynek Schlawack <hs@ox.cx>
527+
http://github.com/hynek/vim-python-pep8-indent
528+
538529

539530
==============================================================================
540531
7. License~
@@ -547,8 +538,6 @@ If you like this plugin, you can send me a postcard :)
547538
My address is: "Russia, 143401, Krasnogorsk, Shkolnaya 1-19" to "Kirill Klenov".
548539
Thanks for your support!
549540

550-
Version 0.6.5: I still haven't received any postcards, guys :(
551-
552541

553542
------------------------------------------------------------------------------
554543

‎ftplugin/python/pymode.vim

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,8 @@ endif
1515

1616
" Options {{{
1717

18-
" Python indent options
19-
ifpymode#Option('options_indent')
20-
setlocalcinwords=if,elif,else,for,while,try,except,finally,def,class
21-
setlocalcindent
22-
setlocaltabstop=4
23-
setlocalsofttabstop=4
24-
setlocalshiftwidth=4
25-
setlocalshiftround
26-
setlocalsmartindent
27-
setlocalsmarttab
28-
setlocalexpandtab
29-
setlocalautoindent
30-
endif
31-
3218
" Python other options
33-
ifpymode#Option('options_other')
19+
ifpymode#Option('options')
3420
setlocalcomplete+=t
3521
setlocalformatoptions-=t
3622
ifv:version >702&&!&relativenumber

‎plugin/pymode.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
letg:pymode_version="0.6.7"
1+
letg:pymode_version="0.6.8"
22

33
com! PymodeVersionechomsg"Current python-mode version:" .g:pymode_version
44

@@ -281,13 +281,13 @@ call pymode#Default("g:pymode_folding", 1)
281281
" OPTION: g:pymode_syntax -- bool. Enable python-mode syntax for pyfiles.
282282
callpymode#Default("g:pymode_syntax",1)
283283

284+
" OPTION: g:pymode_indent -- bool. Enable/Disable pymode PEP8 indentation
285+
callpymode#Default("g:pymode_indent",1)
286+
284287
" OPTION: g:pymode_utils_whitespaces -- bool. Remove unused whitespaces on save
285288
callpymode#Default("g:pymode_utils_whitespaces",1)
286289

287-
" OPTION: g:pymode_options_indent -- bool. To set indent options.
288-
callpymode#Default("g:pymode_options_indent",1)
289-
290-
" OPTION: g:pymode_options_other -- bool. To set other options.
291-
callpymode#Default("g:pymode_options_other",1)
290+
" OPTION: g:pymode_options -- bool. To set some python options.
291+
callpymode#Default("g:pymode_options",1)
292292

293293
" vim:fdm=marker:fdl=0

‎pylibs/autopep8.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
pep8=None
5050

5151

52-
__version__='0.7.3'
52+
__version__='0.8'
5353

5454

5555
PEP8_BIN='pep8'
@@ -1580,4 +1580,7 @@ def main():
15801580

15811581

15821582
if__name__=='__main__':
1583-
sys.exit(main())
1583+
try:
1584+
sys.exit(main())
1585+
exceptKeyboardInterrupt:
1586+
sys.exit(1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp