biviosoftware / home-env

MIT License
2 stars 2 forks source link

Consider comint-send-input to only send if at end of buffer #72

Open robnagler opened 1 year ago

robnagler commented 1 year ago

Maybe consider prompting on a multiline send, since that's not usual.

https://stackoverflow.com/a/52212547:

(defun my-comint-send-input-maybe ()
  "Only `comint-send-input' when point is after the latest prompt.

Otherwise move to the end of the buffer."
  (interactive)
  (let ((proc (get-buffer-process (current-buffer))))
    (if (and proc (>= (point) (marker-position (process-mark proc))))
        (comint-send-input)
      (goto-char (point-max)))))

(with-eval-after-load "comint"
  (define-key shell-mode-map [remap comint-send-input] 'my-comint-send-input-maybe))