Mercurial > emacs
comparison lisp/progmodes/python.el @ 80882:e04539d0ccf5
(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 | Wed, 09 May 2007 16:56:20 +0000 |
| parents | 4882ec1204fb |
| children | f0107aee8e99 d7172f202ab8 |
comparison
equal
deleted
inserted
replaced
| 80881:4882ec1204fb | 80882:e04539d0ccf5 |
|---|---|
| 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. |
| 2237 (set (make-local-variable 'require-final-newline) mode-require-final-newline) | 2237 (set (make-local-variable 'require-final-newline) mode-require-final-newline) |
| 2238 (set (make-local-variable 'add-log-current-defun-function) | 2238 (set (make-local-variable 'add-log-current-defun-function) |
| 2239 #'python-current-defun) | 2239 #'python-current-defun) |
| 2240 (set (make-local-variable 'outline-regexp) | 2240 (set (make-local-variable 'outline-regexp) |
| 2241 (rx (* space) (or "class" "def" "elif" "else" "except" "finally" | 2241 (rx (* space) (or "class" "def" "elif" "else" "except" "finally" |
| 2242 "for" "if" "try" "while") | 2242 "for" "if" "try" "while" "with") |
| 2243 symbol-end)) | 2243 symbol-end)) |
| 2244 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") | 2244 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") |
| 2245 (set (make-local-variable 'outline-level) #'python-outline-level) | 2245 (set (make-local-variable 'outline-level) #'python-outline-level) |
| 2246 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) | 2246 (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) |
| 2247 (make-local-variable 'python-saved-check-command) | 2247 (make-local-variable 'python-saved-check-command) |
