Mercurial > emacs
annotate lisp/net/rcompile.el @ 94029:97873d4b0d7a
Move non-autoloaded define-obsolete-variable-alias calls for
defcustoms not in dumped files before the associated defcustom.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Sat, 12 Apr 2008 03:15:19 +0000 |
parents | 21873b86ecb7 |
children | 924fe8b4e375 91e5880a36c1 |
rev | line source |
---|---|
28210 | 1 ;;; rcompile.el --- run a compilation on a remote machine |
2 | |
74509 | 3 ;; Copyright (C) 1993, 1994, 2001, 2002, 2003, 2004, |
79714 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
28210 | 5 |
6 ;; Author: Albert <alon@milcse.rtsg.mot.com> | |
7 ;; Maintainer: FSF | |
8 ;; Created: 1993 Oct 6 | |
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 | |
78230
84cf1e2214c5
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
28210 | 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 the | |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
28210 | 27 |
28 ;;; Commentary: | |
29 | |
30 ;; This package is for running a remote compilation and using emacs to parse | |
31 ;; the error messages. It works by rsh'ing the compilation to a remote host | |
32 ;; and parsing the output. If the file visited at the time remote-compile was | |
33 ;; called was loaded remotely (ange-ftp), the host and user name are obtained | |
34 ;; by the calling ange-ftp-ftp-name on the current directory. In this case the | |
35 ;; next-error command will also ange-ftp the files over. This is achieved | |
36 ;; automatically because the compilation-parse-errors function uses | |
37 ;; default-directory to build its file names. If however the file visited was | |
38 ;; loaded locally, remote-compile prompts for a host and user and assumes the | |
39 ;; files mounted locally (otherwise, how was the visited file loaded). | |
40 | |
41 ;; See the user defined variables section for more info. | |
42 | |
43 ;; I was contemplating redefining "compile" to "remote-compile" automatically | |
44 ;; if the file visited was ange-ftp'ed but decided against it for now. If you | |
45 ;; feel this is a good idea, let me know and I'll consider it again. | |
46 | |
47 ;; Installation: | |
48 | |
49 ;; To use rcompile, you also need to give yourself permission to connect to | |
50 ;; the remote host. You do this by putting lines like: | |
51 | |
52 ;; monopoly alon | |
53 ;; vme33 | |
54 ;; | |
55 ;; in a file named .rhosts in the home directory (of the remote machine). | |
56 ;; Be careful what you put in this file. A line like: | |
57 ;; | |
58 ;; + | |
59 ;; | |
60 ;; Will allow anyone access to your account without a password. I suggest you | |
61 ;; read the rhosts(5) manual page before you edit this file (if you are not | |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42706
diff
changeset
|
62 ;; familiar with it already) |
28210 | 63 |
64 ;;; Code: | |
65 | |
66 (provide 'rcompile) | |
67 (require 'compile) | |
68 ;;; The following should not be needed. | |
69 ;;; (eval-when-compile (require 'ange-ftp)) | |
70 | |
71 ;;;; user defined variables | |
72 | |
73 (defgroup remote-compile nil | |
64038
9a906236d900
(remote-compile): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
62573
diff
changeset
|
74 "Run a compilation on a remote machine." |
28210 | 75 :group 'processes |
76 :group 'tools) | |
77 | |
78 | |
79 (defcustom remote-compile-host nil | |
80 "*Host for remote compilations." | |
81 :type '(choice string (const nil)) | |
82 :group 'remote-compile) | |
83 | |
84 (defcustom remote-compile-user nil | |
85 "User for remote compilations. | |
86 nil means use the value returned by \\[user-login-name]." | |
87 :type '(choice string (const nil)) | |
88 :group 'remote-compile) | |
89 | |
90 (defcustom remote-compile-run-before nil | |
91 "*Command to run before compilation. | |
92 This can be used for setting up environment 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 :type '(choice string (const nil)) | |
97 :group 'remote-compile) | |
98 | |
99 (defcustom remote-compile-prompt-for-host nil | |
100 "*Non-nil means prompt for host if not available from filename." | |
101 :type 'boolean | |
102 :group 'remote-compile) | |
103 | |
104 (defcustom remote-compile-prompt-for-user nil | |
105 "*Non-nil means prompt for user if not available from filename." | |
106 :type 'boolean | |
107 :group 'remote-compile) | |
108 | |
109 ;;;; internal variables | |
110 | |
111 ;; History of remote compile hosts and users | |
112 (defvar remote-compile-host-history nil) | |
113 (defvar remote-compile-user-history nil) | |
114 | |
115 | |
116 ;;;; entry point | |
117 | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
118 ;; We use the Tramp internal function`tramp-make-tramp-file-name'. |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
119 ;; Better would be, if there are functions to provide user, host and |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
120 ;; localname of a remote filename, independent of Tramp's implementation. |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
121 ;; The function calls are wrapped by `funcall' in order to pacify the byte |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
122 ;; compiler. ange-ftp check removed, because it is handled also by Tramp. |
28210 | 123 ;;;###autoload |
124 (defun remote-compile (host user command) | |
42706 | 125 "Compile the current buffer's directory on HOST. Log in as USER. |
28210 | 126 See \\[compile]." |
127 (interactive | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
128 (let (host user command prompt l l-host l-user) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
129 (setq prompt (if (stringp remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
130 (format "Compile on host (default %s): " |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
131 remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
132 "Compile on host: ") |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
133 host (if (or remote-compile-prompt-for-host |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
134 (null remote-compile-host)) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
135 (read-from-minibuffer prompt |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
136 "" nil nil |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
137 'remote-compile-host-history) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
138 remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
139 user (if remote-compile-prompt-for-user |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
140 (read-from-minibuffer (format |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
141 "Compile by user (default %s): " |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
142 (or remote-compile-user |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
143 (user-login-name))) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
144 "" nil nil |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
145 'remote-compile-user-history) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
146 remote-compile-user)) |
28210 | 147 (setq command (read-from-minibuffer "Compile command: " |
148 compile-command nil nil | |
149 '(compile-history . 1))) | |
150 (list (if (string= host "") remote-compile-host host) | |
151 (if (string= user "") remote-compile-user user) | |
152 command))) | |
153 (setq compile-command command) | |
154 (cond (user | |
155 (setq remote-compile-user user)) | |
156 ((null remote-compile-user) | |
157 (setq remote-compile-user (user-login-name)))) | |
71485
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
158 (let* (localname ;; Pacify byte-compiler. |
28210 | 159 (compile-command |
160 (format "%s %s -l %s \"(%scd %s; %s)\"" | |
161 remote-shell-program | |
162 host | |
163 remote-compile-user | |
164 (if remote-compile-run-before | |
165 (concat remote-compile-run-before "; ") | |
166 "") | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
167 "" |
28210 | 168 compile-command))) |
169 (setq remote-compile-host host) | |
170 (save-some-buffers nil nil) | |
62573
b79d54436669
(remote-compile): Use compilation-start.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
171 (compilation-start compile-command) |
28210 | 172 ;; Set comint-file-name-prefix in the compilation buffer so |
71485
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
173 ;; compilation-parse-errors will find referenced files by Tramp. |
38420
0a4a44975e06
(remote-compile): Use make-local-variable.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
28210
diff
changeset
|
174 (with-current-buffer compilation-last-buffer |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
175 (when (fboundp 'tramp-make-tramp-file-name) |
71485
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
176 (set (make-local-variable 'comint-file-name-prefix) |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
177 (tramp-make-tramp-file-name |
81758
f03856eb136b
* files.el (file-remote-p): Introduce optional parameter CONNECTED.
Michael Albinus <michael.albinus@gmx.de>
parents:
75347
diff
changeset
|
178 nil ;; method. |
71485
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
179 remote-compile-user |
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
180 remote-compile-host |
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
181 "")))))) |
28210 | 182 |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
183 ;; arch-tag: 2866a132-ece4-4ce9-9f91-ec147f803f73 |
28210 | 184 ;;; rcompile.el ends here |