Commit 0d49da68 authored by Fabián Ezequiel Gallina's avatar Fabián Ezequiel Gallina
Browse files

Shell processes: enhancements to startup and CEDET compatibility.

* progmodes/python.el (python-shell-send-setup-max-wait): Delete var.
(python-shell-make-comint): accept-process-output at startup.
(run-python-internal): Set inferior-python-mode-hook to nil.
(python-shell-internal-get-or-create-process): call sit-for.
(python-preoutput-result): Add obsolete alias.
(python-shell-internal-send-string): Use it.
(python-shell-send-setup-code): Remove call to
accept-process-output.
parent bc96620a
2012-07-31 Fabián Ezequiel Gallina <fgallina@cuca>
Shell processes: enhancements to startup and CEDET compatibility.
* progmodes/python.el (python-shell-send-setup-max-wait): Delete var.
(python-shell-make-comint): accept-process-output at startup.
(run-python-internal): Set inferior-python-mode-hook to nil.
(python-shell-internal-get-or-create-process): call sit-for.
(python-preoutput-result): Add obsolete alias.
(python-shell-internal-send-string): Use it.
(python-shell-send-setup-code): Remove call to
accept-process-output.
2012-07-31 Andreas Schwab <schwab@linux-m68k.org> 2012-07-31 Andreas Schwab <schwab@linux-m68k.org>
* buff-menu.el (list-buffers-noselect): Use prefix-numeric-value. * buff-menu.el (list-buffers-noselect): Use prefix-numeric-value.
......
...@@ -1354,14 +1354,6 @@ Restart the python shell after changing this variable for it to take effect." ...@@ -1354,14 +1354,6 @@ Restart the python shell after changing this variable for it to take effect."
:group 'python :group 'python
:safe 'booleanp) :safe 'booleanp)
(defcustom python-shell-send-setup-max-wait 5
"Seconds to wait for process output before code setup.
If output is received before the specified time then control is
returned in that moment and not after waiting."
:type 'integer
:group 'python
:safe 'integerp)
(defcustom python-shell-process-environment nil (defcustom python-shell-process-environment nil
"List of environment variables for Python shell. "List of environment variables for Python shell.
This variable follows the same rules as `process-environment' This variable follows the same rules as `process-environment'
...@@ -1571,7 +1563,8 @@ non-nil the buffer is shown." ...@@ -1571,7 +1563,8 @@ non-nil the buffer is shown."
(current-buffer (current-buffer))) (current-buffer (current-buffer)))
(with-current-buffer buffer (with-current-buffer buffer
(inferior-python-mode) (inferior-python-mode)
(python-util-clone-local-variables current-buffer)))) (python-util-clone-local-variables current-buffer))
(accept-process-output (get-buffer-process buffer))))
(and pop (pop-to-buffer proc-buffer-name t)) (and pop (pop-to-buffer proc-buffer-name t))
proc-buffer-name))) proc-buffer-name)))
...@@ -1605,17 +1598,19 @@ process buffer for a list of commands.)" ...@@ -1605,17 +1598,19 @@ process buffer for a list of commands.)"
"Run an inferior Internal Python process. "Run an inferior Internal Python process.
Input and output via buffer named after Input and output via buffer named after
`python-shell-internal-buffer-name' and what `python-shell-internal-buffer-name' and what
`python-shell-internal-get-process-name' returns. This new kind `python-shell-internal-get-process-name' returns.
of shell is intended to be used for generic communication related
to defined configurations. The main difference with global or This new kind of shell is intended to be used for generic
dedicated shells is that these ones are attached to a communication related to defined configurations, the main
configuration, not a buffer. This means that can be used for difference with global or dedicated shells is that these ones are
example to retrieve the sys.path and other stuff, without messing attached to a configuration, not a buffer. This means that can
with user shells. Runs the hook be used for example to retrieve the sys.path and other stuff,
`inferior-python-mode-hook' (after the `comint-mode-hook' is without messing with user shells. Note that
run). \(Type \\[describe-mode] in the process buffer for a list `python-shell-enable-font-lock' and `inferior-python-mode-hook'
of commands.)" are set to nil for these shells, so setup codes are not sent at
(let ((python-shell-enable-font-lock nil)) startup."
(let ((python-shell-enable-font-lock nil)
(inferior-python-mode-hook nil))
(set-process-query-on-exit-flag (set-process-query-on-exit-flag
(get-buffer-process (get-buffer-process
(python-shell-make-comint (python-shell-make-comint
...@@ -1658,12 +1653,25 @@ This is really not necessary at all for the code to work but it's ...@@ -1658,12 +1653,25 @@ This is really not necessary at all for the code to work but it's
there for compatibility with CEDET.") there for compatibility with CEDET.")
(make-variable-buffer-local 'python-shell-internal-buffer) (make-variable-buffer-local 'python-shell-internal-buffer)
(defvar python-shell-internal-last-output nil
"Last output captured by the internal shell.
This is really not necessary at all for the code to work but it's
there for compatibility with CEDET.")
(make-variable-buffer-local 'python-shell-internal-last-output)
(defun python-shell-internal-get-or-create-process () (defun python-shell-internal-get-or-create-process ()
"Get or create an inferior Internal Python process." "Get or create an inferior Internal Python process."
(let* ((proc-name (python-shell-internal-get-process-name)) (let* ((proc-name (python-shell-internal-get-process-name))
(proc-buffer-name (format "*%s*" proc-name))) (proc-buffer-name (format "*%s*" proc-name)))
(run-python-internal) (when (not (process-live-p proc-name))
(setq python-shell-internal-buffer proc-buffer-name) (run-python-internal)
(setq python-shell-internal-buffer proc-buffer-name)
;; XXX: Why is this `sit-for' needed?
;; `python-shell-make-comint' calls `accept-process-output'
;; already but it is not helping to get proper output on
;; 'gnu/linux when the internal shell process is not running and
;; a call to `python-shell-internal-send-string' is issued.
(sit-for 0.1 t))
(get-buffer-process proc-buffer-name))) (get-buffer-process proc-buffer-name)))
(define-obsolete-function-alias (define-obsolete-function-alias
...@@ -1672,6 +1680,9 @@ there for compatibility with CEDET.") ...@@ -1672,6 +1680,9 @@ there for compatibility with CEDET.")
(define-obsolete-variable-alias (define-obsolete-variable-alias
'python-buffer 'python-shell-internal-buffer "24.2") 'python-buffer 'python-shell-internal-buffer "24.2")
(define-obsolete-variable-alias
'python-preoutput-result 'python-shell-internal-last-output "24.2")
(defun python-shell-send-string (string &optional process msg) (defun python-shell-send-string (string &optional process msg)
"Send STRING to inferior Python PROCESS. "Send STRING to inferior Python PROCESS.
When MSG is non-nil messages the first line of STRING." When MSG is non-nil messages the first line of STRING."
...@@ -1723,11 +1734,14 @@ the output." ...@@ -1723,11 +1734,14 @@ the output."
(defun python-shell-internal-send-string (string) (defun python-shell-internal-send-string (string)
"Send STRING to the Internal Python interpreter. "Send STRING to the Internal Python interpreter.
Returns the output. See `python-shell-send-string-no-output'." Returns the output. See `python-shell-send-string-no-output'."
(python-shell-send-string-no-output ;; XXX Remove `python-shell-internal-last-output' once CEDET is
;; Makes this function compatible with the old ;; updated to support this new mode.
;; python-send-receive. (At least for CEDET). (setq python-shell-internal-last-output
(replace-regexp-in-string "_emacs_out +" "" string) (python-shell-send-string-no-output
(python-shell-internal-get-or-create-process) nil)) ;; Makes this function compatible with the old
;; python-send-receive. (At least for CEDET).
(replace-regexp-in-string "_emacs_out +" "" string)
(python-shell-internal-get-or-create-process) nil)))
(define-obsolete-function-alias (define-obsolete-function-alias
'python-send-receive 'python-shell-internal-send-string "24.2") 'python-send-receive 'python-shell-internal-send-string "24.2")
...@@ -1808,7 +1822,6 @@ This function takes the list of setup code to send from the ...@@ -1808,7 +1822,6 @@ This function takes the list of setup code to send from the
`python-shell-setup-codes' list." `python-shell-setup-codes' list."
(let ((msg "Sent %s") (let ((msg "Sent %s")
(process (get-buffer-process (current-buffer)))) (process (get-buffer-process (current-buffer))))
(accept-process-output process python-shell-send-setup-max-wait)
(dolist (code python-shell-setup-codes) (dolist (code python-shell-setup-codes)
(when code (when code
(message (format msg code)) (message (format msg code))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment