diff --git a/direct/src/directscripts/python-mode.el b/direct/src/directscripts/python-mode.el index 9cdfb1f7df..48bafeace9 100644 --- a/direct/src/directscripts/python-mode.el +++ b/direct/src/directscripts/python-mode.el @@ -585,6 +585,7 @@ support for features needed by `python-mode'.") ;; VR STUDIO ENHANCEMENTS (define-key py-shell-map "\C-d" 'comint-delchar-or-maybe-python-resume) (define-key py-shell-map [return] 'comint-interrupt-subjob-or-maybe-return) + (define-key py-shell-map [C-return] 'comint-interrupt-subjob-or-maybe-return-curbuf) (define-key py-shell-map "\C-c\C-r" 'python-resume) (define-key py-shell-map "\C-c\C-s" 'pyd-shell) (define-key py-shell-map "\C-c\C-f" 'py-kill-shells) @@ -3421,6 +3422,33 @@ These are Python temporary files awaiting execution." ) ) +(defun comint-interrupt-subjob-or-maybe-return-curbuf (arg) + "Enter a return (comint-send-input) or send a comint-interrupt-subjob + if point is at the end of the buffer and there is no input" + (interactive "p") + (let ((proc (get-buffer-process (current-buffer)))) + (if (and (eobp) proc (= (point) (marker-position (process-mark proc)))) + (let ((current (point))) + (goto-char (- current 4)) + (if (or (search-forward ">>> " current t) + (search-forward "... " current t)) + (comint-send-input) + (save-current-buffer + (goto-char current) + (let ((procbuf (process-buffer proc))) + (set-buffer procbuf) + (goto-char (point-max)) + (if (and (eobp) proc (= (point) (marker-position (process-mark proc)))) + (comint-interrupt-subjob)) + ) + ) + ) + ) + (comint-send-input) + ) + ) + ) + (defun py-point-to-max (proc) ;; updates the cursor position of a buffer for all windows ;; into that buffer