diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2010-11-27 15:04:57 -0500 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2010-11-27 15:04:57 -0500 |
commit | 07976ae3b816dea4fd541bbba862603d3132eb2c (patch) | |
tree | 4a437b7cb3abb01fb144530a130c991882a1b7f2 /lisp/progmodes | |
parent | 9610796712a3bc43730c99005906571a2c0bccbd (diff) | |
parent | 402c8a49571227f8a4e678d4a6cdd6ba7841aef9 (diff) | |
download | emacs-07976ae3b816dea4fd541bbba862603d3132eb2c.tar.gz |
Merge changes from emacs-23 branch
Diffstat (limited to 'lisp/progmodes')
-rw-r--r-- | lisp/progmodes/python.el | 52 | ||||
-rw-r--r-- | lisp/progmodes/which-func.el | 8 |
2 files changed, 35 insertions, 25 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 9fe57beec30..0a641d0945f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -1462,6 +1462,16 @@ Default ignores all inputs of 0, 1, or 2 non-blank characters." :type 'regexp :group 'python) +(defcustom python-remove-cwd-from-path t + "Whether to allow loading of Python modules from the current directory. +If this is non-nil, Emacs removes '' from sys.path when starting +an inferior Python process. This is the default, for security +reasons, as it is easy for the Python process to be started +without the user's realization (e.g. to perform completion)." + :type 'boolean + :group 'python + :version "23.3") + (defun python-input-filter (str) "`comint-input-filter' function for inferior Python. Don't save anything for STR matching `inferior-python-filter-regexp'." @@ -1559,20 +1569,24 @@ print version_info >= (2, 2) and version_info < (3, 0)\"")))) ;;;###autoload (defun run-python (&optional cmd noshow new) "Run an inferior Python process, input and output via buffer *Python*. -CMD is the Python command to run. NOSHOW non-nil means don't show the -buffer automatically. - -Normally, if there is a process already running in `python-buffer', -switch to that buffer. Interactively, a prefix arg allows you to edit -the initial command line (default is `python-command'); `-i' etc. args -will be added to this as appropriate. A new process is started if: -one isn't running attached to `python-buffer', or interactively the -default `python-command', or argument NEW is non-nil. See also the -documentation for `python-buffer'. - -Runs the hook `inferior-python-mode-hook' \(after the -`comint-mode-hook' is run). \(Type \\[describe-mode] in the process -buffer for a list of commands.)" +CMD is the Python command to run. NOSHOW non-nil means don't +show the buffer automatically. + +Interactively, a prefix arg means to prompt for the initial +Python command line (default is `python-command'). + +A new process is started if one isn't running attached to +`python-buffer', or if called from Lisp with non-nil arg NEW. +Otherwise, if a process is already running in `python-buffer', +switch to that buffer. + +This command runs the hook `inferior-python-mode-hook' after +running `comint-mode-hook'. Type \\[describe-mode] in the +process buffer for a list of commands. + +By default, Emacs inhibits the loading of Python modules from the +current working directory, for security reasons. To disable this +behavior, change `python-remove-cwd-from-path' to nil." (interactive (if current-prefix-arg (list (read-string "Run Python: " python-command) nil t) (list python-command))) @@ -1586,13 +1600,9 @@ buffer for a list of commands.)" (when (or new (not (comint-check-proc python-buffer))) (with-current-buffer (let* ((cmdlist - (append (python-args-to-list cmd) - ;; It's easy for the user to cause the process to be - ;; started without realizing it (e.g. to perform - ;; completion); for this reason loading files from the - ;; current directory is a security risk. See - ;; http://article.gmane.org/gmane.emacs.devel/103569 - '("-i" "-c" "import sys; sys.path.remove('')"))) + (append (python-args-to-list cmd) '("-i") + (if python-remove-cwd-from-path + '("-c" "import sys; sys.path.remove('')")))) (path (getenv "PYTHONPATH")) (process-environment ; to import emacs.py (cons (concat "PYTHONPATH=" diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 469786e04dd..049d708d191 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -154,7 +154,7 @@ mouse-3: go to end") :type 'sexp) ;;;###autoload (put 'which-func-format 'risky-local-variable t) -(defvar which-func-imenu-joiner-function #'last +(defvar which-func-imenu-joiner-function (lambda (x) (car (last x))) "Function to join together multiple levels of imenu nomenclature. Called with a single argument, a list of strings giving the names of the menus we had to traverse to get to the item. Returns a @@ -242,6 +242,9 @@ continuously displayed in the mode line, in certain major modes. With prefix ARG, turn Which Function mode on if arg is positive, and off otherwise." :global t :group 'which-func + (when (timerp which-func-update-timer) + (cancel-timer which-func-update-timer)) + (setq which-func-update-timer nil) (if which-function-mode ;;Turn it on (progn @@ -253,9 +256,6 @@ and off otherwise." (or (eq which-func-modes t) (member major-mode which-func-modes)))))) ;; Turn it off - (when (timerp which-func-update-timer) - (cancel-timer which-func-update-timer)) - (setq which-func-update-timer nil) (dolist (buf (buffer-list)) (with-current-buffer buf (setq which-func-mode nil))))) |