36 |
;; specific functions, like compilation. |
;; specific functions, like compilation. |
37 |
;; The key remapping works since Emacs 22 only. Unknown for XEmacs. |
;; The key remapping works since Emacs 22 only. Unknown for XEmacs. |
38 |
|
|
39 |
(when (fboundp 'define-minor-mode) |
;; Pacify byte-compiler |
40 |
|
(eval-when-compile |
41 |
|
(unless (fboundp 'define-minor-mode) |
42 |
|
(defalias 'define-minor-mode 'identity) |
43 |
|
(defvar tramp-minor-mode)) |
44 |
|
(unless (featurep 'xemacs) |
45 |
|
(defalias 'add-menu-button 'identity))) |
46 |
|
|
47 |
|
(defvar tramp-minor-mode-map (make-sparse-keymap) |
48 |
|
"Keymap for Tramp minor mode.") |
49 |
|
|
50 |
|
(define-minor-mode tramp-minor-mode "Tramp minor mode for utility functions." |
51 |
|
:group 'tramp |
52 |
|
:global nil |
53 |
|
:init-value nil |
54 |
|
:lighter " Tramp" |
55 |
|
:keymap tramp-minor-mode-map |
56 |
|
(setq tramp-minor-mode |
57 |
|
(and tramp-minor-mode (tramp-tramp-file-p default-directory)))) |
58 |
|
|
59 |
(defvar tramp-minor-mode-map (make-sparse-keymap) |
(add-hook 'find-file-hooks 'tramp-minor-mode t) |
60 |
"Keymap for Tramp minor mode.") |
(add-hook 'dired-mode-hook 'tramp-minor-mode t) |
61 |
|
|
62 |
(define-minor-mode tramp-minor-mode "Tramp minor mode for utility functions." |
(defun tramp-remap-command (old-command new-command) |
63 |
:group 'tramp |
"Replaces bindings of OLD-COMMAND by NEW-COMMAND. |
|
:global nil |
|
|
:init-value nil |
|
|
:lighter " Tramp" |
|
|
:keymap tramp-minor-mode-map |
|
|
(setq tramp-minor-mode |
|
|
(and tramp-minor-mode (tramp-tramp-file-p default-directory)))) |
|
|
|
|
|
(add-hook 'find-file-hooks 'tramp-minor-mode t) |
|
|
(add-hook 'dired-mode-hook 'tramp-minor-mode t) |
|
|
|
|
|
(defun tramp-remap-command (old-command new-command) |
|
|
"Replaces bindings of OLD-COMMAND by NEW-COMMAND. |
|
64 |
If remapping functionality for keymaps is defined, this happens for all |
If remapping functionality for keymaps is defined, this happens for all |
65 |
bindings. Otherwise, only bindings active during invocation are taken |
bindings. Otherwise, only bindings active during invocation are taken |
66 |
into account. XEmacs menubar bindings are not changed by this." |
into account. XEmacs menubar bindings are not changed by this." |
67 |
(if (functionp 'command-remapping) |
(if (functionp 'command-remapping) |
68 |
;; Emacs 22 |
;; Emacs 22 |
69 |
(eval |
(eval |
70 |
`(define-key tramp-minor-mode-map [remap ,old-command] new-command)) |
`(define-key tramp-minor-mode-map [remap ,old-command] new-command)) |
71 |
;; previous Emacs versions. |
;; previous Emacs versions. |
72 |
(mapcar |
(mapcar |
73 |
'(lambda (x) |
'(lambda (x) |
74 |
(define-key tramp-minor-mode-map x new-command)) |
(define-key tramp-minor-mode-map x new-command)) |
75 |
(where-is-internal old-command)))) |
(where-is-internal old-command)))) |
76 |
|
|
77 |
(tramp-remap-command 'compile 'tramp-compile) |
(tramp-remap-command 'compile 'tramp-compile) |
78 |
(tramp-remap-command 'recompile 'tramp-recompile) |
(tramp-remap-command 'recompile 'tramp-recompile) |
79 |
|
|
80 |
;; XEmacs has an own mimic for menu entries |
;; XEmacs has an own mimic for menu entries |
81 |
(when (fboundp 'add-menu-button) |
(when (fboundp 'add-menu-button) |
82 |
(funcall 'add-menu-button |
(funcall 'add-menu-button |
83 |
'("Tools" "Compile") |
'("Tools" "Compile") |
84 |
["Compile..." |
["Compile..." |
85 |
(command-execute (if tramp-minor-mode 'tramp-compile 'compile)) |
(command-execute (if tramp-minor-mode 'tramp-compile 'compile)) |
86 |
:active (fboundp 'compile)]) |
:active (fboundp 'compile)]) |
87 |
(funcall 'add-menu-button |
(funcall 'add-menu-button |
88 |
'("Tools" "Compile") |
'("Tools" "Compile") |
89 |
["Repeat Compilation" |
["Repeat Compilation" |
90 |
(command-execute (if tramp-minor-mode 'tramp-recompile 'recompile)) |
(command-execute (if tramp-minor-mode 'tramp-recompile 'recompile)) |
91 |
:active (fboundp 'compile)]))) |
:active (fboundp 'compile)])) |
92 |
|
|
93 |
;; Utility functions. |
;; Utility functions. |
94 |
|
|