Commit 20e192b6 authored by Brett Cannon's avatar Brett Cannon

Update for 'with' statement.

parent a9f06872
...@@ -14,8 +14,9 @@ if exists("python_highlight_all") ...@@ -14,8 +14,9 @@ if exists("python_highlight_all")
let python_highlight_space_errors = 1 let python_highlight_space_errors = 1
endif endif
syn keyword pythonStatement assert break continue del except exec finally syn keyword pythonStatement as assert break continue del except exec finally
syn keyword pythonStatement global lambda pass print raise return try yield syn keyword pythonStatement global lambda pass print raise return try with
syn keyword pythonStatement yield
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
...@@ -82,8 +83,9 @@ if exists("python_highlight_exceptions") ...@@ -82,8 +83,9 @@ if exists("python_highlight_exceptions")
syn keyword pythonException UnicodeTranslateError MemoryError StopIteration syn keyword pythonException UnicodeTranslateError MemoryError StopIteration
syn keyword pythonException PendingDeprecationWarning EnvironmentError syn keyword pythonException PendingDeprecationWarning EnvironmentError
syn keyword pythonException LookupError OSError DeprecationWarning syn keyword pythonException LookupError OSError DeprecationWarning
syn keyword pythonException UnicodeError FloatingPointError ReferenceError syn keyword pythonException UnicodeError UnicodeEncodeError
syn keyword pythonException NameError OverflowWarning IOError SyntaxError syn keyword pythonException FloatingPointError ReferenceError NameError
syn keyword pythonException OverflowWarning IOError SyntaxError
syn keyword pythonException FutureWarning SystemExit Exception EOFError syn keyword pythonException FutureWarning SystemExit Exception EOFError
syn keyword pythonException StandardError ValueError TabError KeyError syn keyword pythonException StandardError ValueError TabError KeyError
syn keyword pythonException ZeroDivisionError SystemError syn keyword pythonException ZeroDivisionError SystemError
...@@ -92,7 +94,7 @@ if exists("python_highlight_exceptions") ...@@ -92,7 +94,7 @@ if exists("python_highlight_exceptions")
syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning
syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError
syn keyword pythonException Warning NotImplementedError AttributeError syn keyword pythonException Warning NotImplementedError AttributeError
syn keyword pythonException OverflowError UnicodeEncodeError syn keyword pythonException OverflowError BaseException
endif endif
......
...@@ -13,20 +13,28 @@ repository. ...@@ -13,20 +13,28 @@ repository.
# OPTIONAL: XXX catch your attention # OPTIONAL: XXX catch your attention
# Statements # Statements
from __future__ import with_statement # Import
from sys import path as thing
assert True # keyword assert True # keyword
def foo(): # function definition def foo(): # function definition
return [] return []
class Bar(object): # Class definition class Bar(object): # Class definition
def __context__(self):
return self
def __enter__(self):
pass
def __exit__(self, *args):
pass pass
foo() # UNCOLOURED: function call foo() # UNCOLOURED: function call
while False: # 'while' while False: # 'while'
continue continue
for x in foo(): # 'for' for x in foo(): # 'for'
break break
with Bar() as stuff:
pass
if False: pass # 'if' if False: pass # 'if'
elif False: pass elif False: pass
else False: pass else: pass
from sys import path as thing # Import
# Constants # Constants
'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted 'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
......
from __future__ import with_statement
import keyword import keyword
import exceptions import exceptions
import __builtin__ import __builtin__
...@@ -143,10 +145,8 @@ def fill_stmt(iterable, fill_len): ...@@ -143,10 +145,8 @@ def fill_stmt(iterable, fill_len):
except StopIteration: except StopIteration:
if buffer_: if buffer_:
break break
if not buffer_ and overflow: if overflow:
yield buffer_ yield overflow
return
else:
return return
if total_len > fill_len: if total_len > fill_len:
overflow = buffer_.pop() overflow = buffer_.pop()
...@@ -158,8 +158,7 @@ def fill_stmt(iterable, fill_len): ...@@ -158,8 +158,7 @@ def fill_stmt(iterable, fill_len):
FILL = 80 FILL = 80
def main(file_path): def main(file_path):
FILE = open(file_path, 'w') with open(file_path, 'w') as FILE:
try:
# Comment for file # Comment for file
print>>FILE, comment_header print>>FILE, comment_header
print>>FILE, '' print>>FILE, ''
...@@ -222,8 +221,6 @@ def main(file_path): ...@@ -222,8 +221,6 @@ def main(file_path):
print>>FILE, '' print>>FILE, ''
# Statements at the end of the file # Statements at the end of the file
print>>FILE, statement_footer print>>FILE, statement_footer
finally:
FILE.close()
if __name__ == '__main__': if __name__ == '__main__':
main("python.vim") main("python.vim")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment