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 XEmacs.
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
15 ;; the Free Software Foundation; either version 2, or (at your option)
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.
23 ;; You should have received a copy of the GNU General Public License
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
28 ;;; Synched up with: FSF 19.34.
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).
43 ;; See the user defined variables section for more info.
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.
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:
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:
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)
70 ;;; The following should not be needed.
71 ;;; (eval-when-compile (require 'ange-ftp))
73 ;; But this is if you want a clean build on XEmacs. --SY.
75 (when (featurep 'xemacs)
76 (defalias 'ange-ftp-ftp-name 'ignore)
77 (defalias 'ange-ftp-ftp-path 'ignore)))
79 ;;;; user defined variables
81 (defgroup remote-compile nil
82 "Run a compilation on a remote machine"
87 (defcustom remote-compile-host nil
88 "*Host for remote compilations."
89 :type '(choice string (const nil))
90 :group 'remote-compile)
92 (defcustom remote-compile-user nil
93 "User for remote compilations.
94 nil means use the value returned by \\[user-login-name]."
95 :type '(choice string (const nil))
96 :group 'remote-compile)
98 (defcustom remote-compile-run-before nil
99 "*Command to run before compilation.
100 This can be used for setting up environment variables,
101 since rsh does not invoke the shell as a login shell and files like .login
102 \(tcsh\) and .bash_profile \(bash\) are not run.
103 nil means run no commands."
104 :type '(choice string (const nil))
105 :group 'remote-compile)
107 (defcustom remote-compile-prompt-for-host nil
108 "*Non-nil means prompt for host if not available from filename."
110 :group 'remote-compile)
112 (defcustom remote-compile-prompt-for-user nil
113 "*Non-nil means prompt for user if not available from filename."
115 :group 'remote-compile)
117 ;;;; internal variables
119 ;; History of remote compile hosts and users
120 (defvar remote-compile-host-history nil)
121 (defvar remote-compile-user-history nil)
127 (defun remote-compile (host user command)
128 "Compile the current buffer's directory on HOST. Log in as USER.
135 (efs-ftp-path default-directory))
136 ((featurep 'ange-ftp)
137 (if (fboundp 'ange-ftp-ftp-name)
138 (ange-ftp-ftp-name default-directory)
139 (ange-ftp-ftp-path default-directory)))
141 host user command prompt)
143 (setq host (nth 0 parsed)
145 (setq prompt (if (stringp remote-compile-host)
146 (format "Compile on host (default %s): "
149 host (if (or remote-compile-prompt-for-host
150 (null remote-compile-host))
151 (read-from-minibuffer prompt
153 'remote-compile-host-history)
155 user (if remote-compile-prompt-for-user
156 (read-from-minibuffer (format
157 "Compile by user (default %s)"
158 (or remote-compile-user
161 'remote-compile-user-history)
162 remote-compile-user)))
163 (setq command (read-from-minibuffer "Compile command: "
164 compile-command nil nil
165 '(compile-history . 1)))
166 (list (if (string= host "") remote-compile-host host)
167 (if (string= user "") remote-compile-user user)
169 (setq compile-command command)
171 (setq remote-compile-user user))
172 ((null remote-compile-user)
173 (setq remote-compile-user (user-login-name))))
178 (efs-ftp-path default-directory))
179 ((featurep 'ange-ftp)
180 (if (fboundp 'ange-ftp-ftp-name)
181 (ange-ftp-ftp-name default-directory)
182 (ange-ftp-ftp-path default-directory)))
185 (format "%s %s -l %s \"(%scd %s; %s)\""
189 (if remote-compile-run-before
190 (concat remote-compile-run-before "; ")
192 (if parsed (nth 2 parsed) default-directory)
194 (setq remote-compile-host host)
195 (save-some-buffers nil nil)
196 (compile-internal compile-command "No more errors")
197 ;; Set comint-file-name-prefix in the compilation buffer so
198 ;; compilation-parse-errors will find referenced files by ange-ftp.
200 (set-buffer compilation-last-buffer)
201 (setq comint-file-name-prefix (concat "/" user "@" host ":")))))
203 ;;; rcompile.el ends here