seanmcl  committed 14771aa

models now have nested projects, so we can keep the status buffer around when the omake process dies.

  • Participants
  • Parent commits a37aa93
  • Branches default

Comments (0)

Files changed (7)

File bin/


File elisp/jane/jane-micro-features.el

 ;; (Jane.server)
+  (require 'server)
   (defun Jane.server ()
     "Server stuff"
-    (require 'server)
     ;; If there's another server running, (server-start) will
     ;; fail.  Don't die if this happens.
     ;; (server-running-p) can also hang when there is a stopped

File elisp/omake/omake-error.el

   "The fullpath of a file"
   (assert ( e))
   (let* ((id ( e))
-         (project (Omake.Project.find id))
+         (model (Omake.Model.get id))
+         (project (Omake.Model.project model))
          (root (Omake.Project.omakeroot-dir project))
          (relpath (Omake.Error.relpath e))
          (file (Omake.Error.file e)))
 (defun* Omake.Error (&key hash id relpath file line char-beg char-end text full-text)
   "The constructor caches the string representation."
   (let* ((e (Omake.Error.make
-             :hash hash 
+             :hash hash
              :id id :relpath relpath :file file :line line :char-beg char-beg
              :char-end char-end :text text :full-text full-text))
          (cached (gethash e Omake.Error.table)))

File elisp/omake/omake-interface.el

                              (Omake.Project.compilation-dir project) path watch-msg))))
               (if (not kill) (throw 'exit t)
                 (Omake.kill-project id :force t))))
+          ;; Make sure there's no old model
+          (Omake.Model.kill id)
           ;; Now there is no running project, so we start it.
           (let* ((config (Omake.Ocaml.Config.omake-command))
              (initial (when (member cid ps) cid))
              (id (if id id (Omake.Id.of-path
                             (completing-read "Project: " ps nil t initial)))))
+        ;; Kill any old model for the project
+        (Omake.Model.kill id)
         ( id)
         ( id)))))
   ;; project buffers should be dead now
+  ;; CR smclaughlin: no longer true.  We need to kill the status buffers
+  ;; that will show that the underlying omake process is dead
 (defun Omake.shutdown-and-remove-hooks ()

File elisp/omake/omake-model.el

 ;; (Omake.Model.ids)
 (defun Omake.Model.models () ( Omake.Model.table))
+;; (Omake.Model.models)
+;; (length (Omake.Model.models))
 (defun Omake.Model.has (id)
   (assert ( id) t "Model.has: Not an id: %s")
       (error "No model for project: %s" ( id))
     (gethash id Omake.Model.table)))
+(defun Omake.Model.alive (id)
+  (and (Omake.Model.has id)
+       (let ((m (Omake.Model.get id)))
+         (not (Omake.Status.dead-p (Omake.Model.status m))))))
    (:constructor nil)
-    (id &aux
-             (_ (assert ( id)))
-             (_ (when (Omake.Model.has id) (error "A model for %s already exists" id))))))
-  (id nil :read-only t)
+    (project &aux
+             (_ (assert ( project))))))
+  (project nil :read-only t)
   (spinner (Omake.Spinner.create))
   (verbose nil)
   (progress-bar '(0 . 0))
   (result (Omake.Result.Ring (Omake.Ring.empty)))
   (error-msg nil))
-(defun Omake.Model.project (m)
-  (Omake.Project.find ( m)))
+(defun (m)
+  (assert ( m))
+  ( (Omake.Model.project m)))
 (defun Omake.Model.status-buffer (m)
   (Omake.Buffer.get 'status (Omake.Model.project m)))
   "Create an Emacs view of the ocaml project."
   (assert ( p))
   (let* ((id ( p))
-         (model (Omake.Model id)))
-    (when (Omake.Model.has id)
+         (model (Omake.Model p)))
+    (when (Omake.Model.alive id)
       (error "Model already exists: %s" ( id)))
     (puthash id model Omake.Model.table)))
              (project (Omake.Model.project model))
              (dir (Omake.Project.omakeroot-dir project)))
         ;; Critical section
-        ;(Omake.Buffer.kill 'status project t)
+        (Omake.Buffer.kill 'status project t)
         (Omake.Buffer.kill 'raw project)
         (Omake.Buffer.kill 'elisp project)
         (Omake.Buffer.kill 'project-log project)
 (defun Omake.Model.dead-msg (msg)
-   (Emacs.color "FATAL ERROR: The omake process is dead.\n\n" '
+   (Emacs.color "FATAL ERROR: The omake process is dead.\n\n" 'Omake.Face.error)
 ;; (insert (Omake.Model.dead-msg "sean"))
 (defun (model)
   (assert ( model))
-  (let* ((id ( model))
-         (project (Omake.Project.find id))
+  (let* ((project (Omake.Model.project model))
          ;; model state
          (status (Omake.Model.status model))
          (successful (Omake.Model.done model))
 (defun Omake.Model.current ()
   (Omake.Model.get (Omake.Id.current)))
-(defun Omake.Project.current ()
-  (Omake.Model.project (Omake.Model.current)))
 (provide 'omake-model)

File elisp/omake/omake-project.el

   (List.find (lambda (p) (equal ( p) id)) Omake.Project.list))
 ;; (Omake.Project.find (Omake.Id.of-path "/home/seanmcl/ocaml/ocaml1"))
+(defun Omake.Project.current ()
+  (Omake.Model.project (Omake.Model.current)))
 (defun (id)
   (assert ( id))
-  (unless (Omake.Model.has id)
+  (unless ( id)
       (let ((p (Omake.Project.find id))
             (file (Omake.File.elisp id))
 (defun (id)
   (assert ( id))
-  (Omake.Model.has id))
+  (Omake.Model.alive id))
 (defun Omake.Project.unwatch (id)
   (assert ( id))
        (_ (define-key line-keymap (kbd "C-m") dired))
        (fullroot (expand-file-name root))
        (dir (Omake.Project.compilation-dir-relpath p))
-       (watched (if (Omake.Model.has id) "yes" "no"))
+       (watched (if ( id) "yes" "no"))
        (num (Omake.Project.num-watchers p))
        (str (format "[%d] %-8s %-11d %-25s %s\n" i watched num root dir)))
     (propertize str 'keymap line-keymap)))
   "Update the view of the projects with the server."
   ;; Ignore updates when the connection is down
   (when (
-    (let ((remove-old-model
-           (lambda (ps m)
+    (let ((update-dead-model
+           (lambda (m)
              (let* ((p (Omake.Model.project m))
                     (id ( p))
                     (ids ( id)))
                (unless (List.find (lambda (p1) (equal id ( p1))) ps)
-                 (message "The project for %s was killed.  Removing the view." ids)
-                 (Omake.Model.kill id)))))
-          (update-new-env
-           (lambda () )))
-      (mapc (lambda (m) (funcall remove-old-model ps m)) (Omake.Model.models))
+                 ;; (message "The project for %s is dead." ids)
+                 (setf (Omake.Model.status m) Omake.Status.Dead))))))
+      (mapc (lambda (m) (funcall update-dead-model m)) (Omake.Model.models))
       (setq Omake.Project.list ps)
       (Omake.Project.create-buffer :display nil)
+;; (Omake.Project.update nil)
 (provide 'omake-project)

File ocaml/omake/

 let kill_model id =
-  Async.send_all_watching id
-    "(Omake.Model.kill (Omake.Id.of-path \"%s\"))" (Id.to_string id);
+  (* Async.send_all_watching id *)
+  (*   "(Omake.Model.kill (Omake.Id.of-path \"%s\"))" (Id.to_string id); *)
   Hashtbl.iter table ~f:(fun ~key:_ ~data:t -> Hash_set.remove t.watching id)