Mercurial > emacs
annotate lisp/net/rcompile.el @ 99171:36b0ab070ac3
* nsterm.m (ns_draw_window_cursor): When hbar cursor is on over-sized
glyph, draw it with the default glyph width.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 27 Oct 2008 22:29:22 +0000 |
parents | 91e5880a36c1 |
children | a9dc0e7c3f2b |
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 | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88094
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
28210 | 14 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88094
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88094
diff
changeset
|
16 ;; (at your option) any later version. |
28210 | 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 | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
88094
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
28210 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This package is for running a remote compilation and using emacs to parse | |
29 ;; the error messages. It works by rsh'ing the compilation to a remote host | |
30 ;; and parsing the output. If the file visited at the time remote-compile was | |
31 ;; called was loaded remotely (ange-ftp), the host and user name are obtained | |
32 ;; by the calling ange-ftp-ftp-name on the current directory. In this case the | |
33 ;; next-error command will also ange-ftp the files over. This is achieved | |
34 ;; automatically because the compilation-parse-errors function uses | |
35 ;; default-directory to build its file names. If however the file visited was | |
36 ;; loaded locally, remote-compile prompts for a host and user and assumes the | |
37 ;; files mounted locally (otherwise, how was the visited file loaded). | |
38 | |
39 ;; See the user defined variables section for more info. | |
40 | |
41 ;; I was contemplating redefining "compile" to "remote-compile" automatically | |
42 ;; if the file visited was ange-ftp'ed but decided against it for now. If you | |
43 ;; feel this is a good idea, let me know and I'll consider it again. | |
44 | |
45 ;; Installation: | |
46 | |
47 ;; To use rcompile, you also need to give yourself permission to connect to | |
48 ;; the remote host. You do this by putting lines like: | |
49 | |
50 ;; monopoly alon | |
51 ;; vme33 | |
52 ;; | |
53 ;; in a file named .rhosts in the home directory (of the remote machine). | |
54 ;; Be careful what you put in this file. A line like: | |
55 ;; | |
56 ;; + | |
57 ;; | |
58 ;; Will allow anyone access to your account without a password. I suggest you | |
59 ;; 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
|
60 ;; familiar with it already) |
28210 | 61 |
62 ;;; Code: | |
63 | |
64 (provide 'rcompile) | |
65 (require 'compile) | |
66 ;;; The following should not be needed. | |
67 ;;; (eval-when-compile (require 'ange-ftp)) | |
68 | |
69 ;;;; user defined variables | |
70 | |
71 (defgroup remote-compile nil | |
64038
9a906236d900
(remote-compile): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
62573
diff
changeset
|
72 "Run a compilation on a remote machine." |
28210 | 73 :group 'processes |
74 :group 'tools) | |
75 | |
76 | |
77 (defcustom remote-compile-host nil | |
78 "*Host for remote compilations." | |
79 :type '(choice string (const nil)) | |
80 :group 'remote-compile) | |
81 | |
82 (defcustom remote-compile-user nil | |
83 "User for remote compilations. | |
84 nil means use the value returned by \\[user-login-name]." | |
85 :type '(choice string (const nil)) | |
86 :group 'remote-compile) | |
87 | |
88 (defcustom remote-compile-run-before nil | |
89 "*Command to run before compilation. | |
90 This can be used for setting up environment variables, | |
91 since rsh does not invoke the shell as a login shell and files like .login | |
92 \(tcsh\) and .bash_profile \(bash\) are not run. | |
93 nil means run no commands." | |
94 :type '(choice string (const nil)) | |
95 :group 'remote-compile) | |
96 | |
97 (defcustom remote-compile-prompt-for-host nil | |
98 "*Non-nil means prompt for host if not available from filename." | |
99 :type 'boolean | |
100 :group 'remote-compile) | |
101 | |
102 (defcustom remote-compile-prompt-for-user nil | |
103 "*Non-nil means prompt for user if not available from filename." | |
104 :type 'boolean | |
105 :group 'remote-compile) | |
106 | |
107 ;;;; internal variables | |
108 | |
109 ;; History of remote compile hosts and users | |
110 (defvar remote-compile-host-history nil) | |
111 (defvar remote-compile-user-history nil) | |
112 | |
113 | |
114 ;;;; entry point | |
115 | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
116 ;; 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
|
117 ;; 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
|
118 ;; 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
|
119 ;; 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
|
120 ;; compiler. ange-ftp check removed, because it is handled also by Tramp. |
28210 | 121 ;;;###autoload |
122 (defun remote-compile (host user command) | |
42706 | 123 "Compile the current buffer's directory on HOST. Log in as USER. |
28210 | 124 See \\[compile]." |
125 (interactive | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
126 (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
|
127 (setq prompt (if (stringp remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
128 (format "Compile on host (default %s): " |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
129 remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
130 "Compile on host: ") |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
131 host (if (or remote-compile-prompt-for-host |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
132 (null remote-compile-host)) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
133 (read-from-minibuffer prompt |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
134 "" nil nil |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
135 'remote-compile-host-history) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
136 remote-compile-host) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
137 user (if remote-compile-prompt-for-user |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
138 (read-from-minibuffer (format |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
139 "Compile by user (default %s): " |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
140 (or remote-compile-user |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
141 (user-login-name))) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
142 "" nil nil |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
143 'remote-compile-user-history) |
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
144 remote-compile-user)) |
28210 | 145 (setq command (read-from-minibuffer "Compile command: " |
146 compile-command nil nil | |
147 '(compile-history . 1))) | |
148 (list (if (string= host "") remote-compile-host host) | |
149 (if (string= user "") remote-compile-user user) | |
150 command))) | |
151 (setq compile-command command) | |
152 (cond (user | |
153 (setq remote-compile-user user)) | |
154 ((null remote-compile-user) | |
155 (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
|
156 (let* (localname ;; Pacify byte-compiler. |
28210 | 157 (compile-command |
158 (format "%s %s -l %s \"(%scd %s; %s)\"" | |
159 remote-shell-program | |
160 host | |
161 remote-compile-user | |
162 (if remote-compile-run-before | |
163 (concat remote-compile-run-before "; ") | |
164 "") | |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
165 "" |
28210 | 166 compile-command))) |
167 (setq remote-compile-host host) | |
168 (save-some-buffers nil nil) | |
62573
b79d54436669
(remote-compile): Use compilation-start.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
169 (compilation-start compile-command) |
28210 | 170 ;; 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
|
171 ;; 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
|
172 (with-current-buffer compilation-last-buffer |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
173 (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
|
174 (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
|
175 (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
|
176 nil ;; method. |
71485
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
177 remote-compile-user |
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
178 remote-compile-host |
5b1bf37e044d
* net/rcompile.el (remote-compile): Replace ange-ftp based
Michael Albinus <michael.albinus@gmx.de>
parents:
68648
diff
changeset
|
179 "")))))) |
28210 | 180 |
88094
21873b86ecb7
(remote-compile): Remove broken code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
181 ;; arch-tag: 2866a132-ece4-4ce9-9f91-ec147f803f73 |
28210 | 182 ;;; rcompile.el ends here |