branch: elpa/idris-mode
commit a04bf0c31756d8451c0ccdf0f842611fa0c71ad1
Author: Marek L <[email protected]>
Commit: Marek L <[email protected]>

    Move call to idris-list-compiler-notes from idris-eval to idris-user-eval
    
    This removes dependency of inferior-idris module on idris-commands
    and avoids displaying idris notes to evaluations that have not
    been related to user input.
---
 idris-commands.el |  9 ++++++++-
 inferior-idris.el | 13 +++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/idris-commands.el b/idris-commands.el
index b8599d6d60..ddb73cec2f 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -271,7 +271,7 @@ This sets the load position to point, if there is one."
           (idris-switch-working-directory srcdir)
           (idris-toggle-semantic-source-highlighting)
           (let ((result
-                 (idris-user-eval
+                 (idris-eval
                   (if idris-load-to-here
                       `(:load-file ,fn ,(idris-get-line-num 
idris-load-to-here))
                     `(:load-file ,fn))))
@@ -288,6 +288,8 @@ This sets the load position to point, if there is one."
   (let* ((ty (idris-eval (list command name)))
          (result (car ty))
          (formatting (cdr ty)))
+    (when (member 'warnings-tree idris-warnings-printing)
+      (idris-list-compiler-notes))
     (idris-show-info (format "%s" result) formatting)))
 
 
@@ -1401,8 +1403,13 @@ of the term to replace."
 (defun idris-user-eval (what &optional no-errors)
   "Send WHAT to Idris process and return first item in the response.
 
+When `idris-warnings-printing' includes `warnings-tree' it also
+ calls `idris-list-compiler-notes' to display or update existing Idris notes.
+
 If `NO-ERRORS' is non-nil, don't raise `ERROR' if there was an Idris error."
   (let ((ty (idris-eval what no-errors)))
+    (when (member 'warnings-tree idris-warnings-printing)
+      (idris-list-compiler-notes))
     (car ty)))
 
 (provide 'idris-commands)
diff --git a/inferior-idris.el b/inferior-idris.el
index 18b330a3e8..44a64e675c 100644
--- a/inferior-idris.el
+++ b/inferior-idris.el
@@ -305,11 +305,9 @@ versions cannot deal with that."
 (defvar idris-stack-eval-tags nil
   "List of stack-tags of continuations waiting on the stack.")
 
-(autoload 'idris-list-compiler-notes "idris-commands.el")
 (defun idris-eval (sexp &optional no-errors)
   "Evaluate SEXP on the inferior Idris and return the result.
-If `NO-ERRORS' is non-nil, don't trigger warning buffers and
- don't call `ERROR' if there was an Idris error."
+If `NO-ERRORS' is non-nil, don't call `ERROR' if there was an Idris error."
   (let* ((tag (gensym (format "idris-result-%d-"
                               (1+ idris-continuation-counter))))
          (idris-stack-eval-tags (cons tag idris-stack-eval-tags)))
@@ -326,11 +324,10 @@ If `NO-ERRORS' is non-nil, don't trigger warning buffers 
and
               (error "Reply to canceled synchronous eval request tag=%S 
sexp=%S"
                      tag sexp))))
          ((:error condition &optional _spans)
-          (if no-errors
-              (throw tag (list #'identity nil))
-            (when (member 'warnings-tree idris-warnings-printing)
-              (idris-list-compiler-notes))
-            (throw tag (list #'error "%s (synchronous Idris evaluation 
failed)" condition)))))
+          (throw tag (if no-errors
+                         ;; TODO: better way to communicate error upstream
+                         (list #'identity (cons :error condition))
+                       (list #'user-error "%s (synchronous Idris evaluation 
failed)" condition)))))
        (let ((debug-on-quit t)
              (inhibit-quit nil))
          (while t

Reply via email to