Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,11 @@ A prefix argument SET-LINE forces loading but only up to the current line."
(goto-char (overlay-end (car warnings-backward)))
(user-error "No warnings or errors until beginning of buffer"))))

(defun idris-load-file-sync ()
(defun idris-load-file-sync (&optional no-errors)
"Pass the current buffer's file synchronously to the inferior Idris process.
This sets the load position to point, if there is one."
This sets the load position to point, if there is one.

If NO-ERRORS is passed the warnings from Idris will be ignored."
(save-buffer)
(idris-ensure-process-and-repl-buffer)
(if (buffer-file-name)
Expand All @@ -275,11 +277,15 @@ This sets the load position to point, if there is one."
(idris-eval
(if idris-load-to-here
`(:load-file ,fn ,(idris-get-line-num idris-load-to-here))
`(:load-file ,fn)))))
(idris-update-options-cache)
(setq idris-currently-loaded-buffer (current-buffer))
(idris-make-clean)
(idris-update-loaded-region (car result)))))
`(:load-file ,fn))
no-errors)))
;; Currently on success the result contains `(nil)`, on failure just nil
(if (and no-errors (null result))
(message "Failed to load current file into Idris")
(idris-update-options-cache)
(setq idris-currently-loaded-buffer (current-buffer))
(idris-make-clean)
(idris-update-loaded-region (car result))))))
(user-error "Cannot find file for current buffer")))


Expand Down
10 changes: 7 additions & 3 deletions idris-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,12 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the end of the buffer."
(idris-repl-insert-prompt)
(insert current-input))))

(autoload 'idris-load-file-sync "idris-commands.el")
;;;###autoload
(defun idris-switch-to-repl ()
"Select the output buffer and scroll to bottom."
(interactive)
"Load the current Idris file buffer and jump to the Idris REPL."
(interactive nil idris-mode)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifying idris mode should exclude this command from M-x list in non idris-mode based buffers. Depends on user setting as per documentation:

If MODES is present, it should be one or more mode names (symbols)
for which this command is applicable.  This is so that ‘M-x TAB’
will be able to exclude this command from the list of completion
candidates if the current buffer’s mode doesn’t match the list.
Which commands are excluded from the list of completion
candidates based on this information is controlled by the value
of ‘read-extended-command-predicate’, which see.

(idris-load-file-sync t)
(pop-to-buffer (idris-repl-buffer))
(goto-char (point-max)))

Expand All @@ -199,7 +202,8 @@ If ALWAYS-INSERT is non-nil, always insert a prompt at the end of the buffer."
(defun idris-repl ()
(interactive)
(idris-run)
(idris-switch-to-repl))
(pop-to-buffer (idris-repl-buffer))
(goto-char (point-max)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed (idris-switch-to-repl) because user can invoke idris-repl without being in Idris file
and idris-switch-to-repl has now dependency to be invoked only within idr or lidr files.


(defvar idris-repl-mode-map
(let ((map (make-sparse-keymap)))
Expand Down