aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-07-27 09:38:19 -0300
committerFabián Ezequiel Gallina2012-07-27 09:38:19 -0300
commita90dfb95112ebff530ec5c7167c1402b10c2e49b (patch)
treeed9838599c8c7c83a30ff389c693c178c0f9a39c /lisp/progmodes/python.el
parent1e4be88cc192114695362edcffb7e31efe871983 (diff)
downloademacs-a90dfb95112ebff530ec5c7167c1402b10c2e49b.tar.gz
emacs-a90dfb95112ebff530ec5c7167c1402b10c2e49b.zip
* lisp/progmodes/python.el (python-mode-map): Added keybinding for
run-python. (python-shell-make-comint): Fix pop-to-buffer call. (run-python): Autoload. New arg SHOW. (python-shell-get-or-create-process): Do not pop python process buffer.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el35
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 132951aedc8..ab364a5318a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -250,6 +250,7 @@
250 (define-key map "\C-c\C-tt" 'python-skeleton-try) 250 (define-key map "\C-c\C-tt" 'python-skeleton-try)
251 (define-key map "\C-c\C-tw" 'python-skeleton-while) 251 (define-key map "\C-c\C-tw" 'python-skeleton-while)
252 ;; Shell interaction 252 ;; Shell interaction
253 (define-key map "\C-c\C-p" 'run-python)
253 (define-key map "\C-c\C-s" 'python-shell-send-string) 254 (define-key map "\C-c\C-s" 'python-shell-send-string)
254 (define-key map "\C-c\C-r" 'python-shell-send-region) 255 (define-key map "\C-c\C-r" 'python-shell-send-region)
255 (define-key map "\C-\M-x" 'python-shell-send-defun) 256 (define-key map "\C-\M-x" 'python-shell-send-defun)
@@ -1571,30 +1572,33 @@ non-nil the buffer is shown."
1571 (with-current-buffer buffer 1572 (with-current-buffer buffer
1572 (inferior-python-mode) 1573 (inferior-python-mode)
1573 (python-util-clone-local-variables current-buffer)))) 1574 (python-util-clone-local-variables current-buffer))))
1574 (when pop 1575 (and pop (pop-to-buffer proc-buffer-name t))
1575 (pop-to-buffer proc-buffer-name))
1576 proc-buffer-name))) 1576 proc-buffer-name)))
1577 1577
1578(defun run-python (dedicated cmd) 1578;;;###autoload
1579(defun run-python (cmd &optional dedicated show)
1579 "Run an inferior Python process. 1580 "Run an inferior Python process.
1580Input and output via buffer named after 1581Input and output via buffer named after
1581`python-shell-buffer-name'. If there is a process already 1582`python-shell-buffer-name'. If there is a process already
1582running in that buffer, just switch to it. 1583running in that buffer, just switch to it.
1583With argument, allows you to define DEDICATED, so a dedicated 1584
1584process for the current buffer is open, and define CMD so you can 1585With argument, allows you to define CMD so you can edit the
1585edit the command used to call the interpreter (default is value 1586command used to call the interpreter and define DEDICATED, so a
1586of `python-shell-interpreter' and arguments defined in 1587dedicated process for the current buffer is open. When numeric
1587`python-shell-interpreter-args'). Runs the hook 1588prefix arg is other than 0 or 4 do not SHOW.
1588`inferior-python-mode-hook' (after the `comint-mode-hook' is 1589
1589run). 1590Runs the hook `inferior-python-mode-hook' (after the
1590\(Type \\[describe-mode] in the process buffer for a list of commands.)" 1591`comint-mode-hook' is run). \(Type \\[describe-mode] in the
1592process buffer for a list of commands.)"
1591 (interactive 1593 (interactive
1592 (if current-prefix-arg 1594 (if current-prefix-arg
1593 (list 1595 (list
1596 (read-string "Run Python: " (python-shell-parse-command))
1594 (y-or-n-p "Make dedicated process? ") 1597 (y-or-n-p "Make dedicated process? ")
1595 (read-string "Run Python: " (python-shell-parse-command))) 1598 (= (prefix-numeric-value current-prefix-arg) 4))
1596 (list nil (python-shell-parse-command)))) 1599 (list (python-shell-parse-command) nil t)))
1597 (python-shell-make-comint cmd (python-shell-get-process-name dedicated)) 1600 (python-shell-make-comint
1601 cmd (python-shell-get-process-name dedicated) show)
1598 dedicated) 1602 dedicated)
1599 1603
1600(defun run-python-internal () 1604(defun run-python-internal ()
@@ -1611,7 +1615,6 @@ with user shells. Runs the hook
1611`inferior-python-mode-hook' (after the `comint-mode-hook' is 1615`inferior-python-mode-hook' (after the `comint-mode-hook' is
1612run). \(Type \\[describe-mode] in the process buffer for a list 1616run). \(Type \\[describe-mode] in the process buffer for a list
1613of commands.)" 1617of commands.)"
1614 (interactive)
1615 (set-process-query-on-exit-flag 1618 (set-process-query-on-exit-flag
1616 (get-buffer-process 1619 (get-buffer-process
1617 (python-shell-make-comint 1620 (python-shell-make-comint
@@ -1638,7 +1641,7 @@ of commands.)"
1638 (global-proc-buffer-name (format "*%s*" global-proc-name)) 1641 (global-proc-buffer-name (format "*%s*" global-proc-name))
1639 (dedicated-running (comint-check-proc dedicated-proc-buffer-name)) 1642 (dedicated-running (comint-check-proc dedicated-proc-buffer-name))
1640 (global-running (comint-check-proc global-proc-buffer-name)) 1643 (global-running (comint-check-proc global-proc-buffer-name))
1641 (current-prefix-arg 4)) 1644 (current-prefix-arg 16))
1642 (when (and (not dedicated-running) (not global-running)) 1645 (when (and (not dedicated-running) (not global-running))
1643 (if (call-interactively 'run-python) 1646 (if (call-interactively 'run-python)
1644 (setq dedicated-running t) 1647 (setq dedicated-running t)