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

    Move processing syntax highlight responses to own event handler
    
    Why:
    Reduce responsibilities on `idris-load-file` and
    allow enable syntax highlight also for `idris-load-file-sync`
---
 idris-commands.el        | 17 +++++++----------
 idris-highlight-input.el |  7 +++++++
 inferior-idris.el        |  1 +
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/idris-commands.el b/idris-commands.el
index d4860c577b..9eaea2ec60 100644
--- a/idris-commands.el
+++ b/idris-commands.el
@@ -214,16 +214,13 @@ A prefix argument SET-LINE forces loading but only up to 
the current line."
                `(:load-file ,fn ,(idris-get-line-num idris-load-to-here))
              `(:load-file ,fn))
            (lambda (result)
-             (pcase result
-               (`(:highlight-source ,hs)
-                (idris-highlight-source-file hs))
-               (_ (idris-make-clean)
-                  (idris-update-options-cache)
-                  (setq idris-currently-loaded-buffer (current-buffer))
-                  (when (member 'warnings-tree idris-warnings-printing)
-                    (idris-list-compiler-notes))
-                  (run-hooks 'idris-load-file-success-hook)
-                  (idris-update-loaded-region result))))
+             (idris-make-clean)
+             (idris-update-options-cache)
+             (setq idris-currently-loaded-buffer (current-buffer))
+             (when (member 'warnings-tree idris-warnings-printing)
+               (idris-list-compiler-notes))
+             (run-hooks 'idris-load-file-success-hook)
+             (idris-update-loaded-region result))
            (lambda (_condition)
              (when (member 'warnings-tree idris-warnings-printing)
                (idris-list-compiler-notes))))))
diff --git a/idris-highlight-input.el b/idris-highlight-input.el
index 9d1471d7b5..719f7506bb 100644
--- a/idris-highlight-input.el
+++ b/idris-highlight-input.el
@@ -138,5 +138,12 @@ Otherwise return current value of 
`idris-semantic-source-highlighting'"
              "Customize `idris-semantic-source-highlighting-max-buffer-size' 
to enable it.")
     nil))
 
+(defun idris-syntax-highlight-event-hook-function (event)
+  (pcase event
+    (`(:output (:ok (:highlight-source ,hs)) ,_target)
+     (idris-highlight-source-file hs)
+     t)
+    (_ nil)))
+
 (provide 'idris-highlight-input)
 ;;; idris-highlight-input.el ends here
diff --git a/inferior-idris.el b/inferior-idris.el
index adf3341112..a052442bdb 100644
--- a/inferior-idris.el
+++ b/inferior-idris.el
@@ -84,6 +84,7 @@ This is maintained to restart Idris when the arguments 
change.")
     (add-hook 'idris-event-hooks 'idris-log-hook-function)
     (add-hook 'idris-event-hooks 'idris-warning-event-hook-function)
     (add-hook 'idris-event-hooks 'idris-prover-event-hook-function)
+    (add-hook 'idris-event-hooks 'idris-syntax-highlight-event-hook-function)
 
     (if idris-hole-show-on-load
         (progn

Reply via email to