(py-shell): Added optional argprompt, which will prompt for additional

switches to pass into the shell process (only on initial startup).
This commit is contained in:
Barry Warsaw 1999-02-16 23:52:46 +00:00
parent aa384fd616
commit 3b4e2f0b87
1 changed files with 30 additions and 12 deletions

View File

@ -1154,13 +1154,21 @@ with a zero argument, toggles the shell."
(setq py-output-buffer (format "*%s Output*" py-which-bufname)))) (setq py-output-buffer (format "*%s Output*" py-which-bufname))))
;;;###autoload ;;;###autoload
(defun py-shell () (defun py-shell (&optional argprompt)
"Start an interactive Python interpreter in another window. "Start an interactive Python interpreter in another window.
This is like Shell mode, except that Python is running in the 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' instead of a shell. See the `Interactive Shell' and `Shell Mode'
sections of the Emacs manual for details, especially for the key sections of the Emacs manual for details, especially for the key
bindings active in the `*Python*' buffer. 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 Note: You can toggle between using the CPython interpreter and the
JPython interpreter by hitting \\[py-toggle-shells]. This toggles JPython interpreter by hitting \\[py-toggle-shells]. This toggles
buffer local variables which control whether all your subshell 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 interaction between undo and process filters; the same problem exists in
non-Python process buffers using the default (Emacs-supplied) process non-Python process buffers using the default (Emacs-supplied) process
filter." filter."
;; BAW - should undo be disabled in the python process buffer, if (interactive "P")
;; this bug still exists?
(interactive)
(if (null py-which-shell) (if (null py-which-shell)
(cond ((eq py-default-interpreter 'cpython) (cond ((eq py-default-interpreter 'cpython)
(setq py-which-shell py-python-command (setq py-which-shell py-python-command
@ -1195,14 +1201,26 @@ filter."
py-which-args py-jpython-command-args)) py-which-args py-jpython-command-args))
(t (error "Illegal value for `py-default-interpreter': %s" (t (error "Illegal value for `py-default-interpreter': %s"
py-default-interpreter)))) py-default-interpreter))))
(switch-to-buffer-other-window (let ((args py-which-args))
(apply 'make-comint py-which-bufname py-which-shell nil py-which-args)) (when (and argprompt
(make-local-variable 'comint-prompt-regexp) (interactive-p)
(setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) ") (fboundp 'split-string))
(add-hook 'comint-output-filter-functions 'py-comint-output-filter-function) ;; TBD: Perhaps force "-i" in the final list?
(set-syntax-table py-mode-syntax-table) (setq args (split-string
(use-local-map py-shell-map) (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 () (defun py-clear-queue ()
"Clear the queue of temporary files waiting to execute." "Clear the queue of temporary files waiting to execute."