Skip to content

Instantly share code, notes, and snippets.

@luismbo
Last active June 14, 2016 20:13
Show Gist options
  • Save luismbo/b8be134c3b2095a641aa176a957e652f to your computer and use it in GitHub Desktop.
Save luismbo/b8be134c3b2095a641aa176a957e652f to your computer and use it in GitHub Desktop.
Tweaked repl-read mode for Xach
;;;;; REPL Read Mode
(setq slime-repl-read-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map lisp-mode-map)
(define-key map "\C-m" 'slime-repl-return)
(define-key map [return] 'slime-repl-return)
(define-key map "\C-c\C-b" 'slime-repl-read-break)
(define-key map "\C-c\C-c" 'slime-repl-read-break)
(define-key map [remap slime-indent-and-complete-symbol] 'ignore)
(define-key map [remap slime-handle-repl-shortcut] 'self-insert-command)
map))
(define-minor-mode slime-repl-read-mode
"Mode to read input from Emacs
\\{slime-repl-read-mode-map}"
nil
"[read]")
(make-variable-buffer-local
(defvar slime-read-string-threads nil))
(make-variable-buffer-local
(defvar slime-read-string-tags nil))
(defun slime-repl-read-string (thread tag)
(slime-switch-to-output-buffer)
(push thread slime-read-string-threads)
(push tag slime-read-string-tags)
(goto-char (point-max))
(slime-mark-output-end)
(slime-mark-input-start)
(slime-repl-read-mode 1)
(setq slime-current-thread t))
(defun slime-repl-return-string (string)
(slime-dispatch-event `(:emacs-return-string
,(pop slime-read-string-threads)
,(pop slime-read-string-tags)
,string))
(slime-repl-read-mode -1)
(setq slime-current-thread :repl-thread))
(defun slime-repl-read-break ()
(interactive)
(slime-dispatch-event `(:emacs-interrupt ,(car slime-read-string-threads))))
(defun slime-repl-abort-read (thread tag)
(with-current-buffer (slime-output-buffer)
(pop slime-read-string-threads)
(pop slime-read-string-tags)
(slime-repl-read-mode -1)
(setq slime-current-thread :repl-thread)
(message "Read aborted")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment