annotate lisp/ilisp/ilisp-hnd.el @ 58:8b0bdfdf0cf0 r19-16-pre4

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