diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 87b2b92fc..8290b6600 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -1902,6 +1902,7 @@ Other: - Added diminish for importmagic (thanks to Loys Ollivier) - Added debugger integration via =dap= layer - Added documentation on installing importmagic and epc (thanks to Trapez Breen) +- Made python-send-shell-* functions faster (thanks to Trapez Breen) **** Racket - Restore smart closing paren behavior in racket-mode (thanks to Don March) **** Ranger diff --git a/layers/+lang/python/funcs.el b/layers/+lang/python/funcs.el index 45d0ca973..e0c5cbf41 100644 --- a/layers/+lang/python/funcs.el +++ b/layers/+lang/python/funcs.el @@ -361,23 +361,44 @@ to be called for each testrunner. " (defun spacemacs/python-shell-send-buffer-switch () "Send buffer content to shell and switch to it in insert mode." (interactive) - (python-shell-send-buffer) - (python-shell-switch-to-shell) - (evil-insert-state)) + (let ((python-mode-hook nil)) + (python-shell-send-buffer) + (python-shell-switch-to-shell) + (evil-insert-state))) + +(defun spacemacs/python-shell-send-buffer () + "Send buffer content to shell and switch to it in insert mode." + (interactive) + (let ((python-mode-hook nil)) + (python-shell-send-buffer))) (defun spacemacs/python-shell-send-defun-switch () "Send function content to shell and switch to it in insert mode." (interactive) - (python-shell-send-defun nil) - (python-shell-switch-to-shell) - (evil-insert-state)) + (let ((python-mode-hook nil)) + (python-shell-send-defun nil) + (python-shell-switch-to-shell) + (evil-insert-state))) + +(defun spacemacs/python-shell-send-defun () + "Send function content to shell and switch to it in insert mode." + (interactive) + (let ((python-mode-hook nil)) + (python-shell-send-defun nil))) (defun spacemacs/python-shell-send-region-switch (start end) "Send region content to shell and switch to it in insert mode." (interactive "r") - (python-shell-send-region start end) - (python-shell-switch-to-shell) - (evil-insert-state)) + (let ((python-mode-hook nil)) + (python-shell-send-region start end) + (python-shell-switch-to-shell) + (evil-insert-state))) + +(defun spacemacs/python-shell-send-region (start end) + "Send region content to shell and switch to it in insert mode." + (interactive "r") + (let ((python-mode-hook nil)) + (python-shell-send-region start end))) (defun spacemacs/python-start-or-switch-repl () "Start and/or switch to the REPL." diff --git a/layers/+lang/python/packages.el b/layers/+lang/python/packages.el index 0aad1b343..a66057282 100644 --- a/layers/+lang/python/packages.el +++ b/layers/+lang/python/packages.el @@ -324,12 +324,12 @@ "db" 'spacemacs/python-toggle-breakpoint "ri" 'spacemacs/python-remove-unused-imports "sB" 'spacemacs/python-shell-send-buffer-switch - "sb" 'python-shell-send-buffer + "sb" 'spacemacs/python-shell-send-buffer "sF" 'spacemacs/python-shell-send-defun-switch - "sf" 'python-shell-send-defun + "sf" 'spacemacs/python-shell-send-defun "si" 'spacemacs/python-start-or-switch-repl "sR" 'spacemacs/python-shell-send-region-switch - "sr" 'python-shell-send-region) + "sr" 'spacemacs/python-shell-send-region) ;; Set `python-indent-guess-indent-offset' to `nil' to prevent guessing `python-indent-offset ;; (we call python-indent-guess-indent-offset manually so python-mode does not need to do it)