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 the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
30 ;; This package is for running a remote compilation and using emacs to parse
31 ;; the error messages. It works by rsh'ing the compilation to a remote host
32 ;; and parsing the output. If the file visited at the time remote-compile was
33 ;; called was loaded remotely (ange-ftp), the host and user name are obtained
34 ;; by the calling ange-ftp-ftp-name on the current directory. In this case the
35 ;; next-error command will also ange-ftp the files over. This is achieved
36 ;; automatically because the compilation-parse-errors function uses
37 ;; default-directory to build it's file names. If however the file visited was
38 ;; loaded locally, remote-compile prompts for a host and user and assumes the
39 ;; files mounted locally (otherwise, how was the visited file loaded).
41 ;; See the user defined variables section for more info.
43 ;; I was contemplating redefining "compile" to "remote-compile" automatically
44 ;; if the file visited was ange-ftp'ed but decided against it for now. If you
45 ;; feel this is a good idea, let me know and I'll consider it again.
49 ;; To use rcompile, you also need to give yourself permission to connect to
50 ;; the remote host. You do this by putting lines like:
55 ;; in a file named .rhosts in the home directory (of the remote machine).
56 ;; Be careful what you put in this file. A line like:
60 ;; Will allow anyone access to your account without a password. I suggest you
61 ;; read the rhosts(5) manual page before you edit this file (if you are not
62 ;; familiar with it already)
68 ;;; The following should not be needed.
69 ;;; (eval-when-compile (require 'ange-ftp))
71 ;;;; user defined variables
73 (defvar remote-compile-host nil
74 "*Host for remote compilations.")
76 (defvar remote-compile-user nil
77 "User for remote compilations.
78 nil means use the value returned by \\[user-login-name].")
80 (defvar remote-compile-run-before nil
81 "*Command to run before compilation.
82 This can be used for setting up environment variables,
83 since rsh does not invoke the shell as a login shell and files like .login
84 \(tcsh\) and .bash_profile \(bash\) are not run.
85 nil means run no commands.")
87 (defvar remote-compile-prompt-for-host nil
88 "*Non-nil means prompt for host if not available from filename.")
90 (defvar remote-compile-prompt-for-user nil
91 "*Non-nil means prompt for user if not available from filename.")
93 ;;;; internal variables
95 ;; History of remote compile hosts and users
96 (defvar remote-compile-host-history nil
)
97 (defvar remote-compile-user-history nil
)
103 (defun remote-compile (host user command
)
104 "Compile the the current buffer's directory on HOST. Log in as USER.
107 (let ((parsed (or (and (featurep 'ange-ftp
)
108 (ange-ftp-ftp-name default-directory
))))
109 host user command prompt
)
111 (setq host
(nth 0 parsed
)
113 (setq prompt
(if (stringp remote-compile-host
)
114 (format "Compile on host (default %s): "
117 host
(if (or remote-compile-prompt-for-host
118 (null remote-compile-host
))
119 (read-from-minibuffer prompt
121 'remote-compile-host-history
)
123 user
(if remote-compile-prompt-for-user
124 (read-from-minibuffer (format
125 "Compile by user (default %s)"
126 (or remote-compile-user
129 'remote-compile-user-history
)
130 remote-compile-user
)))
131 (setq command
(read-from-minibuffer "Compile command: "
132 compile-command nil nil
133 '(compile-history .
1)))
134 (list (if (string= host
"") remote-compile-host host
)
135 (if (string= user
"") remote-compile-user user
)
137 (setq compile-command command
)
139 (setq remote-compile-user user
))
140 ((null remote-compile-user
)
141 (setq remote-compile-user
(user-login-name))))
142 (let* ((parsed (and (featurep 'ange-ftp
)
143 (ange-ftp-ftp-name default-directory
)))
145 (format "%s %s -l %s \"(%scd %s; %s)\""
149 (if remote-compile-run-before
150 (concat remote-compile-run-before
"; ")
152 (if parsed
(nth 2 parsed
) default-directory
)
154 (setq remote-compile-host host
)
155 (save-some-buffers nil nil
)
156 (compile-internal compile-command
"No more errors")
157 ;; Set comint-file-name-prefix in the compilation buffer so
158 ;; compilation-parse-errors will find referenced files by ange-ftp.
160 (set-buffer compilation-last-buffer
)
161 (setq comint-file-name-prefix
(concat "/" host
":")))))
163 ;;; rcompile.el ends here