emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109347: Shell processes: enhancement


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109347: Shell processes: enhancements to startup and CEDET compatibility.
Date: Tue, 31 Jul 2012 20:43:31 -0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109347
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: trunk
timestamp: Tue 2012-07-31 20:43:31 -0300
message:
  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.
modified:
  lisp/ChangeLog
  lisp/progmodes/python.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-07-31 22:34:36 +0000
+++ b/lisp/ChangeLog    2012-07-31 23:43:31 +0000
@@ -1,3 +1,15 @@
+2012-07-31  Fabián Ezequiel Gallina  <address@hidden>
+
+       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  <address@hidden>
 
        * buff-menu.el (list-buffers-noselect): Use prefix-numeric-value.

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2012-07-31 03:31:10 +0000
+++ b/lisp/progmodes/python.el  2012-07-31 23:43:31 +0000
@@ -1354,14 +1354,6 @@
   :group 'python
   :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
   "List of environment variables for Python shell.
 This variable follows the same rules as `process-environment'
@@ -1571,7 +1563,8 @@
                (current-buffer (current-buffer)))
           (with-current-buffer buffer
             (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))
       proc-buffer-name)))
 
@@ -1605,17 +1598,19 @@
   "Run an inferior Internal Python process.
 Input and output via buffer named after
 `python-shell-internal-buffer-name' and what
-`python-shell-internal-get-process-name' returns.  This new kind
-of shell is intended to be used for generic communication related
-to defined configurations.  The main difference with global or
-dedicated shells is that these ones are attached to a
-configuration, not a buffer.  This means that can be used for
-example to retrieve the sys.path and other stuff, without messing
-with user shells.  Runs the hook
-`inferior-python-mode-hook' (after the `comint-mode-hook' is
-run).  \(Type \\[describe-mode] in the process buffer for a list
-of commands.)"
-  (let ((python-shell-enable-font-lock nil))
+`python-shell-internal-get-process-name' returns.
+
+This new kind of shell is intended to be used for generic
+communication related to defined configurations, the main
+difference with global or dedicated shells is that these ones are
+attached to a configuration, not a buffer.  This means that can
+be used for example to retrieve the sys.path and other stuff,
+without messing with user shells.  Note that
+`python-shell-enable-font-lock' and `inferior-python-mode-hook'
+are set to nil for these shells, so setup codes are not sent at
+startup."
+  (let ((python-shell-enable-font-lock nil)
+        (inferior-python-mode-hook nil))
     (set-process-query-on-exit-flag
      (get-buffer-process
       (python-shell-make-comint
@@ -1658,12 +1653,25 @@
 there for compatibility with CEDET.")
 (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 ()
   "Get or create an inferior Internal Python process."
   (let* ((proc-name (python-shell-internal-get-process-name))
          (proc-buffer-name (format "*%s*" proc-name)))
-    (run-python-internal)
-    (setq python-shell-internal-buffer proc-buffer-name)
+    (when (not (process-live-p proc-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)))
 
 (define-obsolete-function-alias
@@ -1672,6 +1680,9 @@
 (define-obsolete-variable-alias
   '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)
   "Send STRING to inferior Python PROCESS.
 When MSG is non-nil messages the first line of STRING."
@@ -1723,11 +1734,14 @@
 (defun python-shell-internal-send-string (string)
   "Send STRING to the Internal Python interpreter.
 Returns the output.  See `python-shell-send-string-no-output'."
-  (python-shell-send-string-no-output
-   ;; 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))
+  ;; XXX Remove `python-shell-internal-last-output' once CEDET is
+  ;; updated to support this new mode.
+  (setq python-shell-internal-last-output
+        (python-shell-send-string-no-output
+         ;; 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
   'python-send-receive 'python-shell-internal-send-string "24.2")
@@ -1808,7 +1822,6 @@
 `python-shell-setup-codes' list."
   (let ((msg "Sent %s")
         (process (get-buffer-process (current-buffer))))
-    (accept-process-output process python-shell-send-setup-max-wait)
     (dolist (code python-shell-setup-codes)
       (when code
         (message (format msg code))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]