aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-05-17 00:03:23 -0300
committerFabián Ezequiel Gallina2012-05-17 00:03:23 -0300
commit96eeb83a55aaa75fd58ebc631736ecfeb0f5067d (patch)
tree3a27ffd6163324d871223e486effc7bc9ced27b0 /lisp/progmodes/python.el
parent0f55249e18cab573efe672d907d6d9936beb4f1c (diff)
downloademacs-96eeb83a55aaa75fd58ebc631736ecfeb0f5067d.tar.gz
emacs-96eeb83a55aaa75fd58ebc631736ecfeb0f5067d.zip
Make shells inherit variables from parent buffer and internal shells not show by default.
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.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el63
1 files changed, 52 insertions, 11 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 55d854ca8a1..8c80640ec82 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1252,23 +1252,64 @@ variable.
1252 'python-shell-completion-complete-or-indent) 1252 'python-shell-completion-complete-or-indent)
1253 (compilation-shell-minor-mode 1)) 1253 (compilation-shell-minor-mode 1))
1254 1254
1255(defun python-shell-make-comint (cmd proc-name) 1255(defun python-shell-make-comint (cmd proc-name &optional pop)
1256 "Create a python shell comint buffer. 1256 "Create a python shell comint buffer.
1257CMD is the pythone command to be executed and PROC-NAME is the 1257CMD is the python command to be executed and PROC-NAME is the
1258process name the comint buffer will get. After the comint buffer 1258process name the comint buffer will get. After the comint buffer
1259is created the `inferior-python-mode' is activated and the buffer 1259is created the `inferior-python-mode' is activated. If POP is
1260is shown." 1260non-nil the buffer is shown."
1261 (save-excursion 1261 (save-excursion
1262 (let* ((proc-buffer-name (format "*%s*" proc-name)) 1262 (let* ((proc-buffer-name (format "*%s*" proc-name))
1263 (process-environment (python-shell-calculate-process-enviroment)) 1263 (process-environment (python-shell-calculate-process-enviroment))
1264 (exec-path (python-shell-calculate-exec-path))) 1264 (exec-path (python-shell-calculate-exec-path)))
1265 (when (not (comint-check-proc proc-buffer-name)) 1265 (when (not (comint-check-proc proc-buffer-name))
1266 (let ((cmdlist (split-string-and-unquote cmd))) 1266 (let* ((cmdlist (split-string-and-unquote cmd))
1267 (set-buffer 1267 (buffer (apply 'make-comint proc-name (car cmdlist) nil
1268 (apply 'make-comint proc-name (car cmdlist) nil 1268 (cdr cmdlist)))
1269 (cdr cmdlist))) 1269 (python-shell-interpreter-1 python-shell-interpreter)
1270 (inferior-python-mode))) 1270 (python-shell-interpreter-args-1 python-shell-interpreter-args)
1271 (pop-to-buffer proc-buffer-name)))) 1271 (python-shell-prompt-regexp-1 python-shell-prompt-regexp)
1272 (python-shell-prompt-output-regexp-1
1273 python-shell-prompt-output-regexp)
1274 (python-shell-prompt-block-regexp-1
1275 python-shell-prompt-block-regexp)
1276 (python-shell-completion-setup-code-1
1277 python-shell-completion-setup-code)
1278 (python-shell-completion-string-code-1
1279 python-shell-completion-string-code)
1280 (python-eldoc-setup-code-1 python-eldoc-setup-code)
1281 (python-eldoc-string-code-1 python-eldoc-string-code)
1282 (python-ffap-setup-code-1 python-ffap-setup-code)
1283 (python-ffap-string-code-1 python-ffap-string-code)
1284 (python-shell-setup-codes-1 python-shell-setup-codes))
1285 (with-current-buffer buffer
1286 (inferior-python-mode)
1287 (set (make-local-variable 'python-shell-interpreter)
1288 python-shell-interpreter-1)
1289 (set (make-local-variable 'python-shell-interpreter-args)
1290 python-shell-interpreter-args-1)
1291 (set (make-local-variable 'python-shell-prompt-regexp)
1292 python-shell-prompt-regexp-1)
1293 (set (make-local-variable 'python-shell-prompt-output-regexp)
1294 python-shell-prompt-output-regexp-1)
1295 (set (make-local-variable 'python-shell-prompt-block-regexp)
1296 python-shell-prompt-block-regexp-1)
1297 (set (make-local-variable 'python-shell-completion-setup-code)
1298 python-shell-completion-setup-code-1)
1299 (set (make-local-variable 'python-shell-completion-string-code)
1300 python-shell-completion-string-code-1)
1301 (set (make-local-variable 'python-eldoc-setup-code)
1302 python-eldoc-setup-code-1)
1303 (set (make-local-variable 'python-eldoc-string-code)
1304 python-eldoc-string-code-1)
1305 (set (make-local-variable 'python-ffap-setup-code)
1306 python-ffap-setup-code-1)
1307 (set (make-local-variable 'python-ffap-string-code)
1308 python-ffap-string-code-1)
1309 (set (make-local-variable 'python-shell-setup-codes)
1310 python-shell-setup-codes-1))))
1311 (when pop
1312 (pop-to-buffer proc-buffer-name)))))
1272 1313
1273(defun run-python (dedicated cmd) 1314(defun run-python (dedicated cmd)
1274 "Run an inferior Python process. 1315 "Run an inferior Python process.
@@ -1289,7 +1330,7 @@ run).
1289 (y-or-n-p "Make dedicated process? ") 1330 (y-or-n-p "Make dedicated process? ")
1290 (read-string "Run Python: " (python-shell-parse-command))) 1331 (read-string "Run Python: " (python-shell-parse-command)))
1291 (list nil (python-shell-parse-command)))) 1332 (list nil (python-shell-parse-command))))
1292 (python-shell-make-comint cmd (python-shell-get-process-name dedicated)) 1333 (python-shell-make-comint cmd (python-shell-get-process-name dedicated) t)
1293 dedicated) 1334 dedicated)
1294 1335
1295(defun run-python-internal () 1336(defun run-python-internal ()