5814
|
1 ;;; rcompile.el Run a compilation on a remote machine
|
5813
|
2
|
|
3 ;;; Copyright (C) 1993 Free Software Foundation, Inc.
|
|
4
|
5814
|
5 ;; Author: Albert <alon@milcse.rtsg.mot.com>
|
|
6 ;; Maintainer: FSF
|
|
7 ;; Created: 1993 Oct 6
|
|
8 ;; Version: 1.1
|
|
9 ;; Keywords: tools, processes
|
5813
|
10
|
|
11 ;; This file is part of GNU Emacs.
|
|
12
|
|
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)
|
|
16 ;; any later version.
|
|
17
|
|
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.
|
|
22
|
|
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.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
|
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).
|
|
39
|
|
40 ;;; See the user defined variables section for more info.
|
|
41
|
|
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.
|
|
45
|
|
46 ;;; Installation:
|
|
47
|
|
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:
|
|
50
|
|
51 ;;; monopoly alon
|
|
52 ;;; vme33
|
|
53 ;;;
|
|
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:
|
|
56 ;;;
|
|
57 ;;; +
|
|
58 ;;;
|
|
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)
|
|
62
|
|
63 ;;; History:
|
|
64 ;;; V1.1 Oct 13 1993 Alon Albert
|
|
65 ;;; SYSV support by Jay Finger <finger@mikey.convex.com>
|
|
66 ;;; V1.0 Oct 6 1993 Alon Albert
|
|
67 ;;; Initial cut.
|
|
68
|
|
69
|
|
70 ;;; Code:
|
|
71
|
|
72 (provide 'rcompile)
|
|
73 (require 'compile)
|
|
74 ;;; The following should not be needed.
|
|
75 ;;; (eval-when-compile (require 'ange-ftp))
|
|
76
|
|
77 ;;;; user defined variables
|
|
78
|
|
79 (defvar remote-compile-rsh-command
|
|
80 (if (eq system-type 'usg-unix-v) "remsh" "rsh")
|
|
81 "*Name of remote shell command: `rsh' for BSD or `remsh' for SYSV.")
|
|
82
|
|
83 (defvar remote-compile-host nil
|
|
84 "*Host for remote compilations.")
|
|
85
|
|
86 (defvar remote-compile-user nil
|
|
87 "User for remote compilations.
|
|
88 nil means use the value returned by \\[user-login-name].")
|
|
89
|
|
90 (defvar remote-compile-run-before nil
|
|
91 "*Command to run before compilation.
|
|
92 This can be used for setting up enviroment variables,
|
|
93 since rsh does not invoke the shell as a login shell and files like .login
|
|
94 \(tcsh\) and .bash_profile \(bash\) are not run.
|
|
95 nil means run no commands.")
|
|
96
|
|
97 (defvar remote-compile-prompt-for-host nil
|
|
98 "*Non-nil means prompt for host if not available from filename.")
|
|
99
|
|
100 (defvar remote-compile-prompt-for-user nil
|
|
101 "*Non-nil means prompt for user if not available from filename.")
|
|
102
|
|
103 ;;;; internal variables
|
|
104
|
|
105 ;; History of remote compile hosts and users
|
|
106 (defvar remote-compile-host-history nil)
|
|
107 (defvar remote-compile-user-history nil)
|
|
108
|
|
109
|
|
110 ;;;; entry point
|
|
111
|
|
112 ;;;###autoload
|
|
113 (defun remote-compile (host user command)
|
|
114 "Compile the the current buffer's directory on HOST. Log in as USER.
|
|
115 See \\[compile]."
|
|
116 (interactive
|
|
117 (let ((parsed (or (and (featurep 'ange-ftp)
|
|
118 (ange-ftp-ftp-name default-directory))))
|
|
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))))
|
|
152 (let* ((parsed (and (featurep 'ange-ftp)
|
|
153 (ange-ftp-ftp-name default-directory)))
|
|
154 (compile-command
|
|
155 (format "%s %s -l %s \"(%scd %s; %s)\""
|
|
156 remote-compile-rsh-command
|
|
157 host
|
|
158 remote-compile-user
|
|
159 (if remote-compile-run-before
|
|
160 (concat remote-compile-run-before "; ")
|
|
161 "")
|
|
162 (if parsed (nth 2 parsed) default-directory)
|
|
163 compile-command)))
|
|
164 (setq remote-compile-host host)
|
|
165 (save-some-buffers nil nil)
|
|
166 (compile-internal compile-command "No more errors")))
|
|
167
|
|
168 ;;; rcompile.el ends here
|