[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The Top-Level Loop from Hell...



  I've been trying to write a top-level loop for a standalone app
which will allow a user to evaluate forms from fred windows via
eval-selection or eval-buffer.  No matter what I do the forms just
seem to get queued up until I restore the normal toplevel-loop.  I
could just use toplevel-loop but I want to provide an idiot-proof
error handling mechanism.  Below is the code for the loop I'm playing
with now.  Sorry to repost this question, but I didn't get a
satisfactory response last time.  Help!!!  I'm at the end of my
rope!!!  Thanks in advance.

   ...Bill (waander@cs.umd.edu)

=================================================

(defun inner-main-loop (&aux abort-or-cancel-p)
  (multiple-value-bind (result error-p)
    (catch-error-quietly
      (setq abort-or-cancel-p
            (catch-abort
              (catch-cancel
                (multiple-value-bind (form form-supplied-p)
                                     (ask *terminal-io* (get-next-form))
                  (when form-supplied-p
                    (eval form)))
                (event-dispatch))))
      (when (or (eq abort-or-cancel-p :abort)
                (eq abort-or-cancel-p :cancel))
        (message-dialog (format nil "~aed." abort-or-cancel-p))))
    (when error-p
      (unless (y-or-n-dialog
               (format nil "The following error occured:~%~s~%Continue, or quit the application?"
                       (apply #'format nil result))
               :yes-text "Continue"
               :no-text "Quit"
               :cancel-text nil)   ;no cancel button
        (app-quit)))))