Shadow python-mode-hook during python-send-shell-*

This commit is contained in:
Trapez Breen 2019-04-13 09:31:08 +02:00 committed by smile13241324
parent 76ba46893b
commit d25b329c17
3 changed files with 34 additions and 12 deletions

View file

@ -1902,6 +1902,7 @@ Other:
- Added diminish for importmagic (thanks to Loys Ollivier) - Added diminish for importmagic (thanks to Loys Ollivier)
- Added debugger integration via =dap= layer - Added debugger integration via =dap= layer
- Added documentation on installing importmagic and epc (thanks to Trapez Breen) - Added documentation on installing importmagic and epc (thanks to Trapez Breen)
- Made python-send-shell-* functions faster (thanks to Trapez Breen)
**** Racket **** Racket
- Restore smart closing paren behavior in racket-mode (thanks to Don March) - Restore smart closing paren behavior in racket-mode (thanks to Don March)
**** Ranger **** Ranger

View file

@ -361,23 +361,44 @@ to be called for each testrunner. "
(defun spacemacs/python-shell-send-buffer-switch () (defun spacemacs/python-shell-send-buffer-switch ()
"Send buffer content to shell and switch to it in insert mode." "Send buffer content to shell and switch to it in insert mode."
(interactive) (interactive)
(let ((python-mode-hook nil))
(python-shell-send-buffer) (python-shell-send-buffer)
(python-shell-switch-to-shell) (python-shell-switch-to-shell)
(evil-insert-state)) (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 () (defun spacemacs/python-shell-send-defun-switch ()
"Send function content to shell and switch to it in insert mode." "Send function content to shell and switch to it in insert mode."
(interactive) (interactive)
(let ((python-mode-hook nil))
(python-shell-send-defun nil) (python-shell-send-defun nil)
(python-shell-switch-to-shell) (python-shell-switch-to-shell)
(evil-insert-state)) (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) (defun spacemacs/python-shell-send-region-switch (start end)
"Send region content to shell and switch to it in insert mode." "Send region content to shell and switch to it in insert mode."
(interactive "r") (interactive "r")
(let ((python-mode-hook nil))
(python-shell-send-region start end) (python-shell-send-region start end)
(python-shell-switch-to-shell) (python-shell-switch-to-shell)
(evil-insert-state)) (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 () (defun spacemacs/python-start-or-switch-repl ()
"Start and/or switch to the REPL." "Start and/or switch to the REPL."

View file

@ -324,12 +324,12 @@
"db" 'spacemacs/python-toggle-breakpoint "db" 'spacemacs/python-toggle-breakpoint
"ri" 'spacemacs/python-remove-unused-imports "ri" 'spacemacs/python-remove-unused-imports
"sB" 'spacemacs/python-shell-send-buffer-switch "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" 'spacemacs/python-shell-send-defun-switch
"sf" 'python-shell-send-defun "sf" 'spacemacs/python-shell-send-defun
"si" 'spacemacs/python-start-or-switch-repl "si" 'spacemacs/python-start-or-switch-repl
"sR" 'spacemacs/python-shell-send-region-switch "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 ;; 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) ;; (we call python-indent-guess-indent-offset manually so python-mode does not need to do it)