Mercurial > emacs
comparison lisp/dired-x.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 37645a051842 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; dired-x.el --- extra Dired functionality -*-byte-compile-dynamic: t;-*- | 1 ;;; dired-x.el --- extra Dired functionality -*-byte-compile-dynamic: t;-*- |
2 | 2 |
3 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> | 3 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> |
4 ;; Lawrence R. Dodd <dodd@roebling.poly.edu> | 4 ;; Lawrence R. Dodd <dodd@roebling.poly.edu> |
5 ;; Maintainer: FSF (unless Dodd can be found) | 5 ;; Maintainer: Romain Francoise <rfrancoise@gnu.org> |
6 ;; Version: 2.37+ | 6 ;; Version: 2.37+ |
7 ;; Date: 1994/08/18 19:27:42 | 7 ;; Date: 1994/08/18 19:27:42 |
8 ;; Keywords: dired extensions files | 8 ;; Keywords: dired extensions files |
9 | 9 |
10 ;; Copyright (C) 1993, 1994, 1997, 2001, 2003 Free Software Foundation, Inc. | 10 ;; Copyright (C) 1993, 1994, 1997, 2001, 2002, 2003, 2004, |
11 ;; 2005 Free Software Foundation, Inc. | |
11 | 12 |
12 ;; This file is part of GNU Emacs. | 13 ;; This file is part of GNU Emacs. |
13 | 14 |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | 15 ;; GNU Emacs is free software; you can redistribute it and/or modify |
15 ;; it under the terms of the GNU General Public License as published by | 16 ;; it under the terms of the GNU General Public License as published by |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 ;; GNU General Public License for more details. | 23 ;; GNU General Public License for more details. |
23 | 24 |
24 ;; You should have received a copy of the GNU General Public License | 25 ;; You should have received a copy of the GNU General Public License |
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 26 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 27 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
27 ;; Boston, MA 02111-1307, USA. | 28 ;; Boston, MA 02110-1301, USA. |
28 | 29 |
29 ;;; Commentary: | 30 ;;; Commentary: |
30 | 31 |
31 ;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version | 32 ;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version |
32 ;; 1.191, hacked up for GNU Emacs. Redundant or conflicting material has | 33 ;; 1.191, hacked up for GNU Emacs. Redundant or conflicting material has |
48 ;; ;; (setq dired-guess-shell-gnutar "gtar") | 49 ;; ;; (setq dired-guess-shell-gnutar "gtar") |
49 ;; ))) | 50 ;; ))) |
50 ;; (add-hook 'dired-mode-hook | 51 ;; (add-hook 'dired-mode-hook |
51 ;; (function (lambda () | 52 ;; (function (lambda () |
52 ;; ;; Set buffer-local variables here. For example: | 53 ;; ;; Set buffer-local variables here. For example: |
53 ;; ;; (setq dired-omit-files-p t) | 54 ;; ;; (dired-omit-mode 1) |
54 ;; ))) | 55 ;; ))) |
55 ;; | 56 ;; |
56 ;; At load time dired-x.el will install itself, redefine some functions, and | 57 ;; At load time dired-x.el will install itself, redefine some functions, and |
57 ;; bind some dired keys. *Please* see the info pages for more details. | 58 ;; bind some dired keys. *Please* see the info pages for more details. |
58 | 59 |
72 ;; dired-guess-shell-gnutar | 73 ;; dired-guess-shell-gnutar |
73 ;; dired-guess-shell-gzip-quiet | 74 ;; dired-guess-shell-gzip-quiet |
74 ;; dired-guess-shell-znew-switches | 75 ;; dired-guess-shell-znew-switches |
75 ;; dired-guess-shell-alist-user | 76 ;; dired-guess-shell-alist-user |
76 ;; dired-clean-up-buffers-too | 77 ;; dired-clean-up-buffers-too |
77 ;; dired-omit-files-p | 78 ;; dired-omit-mode |
78 ;; dired-omit-files | 79 ;; dired-omit-files |
79 ;; dired-omit-extensions | 80 ;; dired-omit-extensions |
80 ;; dired-omit-size-limit | 81 ;; dired-omit-size-limit |
81 ;; | 82 ;; |
82 ;; To find out more about these variables, load this file, put your cursor at | 83 ;; To find out more about these variables, load this file, put your cursor at |
108 ;; We will redefine some functions and also need some macros so we need to | 109 ;; We will redefine some functions and also need some macros so we need to |
109 ;; load dired stuff of GNU Emacs. | 110 ;; load dired stuff of GNU Emacs. |
110 | 111 |
111 (require 'dired-aux) | 112 (require 'dired-aux) |
112 | 113 |
114 (defvar vm-folder-directory) | |
115 (eval-when-compile (require 'man)) | |
116 | |
113 ;;; User-defined variables. | 117 ;;; User-defined variables. |
114 | 118 |
115 (defgroup dired-x nil | 119 (defgroup dired-x nil |
116 "Extended directory editing (dired-x)." | 120 "Extended directory editing (dired-x)." |
117 :group 'dired) | 121 :group 'dired) |
152 :type '(choice (const :tag "off" nil) | 156 :type '(choice (const :tag "off" nil) |
153 (const :tag "on" t) | 157 (const :tag "on" t) |
154 (other :tag "non-writable only" if-file-read-only)) | 158 (other :tag "non-writable only" if-file-read-only)) |
155 :group 'dired-x) | 159 :group 'dired-x) |
156 | 160 |
157 (defcustom dired-omit-files-p nil | 161 (define-minor-mode dired-omit-mode |
158 "*If non-nil, \"uninteresting\" files are not listed (buffer-local). | 162 "Toggle Dired-Omit mode. |
159 Use \\[dired-omit-toggle] to toggle its value. | 163 With numeric ARG, enable Dired-Omit mode if ARG is positive, disable |
164 otherwise. Enabling and disabling is buffer-local. | |
165 If enabled, \"uninteresting\" files are not listed. | |
160 Uninteresting files are those whose filenames match regexp `dired-omit-files', | 166 Uninteresting files are those whose filenames match regexp `dired-omit-files', |
161 plus those ending with extensions in `dired-omit-extensions'." | 167 plus those ending with extensions in `dired-omit-extensions'." |
162 :type 'boolean | 168 :group 'dired-x |
163 :group 'dired-x) | 169 (if dired-omit-mode |
164 (make-variable-buffer-local 'dired-omit-files-p) | 170 ;; This will mention how many lines were omitted: |
171 (let ((dired-omit-size-limit nil)) (dired-omit-expunge)) | |
172 (revert-buffer))) | |
173 | |
174 ;; For backward compatibility | |
175 (defvaralias 'dired-omit-files-p 'dired-omit-mode) | |
176 (make-obsolete-variable 'dired-omit-files-p 'dired-omit-mode) | |
165 | 177 |
166 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$" | 178 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$" |
167 "*Filenames matching this regexp will not be displayed. | 179 "*Filenames matching this regexp will not be displayed. |
168 This only has effect when `dired-omit-files-p' is t. See interactive function | 180 This only has effect when `dired-omit-mode' is t. See interactive function |
169 `dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable | 181 `dired-omit-mode' \(\\[dired-omit-mode]\) and variable |
170 `dired-omit-extensions'. The default is to omit `.', `..', auto-save | 182 `dired-omit-extensions'. The default is to omit `.', `..', auto-save |
171 files and lock files." | 183 files and lock files." |
172 :type 'regexp | 184 :type 'regexp |
173 :group 'dired-x) | 185 :group 'dired-x) |
174 | 186 |
175 (defcustom dired-find-subdir nil ; t is pretty near to DWIM... | 187 (defcustom dired-find-subdir nil ; t is pretty near to DWIM... |
176 "*If non-nil, Dired always finds a directory in a buffer of its own. | 188 "*If non-nil, Dired always finds a directory in a buffer of its own. |
177 If nil, Dired finds the directory as a subdirectory in some other buffer | 189 If nil, Dired finds the directory as a subdirectory in some other buffer |
178 if it is present as one. | 190 if it is present as one. |
179 | 191 |
180 If there are several Dired buffers for a directory, the most recently | 192 If there are several dired buffers for a directory, the most recently |
181 used is chosen. | 193 used is chosen. |
182 | 194 |
183 Dired avoids switching to the current buffer, so that if you have | 195 Dired avoids switching to the current buffer, so that if you have |
184 a normal and a wildcard buffer for the same directory, \\[dired] will | 196 a normal and a wildcard buffer for the same directory, \\[dired] will |
185 toggle between those two." | 197 toggle between those two." |
191 If nil, there is no maximum size." | 203 If nil, there is no maximum size." |
192 :type '(choice (const :tag "no maximum" nil) integer) | 204 :type '(choice (const :tag "no maximum" nil) integer) |
193 :group 'dired-x) | 205 :group 'dired-x) |
194 | 206 |
195 (defcustom dired-enable-local-variables t | 207 (defcustom dired-enable-local-variables t |
196 "*Control use of local-variables lists in dired. | 208 "*Control use of local-variables lists in Dired. |
197 The value can be t, nil or something else. | 209 The value can be t, nil or something else. |
198 A value of t means local-variables lists are obeyed; | 210 A value of t means local-variables lists are obeyed; |
199 nil means they are ignored; anything else means query. | 211 nil means they are ignored; anything else means query. |
200 | 212 |
201 This temporarily overrides the value of `enable-local-variables' when listing | 213 This temporarily overrides the value of `enable-local-variables' when listing |
222 :type '(choice (const :tag "None" nil) | 234 :type '(choice (const :tag "None" nil) |
223 (string :tag "Switches")) | 235 (string :tag "Switches")) |
224 :group 'dired-x) | 236 :group 'dired-x) |
225 | 237 |
226 (defcustom dired-clean-up-buffers-too t | 238 (defcustom dired-clean-up-buffers-too t |
227 "*Non-nil means offer to kill buffers visiting files and dirs deleted in dired." | 239 "*Non-nil means offer to kill buffers visiting files and dirs deleted in Dired." |
228 :type 'boolean | 240 :type 'boolean |
229 :group 'dired-x) | 241 :group 'dired-x) |
230 | 242 |
231 ;;; KEY BINDINGS. | 243 ;;; KEY BINDINGS. |
232 | 244 |
233 (define-key dired-mode-map "\M-o" 'dired-omit-toggle) | 245 (define-key dired-mode-map "\M-o" 'dired-omit-mode) |
246 (define-key dired-mode-map "*O" 'dired-mark-omitted) | |
234 (define-key dired-mode-map "\M-(" 'dired-mark-sexp) | 247 (define-key dired-mode-map "\M-(" 'dired-mark-sexp) |
235 (define-key dired-mode-map "*(" 'dired-mark-sexp) | 248 (define-key dired-mode-map "*(" 'dired-mark-sexp) |
236 (define-key dired-mode-map "*." 'dired-mark-extension) | 249 (define-key dired-mode-map "*." 'dired-mark-extension) |
237 (define-key dired-mode-map "\M-!" 'dired-smart-shell-command) | 250 (define-key dired-mode-map "\M-!" 'dired-smart-shell-command) |
238 (define-key dired-mode-map "w" 'dired-copy-filename-as-kill) | 251 (define-key dired-mode-map "w" 'dired-copy-filename-as-kill) |
247 (define-key dired-mode-map "N" 'dired-man)) | 260 (define-key dired-mode-map "N" 'dired-man)) |
248 | 261 |
249 (if dired-bind-info | 262 (if dired-bind-info |
250 (define-key dired-mode-map "I" 'dired-info)) | 263 (define-key dired-mode-map "I" 'dired-info)) |
251 | 264 |
265 ;;; MENU BINDINGS | |
266 | |
267 (let ((menu-bar (lookup-key dired-mode-map [menu-bar]))) | |
268 (let ((menu (lookup-key menu-bar [operate]))) | |
269 (define-key-after | |
270 menu | |
271 [find-files] | |
272 '(menu-item | |
273 "Find files" | |
274 dired-do-find-marked-files | |
275 :help "Find current or marked files") | |
276 'delete) | |
277 (define-key-after | |
278 menu | |
279 [relsymlink] | |
280 '(menu-item | |
281 "Relative symlink to..." | |
282 dired-do-relsymlink | |
283 :visible (fboundp 'make-symbolic-link) | |
284 :help "Make relative symbolic links for current or marked files") | |
285 'symlink)) | |
286 (let ((menu (lookup-key menu-bar [mark]))) | |
287 (define-key-after | |
288 menu | |
289 [flag-extension] | |
290 '(menu-item | |
291 "Flag extension..." | |
292 dired-flag-extension | |
293 :help "Flag files with a certain extension for deletion") | |
294 'garbage-files) | |
295 (define-key-after | |
296 menu | |
297 [mark-extension] | |
298 '(menu-item | |
299 "Mark extension..." | |
300 dired-mark-extension | |
301 :help "Mark files with a certain extension") | |
302 'symlinks) | |
303 (define-key-after | |
304 menu | |
305 [mark-omitted] | |
306 '(menu-item | |
307 "Mark omitted" | |
308 dired-mark-omitted | |
309 :help "Mark files matching `dired-omit-files' and `dired-omit-extensions'") | |
310 'mark-extension)) | |
311 (let ((menu (lookup-key menu-bar [regexp]))) | |
312 (define-key-after | |
313 menu | |
314 [relsymlink-regexp] | |
315 '(menu-item | |
316 "Relative symlink..." | |
317 dired-do-relsymlink-regexp | |
318 :visible (fboundp 'make-symbolic-link) | |
319 :help "Make relative symbolic links for files matching regexp") | |
320 'symlink)) | |
321 (let ((menu (lookup-key menu-bar [immediate]))) | |
322 (define-key-after | |
323 menu | |
324 [omit-mode] | |
325 '(menu-item | |
326 "Omit mode" dired-omit-mode | |
327 :button (:toggle . dired-omit-mode) | |
328 :help "Enable or disable omitting \"uninteresting\" files") | |
329 'dashes))) | |
330 | |
252 ;;; GLOBAL BINDING. | 331 ;;; GLOBAL BINDING. |
253 (if dired-bind-jump | 332 (if dired-bind-jump |
254 (progn | 333 (progn |
255 (define-key global-map "\C-x\C-j" 'dired-jump) | 334 (define-key global-map "\C-x\C-j" 'dired-jump) |
256 (define-key global-map "\C-x4\C-j" 'dired-jump-other-window))) | 335 (define-key global-map "\C-x4\C-j" 'dired-jump-other-window))) |
260 | 339 |
261 (add-hook 'dired-mode-hook 'dired-extra-startup) | 340 (add-hook 'dired-mode-hook 'dired-extra-startup) |
262 (add-hook 'dired-after-readin-hook 'dired-omit-expunge) | 341 (add-hook 'dired-after-readin-hook 'dired-omit-expunge) |
263 | 342 |
264 (defun dired-extra-startup () | 343 (defun dired-extra-startup () |
265 "Automatically put on `dired-mode-hook' to get extra dired features: | 344 "Automatically put on `dired-mode-hook' to get extra Dired features: |
266 \\<dired-mode-map> | 345 \\<dired-mode-map> |
267 \\[dired-do-run-mail]\t-- run mail on folder (see `dired-bind-vm') | 346 \\[dired-do-run-mail]\t-- run mail on folder (see `dired-bind-vm') |
268 \\[dired-info]\t-- run info on file | 347 \\[dired-info]\t-- run info on file |
269 \\[dired-man]\t-- run man on file | 348 \\[dired-man]\t-- run man on file |
270 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously | 349 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously |
271 \\[dired-omit-toggle]\t-- toggle omitting of files | 350 \\[dired-omit-mode]\t-- toggle omitting of files |
272 \\[dired-mark-sexp]\t-- mark by Lisp expression | 351 \\[dired-mark-sexp]\t-- mark by Lisp expression |
273 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring. | 352 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring; |
274 \t You can feed it to other commands using \\[yank]. | 353 \t you can feed it to other commands using \\[yank] |
275 | 354 |
276 For more features, see variables | 355 For more features, see variables |
277 | 356 |
278 `dired-bind-vm' | 357 `dired-bind-vm' |
279 `dired-bind-jump' | 358 `dired-bind-jump' |
280 `dired-bind-info' | 359 `dired-bind-info' |
281 `dired-bind-man' | 360 `dired-bind-man' |
282 `dired-vm-read-only-folders' | 361 `dired-vm-read-only-folders' |
283 `dired-omit-files-p' | 362 `dired-omit-mode' |
284 `dired-omit-files' | 363 `dired-omit-files' |
285 `dired-omit-extensions' | 364 `dired-omit-extensions' |
286 `dired-omit-size-limit' | 365 `dired-omit-size-limit' |
287 `dired-find-subdir' | 366 `dired-find-subdir' |
288 `dired-enable-local-variables' | 367 `dired-enable-local-variables' |
346 ;;; EXTENSION MARKING FUNCTIONS. | 425 ;;; EXTENSION MARKING FUNCTIONS. |
347 | 426 |
348 ;;; Mark files with some extension. | 427 ;;; Mark files with some extension. |
349 (defun dired-mark-extension (extension &optional marker-char) | 428 (defun dired-mark-extension (extension &optional marker-char) |
350 "Mark all files with a certain EXTENSION for use in later commands. | 429 "Mark all files with a certain EXTENSION for use in later commands. |
351 A `.' is not automatically prepended to the string entered." | 430 A `.' is *not* automatically prepended to the string entered." |
352 ;; EXTENSION may also be a list of extensions instead of a single one. | 431 ;; EXTENSION may also be a list of extensions instead of a single one. |
353 ;; Optional MARKER-CHAR is marker to use. | 432 ;; Optional MARKER-CHAR is marker to use. |
354 (interactive "sMarking extension: \nP") | 433 (interactive "sMarking extension: \nP") |
355 (or (listp extension) | 434 (or (listp extension) |
356 (setq extension (list extension))) | 435 (setq extension (list extension))) |
396 (interactive) | 475 (interactive) |
397 (dired-flag-extension dired-patch-unclean-extensions)) | 476 (dired-flag-extension dired-patch-unclean-extensions)) |
398 | 477 |
399 (defun dired-clean-tex () | 478 (defun dired-clean-tex () |
400 "Flag dispensable files created by [La]TeX etc. for deletion. | 479 "Flag dispensable files created by [La]TeX etc. for deletion. |
401 See variables `dired-texinfo-unclean-extensions', | 480 See variables `dired-tex-unclean-extensions', |
402 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and | 481 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and |
403 `dired-texinfo-unclean-extensions'." | 482 `dired-texinfo-unclean-extensions'." |
404 (interactive) | 483 (interactive) |
405 (dired-flag-extension (append dired-texinfo-unclean-extensions | 484 (dired-flag-extension (append dired-texinfo-unclean-extensions |
406 dired-latex-unclean-extensions | 485 dired-latex-unclean-extensions |
423 | 502 |
424 ;;;###autoload | 503 ;;;###autoload |
425 (defun dired-jump (&optional other-window) | 504 (defun dired-jump (&optional other-window) |
426 "Jump to dired buffer corresponding to current buffer. | 505 "Jump to dired buffer corresponding to current buffer. |
427 If in a file, dired the current directory and move to file's line. | 506 If in a file, dired the current directory and move to file's line. |
428 If in dired already, pop up a level and goto old directory's line. | 507 If in Dired already, pop up a level and goto old directory's line. |
429 In case the proper dired file line cannot be found, refresh the dired | 508 In case the proper dired file line cannot be found, refresh the dired |
430 buffer and try again." | 509 buffer and try again." |
431 (interactive "P") | 510 (interactive "P") |
432 (let* ((file buffer-file-name) | 511 (let* ((file buffer-file-name) |
433 (dir (if file (file-name-directory file) default-directory))) | 512 (dir (if file (file-name-directory file) default-directory))) |
448 ;; refresh and try again | 527 ;; refresh and try again |
449 (progn | 528 (progn |
450 (dired-insert-subdir (file-name-directory file)) | 529 (dired-insert-subdir (file-name-directory file)) |
451 (dired-goto-file file)) | 530 (dired-goto-file file)) |
452 ;; Toggle omitting, if it is on, and try again. | 531 ;; Toggle omitting, if it is on, and try again. |
453 (if dired-omit-files-p | 532 (if dired-omit-mode |
454 (progn | 533 (progn |
455 (dired-omit-toggle) | 534 (dired-omit-mode) |
456 (dired-goto-file file)))))))) | 535 (dired-goto-file file)))))))) |
457 | 536 |
458 (defun dired-jump-other-window () | 537 (defun dired-jump-other-window () |
459 "Like \\[dired-jump] (dired-jump) but in other window." | 538 "Like \\[dired-jump] (`dired-jump') but in other window." |
460 (interactive) | 539 (interactive) |
461 (dired-jump t)) | 540 (dired-jump t)) |
462 | 541 |
463 ;;; OMITTING. | 542 ;;; OMITTING. |
464 | 543 |
467 | 546 |
468 ;; should probably get rid of this and always use 'no-dir. | 547 ;; should probably get rid of this and always use 'no-dir. |
469 ;; sk 28-Aug-1991 09:37 | 548 ;; sk 28-Aug-1991 09:37 |
470 (defvar dired-omit-localp 'no-dir | 549 (defvar dired-omit-localp 'no-dir |
471 "The LOCALP argument `dired-omit-expunge' passes to `dired-get-filename'. | 550 "The LOCALP argument `dired-omit-expunge' passes to `dired-get-filename'. |
472 If it is 'no-dir, omitting is much faster, but you can only match | 551 If it is `no-dir', omitting is much faster, but you can only match |
473 against the non-directory part of the file name. Set it to nil if you | 552 against the non-directory part of the file name. Set it to nil if you |
474 need to match the entire file name.") | 553 need to match the entire file name.") |
475 | 554 |
476 ;; \017=^O for Omit - other packages can chose other control characters. | 555 ;; \017=^O for Omit - other packages can chose other control characters. |
477 (defvar dired-omit-marker-char ?\017 | 556 (defvar dired-omit-marker-char ?\017 |
478 "Temporary marker used by by dired-omit. | 557 "Temporary marker used by dired-omit. |
479 Should never be used as marker by the user or other packages.") | 558 Should never be used as marker by the user or other packages.") |
480 | 559 |
481 (defun dired-omit-startup () | 560 (defun dired-omit-startup () |
482 (or (assq 'dired-omit-files-p minor-mode-alist) | 561 (or (assq 'dired-omit-mode minor-mode-alist) |
483 (setq minor-mode-alist | 562 (setq minor-mode-alist |
484 (append '((dired-omit-files-p | 563 (append '((dired-omit-mode |
485 (:eval (if (eq major-mode 'dired-mode) | 564 (:eval (if (eq major-mode 'dired-mode) |
486 " Omit" "")))) | 565 " Omit" "")))) |
487 minor-mode-alist)))) | 566 minor-mode-alist)))) |
488 | 567 |
489 (defun dired-omit-toggle (&optional flag) | 568 (defun dired-mark-omitted () |
490 "Toggle omitting files matching `dired-omit-files' and `dired-omit-extensions'. | 569 "Mark files matching `dired-omit-files' and `dired-omit-extensions'." |
491 With an arg, and if omitting was off, don't toggle and just mark the | 570 (interactive) |
492 files but don't actually omit them. | 571 (let ((dired-omit-mode nil)) (revert-buffer)) ;; Show omitted files |
493 With an arg, and if omitting was on, turn it off but don't refresh the buffer." | 572 (dired-mark-unmarked-files (dired-omit-regexp) nil nil dired-omit-localp)) |
494 (interactive "P") | |
495 (if flag | |
496 (if dired-omit-files-p | |
497 (setq dired-omit-files-p (not dired-omit-files-p)) | |
498 (dired-mark-unmarked-files (dired-omit-regexp) nil nil | |
499 dired-omit-localp)) | |
500 ;; no FLAG | |
501 (setq dired-omit-files-p (not dired-omit-files-p)) | |
502 (if (not dired-omit-files-p) | |
503 (revert-buffer) | |
504 ;; this will mention how many were omitted: | |
505 (let ((dired-omit-size-limit nil)) | |
506 (dired-omit-expunge))))) | |
507 | 573 |
508 (defvar dired-omit-extensions | 574 (defvar dired-omit-extensions |
509 (append completion-ignored-extensions | 575 (append completion-ignored-extensions |
510 dired-latex-unclean-extensions | 576 dired-latex-unclean-extensions |
511 dired-bibtex-unclean-extensions | 577 dired-bibtex-unclean-extensions |
513 "If non-nil, a list of extensions \(strings\) to omit from Dired listings. | 579 "If non-nil, a list of extensions \(strings\) to omit from Dired listings. |
514 Defaults to elements of `completion-ignored-extensions', | 580 Defaults to elements of `completion-ignored-extensions', |
515 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and | 581 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and |
516 `dired-texinfo-unclean-extensions'. | 582 `dired-texinfo-unclean-extensions'. |
517 | 583 |
518 See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and | 584 See interactive function `dired-omit-mode' \(\\[dired-omit-mode]\) and |
519 variables `dired-omit-files-p' and `dired-omit-files'.") | 585 variables `dired-omit-mode' and `dired-omit-files'.") |
520 | 586 |
521 (defun dired-omit-expunge (&optional regexp) | 587 (defun dired-omit-expunge (&optional regexp) |
522 "Erases all unmarked files matching REGEXP. | 588 "Erases all unmarked files matching REGEXP. |
523 Does nothing if global variable `dired-omit-files-p' is nil, or if called | 589 Does nothing if global variable `dired-omit-mode' is nil, or if called |
524 non-interactively and buffer is bigger than `dired-omit-size-limit'. | 590 non-interactively and buffer is bigger than `dired-omit-size-limit'. |
525 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits | 591 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits |
526 filenames ending in `dired-omit-extensions'. | 592 filenames ending in `dired-omit-extensions'. |
527 If REGEXP is the empty string, this function is a no-op. | 593 If REGEXP is the empty string, this function is a no-op. |
528 | 594 |
529 This functions works by temporarily binding `dired-marker-char' to | 595 This functions works by temporarily binding `dired-marker-char' to |
530 `dired-omit-marker-char' and calling `dired-do-kill-lines'." | 596 `dired-omit-marker-char' and calling `dired-do-kill-lines'." |
531 (interactive "sOmit files (regexp): ") | 597 (interactive "sOmit files (regexp): ") |
532 (if (and dired-omit-files-p | 598 (if (and dired-omit-mode |
533 (or (interactive-p) | 599 (or (interactive-p) |
534 (not dired-omit-size-limit) | 600 (not dired-omit-size-limit) |
535 (< (buffer-size) dired-omit-size-limit) | 601 (< (buffer-size) dired-omit-size-limit) |
536 (progn | 602 (progn |
537 (message "Not omitting: directory larger than %d characters." | 603 (message "Not omitting: directory larger than %d characters." |
538 dired-omit-size-limit) | 604 dired-omit-size-limit) |
539 (setq dired-omit-files-p nil) | 605 (setq dired-omit-mode nil) |
540 nil))) | 606 nil))) |
541 (let ((omit-re (or regexp (dired-omit-regexp))) | 607 (let ((omit-re (or regexp (dired-omit-regexp))) |
542 (old-modified-p (buffer-modified-p)) | 608 (old-modified-p (buffer-modified-p)) |
543 count) | 609 count) |
544 (or (string= omit-re "") | 610 (or (string= omit-re "") |
571 (defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp) | 637 (defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp) |
572 "Mark unmarked files matching REGEXP, displaying MSG. | 638 "Mark unmarked files matching REGEXP, displaying MSG. |
573 REGEXP is matched against the entire file name. | 639 REGEXP is matched against the entire file name. |
574 Does not re-mark files which already have a mark. | 640 Does not re-mark files which already have a mark. |
575 With prefix argument, unflag all those files. | 641 With prefix argument, unflag all those files. |
576 Second optional argument LOCALP is as in `dired-get-filename'." | 642 Optional fourth argument LOCALP is as in `dired-get-filename'." |
577 (interactive "P") | 643 (interactive "P") |
578 (let ((dired-marker-char (if unflag-p ?\ dired-marker-char))) | 644 (let ((dired-marker-char (if unflag-p ?\s dired-marker-char))) |
579 (dired-mark-if | 645 (dired-mark-if |
580 (and | 646 (and |
581 ;; not already marked | 647 ;; not already marked |
582 (looking-at " ") | 648 (looking-at " ") |
583 ;; uninteresting | 649 ;; uninteresting |
587 | 653 |
588 ;;; REDEFINE. | 654 ;;; REDEFINE. |
589 (defun dired-omit-new-add-entry (filename &optional marker-char relative) | 655 (defun dired-omit-new-add-entry (filename &optional marker-char relative) |
590 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for | 656 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for |
591 ;; files that are going to be omitted anyway. | 657 ;; files that are going to be omitted anyway. |
592 (if dired-omit-files-p | 658 (if dired-omit-mode |
593 ;; perhaps return t without calling ls | 659 ;; perhaps return t without calling ls |
594 (let ((omit-re (dired-omit-regexp))) | 660 (let ((omit-re (dired-omit-regexp))) |
595 (if (or (string= omit-re "") | 661 (if (or (string= omit-re "") |
596 (not | 662 (not |
597 (string-match omit-re | 663 (string-match omit-re |
623 | 689 |
624 ;;; VIRTUAL DIRED MODE. | 690 ;;; VIRTUAL DIRED MODE. |
625 | 691 |
626 ;;; For browsing `ls -lR' listings in a dired-like fashion. | 692 ;;; For browsing `ls -lR' listings in a dired-like fashion. |
627 | 693 |
628 (fset 'virtual-dired 'dired-virtual) | 694 (defalias 'virtual-dired 'dired-virtual) |
629 (defun dired-virtual (dirname &optional switches) | 695 (defun dired-virtual (dirname &optional switches) |
630 "Put this buffer into Virtual Dired mode. | 696 "Put this buffer into Virtual Dired mode. |
631 | 697 |
632 In Virtual Dired mode, all commands that do not actually consult the | 698 In Virtual Dired mode, all commands that do not actually consult the |
633 filesystem will work. | 699 filesystem will work. |
640 buffer. | 706 buffer. |
641 | 707 |
642 If you have save a Dired buffer in a file you can use \\[dired-virtual] to | 708 If you have save a Dired buffer in a file you can use \\[dired-virtual] to |
643 resume it in a later session. | 709 resume it in a later session. |
644 | 710 |
645 Type \\<dired-mode-map>\\[revert-buffer] in the | 711 Type \\<dired-mode-map>\\[revert-buffer] \ |
646 Virtual Dired buffer and answer `y' to convert the virtual to a real | 712 in the Virtual Dired buffer and answer `y' to convert |
647 dired buffer again. You don't have to do this, though: you can relist | 713 the virtual to a real dired buffer again. You don't have to do this, though: |
648 single subdirs using \\[dired-do-redisplay]." | 714 you can relist single subdirs using \\[dired-do-redisplay]." |
649 | 715 |
650 ;; DIRNAME is the top level directory of the buffer. It will become | 716 ;; DIRNAME is the top level directory of the buffer. It will become |
651 ;; its `default-directory'. If nil, the old value of | 717 ;; its `default-directory'. If nil, the old value of |
652 ;; default-directory is used. | 718 ;; default-directory is used. |
653 | 719 |
677 (setq dirname (expand-file-name wildcard default-directory)))) | 743 (setq dirname (expand-file-name wildcard default-directory)))) |
678 ;; If raw ls listing (not a saved old dired buffer), give it a | 744 ;; If raw ls listing (not a saved old dired buffer), give it a |
679 ;; decent subdir headerline: | 745 ;; decent subdir headerline: |
680 (goto-char (point-min)) | 746 (goto-char (point-min)) |
681 (or (looking-at dired-subdir-regexp) | 747 (or (looking-at dired-subdir-regexp) |
682 (dired-insert-headerline default-directory)) | 748 (insert " " |
749 (directory-file-name (file-name-directory default-directory)) | |
750 ":\n")) | |
683 (dired-mode dirname (or switches dired-listing-switches)) | 751 (dired-mode dirname (or switches dired-listing-switches)) |
684 (setq mode-name "Virtual Dired" | 752 (setq mode-name "Virtual Dired" |
685 revert-buffer-function 'dired-virtual-revert) | 753 revert-buffer-function 'dired-virtual-revert) |
686 (set (make-local-variable 'dired-subdir-alist) nil) | 754 (set (make-local-variable 'dired-subdir-alist) nil) |
687 (dired-build-subdir-alist) | 755 (dired-build-subdir-alist) |
727 ;; A zero-arg version of dired-virtual. | 795 ;; A zero-arg version of dired-virtual. |
728 ;; You need my modified version of set-auto-mode for the | 796 ;; You need my modified version of set-auto-mode for the |
729 ;; `buffer-contents-mode-alist'. | 797 ;; `buffer-contents-mode-alist'. |
730 ;; Or you use infer-mode.el and infer-mode-alist, same syntax. | 798 ;; Or you use infer-mode.el and infer-mode-alist, same syntax. |
731 (defun dired-virtual-mode () | 799 (defun dired-virtual-mode () |
732 "Put current buffer into virtual dired mode (see `dired-virtual'). | 800 "Put current buffer into Virtual Dired mode (see `dired-virtual'). |
733 Useful on `buffer-contents-mode-alist' (which see) with the regexp | 801 Useful on `buffer-contents-mode-alist' (which see) with the regexp |
734 | 802 |
735 \"^ \\(/[^ /]+\\)/?+:$\" | 803 \"^ \\(/[^ /]+\\)/?+:$\" |
736 | 804 |
737 to put saved dired buffers automatically into virtual dired mode. | 805 to put saved dired buffers automatically into Virtual Dired mode. |
738 | 806 |
739 Also useful for `auto-mode-alist' (which see) like this: | 807 Also useful for `auto-mode-alist' (which see) like this: |
740 | 808 |
741 \(setq auto-mode-alist (cons '(\"[^/]\\.dired\\'\" . dired-virtual-mode) | 809 \(setq auto-mode-alist (cons '(\"[^/]\\.dired\\'\" . dired-virtual-mode) |
742 auto-mode-alist)\)" | 810 auto-mode-alist)\)" |
770 Knows about the special cases in variable `default-directory-alist'." | 838 Knows about the special cases in variable `default-directory-alist'." |
771 (or (eval (cdr (assq major-mode default-directory-alist))) | 839 (or (eval (cdr (assq major-mode default-directory-alist))) |
772 default-directory)) | 840 default-directory)) |
773 | 841 |
774 (defun dired-smart-shell-command (cmd &optional insert) | 842 (defun dired-smart-shell-command (cmd &optional insert) |
775 "Like function `shell-command', but in the current Tree Dired directory." | 843 "Like function `shell-command', but in the current Virtual Dired directory." |
776 (interactive (list (read-from-minibuffer "Shell command: " | 844 (interactive (list (read-from-minibuffer "Shell command: " |
777 nil nil nil 'shell-command-history) | 845 nil nil nil 'shell-command-history) |
778 current-prefix-arg)) | 846 current-prefix-arg)) |
779 (let ((default-directory (dired-default-directory))) | 847 (let ((default-directory (dired-default-directory))) |
780 (shell-command cmd insert))) | 848 (shell-command cmd insert))) |
802 ;;; Dired Buffer. | 870 ;;; Dired Buffer. |
803 | 871 |
804 (defvar dired-local-variables-file (convert-standard-filename ".dired") | 872 (defvar dired-local-variables-file (convert-standard-filename ".dired") |
805 "Filename, as string, containing local dired buffer variables to be hacked. | 873 "Filename, as string, containing local dired buffer variables to be hacked. |
806 If this file found in current directory, then it will be inserted into dired | 874 If this file found in current directory, then it will be inserted into dired |
807 buffer and `hack-local-variables' will be run. See Emacs Info pages for more | 875 buffer and `hack-local-variables' will be run. See Info node |
808 information on local variables. See also `dired-enable-local-variables'.") | 876 `(emacs)File Variables' for more information on local variables. |
877 See also `dired-enable-local-variables'.") | |
809 | 878 |
810 (defun dired-hack-local-variables () | 879 (defun dired-hack-local-variables () |
811 "Evaluate local variables in `dired-local-variables-file' for dired buffer." | 880 "Evaluate local variables in `dired-local-variables-file' for dired buffer." |
812 (if (and dired-local-variables-file | 881 (if (and dired-local-variables-file |
813 (stringp dired-local-variables-file) | 882 (stringp dired-local-variables-file) |
830 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el. | 899 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el. |
831 (delete-region opoint (point-max))))) | 900 (delete-region opoint (point-max))))) |
832 | 901 |
833 (defun dired-omit-here-always () | 902 (defun dired-omit-here-always () |
834 "Create `dired-local-variables-file' for omitting and reverts directory. | 903 "Create `dired-local-variables-file' for omitting and reverts directory. |
835 Sets dired-omit-file-p to t in a local variables file that is readable by | 904 Sets `dired-omit-mode' to t in a local variables file that is readable by |
836 dired." | 905 dired." |
837 (interactive) | 906 (interactive) |
838 (if (file-exists-p dired-local-variables-file) | 907 (if (file-exists-p dired-local-variables-file) |
839 (message "File `./%s' already exists." dired-local-variables-file) | 908 (message "File `./%s' already exists." dired-local-variables-file) |
840 | 909 |
841 ;; Create `dired-local-variables-file'. | 910 ;; Create `dired-local-variables-file'. |
842 (save-excursion | 911 (save-excursion |
843 (set-buffer (get-buffer-create " *dot-dired*")) | 912 (set-buffer (get-buffer-create " *dot-dired*")) |
844 (erase-buffer) | 913 (erase-buffer) |
845 (insert "Local Variables:\ndired-omit-files-p: t\nEnd:\n") | 914 (insert "Local Variables:\ndired-omit-mode: t\nEnd:\n") |
846 (write-file dired-local-variables-file) | 915 (write-file dired-local-variables-file) |
847 (kill-buffer (current-buffer))) | 916 (kill-buffer (current-buffer))) |
848 | 917 |
849 ;; Run extra-hooks and revert directory. | 918 ;; Run extra-hooks and revert directory. |
850 (dired-extra-startup) | 919 (dired-extra-startup) |
885 ;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not | 954 ;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not |
886 ;;; install GNU zip's version of zcat. | 955 ;;; install GNU zip's version of zcat. |
887 | 956 |
888 (defvar dired-guess-shell-alist-default | 957 (defvar dired-guess-shell-alist-default |
889 (list | 958 (list |
890 (list "\\.tar$" '(if dired-guess-shell-gnutar | 959 (list "\\.tar$" |
891 (concat dired-guess-shell-gnutar " xvf") | 960 '(if dired-guess-shell-gnutar |
892 "tar xvf")) | 961 (concat dired-guess-shell-gnutar " xvf") |
962 "tar xvf") | |
963 ;; Extract files into a separate subdirectory | |
964 '(if dired-guess-shell-gnutar | |
965 (concat "mkdir " (file-name-sans-extension file) | |
966 "; " dired-guess-shell-gnutar " -C " | |
967 (file-name-sans-extension file) " -xvf") | |
968 (concat "mkdir " (file-name-sans-extension file) | |
969 "; tar -C " (file-name-sans-extension file) " -xvf"))) | |
893 | 970 |
894 ;; REGEXPS for compressed archives must come before the .Z rule to | 971 ;; REGEXPS for compressed archives must come before the .Z rule to |
895 ;; be recognized: | 972 ;; be recognized: |
896 (list "\\.tar\\.Z$" | 973 (list "\\.tar\\.Z$" |
897 ;; Untar it. | 974 ;; Untar it. |
905 ;; gzip'ed archives | 982 ;; gzip'ed archives |
906 (list "\\.t\\(ar\\.\\)?gz$" | 983 (list "\\.t\\(ar\\.\\)?gz$" |
907 '(if dired-guess-shell-gnutar | 984 '(if dired-guess-shell-gnutar |
908 (concat dired-guess-shell-gnutar " zxvf") | 985 (concat dired-guess-shell-gnutar " zxvf") |
909 (concat "gunzip -qc * | tar xvf -")) | 986 (concat "gunzip -qc * | tar xvf -")) |
987 ;; Extract files into a separate subdirectory | |
988 '(if dired-guess-shell-gnutar | |
989 (concat "mkdir " (file-name-sans-extension file) | |
990 "; " dired-guess-shell-gnutar " -C " | |
991 (file-name-sans-extension file) " -zxvf") | |
992 (concat "mkdir " (file-name-sans-extension file) | |
993 "; gunzip -qc * | tar -C " | |
994 (file-name-sans-extension file) " -xvf -")) | |
910 ;; Optional decompression. | 995 ;; Optional decompression. |
911 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))) | 996 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))) |
997 | |
912 ;; bzip2'ed archives | 998 ;; bzip2'ed archives |
913 (list "\\.tar\\.bz2$" | 999 (list "\\.t\\(ar\\.bz2\\|bz\\)$" |
914 "bunzip2 -c * | tar xvf -" | 1000 "bunzip2 -c * | tar xvf -" |
1001 ;; Extract files into a separate subdirectory | |
1002 '(concat "mkdir " (file-name-sans-extension file) | |
1003 "; bunzip2 -c * | tar -C " | |
1004 (file-name-sans-extension file) " -xvf -") | |
915 ;; Optional decompression. | 1005 ;; Optional decompression. |
916 "bunzip2") | 1006 "bunzip2") |
917 | 1007 |
918 '("\\.shar.Z$" "zcat * | unshar") | 1008 '("\\.shar\\.Z$" "zcat * | unshar") |
919 '("\\.shar.g?z$" "gunzip -qc * | unshar") | 1009 '("\\.shar\\.g?z$" "gunzip -qc * | unshar") |
920 | 1010 |
921 '("\\.e?ps$" "ghostview" "xloadimage" "lpr") | 1011 '("\\.e?ps$" "ghostview" "xloadimage" "lpr") |
922 (list "\\.e?ps.g?z$" "gunzip -qc * | ghostview -" | 1012 (list "\\.e?ps\\.g?z$" "gunzip -qc * | ghostview -" |
923 ;; Optional decompression. | 1013 ;; Optional decompression. |
924 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | 1014 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) |
925 (list "\\.e?ps.Z$" "zcat * | ghostview -" | 1015 (list "\\.e?ps\\.Z$" "zcat * | ghostview -" |
926 ;; Optional conversion to gzip format. | 1016 ;; Optional conversion to gzip format. |
927 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | 1017 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") |
928 " " dired-guess-shell-znew-switches)) | 1018 " " dired-guess-shell-znew-switches)) |
1019 | |
929 '("\\.patch$" "cat * | patch") | 1020 '("\\.patch$" "cat * | patch") |
930 '("\\.patch.g?z$" "gunzip -qc * | patch") | 1021 (list "\\.patch\\.g?z$" "gunzip -qc * | patch" |
931 (list "\\.patch.Z$" "zcat * | patch" | 1022 ;; Optional decompression. |
1023 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | |
1024 (list "\\.patch\\.Z$" "zcat * | patch" | |
932 ;; Optional conversion to gzip format. | 1025 ;; Optional conversion to gzip format. |
933 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | 1026 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") |
934 " " dired-guess-shell-znew-switches)) | 1027 " " dired-guess-shell-znew-switches)) |
1028 | |
1029 ;; The following four extensions are useful with dired-man ("N" key) | |
1030 (list "\\.[0-9]$" '(progn (require 'man) | |
1031 (if (Man-support-local-filenames) | |
1032 "man -l" | |
1033 "cat * | tbl | nroff -man -h"))) | |
1034 (list "\\.[0-9]\\.g?z$" '(progn (require 'man) | |
1035 (if (Man-support-local-filenames) | |
1036 "man -l" | |
1037 "gunzip -qc * | tbl | nroff -man -h")) | |
1038 ;; Optional decompression. | |
1039 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | |
1040 (list "\\.[0-9]\\.Z$" '(progn (require 'man) | |
1041 (if (Man-support-local-filenames) | |
1042 "man -l" | |
1043 "zcat * | tbl | nroff -man -h")) | |
1044 ;; Optional conversion to gzip format. | |
1045 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | |
1046 " " dired-guess-shell-znew-switches)) | |
1047 '("\\.pod$" "perldoc" "pod2man * | nroff -man") | |
935 | 1048 |
936 '("\\.dvi$" "xdvi" "dvips") ; preview and printing | 1049 '("\\.dvi$" "xdvi" "dvips") ; preview and printing |
937 '("\\.au$" "play") ; play Sun audiofiles | 1050 '("\\.au$" "play") ; play Sun audiofiles |
938 '("\\.mpg$" "mpeg_play") | 1051 '("\\.mpg$" "mpeg_play") |
939 '("\\.uu$" "uudecode") ; for uudecoded files | 1052 '("\\.uu$" "uudecode") ; for uudecoded files |
943 '("\\.gp$" "gnuplot") | 1056 '("\\.gp$" "gnuplot") |
944 '("\\.p[bgpn]m$" "xloadimage") | 1057 '("\\.p[bgpn]m$" "xloadimage") |
945 '("\\.gif$" "xloadimage") ; view gif pictures | 1058 '("\\.gif$" "xloadimage") ; view gif pictures |
946 '("\\.tif$" "xloadimage") | 1059 '("\\.tif$" "xloadimage") |
947 '("\\.png$" "display") ; xloadimage 4.1 doesn't grok PNG | 1060 '("\\.png$" "display") ; xloadimage 4.1 doesn't grok PNG |
948 '("\\.jpg$" "xloadimage") | 1061 '("\\.jpe?g$" "xloadimage") |
949 '("\\.fig$" "xfig") ; edit fig pictures | 1062 '("\\.fig$" "xfig") ; edit fig pictures |
950 '("\\.out$" "xgraph") ; for plotting purposes. | 1063 '("\\.out$" "xgraph") ; for plotting purposes. |
951 '("\\.tex$" "latex" "tex") | 1064 '("\\.tex$" "latex" "tex") |
952 '("\\.texi\\(nfo\\)?$" "makeinfo" "texi2dvi") | 1065 '("\\.texi\\(nfo\\)?$" "makeinfo" "texi2dvi") |
953 '("\\.pdf$" "xpdf") ; edit PDF files | 1066 '("\\.pdf$" "xpdf") ; edit PDF files |
954 | 1067 |
955 ;; Some other popular archivers. | 1068 ;; Some other popular archivers. |
1069 (list "\\.zip$" "unzip" | |
1070 ;; Extract files into a separate subdirectory | |
1071 '(concat "unzip" (if dired-guess-shell-gzip-quiet " -q") | |
1072 " -d " (file-name-sans-extension file))) | |
956 '("\\.zoo$" "zoo x//") | 1073 '("\\.zoo$" "zoo x//") |
957 '("\\.zip$" "unzip") | |
958 '("\\.lzh$" "lharc x") | 1074 '("\\.lzh$" "lharc x") |
959 '("\\.arc$" "arc x") | 1075 '("\\.arc$" "arc x") |
960 '("\\.shar$" "unshar") | 1076 '("\\.shar$" "unshar") |
961 | 1077 |
962 ;; Compression. | 1078 ;; Compression. |
963 (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | 1079 (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) |
1080 (list "\\.dz$" "dictunzip") | |
964 (list "\\.bz2$" "bunzip2") | 1081 (list "\\.bz2$" "bunzip2") |
965 (list "\\.Z$" "uncompress" | 1082 (list "\\.Z$" "uncompress" |
966 ;; Optional conversion to gzip format. | 1083 ;; Optional conversion to gzip format. |
967 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | 1084 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") |
968 " " dired-guess-shell-znew-switches)) | 1085 " " dired-guess-shell-znew-switches)) |
978 | 1095 |
979 Each element of this list looks like | 1096 Each element of this list looks like |
980 | 1097 |
981 \(REGEXP COMMAND...\) | 1098 \(REGEXP COMMAND...\) |
982 | 1099 |
983 where each COMMAND can either be a string or a lisp expression that evaluates | 1100 where each COMMAND can either be a string or a Lisp expression that evaluates |
984 to a string. If several COMMANDs are given, the first one will be the default | 1101 to a string. If several COMMANDs are given, the first one will be the default |
985 and the rest will be added temporarily to the history and can be retrieved | 1102 and the rest will be added temporarily to the history and can be retrieved |
986 with \\[previous-history-element] (M-p) . | 1103 with \\[previous-history-element] (M-p) . |
987 | 1104 |
988 You can set this variable in your ~/.emacs. For example, to add rules for | 1105 You can set this variable in your ~/.emacs. For example, to add rules for |
996 \"BAR-COMMAND-1\" | 1113 \"BAR-COMMAND-1\" |
997 \"BAR-COMMAND-2\")))\)" | 1114 \"BAR-COMMAND-2\")))\)" |
998 :group 'dired-x | 1115 :group 'dired-x |
999 :type '(alist :key-type regexp :value-type (repeat sexp))) | 1116 :type '(alist :key-type regexp :value-type (repeat sexp))) |
1000 | 1117 |
1118 (defcustom dired-guess-shell-case-fold-search t | |
1119 "If non-nil, `dired-guess-shell-alist-default' and | |
1120 `dired-guess-shell-alist-user' are matched case-insensitively." | |
1121 :group 'dired-x | |
1122 :type 'boolean) | |
1123 | |
1001 (defun dired-guess-default (files) | 1124 (defun dired-guess-default (files) |
1002 "Guess a shell commands for FILES. Return command or list of commands. | 1125 "Guess a shell commands for FILES. Return command or list of commands. |
1003 See `dired-guess-shell-alist-user'." | 1126 See `dired-guess-shell-alist-user'." |
1004 | 1127 |
1005 (let* ((case-fold-search nil) ; case-sensitive matching | 1128 (let* ((case-fold-search dired-guess-shell-case-fold-search) |
1006 ;; Prepend the user's alist to the default alist. | 1129 ;; Prepend the user's alist to the default alist. |
1007 (alist (append dired-guess-shell-alist-user | 1130 (alist (append dired-guess-shell-alist-user |
1008 dired-guess-shell-alist-default)) | 1131 dired-guess-shell-alist-default)) |
1009 (file (car files)) | 1132 (file (car files)) |
1010 (flist (cdr files)) | 1133 (flist (cdr files)) |
1171 foo -> /ugly/file/name/that/may/change/any/day/bar/foo" | 1294 foo -> /ugly/file/name/that/may/change/any/day/bar/foo" |
1172 (interactive "P") | 1295 (interactive "P") |
1173 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink) | 1296 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink) |
1174 "RelSymLink" arg dired-keep-marker-relsymlink)) | 1297 "RelSymLink" arg dired-keep-marker-relsymlink)) |
1175 | 1298 |
1176 (defun dired-do-relsymlink-regexp (regexp newname &optional whole-name) | 1299 (defun dired-do-relsymlink-regexp (regexp newname &optional arg whole-name) |
1177 "RelSymlink all marked files containing REGEXP to NEWNAME. | 1300 "RelSymlink all marked files containing REGEXP to NEWNAME. |
1178 See functions `dired-do-rename-regexp' and `dired-do-relsymlink' | 1301 See functions `dired-do-rename-regexp' and `dired-do-relsymlink' |
1179 for more info." | 1302 for more info." |
1180 (interactive (dired-mark-read-regexp "RelSymLink")) | 1303 (interactive (dired-mark-read-regexp "RelSymLink")) |
1181 (dired-do-create-files-regexp | 1304 (dired-do-create-files-regexp |
1182 (function dired-make-relative-symlink) | 1305 (function dired-make-relative-symlink) |
1183 "RelSymLink" nil regexp newname whole-name dired-keep-marker-relsymlink)) | 1306 "RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink)) |
1184 | 1307 |
1185 | 1308 |
1186 ;;; VISIT ALL MARKED FILES SIMULTANEOUSLY. | 1309 ;;; VISIT ALL MARKED FILES SIMULTANEOUSLY. |
1187 | 1310 |
1188 ;;; Brief Description: | 1311 ;;; Brief Description: |
1269 | 1392 |
1270 ;;; Run man on files. | 1393 ;;; Run man on files. |
1271 | 1394 |
1272 (defun dired-man () | 1395 (defun dired-man () |
1273 "Run man on this file. Display old buffer if buffer name matches filename. | 1396 "Run man on this file. Display old buffer if buffer name matches filename. |
1274 Uses ../lisp/man.el of \\[manual-entry] fame." | 1397 Uses `man.el' of \\[manual-entry] fame." |
1275 (interactive) | 1398 (interactive) |
1276 (require 'man) | 1399 (require 'man) |
1277 (let ((file (dired-get-filename)) | 1400 (let* ((file (dired-get-filename)) |
1278 (manual-program "nroff -man -h")) | 1401 (manual-program (replace-regexp-in-string "\\*" "%s" |
1402 (dired-guess-shell-command | |
1403 "Man command: " (list file))))) | |
1279 (Man-getpage-in-background file))) | 1404 (Man-getpage-in-background file))) |
1280 | 1405 |
1281 ;;; Run Info on files. | 1406 ;;; Run Info on files. |
1282 | 1407 |
1283 (defun dired-info () | 1408 (defun dired-info () |
1285 (interactive) | 1410 (interactive) |
1286 (info (dired-get-filename))) | 1411 (info (dired-get-filename))) |
1287 | 1412 |
1288 ;;; Run mail on mail folders. | 1413 ;;; Run mail on mail folders. |
1289 | 1414 |
1290 ;;; (and (not (fboundp 'vm-visit-folder)) | 1415 ;; Avoid compiler warning. |
1291 ;;; (defun vm-visit-folder (file &optional arg) | 1416 (eval-when-compile |
1292 ;;; nil)) | 1417 (when (not (fboundp 'vm-visit-folder)) |
1418 (defun vm-visit-folder (file &optional arg) | |
1419 nil))) | |
1293 | 1420 |
1294 (defun dired-vm (&optional read-only) | 1421 (defun dired-vm (&optional read-only) |
1295 "Run VM on this file. | 1422 "Run VM on this file. |
1296 With prefix arg, visit folder read-only (this requires at least VM 5). | 1423 With prefix arg, visit folder read-only (this requires at least VM 5). |
1297 See also variable `dired-vm-read-only-folders'." | 1424 See also variable `dired-vm-read-only-folders'." |
1387 ;;; REDEFINE. | 1514 ;;; REDEFINE. |
1388 ;;; Redefines dired.el's version of `dired-initial-position' | 1515 ;;; Redefines dired.el's version of `dired-initial-position' |
1389 (defun dired-initial-position (dirname) | 1516 (defun dired-initial-position (dirname) |
1390 "Where point should go in a new listing of DIRNAME. | 1517 "Where point should go in a new listing of DIRNAME. |
1391 Point assumed at beginning of new subdir line. | 1518 Point assumed at beginning of new subdir line. |
1392 You may redefine this function as you wish, e.g. like in dired-x.el." | 1519 You may redefine this function as you wish, e.g. like in `dired-x.el'." |
1393 (end-of-line) | 1520 (end-of-line) |
1394 (if dired-find-subdir (dired-goto-subdir dirname)) ; new | 1521 (if dired-find-subdir (dired-goto-subdir dirname)) ; new |
1395 (if dired-trivial-filenames (dired-goto-next-nontrivial-file))) | 1522 (if dired-trivial-filenames (dired-goto-next-nontrivial-file))) |
1396 | 1523 |
1397 | 1524 |
1447 (beginning-of-line) | 1574 (beginning-of-line) |
1448 (forward-char 2) | 1575 (forward-char 2) |
1449 (if (looking-at dired-re-inode-size) | 1576 (if (looking-at dired-re-inode-size) |
1450 (progn | 1577 (progn |
1451 (goto-char (match-end 0)) | 1578 (goto-char (match-end 0)) |
1452 (setq inode (string-to-int (buffer-substring (match-beginning 1) | 1579 (setq inode (string-to-number (buffer-substring (match-beginning 1) |
1453 (match-end 1))) | 1580 (match-end 1))) |
1454 s (string-to-int (buffer-substring (match-beginning 2) | 1581 s (string-to-number (buffer-substring (match-beginning 2) |
1455 (match-end 2))))) | 1582 (match-end 2))))) |
1456 (setq inode nil | 1583 (setq inode nil |
1457 s nil)) | 1584 s nil)) |
1458 (setq mode (buffer-substring (point) (+ mode-len (point)))) | 1585 (setq mode (buffer-substring (point) (+ mode-len (point)))) |
1459 (forward-char mode-len) | 1586 (forward-char mode-len) |
1460 (setq nlink (read (current-buffer))) | 1587 (setq nlink (read (current-buffer))) |
1461 ;; Karsten Wenger <kw@cis.uni-muenchen.de> fixed uid. | 1588 ;; Karsten Wenger <kw@cis.uni-muenchen.de> fixed uid. |
1462 (setq uid (buffer-substring (+ (point) 1) | 1589 (setq uid (buffer-substring (+ (point) 1) |
1463 (progn (forward-word 1) (point)))) | 1590 (progn (forward-word 1) (point)))) |
1464 (re-search-forward "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|\ | 1591 (re-search-forward directory-listing-before-filename-regexp) |
1465 Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)") | |
1466 (goto-char (match-beginning 1)) | 1592 (goto-char (match-beginning 1)) |
1467 (forward-char -1) | 1593 (forward-char -1) |
1468 (setq size (string-to-int (buffer-substring (save-excursion | 1594 (setq size (string-to-number (buffer-substring (save-excursion |
1469 (backward-word 1) | 1595 (backward-word 1) |
1470 (setq pos (point))) | 1596 (setq pos (point))) |
1471 (point)))) | 1597 (point)))) |
1472 (goto-char pos) | 1598 (goto-char pos) |
1473 (backward-word 1) | 1599 (backward-word 1) |
1474 ;; if no gid is displayed, gid will be set to uid | 1600 ;; if no gid is displayed, gid will be set to uid |
1475 ;; but user will then not reference it anyway in PREDICATE. | 1601 ;; but user will then not reference it anyway in PREDICATE. |
1476 (setq gid (buffer-substring (save-excursion | 1602 (setq gid (buffer-substring (save-excursion |
1497 ;;; FIND FILE AT POINT. | 1623 ;;; FIND FILE AT POINT. |
1498 | 1624 |
1499 (defvar dired-x-hands-off-my-keys t | 1625 (defvar dired-x-hands-off-my-keys t |
1500 "*Non-nil means don't bind `dired-x-find-file' over `find-file' on keyboard. | 1626 "*Non-nil means don't bind `dired-x-find-file' over `find-file' on keyboard. |
1501 Similarly for `dired-x-find-file-other-window' over `find-file-other-window'. | 1627 Similarly for `dired-x-find-file-other-window' over `find-file-other-window'. |
1502 If you change this variable after dired-x.el is loaded then do | 1628 If you change this variable after `dired-x.el' is loaded then do |
1503 \\[dired-x-bind-find-file].") | 1629 \\[dired-x-bind-find-file].") |
1504 | 1630 |
1505 ;;; Bind `dired-x-find-file{-other-window}' over wherever | 1631 ;;; Bind `dired-x-find-file{-other-window}' over wherever |
1506 ;;; `find-file{-other-window}' is bound? | 1632 ;;; `find-file{-other-window}' is bound? |
1507 (defun dired-x-bind-find-file () | 1633 (defun dired-x-bind-find-file () |
1508 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\). | 1634 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\). |
1509 Similarly for `dired-x-find-file-other-window' and `find-file-other-window'. | 1635 Similarly for `dired-x-find-file-other-window' and `find-file-other-window'. |
1510 Binding direction based on `dired-x-hands-off-my-keys'. | 1636 Binding direction based on `dired-x-hands-off-my-keys'. |
1511 This function part of `after-init-hook'." | 1637 This function is part of `after-init-hook'." |
1512 (interactive) | 1638 (interactive) |
1513 (if (interactive-p) | 1639 (if (interactive-p) |
1514 (setq dired-x-hands-off-my-keys | 1640 (setq dired-x-hands-off-my-keys |
1515 (not (y-or-n-p "Bind dired-x-find-file over find-file? ")))) | 1641 (not (y-or-n-p "Bind dired-x-find-file over find-file? ")))) |
1516 (cond ((not dired-x-hands-off-my-keys) | 1642 (cond ((not dired-x-hands-off-my-keys) |
1539 "Edit file FILENAME. | 1665 "Edit file FILENAME. |
1540 May create a new window, or reuse an existing one. | 1666 May create a new window, or reuse an existing one. |
1541 See the function `display-buffer'. | 1667 See the function `display-buffer'. |
1542 | 1668 |
1543 Identical to `find-file' except when called interactively, with a prefix arg | 1669 Identical to `find-file' except when called interactively, with a prefix arg |
1544 \(e.g., \\[universal-argument]\), in which case it guesses filename near | 1670 \(e.g., \\[universal-argument]\), in which case it guesses filename near point. |
1545 point. Useful for editing file mentioned in buffer you are viewing, or to | 1671 Useful for editing file mentioned in buffer you are viewing, |
1546 test if that file exists. Use minibuffer after snatching filename." | 1672 or to test if that file exists. Use minibuffer after snatching filename." |
1547 (interactive (list (read-filename-at-point "Find file: "))) | 1673 (interactive (list (read-filename-at-point "Find file: "))) |
1548 (find-file (expand-file-name filename))) | 1674 (find-file (expand-file-name filename))) |
1549 | 1675 |
1550 (defun dired-x-find-file-other-window (filename) | 1676 (defun dired-x-find-file-other-window (filename) |
1551 "Edit file FILENAME, in another window. | 1677 "Edit file FILENAME, in another window. |
1552 May create a new window, or reuse an existing one. | 1678 May create a new window, or reuse an existing one. |
1553 See the function `display-buffer'. | 1679 See the function `display-buffer'. |
1554 | 1680 |
1555 Identical to `find-file-other-window' except when called interactively, with a | 1681 Identical to `find-file-other-window' except when called interactively, with a |
1556 prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename | 1682 prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename near point. |
1557 near point. Useful for editing file mentioned in buffer you are viewing, or | 1683 Useful for editing file mentioned in buffer you are viewing, |
1558 to test if that file exists. Use minibuffer after snatching filename." | 1684 or to test if that file exists. Use minibuffer after snatching filename." |
1559 (interactive (list (read-filename-at-point "Find file: "))) | 1685 (interactive (list (read-filename-at-point "Find file: "))) |
1560 (find-file-other-window (expand-file-name filename))) | 1686 (find-file-other-window (expand-file-name filename))) |
1561 | 1687 |
1562 ;;; Internal functions. | 1688 ;;; Internal functions. |
1563 | 1689 |
1635 'dired-guess-shell-gnutar | 1761 'dired-guess-shell-gnutar |
1636 'dired-guess-shell-gzip-quiet | 1762 'dired-guess-shell-gzip-quiet |
1637 'dired-guess-shell-znew-switches | 1763 'dired-guess-shell-znew-switches |
1638 'dired-guess-shell-alist-user | 1764 'dired-guess-shell-alist-user |
1639 'dired-clean-up-buffers-too | 1765 'dired-clean-up-buffers-too |
1640 'dired-omit-files-p | 1766 'dired-omit-mode |
1641 'dired-omit-files | 1767 'dired-omit-files |
1642 'dired-omit-extensions | 1768 'dired-omit-extensions |
1643 ) | 1769 ) |
1644 "List of variables to be appended to reports sent by `dired-x-submit-report'.") | 1770 "List of variables to be appended to reports sent by `dired-x-submit-report'.") |
1645 | 1771 |
1646 (defun dired-x-submit-report () | 1772 (defun dired-x-submit-report () |
1647 "Submit via reporter.el a bug report on program. | 1773 "Submit via `reporter.el' a bug report on program. |
1648 Send report on `dired-x-file' version `dired-x-version,' to | 1774 Send report on `dired-x-file' version `dired-x-version,' to |
1649 `dired-x-maintainer' at address `dired-x-help-address' listing | 1775 `dired-x-maintainer' at address `dired-x-help-address' listing |
1650 variables `dired-x-variable-list' in the message." | 1776 variables `dired-x-variable-list' in the message." |
1651 (interactive) | 1777 (interactive) |
1652 | 1778 |
1659 | 1785 |
1660 | 1786 |
1661 ;; As Barry Warsaw would say: "This might be useful..." | 1787 ;; As Barry Warsaw would say: "This might be useful..." |
1662 (provide 'dired-x) | 1788 (provide 'dired-x) |
1663 | 1789 |
1790 ;; arch-tag: 71a43ba2-7a00-4793-a028-0613dd7765ae | |
1664 ;;; dired-x.el ends here | 1791 ;;; dired-x.el ends here |