Undo previous change.
[bpt/emacs.git] / lisp / dired-x.el
CommitLineData
cb3fe1f0
RS
1;;; dired-x.el --- Sebastian Kremer's Extra DIRED hacked up for GNU Emacs19
2
3;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>
4;; Lawrence R. Dodd <dodd@roebling.poly.edu>
5;; Maintainer: Lawrence R. Dodd <dodd@roebling.poly.edu>
9b5ef74b
RS
6;; Version: 2.37+
7;; Date: 1994/08/18 19:27:42
cb3fe1f0
RS
8;; Keywords: dired extensions
9
286c247d 10;; Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc.
cb3fe1f0
RS
11
12;; This file is part of GNU Emacs.
13
14;; 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
de3b6439 16;; the Free Software Foundation; either version 2, or (at your option)
cb3fe1f0
RS
17;; any later version.
18
19;; GNU Emacs is distributed in the hope that it will be useful,
20;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22;; GNU General Public License for more details.
23
24;; You should have received a copy of the GNU General Public License
b578f267
EN
25;; along with GNU Emacs; see the file COPYING. If not, write to the
26;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27;; Boston, MA 02111-1307, USA.
cb3fe1f0 28
9572a9dd 29;;; Commentary:
cb3fe1f0 30
b578f267
EN
31;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version
32;; 1.191, hacked up for GNU Emacs 19. Redundant or conflicting material
33;; has been removed or renamed in order to work properly with dired of
34;; GNU Emacs 19. All suggestions or comments are most welcomed.
35
36;;
37;; Please, PLEASE, *PLEASE* see the info pages.
38;;
39
40;; BUGS: Type M-x dired-x-submit-report and a report will be generated.
41
42;; INSTALLATION: In your ~/.emacs,
43;;
44;; (add-hook 'dired-load-hook
45;; (function (lambda ()
46;; (load "dired-x")
47;; ;; Set global variables here. For example:
48;; ;; (setq dired-guess-shell-gnutar "gtar")
49;; )))
50;; (add-hook 'dired-mode-hook
51;; (function (lambda ()
52;; ;; Set buffer-local variables here. For example:
53;; ;; (setq dired-omit-files-p t)
54;; )))
55;;
56;; 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
59;; CAUTION: If you are using a version of GNU Emacs earlier than 19.20 than
60;; you may have to edit dired.el. The copy of dired.el in GNU Emacs versions
61;; earlier than 19.20 incorrectly had the call to run-hooks *before* the call
62;; to provide. In such a case, it is possible that byte-compiling and/or
63;; loading dired can cause an infinite loop. To prevent this, make sure the
64;; line of code
65;;
66;; (run-hooks 'dired-load-hook)
67;;
68;; is the *last* executable line in the file dired.el. That is, make sure it
69;; comes *after* the line
70;;
71;; (provide 'dired)
72;;
73;; *Please* see the info pages for more details.
74
75;; User defined variables:
76;;
77;; dired-bind-vm
78;; dired-vm-read-only-folders
79;; dired-bind-jump
80;; dired-bind-info
81;; dired-bind-man
82;; dired-x-hands-off-my-keys
83;; dired-find-subdir
84;; dired-enable-local-variables
85;; dired-local-variables-file
86;; dired-guess-shell-gnutar
87;; dired-guess-shell-gzip-quiet
88;; dired-guess-shell-znew-switches
89;; dired-guess-shell-alist-user
90;; dired-clean-up-buffers-too
91;; dired-omit-files-p
92;; dired-omit-files
93;; dired-omit-extensions
ad8c4554 94;; dired-omit-size-limit
b578f267
EN
95;;
96;; To find out more about these variables, load this file, put your cursor at
97;; the end of any of the variable names, and hit C-h v [RET]. *Please* see
98;; the info pages for more details.
99
100;; When loaded this code redefines the following functions of GNU Emacs
101;;
102;; Function Found in this file of GNU Emacs
103;; -------- -------------------------------
104;; dired-clean-up-after-deletion ../lisp/dired.el
105;; dired-find-buffer-nocreate ../lisp/dired.el
106;; dired-initial-position ../lisp/dired.el
107;;
108;; dired-add-entry ../lisp/dired-aux.el
109;; dired-read-shell-command ../lisp/dired-aux.el
110;;
111;; One drawback is that dired-x.el will load dired-aux.el as soon as dired is
112;; loaded. Thus, the advantage of separating out non-essential dired stuff
113;; into dired-aux.el and only loading when necessary will be lost. Please
114;; note also that some of the comments in dired.el and dired-aux.el are
115;; Kremer's that referred to the old dired-x.el. This now should be referring
116;; to this program. (This is also a good reason to call this dired-x.el
117;; instead of dired-x19.el.)
cb3fe1f0
RS
118
119\f
b578f267 120;;; Code:
cb3fe1f0 121
b578f267 122;; LOAD.
cb3fe1f0 123
b578f267
EN
124;; This is a no-op if dired-x is being loaded via `dired-load-hook'. It is
125;; here in case the user has autoloaded dired-x via the dired-jump key binding
126;; (instead of autoloading to dired as is suggested in the info-pages).
9572a9dd 127
d82cfc0c 128(require 'dired)
9572a9dd 129
b578f267
EN
130;; We will redefine some functions and also need some macros so we need to
131;; load dired stuff of GNU Emacs.
d82cfc0c
RS
132
133(require 'dired-aux)
9572a9dd 134
b578f267 135;;; User-defined variables.
cb3fe1f0 136
286c247d
RS
137(defgroup dired-x nil
138 "Extended directory editing (dired-x)."
139 :group 'dired)
cb3fe1f0 140
286c247d
RS
141(defgroup dired-keys nil
142 "Dired keys customizations."
143 :prefix "dired-"
144 :group 'dired-x)
cb3fe1f0 145
286c247d
RS
146(defcustom dired-bind-vm nil
147 "*t says \"V\" in dired-mode will `dired-vm', otherwise \"V\" is `dired-rmail'.
148Also, RMAIL files contain -*- rmail -*- at the top so \"f\",
149`dired-advertised-find-file', will run rmail."
150 :type 'boolean
151 :group 'dired-keys)
152
153(defcustom dired-bind-jump t
154 "*t says bind `dired-jump' to C-x C-j, otherwise do not."
155 :type 'boolean
156 :group 'dired-keys)
157
158(defcustom dired-bind-man t
159 "*t says bind `dired-man' to \"N\" in dired-mode, otherwise do not."
160 :type 'boolean
161 :group 'dired-keys)
162
163(defcustom dired-bind-info t
164 "*t says bind `dired-info' to \"I\" in dired-mode, otherwise do not."
165 :type 'boolean
166 :group 'dired-keys)
167
168(defcustom dired-vm-read-only-folders nil
cb3fe1f0
RS
169 "*If t, \\[dired-vm] will visit all folders read-only.
170If neither nil nor t, e.g. the symbol `if-file-read-only', only
171files not writable by you are visited read-only.
172
286c247d
RS
173Read-only folders only work in VM 5, not in VM 4."
174 :type '(choice (const :tag "off" nil)
175 (const :tag "on" t)
176 (sexp :tag "non-writable only" if-file-read-only))
177 :group 'dired-x)
cb3fe1f0 178
286c247d 179(defcustom dired-omit-files-p nil
cb3fe1f0
RS
180 "*If non-nil, \"uninteresting\" files are not listed (buffer-local).
181Use \\[dired-omit-toggle] to toggle its value.
182Uninteresting files are those whose filenames match regexp `dired-omit-files',
286c247d
RS
183plus those ending with extensions in `dired-omit-extensions'."
184 :type 'boolean
185 :group 'dired-x)
e2439696 186(make-variable-buffer-local 'dired-omit-files-p)
cb3fe1f0 187
99358b97 188(defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$"
e2439696 189 "*Filenames matching this regexp will not be displayed.
685ff9f8
RS
190This only has effect when `dired-omit-files-p' is t. See interactive function
191`dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable
99358b97
RS
192`dired-omit-extensions'. The default is to omit `.', `..', auto-save
193files and lock files."
286c247d
RS
194 :type 'regexp
195 :group 'dired-x)
cb3fe1f0 196
286c247d 197(defcustom dired-find-subdir nil ; t is pretty near to DWIM...
0a44133e
RS
198 "*If non-nil, Dired always finds a directory in a buffer of its own.
199If nil, Dired finds the directory as a subdirectory in some other buffer
200if it is present as one.
cb3fe1f0
RS
201
202If there are several Dired buffers for a directory, the most recently
203used is chosen.
204
205Dired avoids switching to the current buffer, so that if you have
206a normal and a wildcard buffer for the same directory, C-x d RET will
286c247d
RS
207toggle between those two."
208 :type 'boolean
209 :group 'dired-x)
210
211(defcustom dired-omit-size-limit 20000
212 "*Maximum size for the \"omitting\" feature.
213If nil, there is no maximum size."
214 :type '(choice (const :tag "no maximum" nil) integer)
215 :group 'dired-x)
cb3fe1f0 216
286c247d 217(defcustom dired-enable-local-variables t
cb3fe1f0
RS
218 "*Control use of local-variables lists in dired.
219The value can be t, nil or something else.
220A value of t means local-variables lists are obeyed;
221nil means they are ignored; anything else means query.
222
223This temporarily overrides the value of `enable-local-variables' when listing
286c247d
RS
224a directory. See also `dired-local-variables-file'."
225 :type 'boolean
226 :group 'dired-x)
cb3fe1f0 227
286c247d 228(defcustom dired-guess-shell-gnutar nil
cb3fe1f0
RS
229 "*If non-nil, name of GNU tar executable (e.g., \"tar\" or \"gtar\") and `z'
230switch will be used for compressed or gzip'ed tar files. If no GNU tar, set
286c247d
RS
231to nil: a pipe using `zcat' or `gunzip -c' will be used."
232 :type 'boolean
233 :group 'dired-x)
234
235(defcustom dired-guess-shell-gzip-quiet t
236 "*non-nil says pass -q to gzip overriding verbose GZIP environment."
237 :type 'boolean
238 :group 'dired-x)
239
240(defcustom dired-guess-shell-znew-switches nil
241 "*If non-nil, then string of switches passed to `znew', example: \"-K\""
242 :type 'boolean
243 :group 'dired-x)
244
245(defcustom dired-clean-up-buffers-too t
246 "*t says offer to kill buffers visiting files and dirs deleted in dired."
247 :type 'boolean
248 :group 'dired-x)
cb3fe1f0 249
b578f267 250;;; KEY BINDINGS.
cb3fe1f0
RS
251
252(define-key dired-mode-map "\M-o" 'dired-omit-toggle)
253(define-key dired-mode-map "\M-(" 'dired-mark-sexp)
582bd36a
RS
254(define-key dired-mode-map "*(" 'dired-mark-sexp)
255(define-key dired-mode-map "*." 'dired-mark-extension)
cb3fe1f0
RS
256(define-key dired-mode-map "\M-!" 'dired-smart-shell-command)
257(define-key dired-mode-map "T" 'dired-do-toggle)
582bd36a 258(define-key dired-mode-map "*t" 'dired-do-toggle)
cb3fe1f0
RS
259(define-key dired-mode-map "w" 'dired-copy-filename-as-kill)
260(define-key dired-mode-map "\M-g" 'dired-goto-file)
261(define-key dired-mode-map "\M-G" 'dired-goto-subdir)
262(define-key dired-mode-map "F" 'dired-do-find-marked-files)
263(define-key dired-mode-map "Y" 'dired-do-relsymlink)
264(define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp)
265(define-key dired-mode-map "V" 'dired-do-run-mail)
266
267(if dired-bind-man
268 (define-key dired-mode-map "N" 'dired-man))
269
270(if dired-bind-info
271 (define-key dired-mode-map "I" 'dired-info))
272
9572a9dd 273;;; GLOBAL BINDING.
cb3fe1f0
RS
274(if dired-bind-jump
275 (progn
276 (define-key global-map "\C-x\C-j" 'dired-jump)
277 (define-key global-map "\C-x4\C-j" 'dired-jump-other-window)))
278
279\f
b578f267 280;;; Install into appropriate hooks.
cb3fe1f0
RS
281
282(add-hook 'dired-mode-hook 'dired-extra-startup)
283(add-hook 'dired-after-readin-hook 'dired-omit-expunge)
284
285(defun dired-extra-startup ()
286 "Automatically put on dired-mode-hook to get extra dired features:
287\\<dired-mode-map>
288
289 \\[dired-do-run-mail]\t-- run mail on folder (see `dired-bind-vm')
290 \\[dired-info]\t-- run info on file
291 \\[dired-man]\t-- run man on file
292 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously
293 \\[dired-omit-toggle]\t-- toggle omitting of files
294 \\[dired-do-toggle]\t-- toggle marks
295 \\[dired-mark-sexp]\t-- mark by lisp expression
296 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring.
297 \t You can feed it to other commands using \\[yank].
298
299For more features, see variables
300
301 dired-bind-vm
302 dired-bind-jump
303 dired-bind-info
304 dired-bind-man
305 dired-vm-read-only-folders
306 dired-omit-files-p
307 dired-omit-files
308 dired-omit-extensions
ad8c4554 309 dired-omit-size-limit
cb3fe1f0
RS
310 dired-find-subdir
311 dired-enable-local-variables
312 dired-local-variables-file
313 dired-guess-shell-gnutar
314 dired-guess-shell-gzip-quiet
315 dired-guess-shell-znew-switches
316 dired-guess-shell-alist-user
9572a9dd 317 dired-clean-up-buffers-too
cb3fe1f0
RS
318
319See also functions
320
321 dired-flag-extension
322 dired-virtual
323 dired-jump
324 dired-man
325 dired-vm
326 dired-rmail
327 dired-info
328 dired-do-find-marked-files
329"
330 (interactive)
331
332 ;; These must be done in each new dired buffer.
333 (dired-hack-local-variables)
334 (dired-omit-startup))
335
336\f
b578f267 337;;; BUFFER CLEANING.
cb3fe1f0 338
b578f267 339;; REDEFINE.
cb3fe1f0
RS
340(defun dired-clean-up-after-deletion (fn)
341
342 ;; Clean up after a deleted file or directory FN.
343 ;; Remove expanded subdir of deleted dir, if any.
344 (save-excursion (and (cdr dired-subdir-alist)
345 (dired-goto-subdir fn)
346 (dired-kill-subdir)))
347
348 ;; Offer to kill buffer of deleted file FN.
349 (if dired-clean-up-buffers-too
350 (progn
351 (let ((buf (get-file-buffer fn)))
352 (and buf
353 (funcall (function y-or-n-p)
354 (format "Kill buffer of %s, too? "
355 (file-name-nondirectory fn)))
356 (save-excursion ; you never know where kill-buffer leaves you
357 (kill-buffer buf))))
12c38283 358 (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))
cb3fe1f0
RS
359 (buf nil))
360 (and buf-list
361 (y-or-n-p (format "Kill dired buffer%s of %s, too? "
362 (dired-plural-s (length buf-list))
363 (file-name-nondirectory fn)))
364 (while buf-list
365 (save-excursion (kill-buffer (car buf-list)))
366 (setq buf-list (cdr buf-list)))))))
9572a9dd 367 ;; Anything else?
cb3fe1f0
RS
368 )
369
370\f
b578f267 371;;; EXTENSION MARKING FUNCTIONS.
cb3fe1f0 372
9572a9dd 373;;; Mark files with some extension.
cb3fe1f0
RS
374(defun dired-mark-extension (extension &optional marker-char)
375 "Mark all files with a certain extension for use in later commands.
376A `.' is not automatically prepended to the string entered."
377 ;; EXTENSION may also be a list of extensions instead of a single one.
378 ;; Optional MARKER-CHAR is marker to use.
379 (interactive "sMarking extension: \nP")
380 (or (listp extension)
381 (setq extension (list extension)))
382 (dired-mark-files-regexp
383 (concat ".";; don't match names with nothing but an extension
384 "\\("
385 (mapconcat 'regexp-quote extension "\\|")
386 "\\)$")
387 marker-char))
388
389(defun dired-flag-extension (extension)
390 "In dired, flag all files with a certain extension for deletion.
391A `.' is *not* automatically prepended to the string entered."
392 (interactive "sFlagging extension: ")
393 (dired-mark-extension extension dired-del-marker))
394
395;;; Define some unpopular file extensions. Used for cleaning and omitting.
396
397(defvar dired-patch-unclean-extensions
398 '(".rej" ".orig")
399 "List of extensions of dispensable files created by the `patch' program.")
400
401(defvar dired-tex-unclean-extensions
402 '(".toc" ".log" ".aux");; these are already in completion-ignored-extensions
403 "List of extensions of dispensable files created by TeX.")
404
405(defvar dired-latex-unclean-extensions
406 '(".idx" ".lof" ".lot" ".glo")
407 "List of extensions of dispensable files created by LaTeX.")
408
409(defvar dired-bibtex-unclean-extensions
410 '(".blg" ".bbl")
411 "List of extensions of dispensable files created by BibTeX.")
412
413(defvar dired-texinfo-unclean-extensions
414 '(".cp" ".cps" ".fn" ".fns" ".ky" ".kys" ".pg" ".pgs"
415 ".tp" ".tps" ".vr" ".vrs")
416 "List of extensions of dispensable files created by texinfo.")
417
418(defun dired-clean-patch ()
419 "Flag dispensable files created by patch for deletion.
420See variable `dired-patch-unclean-extensions'."
421 (interactive)
422 (dired-flag-extension dired-patch-unclean-extensions))
423
424(defun dired-clean-tex ()
9572a9dd
KH
425 "Flag dispensable files created by [La]TeX etc. for deletion.
426See variables `dired-texinfo-unclean-extensions',
427`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
428`dired-texinfo-unclean-extensions'."
cb3fe1f0
RS
429 (interactive)
430 (dired-flag-extension (append dired-texinfo-unclean-extensions
431 dired-latex-unclean-extensions
432 dired-bibtex-unclean-extensions
433 dired-tex-unclean-extensions)))
434
9572a9dd
KH
435(defun dired-very-clean-tex ()
436 "Flag dispensable files created by [La]TeX *and* \".dvi\" for deletion.
437See variables `dired-texinfo-unclean-extensions',
438`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
439`dired-texinfo-unclean-extensions'."
cb3fe1f0 440 (interactive)
9572a9dd
KH
441 (dired-flag-extension (append dired-texinfo-unclean-extensions
442 dired-latex-unclean-extensions
443 dired-bibtex-unclean-extensions
444 dired-tex-unclean-extensions
445 (list ".dvi"))))
cb3fe1f0 446\f
b578f267 447;;; JUMP.
cb3fe1f0 448
40c8b203 449;;;###autoload
cb3fe1f0
RS
450(defun dired-jump (&optional other-window)
451 "Jump to dired buffer corresponding to current buffer.
452If in a file, dired the current directory and move to file's line.
453If in dired already, pop up a level and goto old directory's line.
454In case the proper dired file line cannot be found, refresh the dired
455buffer and try again."
456 (interactive "P")
457 (let* ((file buffer-file-name)
458 (dir (if file (file-name-directory file) default-directory)))
459 (if (eq major-mode 'dired-mode)
460 (progn
461 (setq dir (dired-current-directory))
462 (dired-up-directory other-window)
463 (or (dired-goto-file dir)
464 ;; refresh and try again
9572a9dd 465 (progn
cb3fe1f0
RS
466 (dired-insert-subdir (file-name-directory dir))
467 (dired-goto-file dir))))
468 (if other-window
469 (dired-other-window dir)
470 (dired dir))
471 (if file
472 (or (dired-goto-file file)
473 ;; refresh and try again
9572a9dd 474 (progn
cb3fe1f0 475 (dired-insert-subdir (file-name-directory file))
7e90bcf5
RS
476 (dired-goto-file file))
477 ;; Toggle omitting, if it is on, and try again.
478 (if dired-omit-files-p
479 (progn
480 (dired-omit-toggle)
481 (dired-goto-file file))))))))
cb3fe1f0
RS
482
483(defun dired-jump-other-window ()
484 "Like \\[dired-jump] (dired-jump) but in other window."
485 (interactive)
486 (dired-jump t))
cb3fe1f0 487\f
b578f267 488;;; TOGGLE.
cb3fe1f0
RS
489;;; Toggle marked files with unmarked files.
490
491(defun dired-do-toggle ()
492 "Toggle marks.
493That is, currently marked files become unmarked and vice versa.
494Files marked with other flags (such as `D') are not affected.
495`.' and `..' are never toggled.
496As always, hidden subdirs are not affected."
497 (interactive)
498 (save-excursion
499 (goto-char (point-min))
500 (let (buffer-read-only)
501 (while (not (eobp))
502 (or (dired-between-files)
503 (looking-at dired-re-dot)
504 ;; use subst instead of insdel because it does not move
505 ;; the gap and thus should be faster and because
506 ;; other characters are left alone automatically
507 (apply 'subst-char-in-region
508 (point) (1+ (point))
509 (if (eq ?\040 (following-char)) ; SPC
510 (list ?\040 dired-marker-char)
511 (list dired-marker-char ?\040))))
512 (forward-line 1)))))
513
514\f
b578f267 515;;; COPY NAMES OF MARKED FILES INTO KILL-RING.
9572a9dd 516
cb3fe1f0
RS
517(defun dired-copy-filename-as-kill (&optional arg)
518 "Copy names of marked (or next ARG) files into the kill ring.
519The names are separated by a space.
520With a zero prefix arg, use the complete pathname of each marked file.
521With \\[universal-argument], use the relative pathname of each marked file.
522
523If on a subdir headerline, use subdirname instead; prefix arg is ignored
524in this case.
525
526You can then feed the file name(s) to other commands with \\[yank]."
527 (interactive "P")
528 (let ((string
529 (or (dired-get-subdir)
530 (mapconcat (function identity)
531 (if arg
532 (cond ((zerop (prefix-numeric-value arg))
533 (dired-get-marked-files))
534 ((integerp arg)
535 (dired-get-marked-files 'no-dir arg))
536 (t ; else a raw arg
537 (dired-get-marked-files t)))
538 (dired-get-marked-files 'no-dir))
539 " "))))
540 (kill-new string)
541 (message "%s" string)))
542
543\f
b578f267 544;;; OMITTING.
cb3fe1f0
RS
545
546;;; Enhanced omitting of lines from directory listings.
547;;; Marked files are never omitted.
548
549;; should probably get rid of this and always use 'no-dir.
550;; sk 28-Aug-1991 09:37
551(defvar dired-omit-localp 'no-dir
552 "The LOCALP argument dired-omit-expunge passes to dired-get-filename.
553If it is 'no-dir, omitting is much faster, but you can only match
554against the basename of the file. Set it to nil if you need to match the
555whole pathname.")
556
557;; \017=^O for Omit - other packages can chose other control characters.
558(defvar dired-omit-marker-char ?\017
559 "Temporary marker used by by dired-omit.
560Should never be used as marker by the user or other packages.")
561
562(defun dired-omit-startup ()
cb3fe1f0
RS
563 (or (assq 'dired-omit-files-p minor-mode-alist)
564 (setq minor-mode-alist
565 (append '((dired-omit-files-p " Omit")) minor-mode-alist))))
566
567(defun dired-omit-toggle (&optional flag)
685ff9f8 568 "Toggle omitting files matching `dired-omit-files' and `dired-omit-extensions'.
cb3fe1f0
RS
569With an arg, and if omitting was off, don't toggle and just mark the
570 files but don't actually omit them.
571With an arg, and if omitting was on, turn it off but don't refresh the buffer."
572 (interactive "P")
573 (if flag
574 (if dired-omit-files-p
575 (setq dired-omit-files-p (not dired-omit-files-p))
576 (dired-mark-unmarked-files (dired-omit-regexp) nil nil
577 dired-omit-localp))
578 ;; no FLAG
579 (setq dired-omit-files-p (not dired-omit-files-p))
580 (if (not dired-omit-files-p)
581 (revert-buffer)
582 ;; this will mention how many were omitted:
ad8c4554
RS
583 (let ((dired-omit-size-limit nil))
584 (dired-omit-expunge)))))
cb3fe1f0
RS
585
586(defvar dired-omit-extensions
587 (append completion-ignored-extensions
588 dired-latex-unclean-extensions
589 dired-bibtex-unclean-extensions
590 dired-texinfo-unclean-extensions)
685ff9f8
RS
591 "If non-nil, a list of extensions \(strings\) to omit from Dired listings.
592Defaults to elements of `completion-ignored-extensions',
593`dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and
594`dired-texinfo-unclean-extensions'.
595
596See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and
597variables `dired-omit-files-p' and `dired-omit-files'.")
cb3fe1f0
RS
598
599(defun dired-omit-expunge (&optional regexp)
600 "Erases all unmarked files matching REGEXP.
ad8c4554
RS
601Does nothing if global variable `dired-omit-files-p' is nil, or if called
602 non-interactively and buffer is bigger than `dired-omit-size-limit'.
cb3fe1f0
RS
603If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
604 filenames ending in `dired-omit-extensions'.
605If REGEXP is the empty string, this function is a no-op.
606
607This functions works by temporarily binding `dired-marker-char' to
608`dired-omit-marker-char' and calling `dired-do-kill-lines'."
609 (interactive "sOmit files (regexp): ")
ad8c4554
RS
610 (if (and dired-omit-files-p
611 (or (interactive-p)
612 (not dired-omit-size-limit)
613 (< (buffer-size) dired-omit-size-limit)))
cb3fe1f0 614 (let ((omit-re (or regexp (dired-omit-regexp)))
9b5ef74b 615 (old-modified-p (buffer-modified-p))
cb3fe1f0
RS
616 count)
617 (or (string= omit-re "")
618 (let ((dired-marker-char dired-omit-marker-char))
619 (message "Omitting...")
620 (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp)
621 (progn
622 (setq count (dired-do-kill-lines nil "Omitted %d line%s."))
048ea441 623 (force-mode-line-update))
cb3fe1f0 624 (message "(Nothing to omit)"))))
9b5ef74b
RS
625 ;; Try to preserve modified state of buffer. So `%*' doesn't appear
626 ;; in mode-line of omitted buffers.
627 (set-buffer-modified-p (and old-modified-p
628 (save-excursion
629 (goto-char (point-min))
630 (re-search-forward dired-re-mark nil t))))
cb3fe1f0
RS
631 count)))
632
633(defun dired-omit-regexp ()
634 (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "")
635 (if (and dired-omit-files dired-omit-extensions) "\\|" "")
636 (if dired-omit-extensions
637 (concat ".";; a non-extension part should exist
638 "\\("
639 (mapconcat 'regexp-quote dired-omit-extensions "\\|")
640 "\\)$")
641 "")))
642
643;; Returns t if any work was done, nil otherwise.
644(defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp)
645 "Marks unmarked files matching REGEXP, displaying MSG.
646REGEXP is matched against the complete pathname.
647Does not re-mark files which already have a mark.
648With prefix argument, unflag all those files.
649Second optional argument LOCALP is as in `dired-get-filename'."
650 (interactive "P")
651 (let ((dired-marker-char (if unflag-p ?\ dired-marker-char)))
652 (dired-mark-if
653 (and
654 ;; not already marked
655 (looking-at " ")
656 ;; uninteresting
657 (let ((fn (dired-get-filename localp t)))
658 (and fn (string-match regexp fn))))
659 msg)))
660
9572a9dd 661;;; REDEFINE.
cb3fe1f0
RS
662(defun dired-omit-new-add-entry (filename &optional marker-char)
663 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for
664 ;; files that are going to be omitted anyway.
665 (if dired-omit-files-p
666 ;; perhaps return t without calling ls
667 (let ((omit-re (dired-omit-regexp)))
668 (if (or (string= omit-re "")
669 (not
670 (string-match omit-re
671 (cond
672 ((eq 'no-dir dired-omit-localp)
673 filename)
674 ((eq t dired-omit-localp)
675 (dired-make-relative filename))
676 (t
677 (dired-make-absolute
678 filename
679 (file-name-directory filename)))))))
680 ;; if it didn't match, go ahead and add the entry
681 (dired-omit-old-add-entry filename marker-char)
682 ;; dired-add-entry returns t for success, perhaps we should
683 ;; return file-exists-p
684 t))
685 ;; omitting is not turned on at all
686 (dired-omit-old-add-entry filename marker-char)))
687
9572a9dd 688;;; REDEFINE.
cb3fe1f0
RS
689;;; Redefine dired-aux.el's version of `dired-add-entry'
690;;; Save old defun if not already done:
691(or (fboundp 'dired-omit-old-add-entry)
692 (fset 'dired-omit-old-add-entry (symbol-function 'dired-add-entry)))
693;; Redefine it.
694(fset 'dired-add-entry 'dired-omit-new-add-entry)
695
696\f
b578f267 697;;; VIRTUAL DIRED MODE.
cb3fe1f0
RS
698
699;;; For browsing `ls -lR' listings in a dired-like fashion.
700
701(fset 'virtual-dired 'dired-virtual)
702(defun dired-virtual (dirname &optional switches)
703 "Put this buffer into Virtual Dired mode.
704
705In Virtual Dired mode, all commands that do not actually consult the
706filesystem will work.
707
708This is useful if you want to peruse and move around in an ls -lR
709output file, for example one you got from an ftp server. With
710ange-ftp, you can even dired a directory containing an ls-lR file,
711visit that file and turn on virtual dired mode. But don't try to save
712this file, as dired-virtual indents the listing and thus changes the
713buffer.
714
715If you have save a Dired buffer in a file you can use \\[dired-virtual] to
716resume it in a later session.
717
718Type \\<dired-mode-map>\\[revert-buffer] in the
719Virtual Dired buffer and answer `y' to convert the virtual to a real
720dired buffer again. You don't have to do this, though: you can relist
721single subdirs using \\[dired-do-redisplay].
722"
723
724 ;; DIRNAME is the top level directory of the buffer. It will become
725 ;; its `default-directory'. If nil, the old value of
726 ;; default-directory is used.
727
728 ;; Optional SWITCHES are the ls switches to use.
729
730 ;; Shell wildcards will be used if there already is a `wildcard'
731 ;; line in the buffer (thus it is a saved Dired buffer), but there
732 ;; is no other way to get wildcards. Insert a `wildcard' line by
733 ;; hand if you want them.
734
735 (interactive
736 (list (read-string "Virtual Dired directory: " (dired-virtual-guess-dir))))
737 (goto-char (point-min))
738 (or (looking-at " ")
739 ;; if not already indented, do it now:
740 (indent-region (point-min) (point-max) 2))
741 (or dirname (setq dirname default-directory))
742 (setq dirname (expand-file-name (file-name-as-directory dirname)))
743 (setq default-directory dirname) ; contains no wildcards
744 (let ((wildcard (save-excursion
745 (goto-char (point-min))
746 (forward-line 1)
747 (and (looking-at "^ wildcard ")
748 (buffer-substring (match-end 0)
749 (progn (end-of-line) (point)))))))
750 (if wildcard
751 (setq dirname (expand-file-name wildcard default-directory))))
752 ;; If raw ls listing (not a saved old dired buffer), give it a
753 ;; decent subdir headerline:
754 (goto-char (point-min))
755 (or (looking-at dired-subdir-regexp)
756 (dired-insert-headerline default-directory))
757 (dired-mode dirname (or switches dired-listing-switches))
758 (setq mode-name "Virtual Dired"
759 revert-buffer-function 'dired-virtual-revert)
760 (set (make-local-variable 'dired-subdir-alist) nil)
761 (dired-build-subdir-alist)
762 (goto-char (point-min))
763 (dired-initial-position dirname))
764
765(defun dired-virtual-guess-dir ()
766
767 ;; Guess and return appropriate working directory of this buffer,
768 ;; assumed to be in Dired or ls -lR format.
769 ;; The guess is based upon buffer contents.
770 ;; If nothing could be guessed, returns nil.
771
772 (let ((regexp "^\\( \\)?\\([^ \n\r]*\\)\\(:\\)[\n\r]")
773 (subexpr 2))
774 (goto-char (point-min))
775 (cond ((looking-at regexp)
776 ;; If a saved dired buffer, look to which dir and
777 ;; perhaps wildcard it belongs:
778 (let ((dir (buffer-substring (match-beginning subexpr)
779 (match-end subexpr))))
780 (file-name-as-directory dir)))
781 ;; Else no match for headerline found. It's a raw ls listing.
782 ;; In raw ls listings the directory does not have a headerline
783 ;; try parent of first subdir, if any
784 ((re-search-forward regexp nil t)
785 (file-name-directory
786 (directory-file-name
787 (file-name-as-directory
788 (buffer-substring (match-beginning subexpr)
789 (match-end subexpr))))))
790 (t ; if all else fails
791 nil))))
792
793
794(defun dired-virtual-revert (&optional arg noconfirm)
795 (if (not
796 (y-or-n-p "Cannot revert a Virtual Dired buffer - switch to Real Dired mode? "))
797 (error "Cannot revert a Virtual Dired buffer.")
798 (setq mode-name "Dired"
799 revert-buffer-function 'dired-revert)
800 (revert-buffer)))
801
802;; A zero-arg version of dired-virtual.
803;; You need my modified version of set-auto-mode for the
804;; `buffer-contents-mode-alist'.
805;; Or you use infer-mode.el and infer-mode-alist, same syntax.
806(defun dired-virtual-mode ()
807 "Put current buffer into virtual dired mode (see `dired-virtual').
808Useful on `buffer-contents-mode-alist' (which see) with the regexp
809
810 \"^ \\(/[^ /]+\\)/?+:$\"
811
812to put saved dired buffers automatically into virtual dired mode.
813
814Also useful for `auto-mode-alist' (which see) like this:
815
e7070c01 816 \(setq auto-mode-alist (cons '(\"[^/]\\.dired\\'\" . dired-virtual-mode)
cb3fe1f0
RS
817 auto-mode-alist)\)"
818 (interactive)
819 (dired-virtual (dired-virtual-guess-dir)))
820
821\f
b578f267 822;;; SMART SHELL.
cb3fe1f0
RS
823
824;;; An Emacs buffer can have but one working directory, stored in the
825;;; buffer-local variable `default-directory'. A Dired buffer may have
826;;; several subdirectories inserted, but still has but one working directory:
827;;; that of the top level Dired directory in that buffer. For some commands
828;;; it is appropriate that they use the current Dired directory instead of
829;;; `default-directory', e.g., `find-file' and `compile'. This is a general
830;;; mechanism is provided for special handling of the working directory in
831;;; special major modes.
832
833;; It's easier to add to this alist than redefine function
834;; default-directory while keeping the old information.
835(defconst default-directory-alist
836 '((dired-mode . (if (fboundp 'dired-current-directory)
837 (dired-current-directory)
838 default-directory)))
839 "Alist of major modes and their opinion on default-directory, as a
840lisp expression to evaluate. A resulting value of nil is ignored in
841favor of default-directory.")
842
843(defun default-directory ()
844 "Usage like variable `default-directory', but knows about the special
845cases in variable `default-directory-alist' (which see)."
846 (or (eval (cdr (assq major-mode default-directory-alist)))
847 default-directory))
848
849(defun dired-smart-shell-command (cmd &optional insert)
850 "Like function `shell-command', but in the current Tree Dired directory."
851 (interactive "sShell command: \nP")
852 (let ((default-directory (default-directory)))
853 (shell-command cmd insert)))
854
855\f
b578f267 856;;; LOCAL VARIABLES FOR DIRED BUFFERS.
cb3fe1f0 857
9572a9dd
KH
858;;; Brief Description:
859;;;
860;;; * `dired-extra-startup' is part of the `dired-mode-hook'.
861;;;
cb3fe1f0 862;;; * `dired-extra-startup' calls `dired-hack-local-variables'
9572a9dd 863;;;
cb3fe1f0 864;;; * `dired-hack-local-variables' checks the value of
9572a9dd
KH
865;;; `dired-local-variables-file'
866;;;
cb3fe1f0
RS
867;;; * Check if `dired-local-variables-file' is a non-nil string and is a
868;;; filename found in the directory of the Dired Buffer being created.
9572a9dd 869;;;
cb3fe1f0
RS
870;;; * If `dired-local-variables-file' satisfies the above, then temporarily
871;;; include it in the Dired Buffer at the bottom.
9572a9dd 872;;;
cb3fe1f0
RS
873;;; * Set `enable-local-variables' temporarily to the user variable
874;;; `dired-enable-local-variables' and run `hack-local-variables' on the
875;;; Dired Buffer.
876
db8f8812 877(defvar dired-local-variables-file (convert-standard-filename ".dired")
cb3fe1f0
RS
878 "Filename, as string, containing local dired buffer variables to be hacked.
879If this file found in current directory, then it will be inserted into dired
880buffer and `hack-local-variables' will be run. See Emacs Info pages for more
881information on local variables. See also `dired-enable-local-variables'.")
882
883(defun dired-hack-local-variables ()
884 "Evaluate local variables in `dired-local-variables-file' for dired buffer."
885 (if (and dired-local-variables-file
886 (stringp dired-local-variables-file)
887 (file-exists-p dired-local-variables-file))
888 (let ((opoint (point-max))
889 buffer-read-only
890 ;; In case user has `enable-local-variables' set to nil we
891 ;; override it locally with dired's variable.
892 (enable-local-variables dired-enable-local-variables))
893 ;; Insert 'em.
894 (save-excursion
895 (goto-char opoint)
896 (insert "\^L\n")
897 (insert-file-contents dired-local-variables-file))
898 ;; Hack 'em.
899 (let ((buffer-file-name dired-local-variables-file))
900 (hack-local-variables))
901 ;; Make sure that the modeline shows the proper information.
902 (dired-sort-set-modeline)
903 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el.
9572a9dd 904 (delete-region opoint (point-max)))))
cb3fe1f0 905
9572a9dd 906(defun dired-omit-here-always ()
cb3fe1f0
RS
907 "Creates `dired-local-variables-file' for omitting and reverts directory.
908Sets dired-omit-file-p to t in a local variables file that is readable by
909dired."
9572a9dd 910 (interactive)
cb3fe1f0
RS
911 (if (file-exists-p dired-local-variables-file)
912 (message "File `./%s' already exists." dired-local-variables-file)
913
914 ;; Create `dired-local-variables-file'.
915 (save-excursion
916 (set-buffer (get-buffer-create " *dot-dired*"))
917 (erase-buffer)
918 (insert "Local Variables:\ndired-omit-files-p: t\nEnd:\n")
919 (write-file dired-local-variables-file)
920 (kill-buffer (current-buffer)))
921
922 ;; Run extra-hooks and revert directory.
923 (dired-extra-startup)
924 (dired-revert)))
925
926\f
b578f267 927;;; GUESS SHELL COMMAND.
cb3fe1f0 928
9572a9dd
KH
929;;; Brief Description:
930;;;
931;;; `dired-do-shell-command' is bound to `!' by dired.el.
932;;;
cb3fe1f0
RS
933;;; * Redefine `dired-do-shell-command' so it calls
934;;; `dired-guess-shell-command'.
9572a9dd 935;;;
cb3fe1f0
RS
936;;; * `dired-guess-shell-command' calls `dired-guess-default' with list of
937;;; marked files.
9572a9dd 938;;;
cb3fe1f0
RS
939;;; * Parse `dired-guess-shell-alist-user' and
940;;; `dired-guess-shell-alist-default' (in that order) for the first REGEXP
941;;; that matches the first file in the file list.
9572a9dd 942;;;
cb3fe1f0 943;;; * If the REGEXP matches all the entries of the file list then evaluate
c0d79871 944;;; COMMAND, which is either a string or a Lisp expression returning a
cb3fe1f0 945;;; string. COMMAND may be a list of commands.
9572a9dd 946;;;
cb3fe1f0 947;;; * Return this command to `dired-guess-shell-command' which prompts user
34ff2275 948;;; with it. The list of commands is temporarily put into the history list.
cb3fe1f0
RS
949;;; If a command is used successfully then it is stored permanently in
950;;; `dired-shell-command-history'.
951
952;;; Guess what shell command to apply to a file.
953(defvar dired-shell-command-history nil
954 "History list for commands that read dired-shell commands.")
955
9572a9dd 956;;; Default list of shell commands.
cb3fe1f0
RS
957
958;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not
959;;; install GNU zip's version of zcat.
960
961(defvar dired-guess-shell-alist-default
962 (list
963 (list "\\.tar$" '(if dired-guess-shell-gnutar
964 (concat dired-guess-shell-gnutar " xvf")
965 "tar xvf"))
966
967 ;; REGEXPS for compressed archives must come before the .Z rule to
968 ;; be recognized:
969 (list "\\.tar\\.Z$"
970 ;; Untar it.
971 '(if dired-guess-shell-gnutar
972 (concat dired-guess-shell-gnutar " zxvf")
973 (concat "zcat * | tar xvf -"))
974 ;; Optional conversion to gzip format.
975 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
976 " " dired-guess-shell-znew-switches))
977
978 ;; gzip'ed archives
979 (list "\\.tar\\.g?z$"
980 '(if dired-guess-shell-gnutar
981 (concat dired-guess-shell-gnutar " zxvf")
982 (concat "gunzip -qc * | tar xvf -"))
983 ;; Optional decompression.
984 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" "")))
985
986 '("\\.shar.Z$" "zcat * | unshar")
987 '("\\.shar.g?z$" "gunzip -qc * | unshar")
988
35f58ede
RS
989 '("\\.e?ps$" "ghostview" "xv" "lpr")
990 (list "\\.e?ps.g?z$" "gunzip -qc * | ghostview -"
cb3fe1f0
RS
991 ;; Optional decompression.
992 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
35f58ede 993 (list "\\.e?ps.Z$" "zcat * | ghostview -"
cb3fe1f0
RS
994 ;; Optional conversion to gzip format.
995 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
996 " " dired-guess-shell-znew-switches))
997 '("\\.patch$" "cat * | patch")
998 '("\\.patch.g?z$" "gunzip -qc * | patch")
999 (list "\\.patch.Z$" "zcat * | patch"
1000 ;; Optional conversion to gzip format.
1001 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1002 " " dired-guess-shell-znew-switches))
1003
1004 '("\\.dvi$" "xdvi" "dvips") ; preview and printing
9572a9dd 1005 '("\\.au$" "play") ; play Sun audiofiles
cb3fe1f0
RS
1006 '("\\.mpg$" "mpeg_play")
1007 '("\\.uu$" "uudecode") ; for uudecoded files
1008 '("\\.hqx$" "mcvert")
1009 '("\\.sh$" "sh") ; execute shell scripts
1010 '("\\.xbm$" "bitmap") ; view X11 bitmaps
1011 '("\\.gp$" "gnuplot")
1012 '("\\.p[bgpn]m$" "xv")
1013 '("\\.gif$" "xv") ; view gif pictures
1014 '("\\.tif$" "xv")
1015 '("\\.jpg$" "xv")
1016 '("\\.fig$" "xfig") ; edit fig pictures
1017 '("\\.out$" "xgraph") ; for plotting purposes.
1018 '("\\.tex$" "latex" "tex")
1019 '("\\.texi\\(nfo\\)?$" "makeinfo" "texi2dvi")
1020
1021 ;; Some other popular archivers.
1022 '("\\.zoo$" "zoo x//")
1023 '("\\.zip$" "unzip")
1024 '("\\.lzh$" "lharc x")
1025 '("\\.arc$" "arc x")
1026 '("\\.shar$" "unshar")
1027
1028 ;; Compression.
1029 (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
1030 (list "\\.Z$" "uncompress"
1031 ;; Optional conversion to gzip format.
1032 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1033 " " dired-guess-shell-znew-switches))
1034 )
9572a9dd 1035
cb3fe1f0
RS
1036 "Default alist used for shell command guessing.
1037See `dired-guess-shell-alist-user'")
1038
1039(defvar dired-guess-shell-alist-user nil
1040 "User-defined alist of rules for suggested commands. These rules take
1041precedence over the predefined rules in the variable
1042`dired-guess-shell-alist-default' (to which they are prepended).
1043
1044Each element of this list looks like
1045
1046 \(REGEXP COMMAND...\)
1047
1048where each COMMAND can either be a string or a lisp expression that evaluates
1049to a string. If several COMMANDs are given, the first one will be the default
1050and the rest will be added temporarily to the history and can be retrieved
1051with \\[previous-history-element] (M-p) .
1052
1053You can set this variable in your ~/.emacs. For example, to add rules for
1054`.foo' and `.bar' files, write
1055
1056 \(setq dired-guess-shell-alist-user
1057 (list (list \"\\\\.foo$\" \"FOO-COMMAND\");; fixed rule
1058 ;; possibly more rules ...
1059 (list \"\\\\.bar$\";; rule with condition test
1060 '(if condition
1061 \"BAR-COMMAND-1\"
1062 \"BAR-COMMAND-2\")))\)
1063")
1064
1065(defun dired-guess-default (files)
1066
9572a9dd
KH
1067 ;; Guess a shell commands for FILES. Return command or list of commands.
1068 ;; See `dired-guess-shell-alist-user'.
cb3fe1f0
RS
1069
1070 (let* ((case-fold-search nil) ; case-sensitive matching
1071 ;; Prepend the user's alist to the default alist.
1072 (alist (append dired-guess-shell-alist-user
1073 dired-guess-shell-alist-default))
1074 (file (car files))
1075 (flist (cdr files))
1076 elt regexp cmds)
1077
1078 ;; Find the first match in the alist for first file in FILES.
1079 (while alist
1080 (setq elt (car alist)
1081 regexp (car elt)
1082 alist (cdr alist))
1083 (if (string-match regexp file)
1084 (setq cmds (cdr elt)
1085 alist nil)))
1086
1087 ;; If more than one file, see if all of FILES match regular expression.
1088 (while (and flist
1089 (string-match regexp (car flist)))
1090 (setq flist (cdr flist)))
9572a9dd 1091
cb3fe1f0
RS
1092 ;; If flist is still non-nil, then do not guess since this means that not
1093 ;; all the files in FILES were matched by the regexp.
1094 (setq cmds (and (not flist) cmds))
1095
9572a9dd
KH
1096 ;; Return commands or nil if flist is still non-nil.
1097 ;; Evaluate the commands in order that any logical testing will be done.
cb3fe1f0
RS
1098 (cond ((not (cdr cmds))
1099 (eval (car cmds))) ; single command
1100 (t
1101 (mapcar (function eval) cmds)))))
1102
1103(defun dired-guess-shell-command (prompt files)
1104
1105 ;; Ask user with PROMPT for a shell command, guessing a default from FILES.
1106
1107 (let ((default (dired-guess-default files))
1108 default-list old-history val (failed t))
1109
1110 (if (null default)
1111 ;; Nothing to guess
1112 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history)
1113
1114 ;; Save current history list
1115 (setq old-history dired-shell-command-history)
1116
1117 (if (listp default)
1118
1119 ;; More than one guess
1120 (setq default-list default
1121 default (car default)
1122 prompt (concat
1123 prompt
1124 (format "{%d guesses} " (length default-list))))
1125
1126 ;; Just one guess
1127 (setq default-list (list default)))
1128
1129 ;; Push all guesses onto history so that they can be retrieved with M-p
1130 ;; and put the first guess in the prompt but not in the initial value.
1131 (setq dired-shell-command-history
1132 (append default-list dired-shell-command-history)
1133 prompt (concat prompt (format "[%s] " default)))
1134
1135 ;; The unwind-protect returns VAL, and we too.
1136 (unwind-protect
1137 ;; BODYFORM
1138 (progn
1139 (setq val (read-from-minibuffer prompt nil nil nil
1140 'dired-shell-command-history)
1141 failed nil)
1142 ;; If we got a return, then use default.
1143 (if (equal val "")
1144 (setq val default))
1145 val)
1146
1147 ;; UNWINDFORMS
1148 ;; Undo pushing onto the history list so that an aborted
1149 ;; command doesn't get the default in the next command.
1150 (setq dired-shell-command-history old-history)
1151 (if (not failed)
1152 (or (equal val (car-safe dired-shell-command-history))
1153 (setq dired-shell-command-history
1154 (cons val dired-shell-command-history))))))))
1155
1156
9572a9dd 1157;;; REDEFINE.
cb3fe1f0
RS
1158;;; Redefine dired-aux.el's version:
1159(defun dired-read-shell-command (prompt arg files)
1160;; "Read a dired shell command prompting with PROMPT (using read-string).
1161;;ARG is the prefix arg and may be used to indicate in the prompt which
1162;; files are affected.
1163;;This is an extra function so that you can redefine it, e.g., to use gmhist."
1164 (dired-mark-pop-up
1165 nil 'shell files
1166 'dired-guess-shell-command
1167 (format prompt (dired-mark-prompt arg files)) ; PROMPT
1168 files)) ; FILES
1169
1170\f
b578f267 1171;;; RELATIVE SYMBOLIC LINKS.
cb3fe1f0
RS
1172
1173(defvar dired-keep-marker-relsymlink ?S
1174 "See variable `dired-keep-marker-move'.")
1175
1176(defun dired-make-relative-symlink (file1 file2 &optional ok-if-already-exists)
1177 "Three arguments: FILE1 FILE2 &optional OK-IF-ALREADY-EXISTS
1178Make a symbolic link (pointing to FILE1) in FILE2.
1179The link is relative (if possible), for example
1180
1181 \"/vol/tex/bin/foo\" \"/vol/local/bin/foo\"
1182
1183results in
1184
1185 \"../../tex/bin/foo\" \"/vol/local/bin/foo\"
1186"
1187 (interactive "FRelSymLink: \nFRelSymLink %s: \np")
1188 (let (name1 name2 len1 len2 (index 0) sub)
1189 (setq file1 (expand-file-name file1)
1190 file2 (expand-file-name file2)
1191 len1 (length file1)
1192 len2 (length file2))
1193 ;; Find common initial pathname components:
1194 (let (next)
1195 (while (and (setq next (string-match "/" file1 index))
1196 (setq next (1+ next))
1197 (< next (min len1 len2))
1198 ;; For the comparison, both substrings must end in
1199 ;; `/', so NEXT is *one plus* the result of the
1200 ;; string-match.
1201 ;; E.g., consider the case of linking "/tmp/a/abc"
34ff2275 1202 ;; to "/tmp/abc" erroneously giving "/tmp/a" instead
cb3fe1f0
RS
1203 ;; of "/tmp/" as common initial component
1204 (string-equal (substring file1 0 next)
1205 (substring file2 0 next)))
1206 (setq index next))
1207 (setq name2 file2
1208 sub (substring file1 0 index)
1209 name1 (substring file1 index)))
1210 (if (string-equal sub "/")
1211 ;; No common initial pathname found
1212 (setq name1 file1)
1213 ;; Else they have a common parent directory
1214 (let ((tem (substring file2 index))
1215 (start 0)
1216 (count 0))
1217 ;; Count number of slashes we must compensate for ...
1218 (while (setq start (string-match "/" tem start))
1219 (setq count (1+ count)
1220 start (1+ start)))
1221 ;; ... and prepend a "../" for each slash found:
1222 (while (> count 0)
1223 (setq count (1- count)
1224 name1 (concat "../" name1)))))
1225 (make-symbolic-link
1226 (directory-file-name name1) ; must not link to foo/
1227 ; (trailing slash!)
1228 name2 ok-if-already-exists)))
1229
1230(defun dired-do-relsymlink (&optional arg)
1231 "Relative symlink all marked (or next ARG) files into a directory,
1232or make a relative symbolic link to the current file.
1233This creates relative symbolic links like
1234
1235 foo -> ../bar/foo
1236
1237not absolute ones like
1238
1239 foo -> /ugly/path/that/may/change/any/day/bar/foo"
1240 (interactive "P")
1241 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink)
1242 "RelSymLink" arg dired-keep-marker-relsymlink))
1243
1244(defun dired-do-relsymlink-regexp (regexp newname &optional whole-path)
1245 "RelSymlink all marked files containing REGEXP to NEWNAME.
1246See functions `dired-do-rename-regexp' and `dired-do-relsymlink'
1247for more info."
1248 (interactive (dired-mark-read-regexp "RelSymLink"))
1249 (dired-do-create-files-regexp
1250 (function dired-make-relative-symlink)
1251 "RelSymLink" nil regexp newname whole-path dired-keep-marker-relsymlink))
1252
1253\f
b578f267 1254;;; VISIT ALL MARKED FILES SIMULTANEOUSLY.
cb3fe1f0 1255
9572a9dd
KH
1256;;; Brief Description:
1257;;;
1258;;; `dired-do-find-marked-files' is bound to `F' by dired-x.el.
1259;;;
cb3fe1f0 1260;;; * Use `dired-get-marked-files' to collect the marked files in the current
9572a9dd
KH
1261;;; Dired Buffer into a list of filenames `FILE-LIST'.
1262;;;
cb3fe1f0
RS
1263;;; * Pass FILE-LIST to `dired-simultaneous-find-file' all with
1264;;; `dired-do-find-marked-files''s prefix argument NOSELECT.
9572a9dd 1265;;;
cb3fe1f0
RS
1266;;; * `dired-simultaneous-find-file' runs through FILE-LIST decrementing the
1267;;; list each time.
9572a9dd 1268;;;
cb3fe1f0
RS
1269;;; * If NOSELECT is non-nil then just run `find-file-noselect' on each
1270;;; element of FILE-LIST.
9572a9dd 1271;;;
cb3fe1f0
RS
1272;;; * If NOSELECT is nil then calculate the `size' of the window for each file
1273;;; by dividing the `window-height' by length of FILE-LIST. Thus, `size' is
1274;;; cognizant of the window-configuration.
9572a9dd 1275;;;
cb3fe1f0
RS
1276;;; * If `size' is too small abort, otherwise run `find-file' on each element
1277;;; of FILE-LIST giving each a window of height `size'.
1278
1279(defun dired-do-find-marked-files (&optional noselect)
1280 "Find all marked files displaying all of them simultaneously.
1281With optional NOSELECT just find files but do not select them.
1282
1283The current window is split across all files marked, as evenly as possible.
1284Remaining lines go to bottom-most window. The number of files that can be
1285displayed this way is restricted by the height of the current window and
1286`window-min-height'.
1287
9572a9dd 1288To keep dired buffer displayed, type \\[split-window-vertically] first.
cb3fe1f0
RS
1289To display just marked files, type \\[delete-other-windows] first."
1290
1291 (interactive "P")
1292 (dired-simultaneous-find-file (dired-get-marked-files) noselect))
1293
1294(defun dired-simultaneous-find-file (file-list noselect)
1295
1296 ;; Visit all files in FILE-LIST and display them simultaneously. The
1297 ;; current window is split across all files in FILE-LIST, as evenly as
1298 ;; possible. Remaining lines go to the bottom-most window. The number of
1299 ;; files that can be displayed this way is restricted by the height of the
1300 ;; current window and the variable `window-min-height'. With non-nil
1301 ;; NOSELECT the files are merely found but not selected.
9572a9dd 1302
cb3fe1f0
RS
1303 ;; We don't make this function interactive because it is usually too clumsy
1304 ;; to specify FILE-LIST interactively unless via dired.
1305
1306 (let (size)
1307
1308 (if noselect
1309 ;; Do not select the buffer.
1310 (find-file-noselect (car file-list))
1311
1312 ;; We will have to select the buffer. Calculate and check window size.
1313 (setq size (/ (window-height) (length file-list)))
1314 (or (<= window-min-height size)
1315 (error "Too many files to visit simultaneously. Try C-u prefix."))
1316 (find-file (car file-list)))
1317
1318 ;; Decrement.
1319 (setq file-list (cdr file-list))
1320
1321 (while file-list
1322
1323 (if noselect
1324 ;; Do not select the buffer.
1325 (find-file-noselect (car file-list))
1326
1327 ;; Vertically split off a window of desired size. Upper window will
1328 ;; have SIZE lines. Select lower (larger) window. We split it again.
1329 (select-window (split-window nil size))
1330 (find-file (car file-list)))
1331
1332 ;; Decrement.
1333 (setq file-list (cdr file-list)))))
1334
1335\f
b578f267 1336;;; MISCELLANEOUS COMMANDS.
cb3fe1f0 1337
9572a9dd
KH
1338;;; Run man on files.
1339
cb3fe1f0 1340(defun dired-man ()
9572a9dd 1341 "Run man on this file. Display old buffer if buffer name matches filename.
685ff9f8 1342Uses ../lisp/man.el of \\[manual-entry] fame."
cb3fe1f0 1343 (interactive)
685ff9f8
RS
1344 (require 'man)
1345 (let ((file (dired-get-filename))
9b5ef74b 1346 (manual-program "nroff -man -h"))
685ff9f8 1347 (Man-getpage-in-background file)))
cb3fe1f0
RS
1348
1349;;; Run Info on files.
1350
1351(defun dired-info ()
1352 "Run info on this file."
1353 (interactive)
1354 (info (dired-get-filename)))
1355
1356;;; Run mail on mail folders.
1357
9572a9dd
KH
1358;;; (and (not (fboundp 'vm-visit-folder))
1359;;; (defun vm-visit-folder (file &optional arg)
1360;;; nil))
1361
cb3fe1f0
RS
1362(defun dired-vm (&optional read-only)
1363 "Run VM on this file.
1364With prefix arg, visit folder read-only (this requires at least VM 5).
1365See also variable `dired-vm-read-only-folders'."
1366 (interactive "P")
1367 (let ((dir (dired-current-directory))
1368 (fil (dired-get-filename)))
1369 ;; take care to supply 2nd arg only if requested - may still run VM 4!
1370 (cond (read-only (vm-visit-folder fil t))
1371 ((eq t dired-vm-read-only-folders) (vm-visit-folder fil t))
1372 ((null dired-vm-read-only-folders) (vm-visit-folder fil))
1373 (t (vm-visit-folder fil (not (file-writable-p fil)))))
1374 ;; so that pressing `v' inside VM does prompt within current directory:
1375 (set (make-local-variable 'vm-folder-directory) dir)))
1376
1377(defun dired-rmail ()
1378 "Run RMAIL on this file."
1379 (interactive)
1380 (rmail (dired-get-filename)))
1381
1382(defun dired-do-run-mail ()
1383 "If `dired-bind-vm' is t, then function `dired-vm', otherwise `dired-rmail'."
1384 (interactive)
1385 (if dired-bind-vm
1386 ;; Read mail folder using vm.
1387 (dired-vm)
1388 ;; Read mail folder using rmail.
1389 (dired-rmail)))
1390
1391\f
b578f267 1392;;; MISCELLANEOUS INTERNAL FUNCTIONS.
cb3fe1f0
RS
1393
1394(or (fboundp 'dired-old-find-buffer-nocreate)
1395 (fset 'dired-old-find-buffer-nocreate
1396 (symbol-function 'dired-find-buffer-nocreate)))
1397
9572a9dd 1398;;; REDEFINE.
cb3fe1f0 1399;;; Redefines dired.el's version of `dired-find-buffer-nocreate'
ac1ce341 1400(defun dired-find-buffer-nocreate (dirname &optional mode)
10774fb5
KH
1401 (if (and dired-find-subdir
1402 ;; don't try to find a wildcard as a subdirectory
1403 (string-equal dirname (file-name-directory dirname)))
cb3fe1f0 1404 (let* ((cur-buf (current-buffer))
10774fb5 1405 (buffers (nreverse
12c38283 1406 (dired-buffers-for-dir (expand-file-name dirname))))
10774fb5
KH
1407 (cur-buf-matches (and (memq cur-buf buffers)
1408 ;; wildcards must match, too:
1409 (equal dired-directory dirname))))
1410 ;; We don't want to switch to the same buffer---
1411 (setq buffers (delq cur-buf buffers));;need setq with delq
1412 (or (car (sort buffers (function dired-buffer-more-recently-used-p)))
1413 ;; ---unless it's the only possibility:
1414 (and cur-buf-matches cur-buf)))
ac1ce341 1415 (dired-old-find-buffer-nocreate dirname mode)))
cb3fe1f0
RS
1416
1417;; This should be a builtin
1418(defun dired-buffer-more-recently-used-p (buffer1 buffer2)
1419 "Return t if BUFFER1 is more recently used than BUFFER2."
1420 (if (equal buffer1 buffer2)
1421 nil
1422 (let ((more-recent nil)
1423 (list (buffer-list)))
1424 (while (and list
1425 (not (setq more-recent (equal buffer1 (car list))))
1426 (not (equal buffer2 (car list))))
1427 (setq list (cdr list)))
1428 more-recent)))
1429
1430;;; Same thing as `dired-buffers-for-dir' of dired.el? - lrd 11/23/93
1431;;; (defun dired-buffers-for-dir-exact (dir)
1432;;; ;; Return a list of buffers that dired DIR (a directory or wildcard)
1433;;; ;; at top level, or as subdirectory.
1434;;; ;; Top level matches must match the wildcard part too, if any.
1435;;; ;; The list is in reverse order of buffer creation, most recent last.
1436;;; ;; As a side effect, killed dired buffers for DIR are removed from
1437;;; ;; dired-buffers.
1438;;; (let ((alist dired-buffers) result elt)
1439;;; (while alist
1440;;; (setq elt (car alist)
1441;;; alist (cdr alist))
1442;;; (let ((buf (cdr elt)))
1443;;; (if (buffer-name buf)
1444;;; ;; Top level must match exactly against dired-directory in
1445;;; ;; case one of them is a wildcard.
1446;;; (if (or (equal dir (save-excursion (set-buffer buf)
1447;;; dired-directory))
1448;;; (assoc dir (save-excursion (set-buffer buf)
1449;;; dired-subdir-alist)))
1450;;; (setq result (cons buf result)))
1451;;; ;; else buffer is killed - clean up:
1452;;; (setq dired-buffers (delq elt dired-buffers)))))
1453;;; result))
1454
9572a9dd 1455;;; REDEFINE.
cb3fe1f0
RS
1456;;; Redefines dired.el's version of `dired-initial-position'
1457(defun dired-initial-position (dirname)
1458 (end-of-line)
1459 (if dired-find-subdir (dired-goto-subdir dirname)) ; new
1460 (if dired-trivial-filenames (dired-goto-next-nontrivial-file)))
1461
1462\f
1463;; Does anyone use this? - lrd 6/29/93.
1464(defun dired-mark-sexp (predicate &optional unflag-p)
1465 "Mark files for which PREDICATE returns non-nil.
1466With a prefix arg, unflag those files instead.
1467
1468PREDICATE is a lisp expression that can refer to the following symbols:
1469
1470 inode [integer] the inode of the file (only for ls -i output)
1471 s [integer] the size of the file for ls -s output
34ff2275 1472 (usually in blocks or, with -k, in KByte)
cb3fe1f0
RS
1473 mode [string] file permission bits, e.g. \"-rw-r--r--\"
1474 nlink [integer] number of links to file
1475 uid [string] owner
1476 gid [string] group (If the gid is not displayed by ls,
1477 this will still be set (to the same as uid))
1478 size [integer] file size in bytes
1479 time [string] the time that ls displays, e.g. \"Feb 12 14:17\"
1480 name [string] the name of the file
1481 sym [string] if file is a symbolic link, the linked-to name, else \"\"
1482
1483For example, use
1484
1485 (equal 0 size)
1486
1487to mark all zero length files."
1488 ;; Using sym="" instead of nil avoids the trap of
1489 ;; (string-match "foo" sym) into which a user would soon fall.
1490 ;; Give `equal' instead of `=' in the example, as this works on
1491 ;; integers and strings.
1492 (interactive "xMark if (lisp expr): \nP")
1493 (message "%s" predicate)
1494 (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char))
1495 inode s mode nlink uid gid size time name sym)
1496 (dired-mark-if
1497 (save-excursion
1498 (and
1499 ;; Sets vars
1500 ;; inode s mode nlink uid gid size time name sym
1501
1502 ;; according to current file line. Returns t for success, nil if
1503 ;; there is no file line. Upon success, all variables are set, either
1504 ;; to nil or the appropriate value, so they need not be initialized.
1505 ;; Moves point within the current line.
1506 (if (dired-move-to-filename)
1507 (let (pos
1508 (mode-len 10) ; length of mode string
1509 ;; like in dired.el, but with subexpressions \1=inode, \2=s:
1510 (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?"))
1511 (beginning-of-line)
1512 (forward-char 2)
1513 (if (looking-at dired-re-inode-size)
1514 (progn
1515 (goto-char (match-end 0))
1516 (setq inode (string-to-int (buffer-substring (match-beginning 1)
1517 (match-end 1)))
1518 s (string-to-int (buffer-substring (match-beginning 2)
1519 (match-end 2)))))
1520 (setq inode nil
1521 s nil))
1522 (setq mode (buffer-substring (point) (+ mode-len (point))))
1523 (forward-char mode-len)
1524 (setq nlink (read (current-buffer)))
1525 (setq uid (buffer-substring (point) (progn (forward-word 1) (point))))
1526 (re-search-forward "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)")
1527 (goto-char (match-beginning 1))
1528 (forward-char -1)
1529 (setq size (string-to-int (buffer-substring (save-excursion
1530 (backward-word 1)
1531 (setq pos (point)))
1532 (point))))
1533 (goto-char pos)
1534 (backward-word 1)
1535 ;; if no gid is displayed, gid will be set to uid
1536 ;; but user will then not reference it anyway in PREDICATE.
1537 (setq gid (buffer-substring (save-excursion (forward-word 1) (point))
1538 (point))
1539 time (buffer-substring (match-beginning 1)
1540 (1- (dired-move-to-filename)))
1541 name (buffer-substring (point)
1542 (or (dired-move-to-end-of-filename t)
1543 (point)))
1544 sym (progn
1545 (if (looking-at " -> ")
1546 (buffer-substring (progn (forward-char 4) (point))
1547 (progn (end-of-line) (point)))
1548 "")))
1549 t)
1550 nil)
1551 (eval predicate)))
1552 (format "'%s file" predicate))))
1553
1554\f
b578f267 1555;;; FIND FILE AT POINT.
cb3fe1f0 1556
ccb1d39a
RS
1557(defvar dired-x-hands-off-my-keys t
1558 "*t means don't bind `dired-x-find-file' over `find-file' on keyboard.
1559Similarly for `dired-x-find-file-other-window' over `find-file-other-window'.
1560If you change this variable after dired-x.el is loaded then do
1561\\[dired-x-bind-find-file].")
1562
1563;;; Bind `dired-x-find-file{-other-window}' over wherever
1564;;; `find-file{-other-window}' is bound?
1565(defun dired-x-bind-find-file ()
1566 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\).
1567Similarly for `dired-x-find-file-other-window' and `find-file-other-window'.
1568Binding direction based on `dired-x-hands-off-my-keys'.
1569This function part of `after-init-hook'."
1570 (interactive)
1571 (if (interactive-p)
1572 (setq dired-x-hands-off-my-keys
1573 (not (y-or-n-p "Bind dired-x-find-file over find-file? "))))
1574 (cond ((not dired-x-hands-off-my-keys)
1575 (substitute-key-definition 'find-file
1576 'dired-x-find-file
1577 (current-global-map))
1578 (substitute-key-definition 'find-file-other-window
1579 'dired-x-find-file-other-window
1580 (current-global-map)))
1581 (t
1582 (substitute-key-definition 'dired-x-find-file
1583 'find-file
1584 (current-global-map))
1585 (substitute-key-definition 'dired-x-find-file-other-window
1586 'find-file-other-window
1587 (current-global-map))))
1588 ;; Clear mini-buffer.
1589 (message nil))
1590
1591;;; Now call it so binding is correct and put on `after-init-hook' in case
1592;;; user changes binding.
1593(dired-x-bind-find-file)
1594(add-hook 'after-init-hook 'dired-x-bind-find-file)
1595
1596(defun dired-x-find-file (filename)
1597 "Edit file FILENAME.
1598May create a new window, or reuse an existing one.
1599See the function `display-buffer'.
1600
1601Identical to `find-file' except when called interactively, with a prefix arg
1602\(e.g., \\[universal-argument]\), in which case it guesses filename near
1603point. Useful for editing file mentioned in buffer you are viewing, or to
1604test if that file exists. Use minibuffer after snatching filename."
1605 (interactive (list (read-filename-at-point "Find file: ")))
1606 (find-file (expand-file-name filename)))
1607
1608(defun dired-x-find-file-other-window (filename)
1609 "Edit file FILENAME, in another window.
1610May create a new window, or reuse an existing one.
1611See the function `display-buffer'.
1612
1613Identical to `find-file-other-window' except when called interactively, with a
1614prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename
1615near point. Useful for editing file mentioned in buffer you are viewing, or
1616to test if that file exists. Use minibuffer after snatching filename."
1617 (interactive (list (read-filename-at-point "Find file: ")))
1618 (find-file-other-window (expand-file-name filename)))
1619
1620;;; Internal functions.
cb3fe1f0
RS
1621(defun dired-filename-at-point ()
1622
1623 ;; Get the filename closest to point, but do not change position. Has a
1624 ;; preference for looking backward when not directly on a symbol. Not
1625 ;; perfect - point must be in middle of or end of filename.
1626
9572a9dd 1627 (let ((filename-chars ".a-zA-Z0-9---_/:$+")
cb3fe1f0
RS
1628 (bol (save-excursion (beginning-of-line) (point)))
1629 (eol (save-excursion (end-of-line) (point)))
1630 start end filename)
1631
1632 (save-excursion
1633 ;; First see if just past a filename.
1634 (if (not (eobp))
1635 (if (looking-at "[] \t\n[{}()]") ; whitespace or some parens
1636 (progn
1637 (skip-chars-backward " \n\t\r({[]})")
1638 (if (not (bobp))
1639 (backward-char 1)))))
9572a9dd 1640
cb3fe1f0
RS
1641 (if (string-match (concat "[" filename-chars "]")
1642 (char-to-string (following-char)))
1643 (progn
1644 (skip-chars-backward filename-chars)
1645 (setq start (point))
1646 (if (string-match "[/~]" (char-to-string (preceding-char)))
1647 (setq start (1- start)))
1648 (skip-chars-forward filename-chars))
1649
1650 (error "No file found around point!"))
1651
9572a9dd 1652 ;; Return string.
cb3fe1f0
RS
1653 (expand-file-name (buffer-substring start (point))))))
1654
ccb1d39a
RS
1655(defun read-filename-at-point (prompt)
1656 ;;; Returns filename prompting with PROMPT with completion. If
1657 ;;; `current-prefix-arg' is non-nil, uses name at point as guess.
1658 (if current-prefix-arg
1659 (let ((guess (dired-filename-at-point)))
1660 (read-file-name prompt
1661 (file-name-directory guess)
1662 guess
1663 nil (file-name-nondirectory guess)))
1664 (read-file-name prompt default-directory)))
1665
cb3fe1f0 1666\f
b578f267 1667;;; BUG REPORTS
cb3fe1f0
RS
1668
1669;;; This section is provided for reports. It uses Barry A. Warsaw's
1670;;; reporter.el which is bundled with GNU Emacs v19.
1671
ccb1d39a 1672(defconst dired-x-version "2.37"
cb3fe1f0 1673 "Revision number of dired-x.el -- dired extra for GNU Emacs v19.
9572a9dd 1674Type \\[dired-x-submit-report] to send a bug report. Available via anonymous
cb3fe1f0
RS
1675ftp in
1676
1677 /roebling.poly.edu:/pub/packages/dired-x.tar.gz")
1678
1679(defconst dired-x-help-address "dodd@roebling.poly.edu"
1680 "Address(es) accepting submission of reports on dired-x.el.")
1681
1682(defconst dired-x-maintainer "Larry"
1683 "First name(s) of people accepting submission of reports on dired-x.el.")
1684
1685(defconst dired-x-file "dired-x.el"
1686 "Name of file containing emacs lisp code.")
1687
1688(defconst dired-x-variable-list
9572a9dd 1689 (list
cb3fe1f0
RS
1690 'dired-bind-vm
1691 'dired-vm-read-only-folders
1692 'dired-bind-jump
1693 'dired-bind-info
1694 'dired-bind-man
1695 'dired-find-subdir
1696 'dired-enable-local-variables
1697 'dired-local-variables-file
1698 'dired-guess-shell-gnutar
1699 'dired-guess-shell-gzip-quiet
1700 'dired-guess-shell-znew-switches
1701 'dired-guess-shell-alist-user
1702 'dired-clean-up-buffers-too
1703 'dired-omit-files-p
1704 'dired-omit-files
1705 'dired-omit-extensions
1706 )
1707 "List of variables to be appended to reports sent by `dired-x-submit-report.'")
1708
1709(defun dired-x-submit-report ()
1710 "Submit via reporter.el a bug report on program. Send report on `dired-x-file'
1711version `dired-x-version,' to `dired-x-maintainer' at address `dired-x-help-address'
1712listing variables `dired-x-variable-list' in the message."
1713 (interactive)
1714
1715 ;; In case we can't find reporter...
1716 (condition-case err
1717 (progn
1718 ;; Get it if we can.
1719 (require 'reporter)
1720
1721 (reporter-submit-bug-report
1722 dired-x-help-address ; address
1723 (concat dired-x-file " (" dired-x-version ")") ; pkgname
1724 dired-x-variable-list ; varlist
1725 nil nil ; pre-/post-hooks
1726 (concat dired-x-maintainer ","))) ; salutation
1727
1728 ;; ...fail gracefully.
9572a9dd 1729 (error
cb3fe1f0
RS
1730 (beep)
1731 (message "Sorry, reporter.el not found."))))
1732
1733\f
1734;; As Barry Warsaw would say: "This might be useful..."
1735(provide 'dired-x)
1736
1737;;; dired-x.el ends here