Mercurial > emacs
comparison lisp/progmodes/python.el @ 90843:d7172f202ab8
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 726-750)
- Update from CVS
- Merge from emacs--rel--22
- Merge from gnus--rel--5.10
* emacs--rel--22 (patch 6-17)
- Update from CVS
- Update from CVS: src/xterm.c (XTread_socket): Revert last change.
* gnus--rel--5.10 (patch 218-221)
- Merge from emacs--devo--0, emacs--rel--22
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-205
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Tue, 15 May 2007 07:17:13 +0000 |
| parents | e6fdae9180d4 e04539d0ccf5 |
| children | 3619e7770f2e |
comparison
equal
deleted
inserted
replaced
| 90842:e8254e8eb079 | 90843:d7172f202ab8 |
|---|---|
| 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. |
| 459 (save-excursion | 459 (save-excursion |
| 460 (python-beginning-of-statement) | 460 (python-beginning-of-statement) |
| 461 (let ((initial (current-indentation))) | 461 (let ((initial (current-indentation))) |
| 462 (if (zerop (python-next-statement)) | 462 (if (zerop (python-next-statement)) |
| 463 (setq indent (- (current-indentation) initial))) | 463 (setq indent (- (current-indentation) initial))) |
| 464 (if (and (>= indent 2) (<= indent 8)) ; sanity check | 464 (if (and indent (>= indent 2) (<= indent 8)) ; sanity check |
| 465 (setq done t)))))) | 465 (setq done t)))))) |
| 466 (when done | 466 (when done |
| 467 (when (/= indent (default-value 'python-indent)) | 467 (when (/= indent (default-value 'python-indent)) |
| 468 (set (make-local-variable 'python-indent) indent) | 468 (set (make-local-variable 'python-indent) indent) |
| 469 (unless (= tab-width python-indent) | 469 (unless (= tab-width python-indent) |
| 881 (cond ((eq 'comment (syntax-ppss-context s)) | 881 (cond ((eq 'comment (syntax-ppss-context s)) |
| 882 (setq comment t) | 882 (setq comment t) |
| 883 nil) | 883 nil) |
| 884 ((eq 'string (syntax-ppss-context s)) | 884 ((eq 'string (syntax-ppss-context s)) |
| 885 ;; Go to start of string and skip it. | 885 ;; Go to start of string and skip it. |
| 886 (goto-char (nth 8 s)) | 886 (let ((pos (point))) |
| 887 (condition-case () ; beware invalid syntax | 887 (goto-char (nth 8 s)) |
| 888 (progn (forward-sexp) t) | 888 (condition-case () ; beware invalid syntax |
| 889 (error (end-of-line)))) | 889 (progn (forward-sexp) t) |
| 890 ;; If there's a mismatched string, make sure | |
| 891 ;; we still overall move *forward*. | |
| 892 (error (goto-char pos) (end-of-line))))) | |
| 890 ((python-skip-out t s)))) | 893 ((python-skip-out t s)))) |
| 891 (end-of-line)) | 894 (end-of-line)) |
| 892 (unless comment | 895 (unless comment |
| 893 (eq ?\\ (char-before)))) ; Line continued? | 896 (eq ?\\ (char-before)))) ; Line continued? |
| 894 (end-of-line 2)) ; Try next line. | 897 (end-of-line 2)) ; Try next line. |
| 979 (while (and (> arg 0) | 982 (while (and (> arg 0) |
| 980 (let* ((point (point)) | 983 (let* ((point (point)) |
| 981 (_ (if (python-comment-line-p) | 984 (_ (if (python-comment-line-p) |
| 982 (python-skip-comments/blanks t))) | 985 (python-skip-comments/blanks t))) |
| 983 (ci (current-indentation)) | 986 (ci (current-indentation)) |
| 984 (open (python-open-block-statement-p)) | 987 (open (python-open-block-statement-p))) |
| 985 opoint) | |
| 986 (if (and (zerop ci) (not open)) | 988 (if (and (zerop ci) (not open)) |
| 987 (not (goto-char point)) | 989 (not (goto-char point)) |
| 988 (catch 'done | 990 (catch 'done |
| 989 (setq opoint (point)) | 991 (while (zerop (python-next-statement)) |
| 990 (while (and (zerop (python-next-statement)) | |
| 991 (not (= opoint (point)))) | |
| 992 (setq opoint (point)) | |
| 993 (when (or (and open (<= (current-indentation) ci)) | 992 (when (or (and open (<= (current-indentation) ci)) |
| 994 (< (current-indentation) ci)) | 993 (< (current-indentation) ci)) |
| 995 (python-skip-comments/blanks t) | 994 (python-skip-comments/blanks t) |
| 996 (beginning-of-line 2) | 995 (beginning-of-line 2) |
| 997 (throw 'done t))))))) | 996 (throw 'done t))))))) |
| 2238 (set (make-local-variable 'require-final-newline) mode-require-final-newline) | 2237 (set (make-local-variable 'require-final-newline) mode-require-final-newline) |
| 2239 (set (make-local-variable 'add-log-current-defun-function) | 2238 (set (make-local-variable 'add-log-current-defun-function) |
| 2240 #'python-current-defun) | 2239 #'python-current-defun) |
| 2241 (set (make-local-variable 'outline-regexp) | 2240 (set (make-local-variable 'outline-regexp) |
| 2242 (rx (* space) (or "class" "def" "elif" "else" "except" "finally" | 2241 (rx (* space) (or "class" "def" "elif" "else" "except" "finally" |
| 2243 "for" "if" "try" "while") | 2242 "for" "if" "try" "while" "with") |
| 2244 symbol-end)) | 2243 symbol-end)) |
| 2245 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") | 2244 (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") |
| 2246 (set (make-local-variable 'outline-level) #'python-outline-level) | 2245 (set (make-local-variable 'outline-level) #'python-outline-level) |
| 2247 (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) |
| 2248 (make-local-variable 'python-saved-check-command) | 2247 (make-local-variable 'python-saved-check-command) |
