annotate lisp/oobr/eif-ise-er.el @ 164:4e0740e5aab2

Added tag r20-3b8 for changeset 0132846995bd
author cvs
date Mon, 13 Aug 2007 09:43:39 +0200
parents 4be1180a9e89
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 ;;!emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; FILE: eif-ise-er.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; SUMMARY: Parses ISE's Eiffel error messages; compiles Eiffel classes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; USAGE: GNU Emacs Lisp Library
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; KEYWORDS: oop, tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; AUTHOR: Bob Weiner
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
9 ;; ORG: InfoDock Associates
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; ORIG-DATE: 7-Dec-89 at 00:17:18
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
12 ;; LAST-MOD: 31-Oct-96 at 22:39:09 by Bob Weiner
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
14 ;; Copyright (C) 1989-1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; See the file BR-COPY for license information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; This file is part of the OO-Browser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; DESCRIPTION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; 'eif-ec' compiles an Eiffel class.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; 'eif-es' compiles an Eiffel system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Load this library and then invoke error parsing via {C-x `}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; See the GNU Emacs Manual for an explanation of error parsing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; 'eif-ise-next-error' bound to {C-x `} parses ISE Eiffel compiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; error messages. As in:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; "my_class", 16: syntax error : Keyword 'expanded' may not be used as identifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Only handles compilation lines of the following form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; <compiler> [<option> ... <option>] <pathname>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Requires the 'br-class-path', 'br-build-sys-paths-htable', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; 'br-build-paths-htable' functions from the OO-Browser 'br-lib' package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; This is used to determine the full pathname for the source code of each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; class since ISE does not include any pathname information in its error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; To reset the {C-x `} key to parse non-Eiffel error messages, use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
45 ;; {M-x load-lib RET compile RET}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; DESCRIP-END.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (require 'br-lib)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (require 'br-eif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (require 'compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (global-set-key "\C-x`" 'eif-ise-next-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (and (boundp 'eiffel-mode-map) (define-key eiffel-mode-map "\C-c!" 'eif-ec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq compilation-error-regexp "\"\\([^ \t]+\\)\", \\([0-9]+\\):.*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defconst eif-compile-dir nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "Default directory in which to invoke an Eiffel compile command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defconst eif-compile-cmd "ec"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "Default command name with which to invoke the Eiffel compiler.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defun eif-ise-next-error (&optional argp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "Visit next compilation error message and corresponding source code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 This operates on the output from the \\[compile] command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 If all preparsed error messages have been processed,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 the error message buffer is checked for new ones.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 A non-nil argument (prefix arg, if interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 means reparse the error message buffer and start at the first error."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (if (or (eq compilation-error-list t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 argp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (progn (compilation-forget-errors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (setq compilation-parsing-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if compilation-error-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (switch-to-buffer "*compilation*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (eif-ise-compilation-parse-errors)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (let ((next-error (car compilation-error-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if (null next-error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (error (concat compilation-error-message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (if (and compilation-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (eq (process-status compilation-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 'run))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 " yet" ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (setq compilation-error-list (cdr compilation-error-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (if (null (car (cdr next-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (switch-to-buffer (marker-buffer (car (cdr next-error))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (goto-char (car (cdr next-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (set-marker (car (cdr next-error)) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (let* ((pop-up-windows t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (w (display-buffer (marker-buffer (car next-error)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (set-window-point w (car next-error))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (set-window-start w (car next-error)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (set-marker (car next-error) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defun eif-ise-compilation-filename ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Return a string which is the last filename from the compilation command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 Ignore quotes around it. Return nil if no filename was given."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; First arg of compile cmd should be filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (if (string-match "^.*[ \t]+\\([^ \t\"]+\\)" compile-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (substring compile-command (match-beginning 1) (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defun eif-ise-compilation-parse-errors ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Parse the current buffer as error messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 This makes a list of error descriptors, compilation-error-list. For each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 error line-number in the buffer, the source file is read in, and the text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 location is saved in compilation-error-list. The function next-error,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 assigned to \\[next-error], takes the next error off the list and visits its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 location."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (setq compilation-error-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (message "Parsing error messages...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (let (text-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 last-filename last-linenum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; Don't reparse messages already seen at last parse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (goto-char compilation-parsing-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; Don't parse the first two lines as error messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; This matters for grep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (bobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (forward-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (let (class-name case-fold-search linenum filename error-marker text-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (while (re-search-forward compilation-error-regexp nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; Extract line number from error message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (setq linenum (string-to-int (buffer-substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (match-beginning 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (match-end 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; Extract class name from error message and convert to the full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; pathname of the class' source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (setq class-name (downcase (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 filename (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if (null filename) ; No matching class name in lookup table.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (message "Rebuilding Eiffel system class locations table...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (sit-for 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (call-interactively 'br-build-sys-classes-htable) ; Typically pretty fast
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (message "Rebuilding Eiffel system class locations table...Done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (setq filename (br-class-path class-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (if (null filename)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 70
diff changeset
143 (error (format "'%s' not in lookup table, use {M-x br-build-paths-htable RET} to update."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 class-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; Locate the erring file and line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (and (equal filename last-filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (= linenum last-linenum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (setq error-marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; text-buffer gets the buffer containing this error's file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if (not (equal filename last-filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq text-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (and (file-exists-p (setq last-filename filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (boundp 'br-find-file-noselect-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (set-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (funcall br-find-file-noselect-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (find-file-noselect filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 last-linenum 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if text-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; Go to that buffer and find the erring line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (set-buffer text-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (zerop last-linenum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (setq last-linenum 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (forward-line (- linenum last-linenum))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq last-linenum linenum)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (setq text-marker (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq compilation-error-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (cons (list error-marker text-marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 compilation-error-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (forward-line 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (setq compilation-parsing-end (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (message "Parsing error messages...done")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (setq compilation-error-list (nreverse compilation-error-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; The following version of 'eif-ec' courtesy of:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; Heinz W. Schmidt hws@icsi.berkeley.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; International Computer Science Institute (415) 643-9153 x175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; 1947 Center Street, Ste. 600 /\/\|;; CLOS saves time and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; Berkeley, CA 94704 \/\/|-- Eiffel is faster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; 2/11/90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;; With a number of Bob Weiner's modifications
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun str2argv (STR)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (string-match "[^ ]" STR)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (let ((arg1 (read-from-string STR)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (cons (prin1-to-string (car arg1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (str2argv (substring STR (cdr arg1)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defvar eif-ec-args "" "Default arguments to send to the Eiffel ec class compiler.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defun eif-ec (ARG &optional CMD DIR CLASS-NAME)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 "Calls Eiffel compiler. Compile with optional CMD, 'eif-compile-cmd' or \"ec\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 By default, the compiler is called on the file associated with the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 buffer. With numeric argument 0 prompts for explicit command line arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 Other numeric arguments allow you to insert options or further class names."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (setq CLASS-NAME (or CLASS-NAME
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (let ((fn (file-name-nondirectory buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (substring fn 0 (- (length fn) 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ec-dir (or DIR eif-compile-dir (file-name-directory buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (let* ((ec-output (get-buffer-create "*compilation*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (ec-process (get-buffer-process ec-output))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (curr-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (if ec-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (y-or-n-p "Kill current Eiffel compilation process? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (delete-process ec-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (error "Can't ec concurrently.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (y-or-n-p (format "Save file %s? " buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (progn (save-buffer) (message "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;; Maybe prompt for args and dispatch according to numeric ARG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq eif-ec-args (if ARG (read-string "ec args: " eif-ec-args) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; Switch to shell buffer and run ec.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (set-buffer ec-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; Move to directory and trim classname so ec works in situations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; like: ec -t class1 <CLASS-NAME>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (cd ec-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (insert (or CMD eif-compile-cmd "ec")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if ARG (format " %s" eif-ec-args) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (format " %s" (if (not (and ARG (zerop ARG))) CLASS-NAME ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (set-buffer curr-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (display-buffer ec-output)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (eval
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (append '(start-process "ec" ec-output (or CMD eif-compile-cmd "ec"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (str2argv eif-ec-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (if (not (and ARG (zerop ARG))) (list CLASS-NAME))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun eif-es (&optional dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "Compile Eiffel system with es."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (eif-ec nil "es" dir ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (provide 'eif-ise-er)