Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Lisp by RS ( 17 years ago )
(defun django-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
Jython interpreter by hitting \\[py-toggle-shells]. This toggles
buffer local variables which control whether all your subshell
interactions happen to the `*Jython*' or `*Python*' buffers (the
latter is the name used for the CPython buffer).
Warning: Don't use an interactive Python if you change sys.ps1 or
sys.ps2 from their default values, or if you're running code that
prints `>>> ' or `... ' at the start of a line. `python-mode' can't
distinguish your output from Python's output, and assumes that `>>> '
at the start of a line is a prompt from Python. Similarly, the Emacs
Shell mode code assumes that both `>>> ' and `... ' at the start of a
line are Python prompts. Bad things can happen if you fool either
mode.
Warning: If you do any editing *in* the process buffer *while* the
buffer is accepting output from Python, do NOT attempt to `undo' the
changes. Some of the output (nowhere near the parts you changed!) may
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."
(interactive "P")
;; Set the default shell if not already set
(when (null py-which-shell)
(py-toggle-shells py-default-interpreter))
(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 " ") " ")
))))
(if (not (equal (buffer-name) "*Django shell*"))
(switch-to-buffer-other-window
(apply 'make-comint py-which-bufname "/Users/richard/SetJam/setjam/setjam/manage.py" nil '("shell")))
(apply 'make-comint py-which-bufname py-which-shell nil args))
(make-local-variable 'comint-prompt-regexp)
(setq comint-prompt-regexp (concat py-shell-input-prompt-1-regexp "\\|"
py-shell-input-prompt-2-regexp "\\|"
"^([Pp]db) "))
(add-hook 'comint-output-filter-functions
'py-comint-output-filter-function)
;; pdbtrack
(add-hook 'comint-output-filter-functions 'py-pdbtrack-track-stack-file)
(setq py-pdbtrack-do-tracking-p t)
(set-syntax-table py-mode-syntax-table)
(use-local-map py-shell-map)
(run-hooks 'py-shell-hook)
))
Revise this Paste