]> code.delx.au - gnu-emacs/commitdiff
Make shells inherit variables from parent buffer and internal shells not show by...
authorFabián Ezequiel Gallina <fgallina@cuca>
Thu, 17 May 2012 03:03:23 +0000 (00:03 -0300)
committerFabián Ezequiel Gallina <fgallina@gnu.org>
Thu, 17 May 2012 03:03:23 +0000 (00:03 -0300)
python-shell-make-comint now passes all parent buffer variables to the
comint buffer created ensuring local variables work as intended. Also,
this function now receives a third optional argument called POP that
establishes if the created comint buffer should be displayed or not
after its creation.

lisp/progmodes/python.el

index 55d854ca8a1dd4c7818acac902b50a898ec3f040..8c80640ec82d0027f7c4ff897b16330f39156f45 100644 (file)
@@ -1252,23 +1252,64 @@ variable.
     'python-shell-completion-complete-or-indent)
   (compilation-shell-minor-mode 1))
 
-(defun python-shell-make-comint (cmd proc-name)
+(defun python-shell-make-comint (cmd proc-name &optional pop)
   "Create a python shell comint buffer.
-CMD is the pythone command to be executed and PROC-NAME is the
+CMD is the python command to be executed and PROC-NAME is the
 process name the comint buffer will get.  After the comint buffer
-is created the `inferior-python-mode' is activated and the buffer
-is shown."
+is created the `inferior-python-mode' is activated.  If POP is
+non-nil the buffer is shown."
   (save-excursion
     (let* ((proc-buffer-name (format "*%s*" proc-name))
            (process-environment (python-shell-calculate-process-enviroment))
            (exec-path (python-shell-calculate-exec-path)))
       (when (not (comint-check-proc proc-buffer-name))
-        (let ((cmdlist (split-string-and-unquote cmd)))
-          (set-buffer
-           (apply 'make-comint proc-name (car cmdlist) nil
-                  (cdr cmdlist)))
-          (inferior-python-mode)))
-      (pop-to-buffer proc-buffer-name))))
+        (let* ((cmdlist (split-string-and-unquote cmd))
+               (buffer (apply 'make-comint proc-name (car cmdlist) nil
+                              (cdr cmdlist)))
+               (python-shell-interpreter-1 python-shell-interpreter)
+               (python-shell-interpreter-args-1 python-shell-interpreter-args)
+               (python-shell-prompt-regexp-1 python-shell-prompt-regexp)
+               (python-shell-prompt-output-regexp-1
+                python-shell-prompt-output-regexp)
+               (python-shell-prompt-block-regexp-1
+                python-shell-prompt-block-regexp)
+               (python-shell-completion-setup-code-1
+                python-shell-completion-setup-code)
+               (python-shell-completion-string-code-1
+                python-shell-completion-string-code)
+               (python-eldoc-setup-code-1 python-eldoc-setup-code)
+               (python-eldoc-string-code-1 python-eldoc-string-code)
+               (python-ffap-setup-code-1 python-ffap-setup-code)
+               (python-ffap-string-code-1 python-ffap-string-code)
+               (python-shell-setup-codes-1 python-shell-setup-codes))
+          (with-current-buffer buffer
+            (inferior-python-mode)
+            (set (make-local-variable 'python-shell-interpreter)
+                 python-shell-interpreter-1)
+            (set (make-local-variable 'python-shell-interpreter-args)
+                 python-shell-interpreter-args-1)
+            (set (make-local-variable 'python-shell-prompt-regexp)
+                 python-shell-prompt-regexp-1)
+            (set (make-local-variable 'python-shell-prompt-output-regexp)
+                 python-shell-prompt-output-regexp-1)
+            (set (make-local-variable 'python-shell-prompt-block-regexp)
+                 python-shell-prompt-block-regexp-1)
+            (set (make-local-variable 'python-shell-completion-setup-code)
+                 python-shell-completion-setup-code-1)
+            (set (make-local-variable 'python-shell-completion-string-code)
+                 python-shell-completion-string-code-1)
+            (set (make-local-variable 'python-eldoc-setup-code)
+                 python-eldoc-setup-code-1)
+            (set (make-local-variable 'python-eldoc-string-code)
+                 python-eldoc-string-code-1)
+            (set (make-local-variable 'python-ffap-setup-code)
+                 python-ffap-setup-code-1)
+            (set (make-local-variable 'python-ffap-string-code)
+                 python-ffap-string-code-1)
+            (set (make-local-variable 'python-shell-setup-codes)
+                 python-shell-setup-codes-1))))
+      (when pop
+        (pop-to-buffer proc-buffer-name)))))
 
 (defun run-python (dedicated cmd)
   "Run an inferior Python process.
@@ -1289,7 +1330,7 @@ run).
         (y-or-n-p "Make dedicated process? ")
         (read-string "Run Python: " (python-shell-parse-command)))
      (list nil (python-shell-parse-command))))
-  (python-shell-make-comint cmd (python-shell-get-process-name dedicated))
+  (python-shell-make-comint cmd (python-shell-get-process-name dedicated) t)
   dedicated)
 
 (defun run-python-internal ()