Peter Szilagyi avatar Peter Szilagyi committed eda82ff

provisional fix for perpetual 'Starting' bug I introduced recently

Comments (0)

Files changed (1)

ocaml/omake/lib/project.ml

     Deferred.unit
   | Ok elisp ->
     logf t "New output";
-    (* Let's see if the file-based approach might be losing messages.
+    (* Keep the file up to date, because it's used to initialize the omake status buffer
+       when a fresh Emacs connects to a project. *)
+    let file = Files.elisp id in
+    Writer.save file ~contents:elisp >>| fun () ->
+    (* A file-based approach might lose messages, because Emacs evaluates this elisp
+       asynchronously.  In particular, by the time Emacs gets around to loading the file,
+       we may be somewhere in the process of writing the next version.
 
-       {[
-         let file = Files.elisp id in
-         Writer.save file ~contents:elisp >>| fun () ->
-         Emacs.Async.load_elisp_file id
-       ]}
+       [Emacs.Async.load_elisp_file id]
 
-       This has the disadvantage of sending lots of large log messages, although we can
-       tweak Emacs.send_str to override that. *)
-    Emacs.Async.send_gen ~id "%s" elisp;
-    Deferred.unit)
+       Fortunately, we can simply also send the elisp to Emacs, which will evaluate it in
+       the order it's received, in its entirety.  *)
+    Emacs.Async.send_gen ~id "%s" elisp)
 
 let kill_when_unwatched t =
   let ivar = Ivar.create () in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.