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
|
|
75 (defvar remote-compile-host nil
|
|
76 "*Host for remote compilations.")
|
|
77
|
|
78 (defvar remote-compile-user nil
|
|
79 "User for remote compilations.
|
|
80 nil means use the value returned by \\[user-login-name].")
|
|
81
|
|
82 (defvar remote-compile-run-before nil
|
|
83 "*Command to run before compilation.
|
2
|
84 This can be used for setting up environment variables,
|
0
|
85 since rsh does not invoke the shell as a login shell and files like .login
|
|
86 \(tcsh\) and .bash_profile \(bash\) are not run.
|
|
87 nil means run no commands.")
|
|
88
|
|
89 (defvar remote-compile-prompt-for-host nil
|
|
90 "*Non-nil means prompt for host if not available from filename.")
|
|
91
|
|
92 (defvar remote-compile-prompt-for-user nil
|
|
93 "*Non-nil means prompt for user if not available from filename.")
|
|
94
|
|
95 ;;;; internal variables
|
|
96
|
|
97 ;; History of remote compile hosts and users
|
|
98 (defvar remote-compile-host-history nil)
|
|
99 (defvar remote-compile-user-history nil)
|
|
100
|
|
101
|
|
102 ;;;; entry point
|
|
103
|
|
104 ;;;###autoload
|
|
105 (defun remote-compile (host user command)
|
2
|
106 "Compile the current buffer's directory on HOST. Log in as USER.
|
0
|
107 See \\[compile]."
|
|
108 (interactive
|
120
|
109 (let ((parsed
|
|
110 ;; XEmacs change
|
|
111 (cond
|
|
112 ((featurep 'efs)
|
|
113 (efs-ftp-path default-directory))
|
|
114 ((featurep 'ange-ftp)
|
|
115 (if (fboundp 'ange-ftp-ftp-name)
|
|
116 (ange-ftp-ftp-name default-directory)
|
|
117 (ange-ftp-ftp-path default-directory)))
|
|
118 (t nil)))
|
0
|
119 host user command prompt)
|
|
120 (if parsed
|
|
121 (setq host (nth 0 parsed)
|
|
122 user (nth 1 parsed))
|
|
123 (setq prompt (if (stringp remote-compile-host)
|
|
124 (format "Compile on host (default %s): "
|
|
125 remote-compile-host)
|
|
126 "Compile on host: ")
|
|
127 host (if (or remote-compile-prompt-for-host
|
|
128 (null remote-compile-host))
|
|
129 (read-from-minibuffer prompt
|
|
130 "" nil nil
|
|
131 'remote-compile-host-history)
|
|
132 remote-compile-host)
|
|
133 user (if remote-compile-prompt-for-user
|
|
134 (read-from-minibuffer (format
|
|
135 "Compile by user (default %s)"
|
|
136 (or remote-compile-user
|
|
137 (user-login-name)))
|
|
138 "" nil nil
|
|
139 'remote-compile-user-history)
|
|
140 remote-compile-user)))
|
|
141 (setq command (read-from-minibuffer "Compile command: "
|
|
142 compile-command nil nil
|
|
143 '(compile-history . 1)))
|
|
144 (list (if (string= host "") remote-compile-host host)
|
|
145 (if (string= user "") remote-compile-user user)
|
|
146 command)))
|
|
147 (setq compile-command command)
|
|
148 (cond (user
|
|
149 (setq remote-compile-user user))
|
|
150 ((null remote-compile-user)
|
|
151 (setq remote-compile-user (user-login-name))))
|
120
|
152 (let* ((parsed
|
|
153 ;; XEmacs change
|
|
154 (cond
|
|
155 ((featurep 'efs)
|
|
156 (efs-ftp-path default-directory))
|
|
157 ((featurep 'ange-ftp)
|
|
158 (if (fboundp 'ange-ftp-ftp-name)
|
|
159 (ange-ftp-ftp-name default-directory)
|
|
160 (ange-ftp-ftp-path default-directory)))
|
|
161 (t nil)))
|
0
|
162 (compile-command
|
|
163 (format "%s %s -l %s \"(%scd %s; %s)\""
|
|
164 remote-shell-program
|
|
165 host
|
|
166 remote-compile-user
|
|
167 (if remote-compile-run-before
|
|
168 (concat remote-compile-run-before "; ")
|
|
169 "")
|
|
170 (if parsed (nth 2 parsed) default-directory)
|
|
171 compile-command)))
|
|
172 (setq remote-compile-host host)
|
|
173 (save-some-buffers nil nil)
|
|
174 (compile-internal compile-command "No more errors")
|
|
175 ;; Set comint-file-name-prefix in the compilation buffer so
|
|
176 ;; compilation-parse-errors will find referenced files by ange-ftp.
|
|
177 (save-excursion
|
|
178 (set-buffer compilation-last-buffer)
|
|
179 (setq comint-file-name-prefix (concat "/" host ":")))))
|
|
180
|
|
181 ;;; rcompile.el ends here
|