Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
;; This is just an example related to the discussion in this Emacs.SE question:
;; https://emacs.stackexchange.com/questions/20732/how-do-i-enable-indentation-in-an-inferior-scheme/
(defun newline-indent-comint-send-input ()
(interactive)
(newline-and-indent)
(comint-send-input))
(with-eval-after-load 'cmuscheme
(define-key inferior-scheme-mode-map (kbd "RET") #'newline-indent-comint-send-input))
;; This (below) appears to work (after, admittedly, very limited testing) but
;; I'm worried it may be fragile. Hopefully some further input will come via the
;; Emacs help mailing list.
;;
;; I asked about the topic here: https://lists.gnu.org/archive/html/help-gnu-emacs/2016-03/msg00075.html
(defun newline-indent-comint-send-input ()
(interactive)
(comint-send-input)
(unless (save-excursion (forward-char -1)
(eq (field-at-pos (point)) 'output))
(indent-for-tab-command)))
(with-eval-after-load 'cmuscheme
(define-key inferior-scheme-mode-map (kbd "RET") #'newline-indent-comint-send-input))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment