Skip to content

Instantly share code, notes, and snippets.

@johnmastro
Last active March 6, 2016 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnmastro/c8bf5013b4e47cdd3ea0 to your computer and use it in GitHub Desktop.
Save johnmastro/c8bf5013b4e47cdd3ea0 to your computer and use it in GitHub Desktop.
;; 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