1 ;;; rcompile.el Run a compilation on a remote machine
3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
5 ;; Author: Albert <alon@milcse.rtsg.mot.com>
9 ;; Keywords: tools, processes
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 ;;; This package is for running a remote compilation and using emacs to parse
30 ;;; the error messages. It works by rsh'ing the compilation to a remote host
31 ;;; and parsing the output. If the file visited at the time remote-compile was
32 ;;; called was loaded remotely (ange-ftp), the host and user name are obtained
33 ;;; by the calling ange-ftp-ftp-name on the current directory. In this case the
34 ;;; next-error command will also ange-ftp the files over. This is achieved
35 ;;; automatically because the compilation-parse-errors function uses
36 ;;; default-directory to build it's file names. If however the file visited was
37 ;;; loaded locally, remote-compile prompts for a host and user and assumes the
38 ;;; files mounted locally (otherwise, how was the visited file loaded).
40 ;;; See the user defined variables section for more info.
42 ;;; I was contemplating redefining "compile" to "remote-compile" automatically
43 ;;; if the file visited was ange-ftp'ed but decided against it for now. If you
44 ;;; feel this is a good idea, let me know and I'll consider it again.
48 ;;; To use rcompile, you also need to give yourself permission to connect to
49 ;;; the remote host. You do this by putting lines like:
54 ;;; in a file named .rhosts in the home directory (of the remote machine).
55 ;;; Be careful what you put in this file. A line like:
59 ;;; Will allow anyone access to your account without a password. I suggest you
60 ;;; read the rhosts(5) manual page before you edit this file (if you are not
61 ;;; familiar with it already)
67 ;;; The following should not be needed.
68 ;;; (eval-when-compile (require 'ange-ftp))
70 ;;;; user defined variables
72 (defvar remote-compile-rsh-command
73 (if (eq system-type
'usg-unix-v
) "remsh" "rsh")
74 "*Name of remote shell command: `rsh' for BSD or `remsh' for SYSV.")
76 (defvar remote-compile-host nil
77 "*Host for remote compilations.")
79 (defvar remote-compile-user nil
80 "User for remote compilations.
81 nil means use the value returned by \\[user-login-name].")
83 (defvar remote-compile-run-before nil
84 "*Command to run before compilation.
85 This can be used for setting up enviroment variables,
86 since rsh does not invoke the shell as a login shell and files like .login
87 \(tcsh\) and .bash_profile \(bash\) are not run.
88 nil means run no commands.")
90 (defvar remote-compile-prompt-for-host nil
91 "*Non-nil means prompt for host if not available from filename.")
93 (defvar remote-compile-prompt-for-user nil
94 "*Non-nil means prompt for user if not available from filename.")
96 ;;;; internal variables
98 ;; History of remote compile hosts and users
99 (defvar remote-compile-host-history nil
)
100 (defvar remote-compile-user-history nil
)
106 (defun remote-compile (host user command
)
107 "Compile the the current buffer's directory on HOST. Log in as USER.
110 (let ((parsed (or (and (featurep 'ange-ftp
)
111 (ange-ftp-ftp-name default-directory
))))
112 host user command prompt
)
114 (setq host
(nth 0 parsed
)
116 (setq prompt
(if (stringp remote-compile-host
)
117 (format "Compile on host (default %s): "
120 host
(if (or remote-compile-prompt-for-host
121 (null remote-compile-host
))
122 (read-from-minibuffer prompt
124 'remote-compile-host-history
)
126 user
(if remote-compile-prompt-for-user
127 (read-from-minibuffer (format
128 "Compile by user (default %s)"
129 (or remote-compile-user
132 'remote-compile-user-history
)
133 remote-compile-user
)))
134 (setq command
(read-from-minibuffer "Compile command: "
135 compile-command nil nil
136 '(compile-history .
1)))
137 (list (if (string= host
"") remote-compile-host host
)
138 (if (string= user
"") remote-compile-user user
)
140 (setq compile-command command
)
142 (setq remote-compile-user user
))
143 ((null remote-compile-user
)
144 (setq remote-compile-user
(user-login-name))))
145 (let* ((parsed (and (featurep 'ange-ftp
)
146 (ange-ftp-ftp-name default-directory
)))
148 (format "%s %s -l %s \"(%scd %s; %s)\""
149 remote-compile-rsh-command
152 (if remote-compile-run-before
153 (concat remote-compile-run-before
"; ")
155 (if parsed
(nth 2 parsed
) default-directory
)
157 (setq remote-compile-host host
)
158 (save-some-buffers nil nil
)
159 (compile-internal compile-command
"No more errors")
160 ;; Set comint-file-name-prefix in the compilation buffer so
161 ;; compilation-parse-errors will find referenced files by ange-ftp.
163 (set-buffer compilation-last-buffer
)
164 (setq comint-file-name-prefix
(concat "/" host
":")))))
166 ;;; rcompile.el ends here