annotate lisp/packages/rcompile.el @ 94:1040fe1366ac xemacs-20-0f2

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