1. Yaron Minsky
  2. js-elisp


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/check.sh

View file
  • Ignore whitespace

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

View file
  • Ignore whitespace
 ;; (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

View file
  • Ignore whitespace
   "The fullpath of a file"
   (assert (Omake.Error.is e))
   (let* ((id (Omake.Error.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

View file
  • Ignore whitespace
                              (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)
         (Omake.Project.watch id)
         (Omake.show-status-buffer 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

View file
  • Ignore whitespace
 ;; (Omake.Model.ids)
 (defun Omake.Model.models () (Hashtbl.data Omake.Model.table))
+;; (Omake.Model.models)
+;; (length (Omake.Model.models))
 (defun Omake.Model.has (id)
   (assert (Omake.Id.is id) t "Model.has: Not an id: %s")
       (error "No model for project: %s" (Omake.Id.to-string 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))))))
    (:predicate Omake.Model.is)
    (:constructor nil)
-    (id &aux
-             (_ (assert (Omake.Id.is id)))
-             (_ (when (Omake.Model.has id) (error "A model for %s already exists" id))))))
-  (id nil :read-only t)
+    (project &aux
+             (_ (assert (Omake.Project.is 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 (Omake.Model.id m)))
+(defun Omake.Model.id (m)
+  (assert (Omake.Model.is m))
+  (Omake.Project.id (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 (Omake.Project.is p))
   (let* ((id (Omake.Project.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" (Omake.Id.to-string 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" 'Omake.Face.red)
+   (Emacs.color "FATAL ERROR: The omake process is dead.\n\n" 'Omake.Face.error)
 ;; (insert (Omake.Model.dead-msg "sean"))
 (defun Omake.Model.to-string (model)
   (assert (Omake.Model.is model))
-  (let* ((id (Omake.Model.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

View file
  • Ignore whitespace
   (List.find (lambda (p) (equal (Omake.Project.id 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 Omake.Project.watch (id)
   (assert (Omake.Id.is id))
-  (unless (Omake.Model.has id)
+  (unless (Omake.Project.is-watching id)
       (let ((p (Omake.Project.find id))
             (file (Omake.File.elisp id))
 (defun Omake.Project.is-watching (id)
   (assert (Omake.Id.is id))
-  (Omake.Model.has id))
+  (Omake.Model.alive id))
 (defun Omake.Project.unwatch (id)
   (assert (Omake.Id.is 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 (Omake.Project.is-watching 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 (Omake.Connection.open-p)
-    (let ((remove-old-model
-           (lambda (ps m)
+    (let ((update-dead-model
+           (lambda (m)
              (let* ((p (Omake.Model.project m))
                     (id (Omake.Project.id p))
                     (ids (Omake.Id.to-string id)))
                (unless (List.find (lambda (p1) (equal id (Omake.Project.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/emacs.ml

View file
  • Ignore whitespace
 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)