Mercurial > hg > xemacs-beta
comparison lisp/dired/dired-xemacs-menu.el @ 0:376386a54a3c r19-14
Import from CVS: tag r19-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:45:50 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:376386a54a3c |
---|---|
1 ;;; dired-xemacs-menu.el: A menu for the dired-mode. | |
2 ;;; v2.90; 7 Dec 1993 | |
3 ;;; Copyright (C) 1993 Heiko Muenkel | |
4 ;;; email: muenkel@tnt.uni-hannover.de | |
5 ;;; | |
6 ;;; This program is free software; you can redistribute it and/or modify | |
7 ;;; it under the terms of the GNU General Public License as published by | |
8 ;;; the Free Software Foundation; either version 1, or (at your option) | |
9 ;;; any later version. | |
10 ;;; | |
11 ;;; This program is distributed in the hope that it will be useful, | |
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 ;;; GNU General Public License for more details. | |
15 ;;; | |
16 ;;; You should have received a copy of the GNU General Public License | |
17 ;;; along with this program; if not, write to the Free Software | |
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | |
20 (require 'mode-motion) | |
21 | |
22 ;; Popup and Pulldown Menu | |
23 | |
24 (defvar dired-menu | |
25 '("Dired Commands" | |
26 ["Open File" dired-find-file t] | |
27 ["Open File Other Window" dired-find-file-other-window t] | |
28 ["View File" dired-view-file t] | |
29 "----" | |
30 ("Mark" | |
31 ["Mark File" dired-mark-subdir-or-file t] | |
32 ["Mark Files in Region" dired-mark-region (mark)] | |
33 ["Mark Files by Regexp..." dired-mark-files-regexp t] | |
34 ["Mark All Directories" dired-mark-directories t] | |
35 ["Mark All Executables" dired-mark-executables t] | |
36 ["Mark All Symbolic Links" dired-mark-symlinks t] | |
37 "----" | |
38 ["Unmark File" dired-unmark-subdir-or-file t] | |
39 ["Unmark All Files" (dired-unflag-all-files nil) t] | |
40 ["Unmark All Files (Query)..." (dired-unflag-all-files nil t) t] | |
41 ["Unmark Files in Region" dired-unmark-region (mark)] | |
42 ) | |
43 ("Copy/Link" | |
44 ["Copy Files..." dired-do-copy t] | |
45 ["Copy Files by Regexp..." dired-do-copy-regexp t] | |
46 "----" | |
47 ["Symlink Files in Directory..." dired-do-symlink t] | |
48 ["Symlink Files in Directory by Regexp..." dired-do-symlink-regexp t] | |
49 "----" | |
50 ["Hard-Link Files in Directory..." dired-do-hardlink t] | |
51 ["Hard-Link Files in Directory by Regexp..." dired-do-hardlink-regexp t] | |
52 ) | |
53 ("Rename" | |
54 ["Rename Marked Files..." dired-do-move t] | |
55 ["Rename Files by Regexp..." dired-do-rename-regexp t] | |
56 "----" | |
57 ["Downcase Names of Marked Files..." dired-downcase t] | |
58 ["Upcase Names of Marked Files..." dired-upcase t] | |
59 ) | |
60 ("Delete" | |
61 ["Delete Marked Files..." dired-do-delete t] | |
62 ["Delete Flagged Files..." dired-do-deletions t] | |
63 "----" | |
64 ["Flag Marked Files for Deletion" dired-flag-file-deleted t] | |
65 ["Flag Files in Region for Deletion" dired-flag-region (mark)] | |
66 ["Flag Files for Deletion by Regexp..." dired-flag-regexp-files t] | |
67 ["Flag Backup Files for Deletion" dired-clean-directory t] | |
68 ["Flag Autosave Files for Deletion" dired-flag-auto-save-files t] | |
69 "----" | |
70 ["Unflag Marked Files" dired-unflag t] | |
71 ["Unflag Backup Files" dired-backup-unflag t] | |
72 ["Unflag All Files" (dired-unflag-all-files nil) t] | |
73 ["Unflag All Files (Query)..." (dired-unflag-all-files nil) t] | |
74 ["Unflag Files in Region" dired-unflag-region (mark)] | |
75 ) | |
76 ("Shell commands" | |
77 ["Compress Marked Files..." dired-do-compress t] | |
78 ["Uncompress Marked Files..." dired-do-uncompress t] | |
79 ["Print Marked Files..." dired-do-print t] | |
80 ["Shell Command on Marked Files..." dired-do-shell-command t] | |
81 "----" | |
82 ["Load Marked Files" dired-do-load t] | |
83 ["Byte-Compile Marked Files..." dired-do-byte-compile t] | |
84 "----" | |
85 ["Diff File Against Backup" dired-backup-diff t] | |
86 ["Diff File..." dired-diff t] | |
87 "----" | |
88 ["Change Permissions of Marked Files..." dired-do-chmod t] | |
89 ["Change Group of Marked Files..." dired-do-chgrp t] | |
90 ["Change Owner of Marked Files..." dired-do-chown t] | |
91 ) | |
92 "----" | |
93 ("Directory" | |
94 ["Up Directory" dired-up-directory t] | |
95 ["Home Directory" (dired "~/") t] | |
96 "----" | |
97 ["Dired..." dired t] | |
98 ["Dired Other Window..." dired-other-window t] | |
99 ["Redisplay All Files" revert-buffer t] | |
100 "----" | |
101 ["Create Directory..." dired-create-directory t] | |
102 "----" | |
103 ["Insert Subdirectory" dired-insert-subdir t] | |
104 ["Hide Subdirectory" dired-kill-subdir t] | |
105 ["Hide All Subdirectories..." dired-kill-tree t] | |
106 ) | |
107 ("Goto" | |
108 ["Next Directory Line" dired-next-dirline t] | |
109 ["Previous Directory Line" dired-prev-dirline t] | |
110 ["Next Marked File" dired-next-marked-file t] | |
111 ["Previous Marked File" dired-prev-marked-file t] | |
112 "----" | |
113 ["File..." dired-goto-file t] | |
114 ["Top of Directory..." dired-goto-subdir t] | |
115 ["Down Directory" dired-tree-down t] | |
116 ["Up Directory" dired-tree-up t] | |
117 ) | |
118 ("Display" | |
119 ["Undisplay Line or Subdirectory" dired-kill-line-or-subdir t] | |
120 ["Undisplay Tree" dired-kill-tree t] | |
121 ["Undisplay Marked Lines" dired-do-kill t] | |
122 "----" | |
123 ["Redisplay All Files" revert-buffer t] | |
124 ["Redisplay All Marked Files" dired-do-redisplay t] | |
125 ["Undo" dired-undo t] | |
126 "----" | |
127 ["Sort by Date/Name (Toggle)" dired-sort-toggle-or-edit t] | |
128 ["Edit `ls' Switches..." (dired-sort-toggle-or-edit t) t] | |
129 ) | |
130 "----" | |
131 ("Options, This Buffer" | |
132 ["Action is find-file" (set (make-local-variable 'dired-mouse-action) | |
133 'dired-mouse-find-file) | |
134 :style radio | |
135 :selected (eq dired-mouse-action 'dired-mouse-find-file)] | |
136 ["Action is find-file-other-window" | |
137 (set (make-local-variable 'dired-mouse-action) | |
138 'dired-mouse-find-file-other-window) | |
139 :style radio | |
140 :selected (eq dired-mouse-action 'dired-mouse-find-file-other-window)]) | |
141 ("Options, Global" | |
142 ["Action is find-file" (setq-default dired-mouse-action | |
143 'dired-mouse-find-file) | |
144 :style radio | |
145 :selected (eq (default-value 'dired-mouse-action) | |
146 'dired-mouse-find-file)] | |
147 ["Action is find-file-other-window" | |
148 (setq-default dired-mouse-action 'dired-mouse-find-file-other-window) | |
149 :style radio | |
150 :selected (eq (default-value 'dired-mouse-action) | |
151 'dired-mouse-find-file-other-window)]) | |
152 "----" | |
153 ["Explain Last Failure" dired-why t] | |
154 ) | |
155 "*The menu for Dired.") | |
156 | |
157 (defun dired-mouse-file-on-line-p (event) | |
158 "Return t if there is a file under the mouse." | |
159 (interactive "@e") | |
160 (save-excursion | |
161 (mouse-set-point event) | |
162 (if (dired-move-to-filename) | |
163 t | |
164 nil))) | |
165 | |
166 (defun dired-mode-motion-highlight-line (event) | |
167 (if (dired-mouse-file-on-line-p event) | |
168 (mode-motion-highlight-line event))) | |
169 | |
170 (defun dired-install-menubar () | |
171 "Installs the Dired menu at the menubar." | |
172 (if (and (boundp 'current-menubar) current-menubar | |
173 (not (assoc "Dired" current-menubar))) | |
174 (progn | |
175 (set-buffer-menubar (copy-sequence current-menubar)) | |
176 (add-menu nil "Dired" (cdr dired-menu)))) | |
177 (make-local-variable 'mode-motion-hook) | |
178 (setq mode-motion-hook '(dired-mode-motion-highlight-line | |
179 mode-motion-add-help-echo)) | |
180 ;; #### double-click left is supposed to work but it doesn't. | |
181 ;; I'm not sure why. | |
182 (setq mode-motion-help-echo-string | |
183 "Middle button to select file under mouse.") | |
184 ) | |
185 (add-hook 'dired-mode-hook 'dired-install-menubar) | |
186 | |
187 (defun dired-popup-menu (event) | |
188 "Display the Dired Menu." | |
189 (interactive "@e") | |
190 (mouse-set-point event) | |
191 (dired-next-line 0) | |
192 (popup-menu dired-menu)) | |
193 | |
194 (defun dired-mouse-find-file (event) | |
195 "Edit the file under the mouse." | |
196 (interactive "e") | |
197 (mouse-set-point event) | |
198 (dired-next-line 0) | |
199 (dired-find-file)) | |
200 | |
201 (defun dired-mouse-find-file-other-window (event) | |
202 "Edit the file under the mouse, in another window." | |
203 (interactive "e") | |
204 (mouse-set-point event) | |
205 (dired-next-line 0) | |
206 (dired-find-file-other-window)) | |
207 | |
208 (defvar dired-mouse-action 'dired-mouse-find-file | |
209 "*Function to be called when button2 is clicked on a file in Dired.") | |
210 | |
211 (defun dired-mouse-do-action (event) | |
212 (interactive "e") | |
213 (funcall dired-mouse-action event)) | |
214 | |
215 (defun dired-mark-region (&optional form-to-eval) | |
216 "Mark all files in the region." | |
217 (interactive) | |
218 (or form-to-eval (setq form-to-eval '(dired-mark-subdir-or-file nil))) | |
219 (save-excursion | |
220 (let ((end (region-end))) | |
221 (goto-char (region-beginning)) | |
222 (beginning-of-line) | |
223 (while (<= (point) end) | |
224 (save-excursion (eval form-to-eval)) | |
225 (forward-line 1))))) | |
226 | |
227 (defun dired-unmark-region () | |
228 "Unmark all files in the region." | |
229 (interactive) | |
230 (dired-mark-region '(dired-unmark-subdir-or-file nil))) | |
231 | |
232 (defun dired-flag-region () | |
233 "Flag all files in the region for deletion." | |
234 (interactive) | |
235 (dired-mark-region '(dired-flag-file-deleted nil))) | |
236 | |
237 (defun dired-unflag-region () | |
238 "Unflag all files in the region for deletion." | |
239 (interactive) | |
240 (dired-mark-region '(dired-unflag 1))) | |
241 | |
242 | |
243 (define-key dired-mode-map 'button2 'dired-mouse-do-action) | |
244 (define-key dired-mode-map 'button3 'dired-popup-menu) | |
245 | |
246 | |
247 (provide 'dired-xemacs-menu) |