comparison lisp/packages/rcompile.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;; rcompile.el Run a compilation on a remote machine
2
3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
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
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 ;;; Synched up with: FSF 19.30.
28
29 ;;; Commentary:
30
31 ;;; This package is for running a remote compilation and using emacs to parse
32 ;;; the error messages. It works by rsh'ing the compilation to a remote host
33 ;;; and parsing the output. If the file visited at the time remote-compile was
34 ;;; called was loaded remotely (ange-ftp), the host and user name are obtained
35 ;;; by the calling ange-ftp-ftp-name on the current directory. In this case the
36 ;;; next-error command will also ange-ftp the files over. This is achieved
37 ;;; automatically because the compilation-parse-errors function uses
38 ;;; default-directory to build it's file names. If however the file visited was
39 ;;; loaded locally, remote-compile prompts for a host and user and assumes the
40 ;;; files mounted locally (otherwise, how was the visited file loaded).
41
42 ;;; See the user defined variables section for more info.
43
44 ;;; I was contemplating redefining "compile" to "remote-compile" automatically
45 ;;; if the file visited was ange-ftp'ed but decided against it for now. If you
46 ;;; feel this is a good idea, let me know and I'll consider it again.
47
48 ;;; Installation:
49
50 ;;; To use rcompile, you also need to give yourself permission to connect to
51 ;;; the remote host. You do this by putting lines like:
52
53 ;;; monopoly alon
54 ;;; vme33
55 ;;;
56 ;;; in a file named .rhosts in the home directory (of the remote machine).
57 ;;; Be careful what you put in this file. A line like:
58 ;;;
59 ;;; +
60 ;;;
61 ;;; Will allow anyone access to your account without a password. I suggest you
62 ;;; read the rhosts(5) manual page before you edit this file (if you are not
63 ;;; familiar with it already)
64
65 ;;; Code:
66
67 (provide 'rcompile)
68 (require 'compile)
69 ;;; The following should not be needed.
70 ;;; (eval-when-compile (require 'ange-ftp))
71
72 ;;;; user defined variables
73
74 (defvar remote-compile-host nil
75 "*Host for remote compilations.")
76
77 (defvar remote-compile-user nil
78 "User for remote compilations.
79 nil means use the value returned by \\[user-login-name].")
80
81 (defvar remote-compile-run-before nil
82 "*Command to run before compilation.
83 This can be used for setting up enviroment variables,
84 since rsh does not invoke the shell as a login shell and files like .login
85 \(tcsh\) and .bash_profile \(bash\) are not run.
86 nil means run no commands.")
87
88 (defvar remote-compile-prompt-for-host nil
89 "*Non-nil means prompt for host if not available from filename.")
90
91 (defvar remote-compile-prompt-for-user nil
92 "*Non-nil means prompt for user if not available from filename.")
93
94 ;;;; internal variables
95
96 ;; History of remote compile hosts and users
97 (defvar remote-compile-host-history nil)
98 (defvar remote-compile-user-history nil)
99
100
101 ;;;; entry point
102
103 ;;;###autoload
104 (defun remote-compile (host user command)
105 "Compile the the current buffer's directory on HOST. Log in as USER.
106 See \\[compile]."
107 (interactive
108 (let ((parsed (and (featurep 'ange-ftp)
109 ;; XEmacs change
110 (or (and (fboundp 'ange-ftp-ftp-name)
111 (ange-ftp-ftp-name default-directory))
112 (and (fboundp 'ange-ftp-ftp-path)
113 (ange-ftp-ftp-path default-directory)))))
114 host user command prompt)
115 (if parsed
116 (setq host (nth 0 parsed)
117 user (nth 1 parsed))
118 (setq prompt (if (stringp remote-compile-host)
119 (format "Compile on host (default %s): "
120 remote-compile-host)
121 "Compile on host: ")
122 host (if (or remote-compile-prompt-for-host
123 (null remote-compile-host))
124 (read-from-minibuffer prompt
125 "" nil nil
126 'remote-compile-host-history)
127 remote-compile-host)
128 user (if remote-compile-prompt-for-user
129 (read-from-minibuffer (format
130 "Compile by user (default %s)"
131 (or remote-compile-user
132 (user-login-name)))
133 "" nil nil
134 'remote-compile-user-history)
135 remote-compile-user)))
136 (setq command (read-from-minibuffer "Compile command: "
137 compile-command nil nil
138 '(compile-history . 1)))
139 (list (if (string= host "") remote-compile-host host)
140 (if (string= user "") remote-compile-user user)
141 command)))
142 (setq compile-command command)
143 (cond (user
144 (setq remote-compile-user user))
145 ((null remote-compile-user)
146 (setq remote-compile-user (user-login-name))))
147 (let* ((parsed (and (featurep 'ange-ftp)
148 ;; XEmacs change
149 (or (and (fboundp 'ange-ftp-ftp-name)
150 (ange-ftp-ftp-name default-directory))
151 (and (fboundp 'ange-ftp-ftp-path)
152 (ange-ftp-ftp-path default-directory)))))
153 (compile-command
154 (format "%s %s -l %s \"(%scd %s; %s)\""
155 remote-shell-program
156 host
157 remote-compile-user
158 (if remote-compile-run-before
159 (concat remote-compile-run-before "; ")
160 "")
161 (if parsed (nth 2 parsed) default-directory)
162 compile-command)))
163 (setq remote-compile-host host)
164 (save-some-buffers nil nil)
165 (compile-internal compile-command "No more errors")
166 ;; Set comint-file-name-prefix in the compilation buffer so
167 ;; compilation-parse-errors will find referenced files by ange-ftp.
168 (save-excursion
169 (set-buffer compilation-last-buffer)
170 (setq comint-file-name-prefix (concat "/" host ":")))))
171
172 ;;; rcompile.el ends here