home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / ilisp / ilisp-hnd.el < prev    next >
Encoding:
Text File  |  1995-01-26  |  3.0 KB  |  107 lines

  1. ;;; -*- Mode: Emacs-Lisp -*-
  2.  
  3. ;;; ilisp-hnd.el --
  4.  
  5. ;;; This file is part of ILISP.
  6. ;;; Version: 5.7
  7. ;;;
  8. ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
  9. ;;;               1993, 1994 Ivan Vasquez
  10. ;;;               1994, 1995 Marco Antoniotti and Rick Busdiecker
  11. ;;;
  12. ;;; Other authors' names for which this Copyright notice also holds
  13. ;;; may appear later in this file.
  14. ;;;
  15. ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
  16. ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
  17. ;;; mailing list were bugs and improvements are discussed.
  18. ;;;
  19. ;;; ILISP is freely redistributable under the terms found in the file
  20. ;;; COPYING.
  21.  
  22.  
  23. ;;;
  24. ;;; ILISP Error handler
  25. ;;;
  26.  
  27.  
  28. ;; Do not handle errors by default.
  29. (defvar ilisp-handle-errors nil)
  30.  
  31. ;;;
  32. (defun ilisp-handler (error-p wait-p message output prompt)
  33.   "Given ERROR-P, WAIT-P, MESSAGE, OUTPUT and PROMPT, show the message
  34. and output if there is an error or the output is multiple lines and
  35. let the user decide what to do."
  36.   (if (not ilisp-handle-errors)
  37.       (progn
  38.     (if message
  39.         (progn
  40.           (setq ilisp-last-message message
  41.             ilisp-last-prompt prompt)
  42.           (if (not wait-p) (lisp-display-output output))))
  43.     nil)
  44.     (if (and (not wait-p)
  45.          (setq output (comint-remove-whitespace output))
  46.          (or error-p (string-match "\n" output)))
  47.     (let* ((buffer (ilisp-output-buffer))
  48.            (out (if error-p 
  49.             (funcall ilisp-error-filter output)
  50.               output))
  51.            (key
  52.         (if (and error-p (not (comint-interrupted)))
  53.             (comint-handle-error
  54.              out
  55.      "SPC-scroll, I-ignore, K-keep, A-abort sends and keep or B-break: "
  56.              '(?i ?k ?a ?b))
  57.           (comint-handle-error 
  58.            out 
  59.        "SPC-scroll, I-ignore, K-keep or A-abort sends and keep: "
  60.            '(?i ?k ?a))))
  61.            (clear comint-queue-emptied))
  62.       (if (= key ?i)
  63.           (progn
  64.         (message "Ignore message")
  65.         (if buffer 
  66.             (funcall
  67.              (ilisp-temp-buffer-show-function)
  68.              buffer)
  69.           (ilisp-bury-output))
  70.         t)
  71.         (save-excursion
  72.           (set-buffer (get-buffer-create "*Errors*"))
  73.           (if clear (delete-region (point-min) (point-max)))
  74.           (goto-char (point-max))
  75.           (insert message)
  76.           (insert ?\n)
  77.           (insert out) 
  78.           (insert "\n\n"))
  79.         (if clear (setq comint-queue-emptied nil))
  80.         (if (= key ?a)
  81.         (progn 
  82.           (message "Abort pending commands and keep in *Errors*")
  83.           (comint-abort-sends)
  84.           t)
  85.           (if (= key ?b)
  86.           (progn 
  87.             (comint-insert
  88.              (concat comment-start comment-start comment-start
  89.                  message "\n"
  90.                  output "\n" prompt))
  91.             (message "Preserve break") nil)
  92.         (message "Keep error in *Errors* and continue")
  93.         t))))
  94.       t)))
  95.  
  96. ;;;
  97. (defun ilisp-abort-handler ()
  98.   "Handle when the user aborts commands."
  99.   (setq ilisp-initializing nil
  100.     ilisp-load-files nil)
  101.   (let ((add nil))
  102.     (while ilisp-pending-changes
  103.       (if (not (memq (car ilisp-pending-changes) lisp-changes))
  104.       (setq add (cons (car ilisp-pending-changes) add)))
  105.       (setq ilisp-pending-changes (cdr ilisp-pending-changes)))
  106.     (setq lisp-changes (nconc lisp-changes add))))
  107.