Mercurial > emacs
comparison lisp/net/tramp-util.el @ 59582:92796330257a
Sync with Tramp 2.0.47.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 16 Jan 2005 13:18:31 +0000 |
parents | 695cf19ef79e |
children | aac0a33f5772 6d92d69fae33 |
comparison
equal
deleted
inserted
replaced
59581:26fb5a3f95ac | 59582:92796330257a |
---|---|
1 ;;; -*- coding: iso-2022-7bit; -*- | 1 ;;; -*- coding: iso-2022-7bit; -*- |
2 ;;; tramp-util.el --- Misc utility functions to use with Tramp | 2 ;;; tramp-util.el --- Misc utility functions to use with Tramp |
3 | 3 |
4 ;; Copyright (C) 2001 Free Software Foundation, Inc. | 4 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Kai Gro,A_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> | 6 ;; Author: kai.grossjohann@gmx.net |
7 ;; Keywords: comm, extensions, processes | 7 ;; Keywords: comm, extensions, processes |
8 | 8 |
9 ;; This file is free software; you can redistribute it and/or modify | 9 ;; This file is free software; you can redistribute it and/or modify |
10 ;; it under the terms of the GNU General Public License as published by | 10 ;; it under the terms of the GNU General Public License as published by |
11 ;; the Free Software Foundation; either version 2, or (at your option) | 11 ;; the Free Software Foundation; either version 2, or (at your option) |
30 | 30 |
31 (eval-when-compile (require 'cl)) | 31 (eval-when-compile (require 'cl)) |
32 (require 'compile) | 32 (require 'compile) |
33 (require 'tramp) | 33 (require 'tramp) |
34 | 34 |
35 ;; Define a Tramp minor mode. It's intention is to redefine some keys for Tramp | |
36 ;; specific functions, like compilation. | |
37 ;; The key remapping works since Emacs 21.4 only. Unknown for XEmacs. | |
38 | |
39 (when (fboundp 'define-minor-mode) | |
40 | |
41 (defvar tramp-minor-mode-map (make-sparse-keymap) | |
42 "Keymap for Tramp minor mode.") | |
43 | |
44 (define-minor-mode tramp-minor-mode "Tramp minor mode for utility functions." | |
45 :group 'tramp | |
46 :global nil | |
47 :init-value nil | |
48 :lighter " Tramp" | |
49 :keymap tramp-minor-mode-map | |
50 (setq tramp-minor-mode | |
51 (and tramp-minor-mode (tramp-tramp-file-p default-directory)))) | |
52 | |
53 (add-hook 'find-file-hooks 'tramp-minor-mode t) | |
54 (add-hook 'dired-mode-hook 'tramp-minor-mode t) | |
55 | |
56 (defun tramp-remap-command (old-command new-command) | |
57 "Replaces bindings of OLD-COMMAND by NEW-COMMAND. | |
58 If remapping functionality for keymaps is defined, this happens for all | |
59 bindings. Otherwise, only bindings active during invocation are taken | |
60 into account. XEmacs menubar bindings are not changed by this." | |
61 (if (functionp 'command-remapping) | |
62 ;; Emacs 21.4 | |
63 (eval | |
64 `(define-key tramp-minor-mode-map [remap ,old-command] new-command)) | |
65 ;; previous Emacs 21 versions. | |
66 (mapcar | |
67 '(lambda (x) | |
68 (define-key tramp-minor-mode-map x new-command)) | |
69 (where-is-internal old-command)))) | |
70 | |
71 (tramp-remap-command 'compile 'tramp-compile) | |
72 (tramp-remap-command 'recompile 'tramp-recompile) | |
73 | |
74 ;; XEmacs has an own mimic for menu entries | |
75 (when (fboundp 'add-menu-button) | |
76 (funcall 'add-menu-button | |
77 '("Tools" "Compile") | |
78 ["Compile..." | |
79 (command-execute (if tramp-minor-mode 'tramp-compile 'compile)) | |
80 :active (fboundp 'compile)]) | |
81 (funcall 'add-menu-button | |
82 '("Tools" "Compile") | |
83 ["Repeat Compilation" | |
84 (command-execute (if tramp-minor-mode 'tramp-recompile 'recompile)) | |
85 :active (fboundp 'compile)]))) | |
86 | |
87 ;; Utility functions. | |
88 | |
35 (defun tramp-compile (command) | 89 (defun tramp-compile (command) |
36 "Compile on remote host." | 90 "Compile on remote host." |
37 (interactive | 91 (interactive |
38 (if (or compilation-read-command current-prefix-arg) | 92 (if (or compilation-read-command current-prefix-arg) |
39 (list (read-from-minibuffer "Compile command: " | 93 (list (read-from-minibuffer "Compile command: " |
47 (pop-to-buffer (get-buffer-create "*Compilation*") t) | 101 (pop-to-buffer (get-buffer-create "*Compilation*") t) |
48 (erase-buffer) | 102 (erase-buffer) |
49 (setq default-directory d))) | 103 (setq default-directory d))) |
50 (tramp-handle-shell-command command (get-buffer "*Compilation*")) | 104 (tramp-handle-shell-command command (get-buffer "*Compilation*")) |
51 (pop-to-buffer (get-buffer "*Compilation*")) | 105 (pop-to-buffer (get-buffer "*Compilation*")) |
106 (tramp-minor-mode 1) | |
107 (compilation-minor-mode 1)) | |
108 | |
109 (defun tramp-recompile () | |
110 "Re-compile on remote host." | |
111 (interactive) | |
112 (save-some-buffers (not compilation-ask-about-save) nil) | |
113 (tramp-handle-shell-command compile-command (get-buffer "*Compilation*")) | |
114 (pop-to-buffer (get-buffer "*Compilation*")) | |
115 (tramp-minor-mode 1) | |
52 (compilation-minor-mode 1)) | 116 (compilation-minor-mode 1)) |
53 | 117 |
54 (provide 'tramp-util) | 118 (provide 'tramp-util) |
55 | 119 |
56 ;;; arch-tag: 500f9992-a44e-46d0-83a7-980799251808 | 120 ;;; arch-tag: 500f9992-a44e-46d0-83a7-980799251808 |