2
|
1 ;;; rcompile.el --- run a compilation on a remote machine
|
0
|
2
|
2
|
3 ;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
|
0
|
4
|
|
5 ;; Author: Albert <alon@milcse.rtsg.mot.com>
|
|
6 ;; Maintainer: FSF
|
|
7 ;; Created: 1993 Oct 6
|
|
8 ;; Version: 1.1
|
|
9 ;; Keywords: tools, processes
|
|
10
|
2
|
11 ;; This file is part of XEmacs.
|
0
|
12
|
2
|
13 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
14 ;; under the terms of the GNU General Public License as published by
|
0
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
2
|
18 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
21 ;; General Public License for more details.
|
0
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
2
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
25 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
26 ;; 02111-1307, USA.
|
0
|
27
|
2
|
28 ;;; Synched up with: FSF 19.34.
|
0
|
29
|
|
30 ;;; Commentary:
|
|
31
|
2
|
32 ;; This package is for running a remote compilation and using emacs to parse
|
|
33 ;; the error messages. It works by rsh'ing the compilation to a remote host
|
|
34 ;; and parsing the output. If the file visited at the time remote-compile was
|
|
35 ;; called was loaded remotely (ange-ftp), the host and user name are obtained
|
|
36 ;; by the calling ange-ftp-ftp-name on the current directory. In this case the
|
|
37 ;; next-error command will also ange-ftp the files over. This is achieved
|
|
38 ;; automatically because the compilation-parse-errors function uses
|
|
39 ;; default-directory to build it's file names. If however the file visited was
|
|
40 ;; loaded locally, remote-compile prompts for a host and user and assumes the
|
|
41 ;; files mounted locally (otherwise, how was the visited file loaded).
|
0
|
42
|
2
|
43 ;; See the user defined variables section for more info.
|
0
|
44
|
2
|
45 ;; I was contemplating redefining "compile" to "remote-compile" automatically
|
|
46 ;; if the file visited was ange-ftp'ed but decided against it for now. If you
|
|
47 ;; feel this is a good idea, let me know and I'll consider it again.
|
0
|
48
|
|
49 ;;; Installation:
|
|
50
|
2
|
51 ;; To use rcompile, you also need to give yourself permission to connect to
|
|
52 ;; the remote host. You do this by putting lines like:
|
0
|
53
|
2
|
54 ;; monopoly alon
|
|
55 ;; vme33
|
|
56 ;;
|
|
57 ;; in a file named .rhosts in the home directory (of the remote machine).
|
|
58 ;; Be careful what you put in this file. A line like:
|
|
59 ;;
|
|
60 ;; +
|
|
61 ;;
|
|
62 ;; Will allow anyone access to your account without a password. I suggest you
|
|
63 ;; read the rhosts(5) manual page before you edit this file (if you are not
|
|
64 ;; familiar with it already)
|
0
|
65
|
|
66 ;;; Code:
|
|
67
|
|
68 (provide 'rcompile)
|
|
69 (require 'compile)
|
|
70 ;;; The following should not be needed.
|
|
71 ;;; (eval-when-compile (require 'ange-ftp))
|
|
72
|
|
73 ;;;; user defined variables
|
|
74
|
134
|
75 (defgroup remote-compile nil
|
|
76 "Run a compilation on a remote machine"
|
|
77 :group 'processes
|
|
78 :group 'tools)
|
|
79
|
0
|
80
|
134
|
81 (defcustom remote-compile-host nil
|
|
82 "*Host for remote compilations."
|
|
83 :type '(choice string (const nil))
|
|
84 :group 'remote-compile)
|
|
85
|
|
86 (defcustom remote-compile-user nil
|
0
|
87 "User for remote compilations.
|
134
|
88 nil means use the value returned by \\[user-login-name]."
|
|
89 :type '(choice string (const nil))
|
|
90 :group 'remote-compile)
|
0
|
91
|
134
|
92 (defcustom remote-compile-run-before nil
|
0
|
93 "*Command to run before compilation.
|
2
|
94 This can be used for setting up environment variables,
|
0
|
95 since rsh does not invoke the shell as a login shell and files like .login
|
|
96 \(tcsh\) and .bash_profile \(bash\) are not run.
|
134
|
97 nil means run no commands."
|
|
98 :type '(choice string (const nil))
|
|
99 :group 'remote-compile)
|
0
|
100
|
134
|
101 (defcustom remote-compile-prompt-for-host nil
|
|
102 "*Non-nil means prompt for host if not available from filename."
|
|
103 :type 'boolean
|
|
104 :group 'remote-compile)
|
0
|
105
|
134
|
106 (defcustom remote-compile-prompt-for-user nil
|
|
107 "*Non-nil means prompt for user if not available from filename."
|
|
108 :type 'boolean
|
|
109 :group 'remote-compile)
|
0
|
110
|
|
111 ;;;; internal variables
|
|
112
|
|
113 ;; History of remote compile hosts and users
|
|
114 (defvar remote-compile-host-history nil)
|
|
115 (defvar remote-compile-user-history nil)
|
|
116
|
|
117
|
|
118 ;;;; entry point
|
|
119
|
|
120 ;;;###autoload
|
|
121 (defun remote-compile (host user command)
|
2
|
122 "Compile the current buffer's directory on HOST. Log in as USER.
|
0
|
123 See \\[compile]."
|
|
124 (interactive
|
120
|
125 (let ((parsed
|
|
126 ;; XEmacs change
|
|
127 (cond
|
|
128 ((featurep 'efs)
|
|
129 (efs-ftp-path default-directory))
|
|
130 ((featurep 'ange-ftp)
|
|
131 (if (fboundp 'ange-ftp-ftp-name)
|
|
132 (ange-ftp-ftp-name default-directory)
|
|
133 (ange-ftp-ftp-path default-directory)))
|
|
134 (t nil)))
|
0
|
135 host user command prompt)
|
|
136 (if parsed
|
|
137 (setq host (nth 0 parsed)
|
|
138 user (nth 1 parsed))
|
|
139 (setq prompt (if (stringp remote-compile-host)
|
|
140 (format "Compile on host (default %s): "
|
|
141 remote-compile-host)
|
|
142 "Compile on host: ")
|
|
143 host (if (or remote-compile-prompt-for-host
|
|
144 (null remote-compile-host))
|
|
145 (read-from-minibuffer prompt
|
|
146 "" nil nil
|
|
147 'remote-compile-host-history)
|
|
148 remote-compile-host)
|
|
149 user (if remote-compile-prompt-for-user
|
|
150 (read-from-minibuffer (format
|
|
151 "Compile by user (default %s)"
|
|
152 (or remote-compile-user
|
|
153 (user-login-name)))
|
|
154 "" nil nil
|
|
155 'remote-compile-user-history)
|
|
156 remote-compile-user)))
|
|
157 (setq command (read-from-minibuffer "Compile command: "
|
|
158 compile-command nil nil
|
|
159 '(compile-history . 1)))
|
|
160 (list (if (string= host "") remote-compile-host host)
|
|
161 (if (string= user "") remote-compile-user user)
|
|
162 command)))
|
|
163 (setq compile-command command)
|
|
164 (cond (user
|
|
165 (setq remote-compile-user user))
|
|
166 ((null remote-compile-user)
|
|
167 (setq remote-compile-user (user-login-name))))
|
120
|
168 (let* ((parsed
|
|
169 ;; XEmacs change
|
|
170 (cond
|
|
171 ((featurep 'efs)
|
|
172 (efs-ftp-path default-directory))
|
|
173 ((featurep 'ange-ftp)
|
|
174 (if (fboundp 'ange-ftp-ftp-name)
|
|
175 (ange-ftp-ftp-name default-directory)
|
|
176 (ange-ftp-ftp-path default-directory)))
|
|
177 (t nil)))
|
0
|
178 (compile-command
|
|
179 (format "%s %s -l %s \"(%scd %s; %s)\""
|
|
180 remote-shell-program
|
|
181 host
|
|
182 remote-compile-user
|
|
183 (if remote-compile-run-before
|
|
184 (concat remote-compile-run-before "; ")
|
|
185 "")
|
|
186 (if parsed (nth 2 parsed) default-directory)
|
|
187 compile-command)))
|
|
188 (setq remote-compile-host host)
|
|
189 (save-some-buffers nil nil)
|
|
190 (compile-internal compile-command "No more errors")
|
|
191 ;; Set comint-file-name-prefix in the compilation buffer so
|
|
192 ;; compilation-parse-errors will find referenced files by ange-ftp.
|
|
193 (save-excursion
|
|
194 (set-buffer compilation-last-buffer)
|
|
195 (setq comint-file-name-prefix (concat "/" host ":")))))
|
|
196
|
|
197 ;;; rcompile.el ends here
|