comparison lisp/progmodes/python.el @ 77678:0b0c0f93563c

(python-font-lock-keywords, python-open-block-statement-p, python-mode): Add support for the new "with" keyword.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 10 May 2007 17:39:27 +0000
parents 32334cd7302e
children c1ec1c8a8d2e
comparison
equal deleted inserted replaced
77677:861b8417e148 77678:0b0c0f93563c
94 (or "and" "assert" "break" "continue" "del" "elif" "else" 94 (or "and" "assert" "break" "continue" "del" "elif" "else"
95 "except" "exec" "finally" "for" "from" "global" "if" 95 "except" "exec" "finally" "for" "from" "global" "if"
96 "import" "in" "is" "lambda" "not" "or" "pass" "print" 96 "import" "in" "is" "lambda" "not" "or" "pass" "print"
97 "raise" "return" "try" "while" "yield" 97 "raise" "return" "try" "while" "yield"
98 ;; Future keywords 98 ;; Future keywords
99 "as" "None" 99 "as" "None" "with"
100 ;; Not real keywords, but close enough to be fontified as such 100 ;; Not real keywords, but close enough to be fontified as such
101 "self" "True" "False") 101 "self" "True" "False")
102 symbol-end) 102 symbol-end)
103 ;; Definitions 103 ;; Definitions
104 (,(rx symbol-start (group "class") (1+ space) (group (1+ (or word ?_)))) 104 (,(rx symbol-start (group "class") (1+ space) (group (1+ (or word ?_))))
372 "Return non-nil if statement at point opens a block. 372 "Return non-nil if statement at point opens a block.
373 BOS non-nil means point is known to be at beginning of statement." 373 BOS non-nil means point is known to be at beginning of statement."
374 (save-excursion 374 (save-excursion
375 (unless bos (python-beginning-of-statement)) 375 (unless bos (python-beginning-of-statement))
376 (looking-at (rx (and (or "if" "else" "elif" "while" "for" "def" 376 (looking-at (rx (and (or "if" "else" "elif" "while" "for" "def"
377 "class" "try" "except" "finally") 377 "class" "try" "except" "finally" "with")
378 symbol-end))))) 378 symbol-end)))))
379 379
380 (defun python-close-block-statement-p (&optional bos) 380 (defun python-close-block-statement-p (&optional bos)
381 "Return non-nil if current line is a statement closing a block. 381 "Return non-nil if current line is a statement closing a block.
382 BOS non-nil means point is at beginning of statement. 382 BOS non-nil means point is at beginning of statement.
2238 (set (make-local-variable 'require-final-newline) mode-require-final-newline) 2238 (set (make-local-variable 'require-final-newline) mode-require-final-newline)
2239 (set (make-local-variable 'add-log-current-defun-function) 2239 (set (make-local-variable 'add-log-current-defun-function)
2240 #'python-current-defun) 2240 #'python-current-defun)
2241 (set (make-local-variable 'outline-regexp) 2241 (set (make-local-variable 'outline-regexp)
2242 (rx (* space) (or "class" "def" "elif" "else" "except" "finally" 2242 (rx (* space) (or "class" "def" "elif" "else" "except" "finally"
2243 "for" "if" "try" "while") 2243 "for" "if" "try" "while" "with")
2244 symbol-end)) 2244 symbol-end))
2245 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") 2245 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n")
2246 (set (make-local-variable 'outline-level) #'python-outline-level) 2246 (set (make-local-variable 'outline-level) #'python-outline-level)
2247 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) 2247 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)
2248 (make-local-variable 'python-saved-check-command) 2248 (make-local-variable 'python-saved-check-command)