Skip to content

Commit 32a9313

Browse files
committed
Ensure Idris is running and current idr file loaded when using idris-switch-to-repl
Why: Allows to jump to the repl without having to manually start repl using a shortcut
1 parent da5c22f commit 32a9313

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

idris-repl.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,16 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the end of the buffer."
186186
(idris-repl-insert-prompt)
187187
(insert current-input))))
188188

189+
(autoload 'idris-load-file "idris-commands.el")
190+
;;;###autoload
189191
(defun idris-switch-to-repl ()
190192
"Select the output buffer and scroll to bottom."
191193
(interactive)
194+
(if (and buffer-file-name
195+
;; in Emacs 29.1 > we can use string-equal-ignore-case
196+
(string= "idr" (downcase (file-name-extension buffer-file-name))))
197+
(idris-load-file)
198+
(user-error "This command can only be run from a buffer visiting an Idris `.idr' file"))
192199
(pop-to-buffer (idris-repl-buffer))
193200
(goto-char (point-max)))
194201

0 commit comments

Comments
 (0)