summaryrefslogtreecommitdiff
path: root/Misc/Vim
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-03-01 20:53:08 +0000
committerBrett Cannon <bcannon@gmail.com>2006-03-01 20:53:08 +0000
commitb1e7ba7e6c86206006724541fc0c2fb59ee4bc27 (patch)
tree0df764376984a8d7e884fd424db855ca1e23f500 /Misc/Vim
parent57b3435d3b92b5643a94b83d48b2b8aee90c8266 (diff)
downloadcpython-b1e7ba7e6c86206006724541fc0c2fb59ee4bc27.tar.gz
Update for 'with' statement.
Diffstat (limited to 'Misc/Vim')
-rw-r--r--Misc/Vim/python.vim12
-rw-r--r--Misc/Vim/syntax_test.py14
-rw-r--r--Misc/Vim/vim_syntax.py15
3 files changed, 24 insertions, 17 deletions
diff --git a/Misc/Vim/python.vim b/Misc/Vim/python.vim
index 6a1fa9f40d..0d5e6d05e2 100644
--- a/Misc/Vim/python.vim
+++ b/Misc/Vim/python.vim
@@ -14,8 +14,9 @@ if exists("python_highlight_all")
let python_highlight_space_errors = 1
endif
-syn keyword pythonStatement assert break continue del except exec finally
-syn keyword pythonStatement global lambda pass print raise return try yield
+syn keyword pythonStatement as assert break continue del except exec finally
+syn keyword pythonStatement global lambda pass print raise return try with
+syn keyword pythonStatement yield
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
@@ -82,8 +83,9 @@ if exists("python_highlight_exceptions")
syn keyword pythonException UnicodeTranslateError MemoryError StopIteration
syn keyword pythonException PendingDeprecationWarning EnvironmentError
syn keyword pythonException LookupError OSError DeprecationWarning
- syn keyword pythonException UnicodeError FloatingPointError ReferenceError
- syn keyword pythonException NameError OverflowWarning IOError SyntaxError
+ syn keyword pythonException UnicodeError UnicodeEncodeError
+ syn keyword pythonException FloatingPointError ReferenceError NameError
+ syn keyword pythonException OverflowWarning IOError SyntaxError
syn keyword pythonException FutureWarning SystemExit Exception EOFError
syn keyword pythonException StandardError ValueError TabError KeyError
syn keyword pythonException ZeroDivisionError SystemError
@@ -92,7 +94,7 @@ if exists("python_highlight_exceptions")
syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning
syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError
syn keyword pythonException Warning NotImplementedError AttributeError
- syn keyword pythonException OverflowError UnicodeEncodeError
+ syn keyword pythonException OverflowError BaseException
endif
diff --git a/Misc/Vim/syntax_test.py b/Misc/Vim/syntax_test.py
index f313392ea9..a530a25364 100644
--- a/Misc/Vim/syntax_test.py
+++ b/Misc/Vim/syntax_test.py
@@ -13,20 +13,28 @@ repository.
# OPTIONAL: XXX catch your attention
# Statements
+from __future__ import with_statement # Import
+from sys import path as thing
assert True # keyword
def foo(): # function definition
return []
class Bar(object): # Class definition
- pass
+ def __context__(self):
+ return self
+ def __enter__(self):
+ pass
+ def __exit__(self, *args):
+ pass
foo() # UNCOLOURED: function call
while False: # 'while'
continue
for x in foo(): # 'for'
break
+with Bar() as stuff:
+ pass
if False: pass # 'if'
elif False: pass
-else False: pass
-from sys import path as thing # Import
+else: pass
# Constants
'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
diff --git a/Misc/Vim/vim_syntax.py b/Misc/Vim/vim_syntax.py
index 8ef5bb89d0..3f2a3d8a23 100644
--- a/Misc/Vim/vim_syntax.py
+++ b/Misc/Vim/vim_syntax.py
@@ -1,3 +1,5 @@
+from __future__ import with_statement
+
import keyword
import exceptions
import __builtin__
@@ -143,11 +145,9 @@ def fill_stmt(iterable, fill_len):
except StopIteration:
if buffer_:
break
- if not buffer_ and overflow:
- yield buffer_
- return
- else:
- return
+ if overflow:
+ yield overflow
+ return
if total_len > fill_len:
overflow = buffer_.pop()
total_len -= len(overflow) - 1
@@ -158,8 +158,7 @@ def fill_stmt(iterable, fill_len):
FILL = 80
def main(file_path):
- FILE = open(file_path, 'w')
- try:
+ with open(file_path, 'w') as FILE:
# Comment for file
print>>FILE, comment_header
print>>FILE, ''
@@ -222,8 +221,6 @@ def main(file_path):
print>>FILE, ''
# Statements at the end of the file
print>>FILE, statement_footer
- finally:
- FILE.close()
if __name__ == '__main__':
main("python.vim")