File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,33 @@ Bind formatter to '==' for LSP and '='for all other backends."
422
422
423
423
424
424
; ; REPL
425
+ (defun spacemacs/python-shell-send-block (&optional arg )
426
+ " Send the block under cursor to shell. If optional argument ARG is non-nil
427
+ (interactively, the prefix argument), send the block body with its header."
428
+ (interactive " P" )
429
+ (if (fboundp 'python-shell-send-block )
430
+ (let ((python-mode-hook nil ))
431
+ (call-interactively #'python-shell-send-block ))
432
+ (let ((python-mode-hook nil )
433
+ (beg (save-excursion
434
+ (when (python-nav-beginning-of-block )
435
+ (if arg
436
+ (beginning-of-line )
437
+ (python-nav-end-of-statement )
438
+ (beginning-of-line 2 )))
439
+ (point-marker )))
440
+ (end (save-excursion (python-nav-end-of-block )))
441
+ (python-indent-guess-indent-offset-verbose nil ))
442
+ (if (and beg end)
443
+ (python-shell-send-region beg end nil msg t )
444
+ (user-error " Can't get code block from current position." )))))
445
+
446
+ (defun spacemacs/python-shell-send-block-switch (&optional arg )
447
+ " Send block to shell and switch to it in insert mode."
448
+ (interactive " P" )
449
+ (call-interactively #'spacemacs/python-shell-send-block )
450
+ (python-shell-switch-to-shell )
451
+ (evil-insert-state))
425
452
426
453
(defun spacemacs/python-shell-send-buffer-switch ()
427
454
" Send buffer content to shell and switch to it in insert mode."
Original file line number Diff line number Diff line change 404
404
" sF" 'spacemacs/python-shell-send-defun-switch
405
405
" sf" 'spacemacs/python-shell-send-defun
406
406
" si" 'spacemacs/python-start-or-switch-repl
407
+ " sK" 'spacemacs/python-shell-send-block-switch
408
+ " sk" 'spacemacs/python-shell-send-block
407
409
" sn" 'spacemacs/python-shell-restart
408
410
" sN" 'spacemacs/python-shell-restart-switch
409
411
" sR" 'spacemacs/python-shell-send-region-switch
You can’t perform that action at this time.
0 commit comments