annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; rcompile.el Run a compilation on a remote machine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Albert <alon@milcse.rtsg.mot.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created: 1993 Oct 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Version: 1.1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Keywords: tools, processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; This package is for running a remote compilation and using emacs to parse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; the error messages. It works by rsh'ing the compilation to a remote host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; and parsing the output. If the file visited at the time remote-compile was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; called was loaded remotely (ange-ftp), the host and user name are obtained
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; by the calling ange-ftp-ftp-name on the current directory. In this case the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; next-error command will also ange-ftp the files over. This is achieved
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; automatically because the compilation-parse-errors function uses
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; default-directory to build it's file names. If however the file visited was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; loaded locally, remote-compile prompts for a host and user and assumes the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; files mounted locally (otherwise, how was the visited file loaded).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; See the user defined variables section for more info.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; I was contemplating redefining "compile" to "remote-compile" automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; if the file visited was ange-ftp'ed but decided against it for now. If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; feel this is a good idea, let me know and I'll consider it again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; Installation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; To use rcompile, you also need to give yourself permission to connect to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; the remote host. You do this by putting lines like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; monopoly alon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; vme33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; in a file named .rhosts in the home directory (of the remote machine).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; Be careful what you put in this file. A line like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; +
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; Will allow anyone access to your account without a password. I suggest you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; read the rhosts(5) manual page before you edit this file (if you are not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;; familiar with it already)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (provide 'rcompile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (require 'compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;; The following should not be needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; (eval-when-compile (require 'ange-ftp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;; user defined variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defvar remote-compile-host nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "*Host for remote compilations.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defvar remote-compile-user nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "User for remote compilations.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 nil means use the value returned by \\[user-login-name].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defvar remote-compile-run-before nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "*Command to run before compilation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 This can be used for setting up enviroment variables,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 since rsh does not invoke the shell as a login shell and files like .login
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 \(tcsh\) and .bash_profile \(bash\) are not run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 nil means run no commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defvar remote-compile-prompt-for-host nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "*Non-nil means prompt for host if not available from filename.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar remote-compile-prompt-for-user nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 "*Non-nil means prompt for user if not available from filename.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;;; internal variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; History of remote compile hosts and users
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (defvar remote-compile-host-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defvar remote-compile-user-history nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;; entry point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun remote-compile (host user command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "Compile the the current buffer's directory on HOST. Log in as USER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 See \\[compile]."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (let ((parsed (and (featurep 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (or (and (fboundp 'ange-ftp-ftp-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (ange-ftp-ftp-name default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (and (fboundp 'ange-ftp-ftp-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (ange-ftp-ftp-path default-directory)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 host user command prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if parsed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (setq host (nth 0 parsed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 user (nth 1 parsed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (setq prompt (if (stringp remote-compile-host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (format "Compile on host (default %s): "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 remote-compile-host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Compile on host: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 host (if (or remote-compile-prompt-for-host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (null remote-compile-host))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (read-from-minibuffer prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 "" nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 'remote-compile-host-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 remote-compile-host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 user (if remote-compile-prompt-for-user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (read-from-minibuffer (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "Compile by user (default %s)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (or remote-compile-user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 "" nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 'remote-compile-user-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 remote-compile-user)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq command (read-from-minibuffer "Compile command: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 compile-command nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 '(compile-history . 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (list (if (string= host "") remote-compile-host host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (if (string= user "") remote-compile-user user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (setq compile-command command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (cond (user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq remote-compile-user user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ((null remote-compile-user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (setq remote-compile-user (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let* ((parsed (and (featurep 'ange-ftp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (or (and (fboundp 'ange-ftp-ftp-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (ange-ftp-ftp-name default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (and (fboundp 'ange-ftp-ftp-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (ange-ftp-ftp-path default-directory)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (compile-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (format "%s %s -l %s \"(%scd %s; %s)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 remote-shell-program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 remote-compile-user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if remote-compile-run-before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (concat remote-compile-run-before "; ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if parsed (nth 2 parsed) default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 compile-command)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (setq remote-compile-host host)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (save-some-buffers nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (compile-internal compile-command "No more errors")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; Set comint-file-name-prefix in the compilation buffer so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; compilation-parse-errors will find referenced files by ange-ftp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (set-buffer compilation-last-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq comint-file-name-prefix (concat "/" host ":")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; rcompile.el ends here