From ab92ad758e1dfe49443849f6478351834873ca14 Mon Sep 17 00:00:00 2001 From: Christoph Paulik Date: Sat, 14 Mar 2015 10:41:54 +0100 Subject: [PATCH 1/2] fixes python compile command - now sets the compile command correctly if python buffers are switched - moves point to end of comint buffer, useful if a breakpoint is set --- contrib/lang/python/packages.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/contrib/lang/python/packages.el b/contrib/lang/python/packages.el index e8ac75cf909b..a9a17af35b1f 100644 --- a/contrib/lang/python/packages.el +++ b/contrib/lang/python/packages.el @@ -210,26 +210,21 @@ which require an initialization must be listed explicitly in the list.") "Execute a python script in a shell." (interactive "P") ;; set compile command to buffer-file-name - ;; if buffer-file-name exists - ;; otherwise error occurs on e.g. org export including python src ;; universal argument put compile buffer in comint mode (setq universal-argument t) (if arg (call-interactively 'compile) - (unless compile-command (setq compile-command (format "python %s" (file-name-nondirectory - buffer-file-name)))) + buffer-file-name))) (compile compile-command t))) (defun spacemacs/python-execute-file-focus (arg) "Execute a python script in a shell and switch to the shell buffer in `insert state'." (interactive "P") - ;; set compile command to buffer-file-name - ;; if buffer-file-name exists - ;; otherwise error occurs on e.g. org export including python src (spacemacs/python-execute-file arg) (switch-to-buffer-other-window "*compilation*") + (end-of-buffer) (evil-insert-state)) (evil-leader/set-key-for-mode 'python-mode From 2c0328c8a1ba68b8f0d4444fad342d23a32c1348 Mon Sep 17 00:00:00 2001 From: Christoph Paulik Date: Sat, 14 Mar 2015 12:14:11 +0100 Subject: [PATCH 2/2] activate inferior-python-mode in comint buffer this enables autocompletion This code still has the bug that point stays in the comint buffer --- contrib/lang/python/packages.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/lang/python/packages.el b/contrib/lang/python/packages.el index a9a17af35b1f..4aa53ab901a7 100644 --- a/contrib/lang/python/packages.el +++ b/contrib/lang/python/packages.el @@ -214,9 +214,12 @@ which require an initialization must be listed explicitly in the list.") (setq universal-argument t) (if arg (call-interactively 'compile) + (setq compile-command (format "python %s" (file-name-nondirectory buffer-file-name))) - (compile compile-command t))) + (compile compile-command t) + (with-current-buffer (get-buffer "*compilation*") + (inferior-python-mode)))) (defun spacemacs/python-execute-file-focus (arg) "Execute a python script in a shell and switch to the shell buffer in