diff options
| author | Joakim Verona | 2011-02-05 11:23:09 +0100 |
|---|---|---|
| committer | Joakim Verona | 2011-02-05 11:23:09 +0100 |
| commit | 4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch) | |
| tree | 894801e7308ce4ecc34933f959e28f4b9cff9533 /lisp/progmodes/python.el | |
| parent | 13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff) | |
| parent | 9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff) | |
| download | emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip | |
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 10e852223ce..4246177495c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | ;;; python.el --- silly walks for Python -*- coding: iso-8859-1 -*- | 1 | ;;; python.el --- silly walks for Python -*- coding: iso-8859-1 -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 3 | ;; Copyright (C) 2003-2011 Free Software Foundation, Inc. |
| 4 | ;; Free Software Foundation, Inc. | ||
| 5 | 4 | ||
| 6 | ;; Author: Dave Love <fx@gnu.org> | 5 | ;; Author: Dave Love <fx@gnu.org> |
| 7 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -110,7 +109,8 @@ | |||
| 110 | (,(rx symbol-start (group "def") (1+ space) (group (1+ (or word ?_)))) | 109 | (,(rx symbol-start (group "def") (1+ space) (group (1+ (or word ?_)))) |
| 111 | (1 font-lock-keyword-face) (2 font-lock-function-name-face)) | 110 | (1 font-lock-keyword-face) (2 font-lock-function-name-face)) |
| 112 | ;; Top-level assignments are worth highlighting. | 111 | ;; Top-level assignments are worth highlighting. |
| 113 | (,(rx line-start (group (1+ (or word ?_))) (0+ space) "=") | 112 | (,(rx line-start (group (1+ (or word ?_))) (0+ space) |
| 113 | (opt (or "+" "-" "*" "**" "/" "//" "&" "%" "|" "^" "<<" ">>")) "=") | ||
| 114 | (1 font-lock-variable-name-face)) | 114 | (1 font-lock-variable-name-face)) |
| 115 | ;; Decorators. | 115 | ;; Decorators. |
| 116 | (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_)) | 116 | (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_)) |
| @@ -171,21 +171,9 @@ | |||
| 171 | ;; string delimiters. Fixme: Is there a better way? | 171 | ;; string delimiters. Fixme: Is there a better way? |
| 172 | ;; First avoid a sequence preceded by an odd number of backslashes. | 172 | ;; First avoid a sequence preceded by an odd number of backslashes. |
| 173 | (syntax-propertize-rules | 173 | (syntax-propertize-rules |
| 174 | (;; (rx (not (any ?\\)) | 174 | (;; ĦBackrefs don't work in syntax-propertize-rules! |
| 175 | ;; ?\\ (* (and ?\\ ?\\)) | 175 | (concat "\\(?:\\([RUru]\\)[Rr]?\\|^\\|[^\\]\\(?:\\\\.\\)*\\)" ;Prefix. |
| 176 | ;; (group (syntax string-quote)) | 176 | "\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)") |
| 177 | ;; (backref 1) | ||
| 178 | ;; (group (backref 1))) | ||
| 179 | ;; ĦBackrefs don't work in syntax-propertize-rules! | ||
| 180 | "[^\\]\\\\\\(\\\\\\\\\\)*\\(?:''\\('\\)\\|\"\"\\(?2:\"\\)\\)" | ||
| 181 | (2 "\"")) ; dummy | ||
| 182 | (;; (rx (optional (group (any "uUrR"))) ; prefix gets syntax property | ||
| 183 | ;; (optional (any "rR")) ; possible second prefix | ||
| 184 | ;; (group (syntax string-quote)) ; maybe gets property | ||
| 185 | ;; (backref 2) ; per first quote | ||
| 186 | ;; (group (backref 2))) ; maybe gets property | ||
| 187 | ;; ĦBackrefs don't work in syntax-propertize-rules! | ||
| 188 | "\\([RUru]\\)?[Rr]?\\(?:\\('\\)'\\('\\)\\|\\(?2:\"\\)\"\\(?3:\"\\)\\)" | ||
| 189 | (3 (ignore (python-quote-syntax)))) | 177 | (3 (ignore (python-quote-syntax)))) |
| 190 | ;; This doesn't really help. | 178 | ;; This doesn't really help. |
| 191 | ;;((rx (and ?\\ (group ?\n))) (1 " ")) | 179 | ;;((rx (and ?\\ (group ?\n))) (1 " ")) |
| @@ -1328,7 +1316,7 @@ See `python-check-command' for the default." | |||
| 1328 | (let ((name (buffer-file-name))) | 1316 | (let ((name (buffer-file-name))) |
| 1329 | (if name | 1317 | (if name |
| 1330 | (file-name-nondirectory name)))))))) | 1318 | (file-name-nondirectory name)))))))) |
| 1331 | (setq python-saved-check-command command) | 1319 | (set (make-local-variable 'python-saved-check-command) command) |
| 1332 | (require 'compile) ;To define compilation-* variables. | 1320 | (require 'compile) ;To define compilation-* variables. |
| 1333 | (save-some-buffers (not compilation-ask-about-save) nil) | 1321 | (save-some-buffers (not compilation-ask-about-save) nil) |
| 1334 | (let ((compilation-error-regexp-alist | 1322 | (let ((compilation-error-regexp-alist |
| @@ -1473,6 +1461,16 @@ Default ignores all inputs of 0, 1, or 2 non-blank characters." | |||
| 1473 | :type 'regexp | 1461 | :type 'regexp |
| 1474 | :group 'python) | 1462 | :group 'python) |
| 1475 | 1463 | ||
| 1464 | (defcustom python-remove-cwd-from-path t | ||
| 1465 | "Whether to allow loading of Python modules from the current directory. | ||
| 1466 | If this is non-nil, Emacs removes '' from sys.path when starting | ||
| 1467 | an inferior Python process. This is the default, for security | ||
| 1468 | reasons, as it is easy for the Python process to be started | ||
| 1469 | without the user's realization (e.g. to perform completion)." | ||
| 1470 | :type 'boolean | ||
| 1471 | :group 'python | ||
| 1472 | :version "23.3") | ||
| 1473 | |||
| 1476 | (defun python-input-filter (str) | 1474 | (defun python-input-filter (str) |
| 1477 | "`comint-input-filter' function for inferior Python. | 1475 | "`comint-input-filter' function for inferior Python. |
| 1478 | Don't save anything for STR matching `inferior-python-filter-regexp'." | 1476 | Don't save anything for STR matching `inferior-python-filter-regexp'." |
| @@ -1570,20 +1568,24 @@ print version_info >= (2, 2) and version_info < (3, 0)\"")))) | |||
| 1570 | ;;;###autoload | 1568 | ;;;###autoload |
| 1571 | (defun run-python (&optional cmd noshow new) | 1569 | (defun run-python (&optional cmd noshow new) |
| 1572 | "Run an inferior Python process, input and output via buffer *Python*. | 1570 | "Run an inferior Python process, input and output via buffer *Python*. |
| 1573 | CMD is the Python command to run. NOSHOW non-nil means don't show the | 1571 | CMD is the Python command to run. NOSHOW non-nil means don't |
| 1574 | buffer automatically. | 1572 | show the buffer automatically. |
| 1575 | 1573 | ||
| 1576 | Normally, if there is a process already running in `python-buffer', | 1574 | Interactively, a prefix arg means to prompt for the initial |
| 1577 | switch to that buffer. Interactively, a prefix arg allows you to edit | 1575 | Python command line (default is `python-command'). |
| 1578 | the initial command line (default is `python-command'); `-i' etc. args | 1576 | |
| 1579 | will be added to this as appropriate. A new process is started if: | 1577 | A new process is started if one isn't running attached to |
| 1580 | one isn't running attached to `python-buffer', or interactively the | 1578 | `python-buffer', or if called from Lisp with non-nil arg NEW. |
| 1581 | default `python-command', or argument NEW is non-nil. See also the | 1579 | Otherwise, if a process is already running in `python-buffer', |
| 1582 | documentation for `python-buffer'. | 1580 | switch to that buffer. |
| 1583 | 1581 | ||
| 1584 | Runs the hook `inferior-python-mode-hook' \(after the | 1582 | This command runs the hook `inferior-python-mode-hook' after |
| 1585 | `comint-mode-hook' is run). \(Type \\[describe-mode] in the process | 1583 | running `comint-mode-hook'. Type \\[describe-mode] in the |
| 1586 | buffer for a list of commands.)" | 1584 | process buffer for a list of commands. |
| 1585 | |||
| 1586 | By default, Emacs inhibits the loading of Python modules from the | ||
| 1587 | current working directory, for security reasons. To disable this | ||
| 1588 | behavior, change `python-remove-cwd-from-path' to nil." | ||
| 1587 | (interactive (if current-prefix-arg | 1589 | (interactive (if current-prefix-arg |
| 1588 | (list (read-string "Run Python: " python-command) nil t) | 1590 | (list (read-string "Run Python: " python-command) nil t) |
| 1589 | (list python-command))) | 1591 | (list python-command))) |
| @@ -1597,8 +1599,9 @@ buffer for a list of commands.)" | |||
| 1597 | (when (or new (not (comint-check-proc python-buffer))) | 1599 | (when (or new (not (comint-check-proc python-buffer))) |
| 1598 | (with-current-buffer | 1600 | (with-current-buffer |
| 1599 | (let* ((cmdlist | 1601 | (let* ((cmdlist |
| 1600 | (append (python-args-to-list cmd) | 1602 | (append (python-args-to-list cmd) '("-i") |
| 1601 | '("-i" "-c" "import sys; sys.path.remove('')"))) | 1603 | (if python-remove-cwd-from-path |
| 1604 | '("-c" "import sys; sys.path.remove('')")))) | ||
| 1602 | (path (getenv "PYTHONPATH")) | 1605 | (path (getenv "PYTHONPATH")) |
| 1603 | (process-environment ; to import emacs.py | 1606 | (process-environment ; to import emacs.py |
| 1604 | (cons (concat "PYTHONPATH=" | 1607 | (cons (concat "PYTHONPATH=" |
| @@ -2518,7 +2521,6 @@ with skeleton expansions for compound statement templates. | |||
| 2518 | (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") | 2521 | (set (make-local-variable 'outline-heading-end-regexp) ":\\s-*\n") |
| 2519 | (set (make-local-variable 'outline-level) #'python-outline-level) | 2522 | (set (make-local-variable 'outline-level) #'python-outline-level) |
| 2520 | (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) | 2523 | (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) |
| 2521 | (make-local-variable 'python-saved-check-command) | ||
| 2522 | (set (make-local-variable 'beginning-of-defun-function) | 2524 | (set (make-local-variable 'beginning-of-defun-function) |
| 2523 | 'python-beginning-of-defun) | 2525 | 'python-beginning-of-defun) |
| 2524 | (set (make-local-variable 'end-of-defun-function) 'python-end-of-defun) | 2526 | (set (make-local-variable 'end-of-defun-function) 'python-end-of-defun) |
| @@ -2546,7 +2548,6 @@ with skeleton expansions for compound statement templates. | |||
| 2546 | (^ '(- (1+ (current-indentation)))))) | 2548 | (^ '(- (1+ (current-indentation)))))) |
| 2547 | ;; Python defines TABs as being 8-char wide. | 2549 | ;; Python defines TABs as being 8-char wide. |
| 2548 | (set (make-local-variable 'tab-width) 8) | 2550 | (set (make-local-variable 'tab-width) 8) |
| 2549 | (unless font-lock-mode (font-lock-mode 1)) | ||
| 2550 | (when python-guess-indent (python-guess-indent)) | 2551 | (when python-guess-indent (python-guess-indent)) |
| 2551 | ;; Let's make it harder for the user to shoot himself in the foot. | 2552 | ;; Let's make it harder for the user to shoot himself in the foot. |
| 2552 | (unless (= tab-width python-indent) | 2553 | (unless (= tab-width python-indent) |
| @@ -2605,7 +2606,7 @@ This function is appropriate for `comint-output-filter-functions'." | |||
| 2605 | overlay-arrow-string "=>" | 2606 | overlay-arrow-string "=>" |
| 2606 | python-pdbtrack-is-tracking-p t) | 2607 | python-pdbtrack-is-tracking-p t) |
| 2607 | (set-marker overlay-arrow-position | 2608 | (set-marker overlay-arrow-position |
| 2608 | (save-excursion (beginning-of-line) (point)) | 2609 | (line-beginning-position) |
| 2609 | (current-buffer))) | 2610 | (current-buffer))) |
| 2610 | (setq overlay-arrow-position nil | 2611 | (setq overlay-arrow-position nil |
| 2611 | python-pdbtrack-is-tracking-p nil))) | 2612 | python-pdbtrack-is-tracking-p nil))) |
| @@ -2814,7 +2815,7 @@ command is used to switch to an existing process, only when a new | |||
| 2814 | process is started. If you use this, you will probably want to ensure | 2815 | process is started. If you use this, you will probably want to ensure |
| 2815 | that the current arguments are retained (they will be included in the | 2816 | that the current arguments are retained (they will be included in the |
| 2816 | prompt). This argument is ignored when this function is called | 2817 | prompt). This argument is ignored when this function is called |
| 2817 | programmatically, or when running in Emacs 19.34 or older. | 2818 | programmatically. |
| 2818 | 2819 | ||
| 2819 | Note: You can toggle between using the CPython interpreter and the | 2820 | Note: You can toggle between using the CPython interpreter and the |
| 2820 | JPython interpreter by hitting \\[python-toggle-shells]. This toggles | 2821 | JPython interpreter by hitting \\[python-toggle-shells]. This toggles |
| @@ -2891,5 +2892,4 @@ filter." | |||
| 2891 | (provide 'python) | 2892 | (provide 'python) |
| 2892 | (provide 'python-21) | 2893 | (provide 'python-21) |
| 2893 | 2894 | ||
| 2894 | ;; arch-tag: 6fce1d99-a704-4de9-ba19-c6e4912b0554 | ||
| 2895 | ;;; python.el ends here | 2895 | ;;; python.el ends here |