diff options
author | Barry Warsaw <barry@python.org> | 1999-02-16 23:52:46 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1999-02-16 23:52:46 (GMT) |
commit | 3b4e2f0b87a6b2c08bb805d26b1fae139432b9c3 (patch) | |
tree | e922e57c471c8dc9e6cb92b4196cf5ddf58d7bba | |
parent | aa384fd616144a99324835c0c273eec481143b59 (diff) | |
download | cpython-3b4e2f0b87a6b2c08bb805d26b1fae139432b9c3.zip cpython-3b4e2f0b87a6b2c08bb805d26b1fae139432b9c3.tar.gz cpython-3b4e2f0b87a6b2c08bb805d26b1fae139432b9c3.tar.bz2 |
(py-shell): Added optional argprompt, which will prompt for additional
switches to pass into the shell process (only on initial startup).
-rw-r--r-- | Misc/python-mode.el | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el index d8983a7..e139b51 100644 --- a/Misc/python-mode.el +++ b/Misc/python-mode.el @@ -1154,13 +1154,21 @@ with a zero argument, toggles the shell." (setq py-output-buffer (format "*%s Output*" py-which-bufname)))) ;;;###autoload -(defun py-shell () +(defun py-shell (&optional argprompt) "Start an interactive Python interpreter in another window. This is like Shell mode, except that Python is running in the window instead of a shell. See the `Interactive Shell' and `Shell Mode' sections of the Emacs manual for details, especially for the key bindings active in the `*Python*' buffer. +With optional \\[universal-argument], the user is prompted for the +flags to pass to the Python interpreter. This has no effect when this +command is used to switch to an existing process, only when a new +process is started. If you use this, you will probably want to ensure +that the current arguments are retained (they will be included in the +prompt). This argument is ignored when this function is called +programmatically, or when running in Emacs 19.34 or older. + Note: You can toggle between using the CPython interpreter and the JPython interpreter by hitting \\[py-toggle-shells]. This toggles buffer local variables which control whether all your subshell @@ -1183,9 +1191,7 @@ be lost if you do. This appears to be an Emacs bug, an unfortunate interaction between undo and process filters; the same problem exists in non-Python process buffers using the default (Emacs-supplied) process filter." - ;; BAW - should undo be disabled in the python process buffer, if - ;; this bug still exists? - (interactive) + (interactive "P") (if (null py-which-shell) (cond ((eq py-default-interpreter 'cpython) (setq py-which-shell py-python-command @@ -1195,14 +1201,26 @@ filter." py-which-args py-jpython-command-args)) (t (error "Illegal value for `py-default-interpreter': %s" py-default-interpreter)))) - (switch-to-buffer-other-window - (apply 'make-comint py-which-bufname py-which-shell nil py-which-args)) - (make-local-variable 'comint-prompt-regexp) - (setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ") - (add-hook 'comint-output-filter-functions 'py-comint-output-filter-function) - (set-syntax-table py-mode-syntax-table) - (use-local-map py-shell-map) - ) + (let ((args py-which-args)) + (when (and argprompt + (interactive-p) + (fboundp 'split-string)) + ;; TBD: Perhaps force "-i" in the final list? + (setq args (split-string + (read-string (concat py-which-bufname + " arguments: ") + (concat + (mapconcat 'identity py-which-args " ") " ") + )))) + (switch-to-buffer-other-window + (apply 'make-comint py-which-bufname py-which-shell nil args)) + (make-local-variable 'comint-prompt-regexp) + (setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ") + (add-hook 'comint-output-filter-functions + 'py-comint-output-filter-function) + (set-syntax-table py-mode-syntax-table) + (use-local-map py-shell-map) + )) (defun py-clear-queue () "Clear the queue of temporary files waiting to execute." |