diff options
| author | Miles Bader | 2005-03-31 09:58:14 +0000 |
|---|---|---|
| committer | Miles Bader | 2005-03-31 09:58:14 +0000 |
| commit | 773415d9340f12db3bd8654de5014deec57d49b7 (patch) | |
| tree | 579ecf466891c80df147934b0db24cb89d0abe3d /lisp/progmodes/python.el | |
| parent | e9d5a4e18a8955cf60e78c54a511fd8e1259716f (diff) | |
| parent | 7c315e1cff9019c8af55921fab6f571e68b09623 (diff) | |
| download | emacs-773415d9340f12db3bd8654de5014deec57d49b7.tar.gz emacs-773415d9340f12db3bd8654de5014deec57d49b7.zip | |
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-31
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 206-222)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 45-52)
- Update from CVS
- Update from CVS: texi Makefile.in CVS keyw cruft
- Update from CVS: ChangeLog tweaks
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 745bc57a9b0..5073f2bc23a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; python.el --- silly walks for Python | 1 | ;;; python.el --- silly walks for Python |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -336,14 +336,14 @@ keyword `raise', `break', `continue' or `pass'." | |||
| 336 | (unless bos (python-beginning-of-statement)) | 336 | (unless bos (python-beginning-of-statement)) |
| 337 | (back-to-indentation) | 337 | (back-to-indentation) |
| 338 | (looking-at (rx (and (or "return" "raise" "break" "continue" "pass") | 338 | (looking-at (rx (and (or "return" "raise" "break" "continue" "pass") |
| 339 | word-end))))) | 339 | symbol-end))))) |
| 340 | 340 | ||
| 341 | (defun python-outdent-p () | 341 | (defun python-outdent-p () |
| 342 | "Return non-nil if current line should outdent a level." | 342 | "Return non-nil if current line should outdent a level." |
| 343 | (save-excursion | 343 | (save-excursion |
| 344 | (back-to-indentation) | 344 | (back-to-indentation) |
| 345 | (and (looking-at (rx (and (or (and (or "else" "finally") word-end) | 345 | (and (looking-at (rx (and (or (and (or "else" "finally") symbol-end) |
| 346 | (and (or "except" "elif") word-end | 346 | (and (or "except" "elif") symbol-end |
| 347 | (1+ (not (any ?:))))) | 347 | (1+ (not (any ?:))))) |
| 348 | (optional space) ":" (optional space) | 348 | (optional space) ":" (optional space) |
| 349 | (or (syntax comment-start) line-end)))) | 349 | (or (syntax comment-start) line-end)))) |
| @@ -355,8 +355,8 @@ keyword `raise', `break', `continue' or `pass'." | |||
| 355 | ;; Fixme: check this | 355 | ;; Fixme: check this |
| 356 | (not (looking-at (rx (and (or (and (or "if" "elif" "except" | 356 | (not (looking-at (rx (and (or (and (or "if" "elif" "except" |
| 357 | "for" "while") | 357 | "for" "while") |
| 358 | word-end (1+ (not (any ?:)))) | 358 | symbol-end (1+ (not (any ?:)))) |
| 359 | (and "try" word-end)) | 359 | (and "try" symbol-end)) |
| 360 | (optional space) ":" (optional space) | 360 | (optional space) ":" (optional space) |
| 361 | (or (syntax comment-start) line-end))))) | 361 | (or (syntax comment-start) line-end))))) |
| 362 | (progn (end-of-line) | 362 | (progn (end-of-line) |
| @@ -1098,28 +1098,40 @@ Don't save anything for STR matching `inferior-python-filter-regexp'." | |||
| 1098 | (defvar python-preoutput-continuation nil | 1098 | (defvar python-preoutput-continuation nil |
| 1099 | "If non-nil, funcall this when `python-preoutput-filter' sees `_emacs_ok'.") | 1099 | "If non-nil, funcall this when `python-preoutput-filter' sees `_emacs_ok'.") |
| 1100 | 1100 | ||
| 1101 | (defvar python-preoutput-leftover nil) | ||
| 1102 | |||
| 1101 | ;; Using this stops us getting lines in the buffer like | 1103 | ;; Using this stops us getting lines in the buffer like |
| 1102 | ;; >>> ... ... >>> | 1104 | ;; >>> ... ... >>> |
| 1103 | ;; Also look for (and delete) an `_emacs_ok' string and call | 1105 | ;; Also look for (and delete) an `_emacs_ok' string and call |
| 1104 | ;; `python-preoutput-continuation' if we get it. | 1106 | ;; `python-preoutput-continuation' if we get it. |
| 1105 | (defun python-preoutput-filter (s) | 1107 | (defun python-preoutput-filter (s) |
| 1106 | "`comint-preoutput-filter-functions' function: ignore prompts not at bol." | 1108 | "`comint-preoutput-filter-functions' function: ignore prompts not at bol." |
| 1109 | (when python-preoutput-leftover | ||
| 1110 | (setq s (concat python-preoutput-leftover s)) | ||
| 1111 | (setq python-preoutput-leftover nil)) | ||
| 1107 | (cond ((and (string-match (rx (and string-start (repeat 3 (any ".>")) | 1112 | (cond ((and (string-match (rx (and string-start (repeat 3 (any ".>")) |
| 1108 | " " string-end)) | 1113 | " " string-end)) |
| 1109 | s) | 1114 | s) |
| 1110 | (/= (let ((inhibit-field-text-motion t)) | 1115 | (/= (let ((inhibit-field-text-motion t)) |
| 1111 | (line-beginning-position)) | 1116 | (line-beginning-position)) |
| 1112 | (point))) | 1117 | (point))) |
| 1113 | "") | 1118 | "") |
| 1114 | ((string= s "_emacs_ok\n") | 1119 | ((string= s "_emacs_ok\n") |
| 1115 | (when python-preoutput-continuation | 1120 | (when python-preoutput-continuation |
| 1116 | (funcall python-preoutput-continuation) | 1121 | (funcall python-preoutput-continuation) |
| 1117 | (setq python-preoutput-continuation nil)) | 1122 | (setq python-preoutput-continuation nil)) |
| 1118 | "") | 1123 | "") |
| 1119 | ((string-match "_emacs_out \\(.*\\)\n" s) | 1124 | ((string-match "_emacs_out \\(.*\\)\n" s) |
| 1120 | (setq python-preoutput-result (match-string 1 s)) | 1125 | (setq python-preoutput-result (match-string 1 s)) |
| 1126 | "") | ||
| 1127 | ((string-match ".*\n" s) | ||
| 1128 | s) | ||
| 1129 | ((or (eq t (compare-strings s nil nil "_emacs_ok\n" nil (length s))) | ||
| 1130 | (let ((end (min (length "_emacs_out ") (length s)))) | ||
| 1131 | (eq t (compare-strings s nil end "_emacs_out " nil end)))) | ||
| 1132 | (setq python-preoutput-leftover s) | ||
| 1121 | "") | 1133 | "") |
| 1122 | (t s))) | 1134 | (t s))) |
| 1123 | 1135 | ||
| 1124 | ;;;###autoload | 1136 | ;;;###autoload |
| 1125 | (defun run-python (&optional cmd noshow) | 1137 | (defun run-python (&optional cmd noshow) |
| @@ -1359,7 +1371,9 @@ The result is what follows `_emacs_out' in the output (or nil)." | |||
| 1359 | (let ((proc (python-proc))) | 1371 | (let ((proc (python-proc))) |
| 1360 | (python-send-string string) | 1372 | (python-send-string string) |
| 1361 | (setq python-preoutput-result nil) | 1373 | (setq python-preoutput-result nil) |
| 1362 | (accept-process-output proc 5) | 1374 | (while (progn |
| 1375 | (accept-process-output proc 5) | ||
| 1376 | python-preoutput-leftover)) | ||
| 1363 | python-preoutput-result)) | 1377 | python-preoutput-result)) |
| 1364 | 1378 | ||
| 1365 | ;; Fixme: try to make it work with point in the arglist. Also, is | 1379 | ;; Fixme: try to make it work with point in the arglist. Also, is |
| @@ -1562,7 +1576,8 @@ of current line." | |||
| 1562 | (beginning-of-defun) | 1576 | (beginning-of-defun) |
| 1563 | (if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) | 1577 | (if (looking-at (rx (and (0+ space) (or "def" "class") (1+ space) |
| 1564 | (group (1+ (or word (syntax symbol)))) | 1578 | (group (1+ (or word (syntax symbol)))) |
| 1565 | word-end))) | 1579 | ;; Greediness makes this unnecessary? --Stef |
| 1580 | symbol-end))) | ||
| 1566 | (push (match-string 1) accum))) | 1581 | (push (match-string 1) accum))) |
| 1567 | (if accum (mapconcat 'identity accum "."))))) | 1582 | (if accum (mapconcat 'identity accum "."))))) |
| 1568 | 1583 | ||
| @@ -1702,9 +1717,9 @@ lines count as headers. | |||
| 1702 | '(python-font-lock-keywords nil nil ((?_ . "w")) nil | 1717 | '(python-font-lock-keywords nil nil ((?_ . "w")) nil |
| 1703 | (font-lock-syntactic-keywords | 1718 | (font-lock-syntactic-keywords |
| 1704 | . python-font-lock-syntactic-keywords) | 1719 | . python-font-lock-syntactic-keywords) |
| 1705 | ;;; This probably isn't worth it. | 1720 | ;; This probably isn't worth it. |
| 1706 | ;;; (font-lock-syntactic-face-function | 1721 | ;; (font-lock-syntactic-face-function |
| 1707 | ;;; . python-font-lock-syntactic-face-function) | 1722 | ;; . python-font-lock-syntactic-face-function) |
| 1708 | )) | 1723 | )) |
| 1709 | (set (make-local-variable 'parse-sexp-lookup-properties) t) | 1724 | (set (make-local-variable 'parse-sexp-lookup-properties) t) |
| 1710 | (set (make-local-variable 'comment-start) "# ") | 1725 | (set (make-local-variable 'comment-start) "# ") |