diff options
| author | Chong Yidong | 2010-11-21 11:52:05 -0500 |
|---|---|---|
| committer | Chong Yidong | 2010-11-21 11:52:05 -0500 |
| commit | 1d851570a67adec22da23bdc7499bb489992d578 (patch) | |
| tree | 28cde17f9ee4b28ffb22e99416aa82a8d7bc05a3 | |
| parent | 0d6607ab81be365f247b8dd7a831fdb390591e49 (diff) | |
| download | emacs-1d851570a67adec22da23bdc7499bb489992d578.tar.gz emacs-1d851570a67adec22da23bdc7499bb489992d578.zip | |
Make the sys.path remove in Python mode customizable (Bug#7454).
* progmodes/python.el (run-python): Doc fix.
(python-keep-current-directory-in-path): New var (Bug#7454).
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 48 |
3 files changed, 40 insertions, 17 deletions
| @@ -36,6 +36,10 @@ used on x86-64 and s390x GNU/Linux architectures. | |||
| 36 | ** The appt-add command takes an optional argument for the warning time. | 36 | ** The appt-add command takes an optional argument for the warning time. |
| 37 | This can be used in place of the default appt-message-warning-time. | 37 | This can be used in place of the default appt-message-warning-time. |
| 38 | 38 | ||
| 39 | --- | ||
| 40 | ** You can allow inferior Python processes to load modules from the | ||
| 41 | current directory by setting `python-remove-cwd-from-path' to nil. | ||
| 42 | |||
| 39 | ** VC and related modes | 43 | ** VC and related modes |
| 40 | 44 | ||
| 41 | *** New VC command `vc-log-incoming', bound to `C-x v I'. | 45 | *** New VC command `vc-log-incoming', bound to `C-x v I'. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0f0308be41b..4796239b366 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-11-21 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * progmodes/python.el (run-python): Doc fix. | ||
| 4 | (python-keep-current-directory-in-path): New var (Bug#7454). | ||
| 5 | |||
| 1 | 2010-11-20 Chong Yidong <cyd@stupidchicken.com> | 6 | 2010-11-20 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * lpr.el (lpr-buffer, print-buffer, lpr-region, print-region): | 8 | * lpr.el (lpr-buffer, print-buffer, lpr-region, print-region): |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 5d528e5fa28..653ef3150e5 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -1426,6 +1426,16 @@ Default ignores all inputs of 0, 1, or 2 non-blank characters." | |||
| 1426 | :type 'regexp | 1426 | :type 'regexp |
| 1427 | :group 'python) | 1427 | :group 'python) |
| 1428 | 1428 | ||
| 1429 | (defcustom python-remove-cwd-from-path t | ||
| 1430 | "Whether to allow loading of Python modules from the current directory. | ||
| 1431 | If this is non-nil, Emacs removes '' from sys.path when starting | ||
| 1432 | an inferior Python process. This is the default, for security | ||
| 1433 | reasons, as it is easy for the Python process to be started | ||
| 1434 | without the user's realization (e.g. to perform completion)." | ||
| 1435 | :type 'boolean | ||
| 1436 | :group 'python | ||
| 1437 | :version "23.3") | ||
| 1438 | |||
| 1429 | (defun python-input-filter (str) | 1439 | (defun python-input-filter (str) |
| 1430 | "`comint-input-filter' function for inferior Python. | 1440 | "`comint-input-filter' function for inferior Python. |
| 1431 | Don't save anything for STR matching `inferior-python-filter-regexp'." | 1441 | Don't save anything for STR matching `inferior-python-filter-regexp'." |
| @@ -1523,20 +1533,24 @@ Don't save anything for STR matching `inferior-python-filter-regexp'." | |||
| 1523 | ;;;###autoload | 1533 | ;;;###autoload |
| 1524 | (defun run-python (&optional cmd noshow new) | 1534 | (defun run-python (&optional cmd noshow new) |
| 1525 | "Run an inferior Python process, input and output via buffer *Python*. | 1535 | "Run an inferior Python process, input and output via buffer *Python*. |
| 1526 | CMD is the Python command to run. NOSHOW non-nil means don't show the | 1536 | CMD is the Python command to run. NOSHOW non-nil means don't |
| 1527 | buffer automatically. | 1537 | show the buffer automatically. |
| 1528 | 1538 | ||
| 1529 | Normally, if there is a process already running in `python-buffer', | 1539 | Interactively, a prefix arg means to prompt for the initial |
| 1530 | switch to that buffer. Interactively, a prefix arg allows you to edit | 1540 | Python command line (default is `python-command'). |
| 1531 | the initial command line (default is `python-command'); `-i' etc. args | 1541 | |
| 1532 | will be added to this as appropriate. A new process is started if: | 1542 | A new process is started if one isn't running attached to |
| 1533 | one isn't running attached to `python-buffer', or interactively the | 1543 | `python-buffer', or if called from Lisp with non-nil arg NEW. |
| 1534 | default `python-command', or argument NEW is non-nil. See also the | 1544 | Otherwise, if a process is already running in `python-buffer', |
| 1535 | documentation for `python-buffer'. | 1545 | switch to that buffer. |
| 1536 | 1546 | ||
| 1537 | Runs the hook `inferior-python-mode-hook' \(after the | 1547 | This command runs the hook `inferior-python-mode-hook' after |
| 1538 | `comint-mode-hook' is run). \(Type \\[describe-mode] in the process | 1548 | running `comint-mode-hook'. Type \\[describe-mode] in the |
| 1539 | buffer for a list of commands.)" | 1549 | process buffer for a list of commands. |
| 1550 | |||
| 1551 | By default, Emacs inhibits the loading of Python modules from the | ||
| 1552 | current working directory, for security reasons. To disable this | ||
| 1553 | behavior, change `python-remove-cwd-from-path' to nil." | ||
| 1540 | (interactive (if current-prefix-arg | 1554 | (interactive (if current-prefix-arg |
| 1541 | (list (read-string "Run Python: " python-command) nil t) | 1555 | (list (read-string "Run Python: " python-command) nil t) |
| 1542 | (list python-command))) | 1556 | (list python-command))) |
| @@ -1549,9 +1563,9 @@ buffer for a list of commands.)" | |||
| 1549 | (when (or new (not (comint-check-proc python-buffer))) | 1563 | (when (or new (not (comint-check-proc python-buffer))) |
| 1550 | (with-current-buffer | 1564 | (with-current-buffer |
| 1551 | (let* ((cmdlist | 1565 | (let* ((cmdlist |
| 1552 | (append (python-args-to-list cmd) | 1566 | (append (python-args-to-list cmd) '("-i") |
| 1553 | ;; See http://lists.gnu.org/archive/html/emacs-devel/2008-09/msg00215.html | 1567 | (if python-remove-cwd-from-path |
| 1554 | '("-i" "-c" "import sys; sys.path.remove('')"))) | 1568 | '("-c" "import sys; sys.path.remove('')")))) |
| 1555 | (path (getenv "PYTHONPATH")) | 1569 | (path (getenv "PYTHONPATH")) |
| 1556 | (process-environment ; to import emacs.py | 1570 | (process-environment ; to import emacs.py |
| 1557 | (cons (concat "PYTHONPATH=" | 1571 | (cons (concat "PYTHONPATH=" |