Skip to content

Commit b339073

Browse files
committed
Check for idr and lidr file in idris-switch-to-repl
1 parent 76d183c commit b339073

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

idris-common-utils.el

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@ corresponding values in the CDR of VALUE."
365365
'()
366366
`((t (error "ELISP destructure-case failed: %S" ,tmp))))))))
367367

368+
(defun idris-idr-p (&optional buffer)
369+
"Return t if BUFFER is an Idris file (.idr)."
370+
(if-let* ((file-name (buffer-file-name buffer)))
371+
(string-equal (downcase (file-name-extension file-name)) "idr")))
372+
368373
(defun idris-lidr-p (&optional buffer)
369-
"Return t if BUFFER is a literate Idris file, or nil otherwise.
370-
Use the current buffer if BUFFER is not supplied or is nil."
371-
(let ((file-name (buffer-file-name buffer)))
372-
;; We check for nil here because idris-lidr-p might be called on
373-
;; buffers that don't have associated files, such as the REPL
374-
;; buffer or an info buffer
375-
(and (stringp file-name)
376-
(string= (file-name-extension file-name) "lidr"))))
374+
"Return t if BUFFER is a literate Idris file (.lidr)."
375+
(if-let* ((file-name (buffer-file-name buffer)))
376+
(string-equal (downcase (file-name-extension file-name)) "lidr")))
377377

378378
(defun idris-make-file-link-overlay (start end keymap help-echo)
379379
(let ((overlay (make-overlay start end)))

idris-repl.el

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,11 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the end of the buffer."
189189
(autoload 'idris-load-file "idris-commands.el")
190190
;;;###autoload
191191
(defun idris-switch-to-repl ()
192-
"Select the output buffer and scroll to bottom."
192+
"Load the current Idris file buffer and jump to the Idris REPL."
193193
(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"))
194+
(if (or (idris-idr-p) (idris-lidr-p))
195+
(idris-load-file-sync)
196+
(user-error "This command can only be run from a buffer visiting an Idris `.idr' or `.lidr' file"))
199197
(pop-to-buffer (idris-repl-buffer))
200198
(goto-char (point-max)))
201199

0 commit comments

Comments
 (0)