* lisp/vc/diff-mode.el (diff-wiggle): New command.
[emacs.git] / lisp / obsolete / rcompile.el
blob6e7e37fe36bcb59dd36a8b9e797112fffbbfe1f4
1 ;;; rcompile.el --- run a compilation on a remote machine
3 ;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
5 ;; Author: Alon Albert <alon@milcse.rtsg.mot.com>
6 ;; Maintainer: emacs-devel@gnu.org
7 ;; Created: 1993 Oct 6
8 ;; Keywords: tools, processes
9 ;; Obsolete-since: 24.4
11 ;; This file is part of GNU Emacs.
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 3 of the License, or
16 ;; (at your option) any later version.
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.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
26 ;;; Commentary:
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).
39 ;; See the user defined variables section for more info.
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.
45 ;; Installation:
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:
50 ;; monopoly alon
51 ;; vme33
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:
56 ;; +
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
60 ;; familiar with it already)
62 ;;; Code:
64 (provide 'rcompile)
65 (require 'compile)
66 ;;; The following should not be needed.
67 ;;; (eval-when-compile (require 'ange-ftp))
69 ;;;; user defined variables
71 (defgroup remote-compile nil
72 "Run a compilation on a remote machine."
73 :group 'processes
74 :group 'tools)
77 (defcustom remote-compile-host nil
78 "Host for remote compilations."
79 :type '(choice string (const nil))
80 :group 'remote-compile)
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)
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)
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)
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)
107 ;;;; internal variables
109 ;; History of remote compile hosts and users
110 (defvar remote-compile-host-history nil)
111 (defvar remote-compile-user-history nil)
114 ;;;; entry point
116 ;; We use the Tramp internal function`tramp-make-tramp-file-name'.
117 ;; Better would be, if there are functions to provide user, host and
118 ;; localname of a remote filename, independent of Tramp's implementation.
119 ;; The function calls are wrapped by `funcall' in order to pacify the byte
120 ;; compiler. ange-ftp check removed, because it is handled also by Tramp.
121 ;;;###autoload
122 (defun remote-compile (host user command)
123 "Compile the current buffer's directory on HOST. Log in as USER.
124 See \\[compile]."
125 (interactive
126 (let (host user command prompt l l-host l-user)
127 (setq prompt (if (stringp remote-compile-host)
128 (format "Compile on host (default %s): "
129 remote-compile-host)
130 "Compile on host: ")
131 host (if (or remote-compile-prompt-for-host
132 (null remote-compile-host))
133 (read-from-minibuffer prompt
134 "" nil nil
135 'remote-compile-host-history)
136 remote-compile-host)
137 user (if remote-compile-prompt-for-user
138 (read-from-minibuffer (format
139 "Compile by user (default %s): "
140 (or remote-compile-user
141 (user-login-name)))
142 "" nil nil
143 'remote-compile-user-history)
144 remote-compile-user))
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))))
156 (let* (localname ;; Pacify byte-compiler.
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 "; ")
166 compile-command)))
167 (setq remote-compile-host host)
168 (save-some-buffers nil nil)
169 (compilation-start compile-command)
170 ;; Set comint-file-name-prefix in the compilation buffer so
171 ;; compilation-parse-errors will find referenced files by Tramp.
172 (with-current-buffer compilation-last-buffer
173 (when (fboundp 'tramp-make-tramp-file-name)
174 (set (make-local-variable 'comint-file-name-prefix)
175 (tramp-make-tramp-file-name
176 nil ;; method.
177 remote-compile-user
178 remote-compile-host
179 ""))))))
181 ;;; rcompile.el ends here