branch: elpa/idris-mode
commit 115b409d685409ca5befd3116dbf05f55ca0ad98
Author: Marek L <[email protected]>
Commit: Marek L <[email protected]>
Allow idris-load-file-sync to ignore errors
Why:
When jumping to a repl from non-loaded file
we want to do optimistic load.
Ergo even if Idris finds errors in the file the jump
to the repl should succeed.
---
idris-commands.el | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/idris-commands.el b/idris-commands.el
index a5aaf2a7a4..eabdc08686 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -251,9 +251,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)
@@ -274,11 +276,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))))
+ `(:load-file ,fn))
+ no-errors))
(idris-currently-loaded-buffer (current-buffer)))
- (idris-update-options-cache)
- (idris-make-clean)
- (idris-update-loaded-region (car result)))))
+ ;; 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)
+ (idris-make-clean)
+ (idris-update-loaded-region (car result))))))
(user-error "Cannot find file for current buffer")))