1 ;;; -*- Mode: Emacs-Lisp -*-
4 ;;; Inferior LISP interaction package batch submodule.
5 ;;; See ilisp.el for more information.
7 ;;; This file is part of ILISP.
8 ;;; Please refer to the file COPYING for copyrights and licensing
10 ;;; Please refer to the file ACKNOWLEGDEMENTS for an (incomplete) list
11 ;;; of present and past contributors.
13 ;;; $Id: ilisp-bat.el,v 1.3 2001-07-02 09:40:45 youngs Exp $
15 (defun mark-change-lisp (arg)
16 "Mark the current defun as being changed.
17 This is to make 'lisp-eval-changes' or 'lisp-compile-changes' work on
18 it. With a prefix, unmark."
22 (setq point (lisp-defun-begin)
23 name (lisp-def-name)))
25 (let ((marker (car (member* point lisp-changes
27 :key #'marker-position))))
28 (message "%s marked as unchanged" name)
29 (setq lisp-changes (delq marker lisp-changes)))
30 (message "%s marked as changed" name)
31 (if (not (member* point lisp-changes
33 :key #'marker-position))
34 (let ((new (make-marker)))
35 (set-marker new point)
36 (setq lisp-changes (cons new lisp-changes)))))))
39 (defun list-changes-lisp ()
40 "List the name of LISP forms currently marked as being changed."
42 (let ((names (reverse (mapcar (function
45 (set-buffer (marker-buffer change))
50 (with-output-to-temp-buffer "*Changed-Definitions*"
51 (display-completion-list names)
53 (set-buffer "*Changed-Definitions*")
54 (goto-char (point-min))
56 (insert "Changed LISP forms:")))
57 (error "No changed definitions"))))
60 (defun clear-changes-lisp ()
61 "Clear the list of LISP forms currently marked as being changed."
63 (message "Cleared changes")
64 (setq lisp-changes nil))
67 (defun lisp-change-handler (&rest args)
68 "Handle an error during a batch process by keeping the change on the
69 list and passing it on to the normal error handler."
70 (let ((change (car ilisp-pending-changes)))
71 (when (and comint-errorp
72 (not (member* change lisp-changes
74 :key #'marker-position)))
75 (setq lisp-changes (nconc lisp-changes (cons change nil)))))
76 (setq ilisp-pending-changes (cdr ilisp-pending-changes))
77 (apply comint-handler args))
80 (defun lisp-changes (command message)
81 "Apply COMMAND to each of the changes and use MESSAGE to print a
82 message given the name of the change. If there is a positive prefix,
83 the change list will not be changed."
85 (set-buffer (ilisp-buffer))
86 (let ((keep (and current-prefix-arg (not (eq current-prefix-arg '-))))
87 (changes (reverse lisp-changes))
89 (setq ilisp-pending-changes (nconc ilisp-pending-changes changes)
90 current-prefix-arg nil) ;Prevent buffer insertion
91 (if comint-queue-emptied
93 (setq comint-queue-emptied nil)
94 (set-buffer (get-buffer-create "*Errors*"))
95 (delete-region (point-min) (point-max))))
97 (let* ((change (car changes))
99 (set-buffer (marker-buffer change))
101 (setq name (lisp-def-name))
103 (funcall command change (point) nil (format message name)
104 nil 'lisp-change-handler)
105 (setq changes (cdr changes))))
110 (set-buffer (get-buffer-create "*Last-Changes*"))
111 (delete-region (point-min) (point-max))
112 (insert (save-excursion
113 (set-buffer "*Errors*")
114 (buffer-string)))))))
116 (message "Started, but keeping changes")
117 (message "Started changes")
118 (setq lisp-changes nil)))))
121 (defun eval-changes-lisp ()
122 "Evaluate the forms marked as being changed. With prefix, do not
123 clear the change list."
125 (lisp-changes 'eval-region-lisp "Evaluate changed %s"))
128 (defun compile-changes-lisp ()
129 "Compile the forms marked as being changed. With prefix, do not
130 clear the change list."
132 (lisp-changes 'compile-region-lisp "Compile changed %s"))