Mercurial > emacs
comparison lisp/progmodes/python.el @ 111779:141d3f14d8c3
Merge changes from emacs-23 branch
| author | Chong Yidong <cyd@stupidchicken.com> |
|---|---|
| date | Sat, 27 Nov 2010 15:04:57 -0500 |
| parents | 946fe738ec2b f84b2c2c0b1b |
| children | b47e85affa59 |
comparison
equal
deleted
inserted
replaced
| 111742:f026c8607795 | 111779:141d3f14d8c3 |
|---|---|
| 1460 "Input matching this regexp is not saved on the history list. | 1460 "Input matching this regexp is not saved on the history list. |
| 1461 Default ignores all inputs of 0, 1, or 2 non-blank characters." | 1461 Default ignores all inputs of 0, 1, or 2 non-blank characters." |
| 1462 :type 'regexp | 1462 :type 'regexp |
| 1463 :group 'python) | 1463 :group 'python) |
| 1464 | 1464 |
| 1465 (defcustom python-remove-cwd-from-path t | |
| 1466 "Whether to allow loading of Python modules from the current directory. | |
| 1467 If this is non-nil, Emacs removes '' from sys.path when starting | |
| 1468 an inferior Python process. This is the default, for security | |
| 1469 reasons, as it is easy for the Python process to be started | |
| 1470 without the user's realization (e.g. to perform completion)." | |
| 1471 :type 'boolean | |
| 1472 :group 'python | |
| 1473 :version "23.3") | |
| 1474 | |
| 1465 (defun python-input-filter (str) | 1475 (defun python-input-filter (str) |
| 1466 "`comint-input-filter' function for inferior Python. | 1476 "`comint-input-filter' function for inferior Python. |
| 1467 Don't save anything for STR matching `inferior-python-filter-regexp'." | 1477 Don't save anything for STR matching `inferior-python-filter-regexp'." |
| 1468 (not (string-match inferior-python-filter-regexp str))) | 1478 (not (string-match inferior-python-filter-regexp str))) |
| 1469 | 1479 |
| 1557 (setq python-version-checked t))) | 1567 (setq python-version-checked t))) |
| 1558 | 1568 |
| 1559 ;;;###autoload | 1569 ;;;###autoload |
| 1560 (defun run-python (&optional cmd noshow new) | 1570 (defun run-python (&optional cmd noshow new) |
| 1561 "Run an inferior Python process, input and output via buffer *Python*. | 1571 "Run an inferior Python process, input and output via buffer *Python*. |
| 1562 CMD is the Python command to run. NOSHOW non-nil means don't show the | 1572 CMD is the Python command to run. NOSHOW non-nil means don't |
| 1563 buffer automatically. | 1573 show the buffer automatically. |
| 1564 | 1574 |
| 1565 Normally, if there is a process already running in `python-buffer', | 1575 Interactively, a prefix arg means to prompt for the initial |
| 1566 switch to that buffer. Interactively, a prefix arg allows you to edit | 1576 Python command line (default is `python-command'). |
| 1567 the initial command line (default is `python-command'); `-i' etc. args | 1577 |
| 1568 will be added to this as appropriate. A new process is started if: | 1578 A new process is started if one isn't running attached to |
| 1569 one isn't running attached to `python-buffer', or interactively the | 1579 `python-buffer', or if called from Lisp with non-nil arg NEW. |
| 1570 default `python-command', or argument NEW is non-nil. See also the | 1580 Otherwise, if a process is already running in `python-buffer', |
| 1571 documentation for `python-buffer'. | 1581 switch to that buffer. |
| 1572 | 1582 |
| 1573 Runs the hook `inferior-python-mode-hook' \(after the | 1583 This command runs the hook `inferior-python-mode-hook' after |
| 1574 `comint-mode-hook' is run). \(Type \\[describe-mode] in the process | 1584 running `comint-mode-hook'. Type \\[describe-mode] in the |
| 1575 buffer for a list of commands.)" | 1585 process buffer for a list of commands. |
| 1586 | |
| 1587 By default, Emacs inhibits the loading of Python modules from the | |
| 1588 current working directory, for security reasons. To disable this | |
| 1589 behavior, change `python-remove-cwd-from-path' to nil." | |
| 1576 (interactive (if current-prefix-arg | 1590 (interactive (if current-prefix-arg |
| 1577 (list (read-string "Run Python: " python-command) nil t) | 1591 (list (read-string "Run Python: " python-command) nil t) |
| 1578 (list python-command))) | 1592 (list python-command))) |
| 1579 (require 'ansi-color) ; for ipython | 1593 (require 'ansi-color) ; for ipython |
| 1580 (unless cmd (setq cmd python-command)) | 1594 (unless cmd (setq cmd python-command)) |
| 1584 ;; (not a name) in Python buffers from which `run-python' &c is | 1598 ;; (not a name) in Python buffers from which `run-python' &c is |
| 1585 ;; invoked. Would support multiple processes better. | 1599 ;; invoked. Would support multiple processes better. |
| 1586 (when (or new (not (comint-check-proc python-buffer))) | 1600 (when (or new (not (comint-check-proc python-buffer))) |
| 1587 (with-current-buffer | 1601 (with-current-buffer |
| 1588 (let* ((cmdlist | 1602 (let* ((cmdlist |
| 1589 (append (python-args-to-list cmd) | 1603 (append (python-args-to-list cmd) '("-i") |
| 1590 ;; It's easy for the user to cause the process to be | 1604 (if python-remove-cwd-from-path |
| 1591 ;; started without realizing it (e.g. to perform | 1605 '("-c" "import sys; sys.path.remove('')")))) |
| 1592 ;; completion); for this reason loading files from the | |
| 1593 ;; current directory is a security risk. See | |
| 1594 ;; http://article.gmane.org/gmane.emacs.devel/103569 | |
| 1595 '("-i" "-c" "import sys; sys.path.remove('')"))) | |
| 1596 (path (getenv "PYTHONPATH")) | 1606 (path (getenv "PYTHONPATH")) |
| 1597 (process-environment ; to import emacs.py | 1607 (process-environment ; to import emacs.py |
| 1598 (cons (concat "PYTHONPATH=" | 1608 (cons (concat "PYTHONPATH=" |
| 1599 (if path (concat path path-separator)) | 1609 (if path (concat path path-separator)) |
| 1600 data-directory) | 1610 data-directory) |
