• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +refs:dired +refs:mark +refs:files +refs:regexp

0 ;;; dired-x.el --- extra Dired functionality -*-byte-compile-dynamic: t;-*-
8 ;; Keywords: dired extensions files
32 ;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version
34 ;; been removed or renamed in order to work properly with dired of GNU
41 ;; BUGS: Type M-x dired-x-submit-report and a report will be generated.
45 ;; (add-hook 'dired-load-hook
47 ;; (load "dired-x")
49 ;; ;; (setq dired-guess-shell-gnutar "gtar")
51 ;; (add-hook 'dired-mode-hook
54 ;; ;; (dired-omit-mode 1)
57 ;; At load time dired-x.el will install itself, redefine some functions, and
58 ;; bind some dired keys. *Please* see the info pages for more details.
64 ;; dired-bind-vm
65 ;; dired-vm-read-only-folders
66 ;; dired-bind-jump
67 ;; dired-bind-info
68 ;; dired-bind-man
69 ;; dired-x-hands-off-my-keys
70 ;; dired-find-subdir
71 ;; dired-enable-local-variables
72 ;; dired-local-variables-file
73 ;; dired-guess-shell-gnutar
74 ;; dired-guess-shell-gzip-quiet
75 ;; dired-guess-shell-znew-switches
76 ;; dired-guess-shell-alist-user
77 ;; dired-clean-up-buffers-too
78 ;; dired-omit-mode
79 ;; dired-omit-files
80 ;; dired-omit-extensions
81 ;; dired-omit-size-limit
91 ;; dired-clean-up-after-deletion ../lisp/dired.el
92 ;; dired-find-buffer-nocreate ../lisp/dired.el
93 ;; dired-initial-position ../lisp/dired.el
95 ;; dired-add-entry ../lisp/dired-aux.el
96 ;; dired-read-shell-command ../lisp/dired-aux.el
104 ;; This is a no-op if dired-x is being loaded via `dired-load-hook'. It is
105 ;; here in case the user has autoloaded dired-x via the dired-jump key binding
106 ;; (instead of autoloading to dired as is suggested in the info-pages).
108 (require 'dired)
111 ;; load dired stuff of GNU Emacs.
113 (require 'dired-aux)
120 (defgroup dired-x nil
121 "Extended directory editing (dired-x)."
122 :group 'dired)
124 (defgroup dired-keys nil
126 :prefix "dired-"
127 :group 'dired-x)
129 (defcustom dired-bind-vm nil
130 "*Non-nil means \"V\" runs `dired-vm', otherwise \"V\" runs `dired-rmail'.
131 Also, RMAIL files contain -*- rmail -*- at the top so \"f\",
132 `dired-advertised-find-file', will run rmail."
134 :group 'dired-keys)
136 (defcustom dired-bind-jump t
137 "*Non-nil means bind `dired-jump' to C-x C-j, otherwise do not."
139 :group 'dired-keys)
141 (defcustom dired-bind-man t
142 "*Non-nil means bind `dired-man' to \"N\" in dired-mode, otherwise do not."
144 :group 'dired-keys)
146 (defcustom dired-bind-info t
147 "*Non-nil means bind `dired-info' to \"I\" in dired-mode, otherwise do not."
149 :group 'dired-keys)
151 (defcustom dired-vm-read-only-folders nil
152 "*If non-nil, \\[dired-vm] will visit all folders read-only.
154 files not writable by you are visited read-only.
160 :group 'dired-x)
162 (define-minor-mode dired-omit-mode
166 If enabled, \"uninteresting\" files are not listed.
167 Uninteresting files are those whose filenames match regexp `dired-omit-files',
168 plus those ending with extensions in `dired-omit-extensions'."
169 :group 'dired-x
170 (if dired-omit-mode
172 (let ((dired-omit-size-limit nil)) (dired-omit-expunge))
176 (defvaralias 'dired-omit-files-p 'dired-omit-mode)
177 (make-obsolete-variable 'dired-omit-files-p 'dired-omit-mode)
179 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$"
180 "*Filenames matching this regexp will not be displayed.
181 This only has effect when `dired-omit-mode' is t. See interactive function
182 `dired-omit-mode' \(\\[dired-omit-mode]\) and variable
183 `dired-omit-extensions'. The default is to omit `.', `..', auto-save
184 files and lock files."
185 :type 'regexp
186 :group 'dired-x)
188 (defcustom dired-find-subdir nil ; t is pretty near to DWIM...
193 If there are several dired buffers for a directory, the most recently
197 a normal and a wildcard buffer for the same directory, \\[dired] will
200 :group 'dired-x)
202 (defcustom dired-omit-size-limit 30000
206 :group 'dired-x)
208 (defcustom dired-enable-local-variables t
215 a directory. See also `dired-local-variables-file'."
217 :group 'dired-x)
219 (defcustom dired-guess-shell-gnutar (when (or (eq system-type 'gnu)
224 compressed or gzip'ed tar files. If you don't have GNU tar, set this
228 :group 'dired-x)
230 (defcustom dired-guess-shell-gzip-quiet t
233 :group 'dired-x)
235 (defcustom dired-guess-shell-znew-switches nil
239 :group 'dired-x)
241 (defcustom dired-clean-up-buffers-too t
242 "*Non-nil means offer to kill buffers visiting files and dirs deleted in Dired."
244 :group 'dired-x)
248 (define-key dired-mode-map "\M-o" 'dired-omit-mode)
249 (define-key dired-mode-map "*O" 'dired-mark-omitted)
250 (define-key dired-mode-map "\M-(" 'dired-mark-sexp)
251 (define-key dired-mode-map "*(" 'dired-mark-sexp)
252 (define-key dired-mode-map "*." 'dired-mark-extension)
253 (define-key dired-mode-map "\M-!" 'dired-smart-shell-command)
254 (define-key dired-mode-map "w" 'dired-copy-filename-as-kill)
255 (define-key dired-mode-map "\M-G" 'dired-goto-subdir)
256 (define-key dired-mode-map "F" 'dired-do-find-marked-files)
257 (define-key dired-mode-map "Y" 'dired-do-relsymlink)
258 (define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp)
259 (define-key dired-mode-map "V" 'dired-do-run-mail)
261 (if dired-bind-man
262 (define-key dired-mode-map "N" 'dired-man))
264 (if dired-bind-info
265 (define-key dired-mode-map "I" 'dired-info))
269 (let ((menu-bar (lookup-key dired-mode-map [menu-bar])))
273 [find-files]
275 "Find files"
276 dired-do-find-marked-files
277 :help "Find current or marked files")
284 dired-do-relsymlink
286 :help "Make relative symbolic links for current or marked files")
288 (let ((menu (lookup-key menu-bar [mark])))
294 dired-flag-extension
295 :help "Flag files with a certain extension for deletion")
296 'garbage-files)
299 [mark-extension]
302 dired-mark-extension
303 :help "Mark files with a certain extension")
307 [mark-omitted]
310 dired-mark-omitted
311 :help "Mark files matching `dired-omit-files' and `dired-omit-extensions'")
312 'mark-extension))
313 (let ((menu (lookup-key menu-bar [regexp])))
316 [relsymlink-regexp]
319 dired-do-relsymlink-regexp
321 :help "Make relative symbolic links for files matching regexp")
328 "Omit mode" dired-omit-mode
329 :button (:toggle . dired-omit-mode)
330 :help "Enable or disable omitting \"uninteresting\" files")
334 (if dired-bind-jump
336 (define-key global-map "\C-x\C-j" 'dired-jump)
337 (define-key global-map "\C-x4\C-j" 'dired-jump-other-window)))
343 (add-hook 'dired-mode-hook 'dired-extra-startup)
344 (add-hook 'dired-after-readin-hook 'dired-omit-expunge)
346 (defun dired-extra-startup ()
347 "Automatically put on `dired-mode-hook' to get extra Dired features:
348 \\<dired-mode-map>
349 \\[dired-do-run-mail]\t-- run mail on folder (see `dired-bind-vm')
350 \\[dired-info]\t-- run info on file
351 \\[dired-man]\t-- run man on file
352 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously
353 \\[dired-omit-mode]\t-- toggle omitting of files
354 \\[dired-mark-sexp]\t-- mark by Lisp expression
355 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring;
360 `dired-bind-vm'
361 `dired-bind-jump'
362 `dired-bind-info'
363 `dired-bind-man'
364 `dired-vm-read-only-folders'
365 `dired-omit-mode'
366 `dired-omit-files'
367 `dired-omit-extensions'
368 `dired-omit-size-limit'
369 `dired-find-subdir'
370 `dired-enable-local-variables'
371 `dired-local-variables-file'
372 `dired-guess-shell-gnutar'
373 `dired-guess-shell-gzip-quiet'
374 `dired-guess-shell-znew-switches'
375 `dired-guess-shell-alist-user'
376 `dired-clean-up-buffers-too'
380 `dired-flag-extension'
381 `dired-virtual'
382 `dired-jump'
383 `dired-man'
384 `dired-vm'
385 `dired-rmail'
386 `dired-info'
387 `dired-do-find-marked-files'"
390 ;; These must be done in each new dired buffer.
391 (dired-hack-local-variables)
392 (dired-omit-startup))
399 (defun dired-clean-up-after-deletion (fn)
402 (save-excursion (and (cdr dired-subdir-alist)
403 (dired-goto-subdir fn)
404 (dired-kill-subdir)))
407 (if dired-clean-up-buffers-too
416 (let ((buf-list (dired-buffers-for-dir (expand-file-name fn)))
419 (y-or-n-p (format "Kill dired buffer%s of %s, too? "
420 (dired-plural-s (length buf-list))
432 ;;; Mark files with some extension.
433 (defun dired-mark-extension (extension &optional marker-char)
434 "Mark all files with a certain EXTENSION for use in later commands.
441 (dired-mark-files-regexp
444 (mapconcat 'regexp-quote extension "\\|")
448 (defun dired-flag-extension (extension)
449 "In dired, flag all files with a certain EXTENSION for deletion.
452 (dired-mark-extension extension dired-del-marker))
456 (defvar dired-patch-unclean-extensions
458 "List of extensions of dispensable files created by the `patch' program.")
460 (defvar dired-tex-unclean-extensions
462 "List of extensions of dispensable files created by TeX.")
464 (defvar dired-latex-unclean-extensions
466 "List of extensions of dispensable files created by LaTeX.")
468 (defvar dired-bibtex-unclean-extensions
470 "List of extensions of dispensable files created by BibTeX.")
472 (defvar dired-texinfo-unclean-extensions
475 "List of extensions of dispensable files created by texinfo.")
477 (defun dired-clean-patch ()
478 "Flag dispensable files created by patch for deletion.
479 See variable `dired-patch-unclean-extensions'."
481 (dired-flag-extension dired-patch-unclean-extensions))
483 (defun dired-clean-tex ()
484 "Flag dispensable files created by [La]TeX etc. for deletion.
485 See variables `dired-tex-unclean-extensions',
486 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
487 `dired-texinfo-unclean-extensions'."
489 (dired-flag-extension (append dired-texinfo-unclean-extensions
490 dired-latex-unclean-extensions
491 dired-bibtex-unclean-extensions
492 dired-tex-unclean-extensions)))
494 (defun dired-very-clean-tex ()
495 "Flag dispensable files created by [La]TeX *and* \".dvi\" for deletion.
496 See variables `dired-texinfo-unclean-extensions',
497 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and
498 `dired-texinfo-unclean-extensions'."
500 (dired-flag-extension (append dired-texinfo-unclean-extensions
501 dired-latex-unclean-extensions
502 dired-bibtex-unclean-extensions
503 dired-tex-unclean-extensions
510 (defun dired-jump (&optional other-window)
511 "Jump to dired buffer corresponding to current buffer.
512 If in a file, dired the current directory and move to file's line.
514 In case the proper dired file line cannot be found, refresh the dired
519 (if (eq major-mode 'dired-mode)
521 (setq dir (dired-current-directory))
522 (dired-up-directory other-window)
523 (or (dired-goto-file dir)
526 (dired-insert-subdir (file-name-directory dir))
527 (dired-goto-file dir))))
529 (dired-other-window dir)
530 (dired dir))
532 (or (dired-goto-file file)
535 (dired-insert-subdir (file-name-directory file))
536 (dired-goto-file file))
538 (if dired-omit-mode
540 (dired-omit-mode)
541 (dired-goto-file file))))))))
543 (defun dired-jump-other-window ()
544 "Like \\[dired-jump] (`dired-jump') but in other window."
546 (dired-jump t))
552 ;;; Marked files are never omitted.
556 (defvar dired-omit-localp 'no-dir
557 "The LOCALP argument `dired-omit-expunge' passes to `dired-get-filename'.
563 (defvar dired-omit-marker-char ?\017
564 "Temporary marker used by dired-omit.
567 (defun dired-omit-startup ()
568 (or (assq 'dired-omit-mode minor-mode-alist)
570 (append '((dired-omit-mode
571 (:eval (if (eq major-mode 'dired-mode)
575 (defun dired-mark-omitted ()
576 "Mark files matching `dired-omit-files' and `dired-omit-extensions'."
578 (let ((dired-omit-mode nil)) (revert-buffer)) ;; Show omitted files
579 (dired-mark-unmarked-files (dired-omit-regexp) nil nil dired-omit-localp))
581 (defvar dired-omit-extensions
583 dired-latex-unclean-extensions
584 dired-bibtex-unclean-extensions
585 dired-texinfo-unclean-extensions)
588 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and
589 `dired-texinfo-unclean-extensions'.
591 See interactive function `dired-omit-mode' \(\\[dired-omit-mode]\) and
592 variables `dired-omit-mode' and `dired-omit-files'.")
594 (defun dired-omit-expunge (&optional regexp)
595 "Erases all unmarked files matching REGEXP.
596 Does nothing if global variable `dired-omit-mode' is nil, or if called
597 non-interactively and buffer is bigger than `dired-omit-size-limit'.
598 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits
599 filenames ending in `dired-omit-extensions'.
602 This functions works by temporarily binding `dired-marker-char' to
603 `dired-omit-marker-char' and calling `dired-do-kill-lines'."
604 (interactive "sOmit files (regexp): ")
605 (if (and dired-omit-mode
607 (not dired-omit-size-limit)
608 (< (buffer-size) dired-omit-size-limit)
611 dired-omit-size-limit)
612 (setq dired-omit-mode nil)
614 (let ((omit-re (or regexp (dired-omit-regexp)))
618 (let ((dired-marker-char dired-omit-marker-char))
620 (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp)
622 (setq count (dired-do-kill-lines nil "Omitted %d line%s."))
630 (re-search-forward dired-re-mark nil t))))
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
639 (mapconcat 'regexp-quote dired-omit-extensions "\\|")
644 (defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp)
645 "Mark unmarked files matching REGEXP, displaying MSG.
647 Does not re-mark files which already have a mark.
648 With prefix argument, unflag all those files.
649 Optional fourth argument LOCALP is as in `dired-get-filename'."
651 (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
652 (dired-mark-if
657 (let ((fn (dired-get-filename localp t)))
658 (and fn (string-match regexp fn))))
662 (defun dired-omit-new-add-entry (filename &optional marker-char relative)
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-mode
667 (let ((omit-re (dired-omit-regexp)))
672 ((eq 'no-dir dired-omit-localp)
674 ((eq t dired-omit-localp)
675 (dired-make-relative filename))
677 (dired-make-absolute
681 (dired-omit-old-add-entry filename marker-char relative)
682 ;; dired-add-entry returns t for success, perhaps we should
686 (dired-omit-old-add-entry filename marker-char relative)))
689 ;;; Redefine dired-aux.el's version of `dired-add-entry'
691 (or (fboundp 'dired-omit-old-add-entry)
692 (fset 'dired-omit-old-add-entry (symbol-function 'dired-add-entry)))
694 (fset 'dired-add-entry 'dired-omit-new-add-entry)
700 ;;; For browsing `ls -lR' listings in a dired-like fashion.
702 (defalias 'virtual-dired 'dired-virtual)
703 (defun dired-virtual (dirname &optional switches)
711 ange-ftp, you can even dired a directory containing an ls-lR file,
712 visit that file and turn on virtual dired mode. But don't try to save
713 this file, as dired-virtual indents the listing and thus changes the
716 If you have save a Dired buffer in a file you can use \\[dired-virtual] to
719 Type \\<dired-mode-map>\\[revert-buffer] \
721 the virtual to a real dired buffer again. You don't have to do this, though:
722 you can relist single subdirs using \\[dired-do-redisplay]."
736 (list (read-string "Virtual Dired directory: " (dired-virtual-guess-dir))))
752 ;; If raw ls listing (not a saved old dired buffer), give it a
755 (or (looking-at dired-subdir-regexp)
759 (dired-mode dirname (or switches dired-listing-switches))
761 revert-buffer-function 'dired-virtual-revert)
762 (set (make-local-variable 'dired-subdir-alist) nil)
763 (dired-build-subdir-alist)
765 (dired-initial-position dirname))
767 (defun dired-virtual-guess-dir ()
773 (let ((regexp "^\\( \\)?\\([^ \n\r]*\\)\\(:\\)[\n\r]")
776 (cond ((looking-at regexp)
777 ;; If a saved dired buffer, look to which dir and
785 ((re-search-forward regexp nil t)
795 (defun dired-virtual-revert (&optional arg noconfirm)
800 revert-buffer-function 'dired-revert)
803 ;; A zero-arg version of dired-virtual.
804 (defun dired-virtual-mode ()
805 "Put current buffer into Virtual Dired mode (see `dired-virtual').
806 Useful on `magic-mode-alist' with the regexp
810 to put saved dired buffers automatically into Virtual Dired mode.
815 '(\"[^/]\\\\.dired\\\\'\" . dired-virtual-mode))"
817 (dired-virtual (dired-virtual-guess-dir)))
835 '((dired-mode . (if (fboundp 'dired-current-directory)
836 (dired-current-directory)
842 (defun dired-default-directory ()
848 (defun dired-smart-shell-command (cmd &optional insert)
853 (let ((default-directory (dired-default-directory)))
862 ;;; * `dired-extra-startup' is part of the `dired-mode-hook'.
864 ;;; * `dired-extra-startup' calls `dired-hack-local-variables'
866 ;;; * `dired-hack-local-variables' checks the value of
867 ;;; `dired-local-variables-file'
869 ;;; * Check if `dired-local-variables-file' is a non-nil string and is a
872 ;;; * If `dired-local-variables-file' satisfies the above, then temporarily
876 ;;; `dired-enable-local-variables' and run `hack-local-variables' on the
879 (defvar dired-local-variables-file (convert-standard-filename ".dired")
880 "Filename, as string, containing local dired buffer variables to be hacked.
881 If this file found in current directory, then it will be inserted into dired
884 See also `dired-enable-local-variables'.")
886 (defun dired-hack-local-variables ()
887 "Evaluate local variables in `dired-local-variables-file' for dired buffer."
888 (if (and dired-local-variables-file
889 (stringp dired-local-variables-file)
890 (file-exists-p dired-local-variables-file))
894 ;; override it locally with dired's variable.
895 (enable-local-variables dired-enable-local-variables))
900 (insert-file-contents dired-local-variables-file))
902 (let ((buffer-file-name dired-local-variables-file))
905 (dired-sort-set-modeline)
906 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el.
909 (defun dired-omit-here-always ()
910 "Create `dired-local-variables-file' for omitting and reverts directory.
911 Sets `dired-omit-mode' to t in a local variables file that is readable by
912 dired."
914 (if (file-exists-p dired-local-variables-file)
915 (message "File `./%s' already exists." dired-local-variables-file)
917 ;; Create `dired-local-variables-file'.
919 (set-buffer (get-buffer-create " *dot-dired*"))
922 (write-file dired-local-variables-file)
926 (dired-extra-startup)
927 (dired-revert)))
935 ;;; `dired-do-shell-command' is bound to `!' by dired.el.
937 ;;; * Redefine `dired-do-shell-command' so it calls
938 ;;; `dired-guess-shell-command'.
940 ;;; * `dired-guess-shell-command' calls `dired-guess-default' with list of
941 ;;; marked files.
943 ;;; * Parse `dired-guess-shell-alist-user' and
944 ;;; `dired-guess-shell-alist-default' (in that order) for the first REGEXP
951 ;;; * Return this command to `dired-guess-shell-command' which prompts user
954 ;;; `dired-shell-command-history'.
957 (defvar dired-shell-command-history nil
958 "History list for commands that read dired-shell commands.")
962 ;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not
965 (defvar dired-guess-shell-alist-default
968 '(if dired-guess-shell-gnutar
969 (concat dired-guess-shell-gnutar " xvf")
971 ;; Extract files into a separate subdirectory
972 '(if dired-guess-shell-gnutar
974 "; " dired-guess-shell-gnutar " -C "
979 '(if dired-guess-shell-gnutar
980 (concat dired-guess-shell-gnutar " tvf")
987 '(if dired-guess-shell-gnutar
988 (concat dired-guess-shell-gnutar " zxvf")
991 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
992 " " dired-guess-shell-znew-switches))
996 '(if dired-guess-shell-gnutar
997 (concat dired-guess-shell-gnutar " zxvf")
999 ;; Extract files into a separate subdirectory
1000 '(if dired-guess-shell-gnutar
1002 "; " dired-guess-shell-gnutar " -C "
1008 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))
1010 '(if dired-guess-shell-gnutar
1011 (concat dired-guess-shell-gnutar " ztvf")
1017 ;; Extract files into a separate subdirectory
1030 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
1033 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1034 " " dired-guess-shell-znew-switches))
1039 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
1042 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1043 " " dired-guess-shell-znew-switches))
1045 ;; The following four extensions are useful with dired-man ("N" key)
1055 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
1061 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1062 " " dired-guess-shell-znew-switches))
1069 '("\\.uu$" "uudecode") ; for uudecoded files
1091 ;; Extract files into a separate subdirectory
1092 '(concat "unzip" (if dired-guess-shell-gzip-quiet " -q")
1100 (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q")))
1105 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q")
1106 " " dired-guess-shell-znew-switches))
1111 See `dired-guess-shell-alist-user'.")
1113 (defcustom dired-guess-shell-alist-user nil
1116 `dired-guess-shell-alist-default' (to which they are prepended).
1128 `.foo' and `.bar' files, write
1130 \(setq dired-guess-shell-alist-user
1137 :group 'dired-x
1138 :type '(alist :key-type regexp :value-type (repeat sexp)))
1140 (defcustom dired-guess-shell-case-fold-search t
1141 "If non-nil, `dired-guess-shell-alist-default' and
1142 `dired-guess-shell-alist-user' are matched case-insensitively."
1143 :group 'dired-x
1146 (defun dired-guess-default (files)
1148 See `dired-guess-shell-alist-user'."
1150 (let* ((case-fold-search dired-guess-shell-case-fold-search)
1152 (alist (append dired-guess-shell-alist-user
1153 dired-guess-shell-alist-default))
1154 (file (car files))
1155 (flist (cdr files))
1156 elt regexp cmds)
1161 regexp (car elt)
1163 (if (string-match regexp file)
1169 (string-match regexp (car flist)))
1173 ;; all the files in FILES were matched by the regexp.
1183 (defun dired-guess-shell-command (prompt files)
1186 (let ((default (dired-guess-default files))
1191 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history)
1194 (setq old-history dired-shell-command-history)
1210 (setq dired-shell-command-history
1211 (append default-list dired-shell-command-history)
1219 'dired-shell-command-history)
1229 (setq dired-shell-command-history old-history)
1231 (or (equal val (car-safe dired-shell-command-history))
1232 (setq dired-shell-command-history
1233 (cons val dired-shell-command-history))))))))
1237 ;;; Redefine dired-aux.el's version:
1238 (defun dired-read-shell-command (prompt arg files)
1239 "Read a dired shell command prompting with PROMPT (using read-string).
1241 files are affected.
1243 (dired-mark-pop-up
1244 nil 'shell files
1245 'dired-guess-shell-command
1246 (format prompt (dired-mark-prompt arg files)) ; PROMPT
1247 files)) ; FILES
1253 (defvar dired-keep-marker-relsymlink ?S
1254 "See variable `dired-keep-marker-move'.")
1256 (defun dired-make-relative-symlink (file1 file2 &optional ok-if-already-exists)
1309 (defun dired-do-relsymlink (&optional arg)
1310 "Relative symlink all marked (or next ARG) files into a directory.
1320 For absolute symlinks, use \\[dired-do-symlink]."
1322 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink)
1323 "RelSymLink" arg dired-keep-marker-relsymlink))
1325 (defun dired-do-relsymlink-regexp (regexp newname &optional arg whole-name)
1326 "RelSymlink all marked files containing REGEXP to NEWNAME.
1327 See functions `dired-do-rename-regexp' and `dired-do-relsymlink'
1329 (interactive (dired-mark-read-regexp "RelSymLink"))
1330 (dired-do-create-files-regexp
1331 (function dired-make-relative-symlink)
1332 "RelSymLink" arg regexp newname whole-name dired-keep-marker-relsymlink))
1340 ;;; `dired-do-find-marked-files' is bound to `F' by dired-x.el.
1342 ;;; * Use `dired-get-marked-files' to collect the marked files in the current
1345 ;;; * Pass FILE-LIST to `dired-simultaneous-find-file' all with
1346 ;;; `dired-do-find-marked-files''s prefix argument NOSELECT.
1348 ;;; * `dired-simultaneous-find-file' runs through FILE-LIST decrementing the
1361 (defun dired-do-find-marked-files (&optional noselect)
1362 "Find all marked files displaying all of them simultaneously.
1363 With optional NOSELECT just find files but do not select them.
1365 The current window is split across all files marked, as evenly as possible.
1366 Remaining lines go to bottom-most window. The number of files that can be
1370 To keep dired buffer displayed, type \\[split-window-vertically] first.
1371 To display just marked files, type \\[delete-other-windows] first."
1374 (dired-simultaneous-find-file (dired-get-marked-files) noselect))
1376 (defun dired-simultaneous-find-file (file-list noselect)
1378 "Visit all files in FILE-LIST and display them simultaneously.
1379 The current window is split across all files in FILE-LIST, as evenly as
1381 files that can be displayed this way is restricted by the height of the
1383 NOSELECT the files are merely found but not selected."
1386 ;; to specify FILE-LIST interactively unless via dired.
1397 (error "Too many files to visit simultaneously. Try C-u prefix"))
1421 ;;; Run man on files.
1423 (defun dired-man ()
1428 (let* ((file (dired-get-filename))
1429 (manual-program (replace-regexp-in-string "\\*" "%s"
1430 (dired-guess-shell-command
1434 ;;; Run Info on files.
1436 (defun dired-info ()
1439 (info (dired-get-filename)))
1449 (defun dired-vm (&optional read-only)
1452 See also variable `dired-vm-read-only-folders'."
1454 (let ((dir (dired-current-directory))
1455 (fil (dired-get-filename)))
1458 ((eq t dired-vm-read-only-folders) (vm-visit-folder fil t))
1459 ((null dired-vm-read-only-folders) (vm-visit-folder fil))
1464 (defun dired-rmail ()
1467 (rmail (dired-get-filename)))
1469 (defun dired-do-run-mail ()
1470 "If `dired-bind-vm' is t, then function `dired-vm', otherwise `dired-rmail'."
1472 (if dired-bind-vm
1474 (dired-vm)
1476 (dired-rmail)))
1482 (or (fboundp 'dired-old-find-buffer-nocreate)
1483 (fset 'dired-old-find-buffer-nocreate
1484 (symbol-function 'dired-find-buffer-nocreate)))
1487 ;;; Redefines dired.el's version of `dired-find-buffer-nocreate'
1488 (defun dired-find-buffer-nocreate (dirname &optional mode)
1489 (if (and dired-find-subdir
1494 (dired-buffers-for-dir (expand-file-name dirname))))
1497 (equal dired-directory dirname))))
1500 (or (car (sort buffers (function dired-buffer-more-recently-used-p)))
1503 (dired-old-find-buffer-nocreate dirname mode)))
1506 (defun dired-buffer-more-recently-used-p (buffer1 buffer2)
1518 ;;; Same thing as `dired-buffers-for-dir' of dired.el? - lrd 11/23/93
1519 ;;; (defun dired-buffers-for-dir-exact (dir)
1520 ;;; ;; Return a list of buffers that dired DIR (a directory or wildcard)
1524 ;;; ;; As a side effect, killed dired buffers for DIR are removed from
1525 ;;; ;; dired-buffers.
1526 ;;; (let ((alist dired-buffers) result elt)
1532 ;;; ;; Top level must match exactly against dired-directory in
1535 ;;; dired-directory))
1537 ;;; dired-subdir-alist)))
1540 ;;; (setq dired-buffers (delq elt dired-buffers)))))
1544 ;;; Redefines dired.el's version of `dired-initial-position'
1545 (defun dired-initial-position (dirname)
1548 You may redefine this function as you wish, e.g. like in `dired-x.el'."
1550 (if dired-find-subdir (dired-goto-subdir dirname)) ; new
1551 (if dired-trivial-filenames (dired-goto-next-nontrivial-file)))
1557 (defun dired-mark-sexp (predicate &optional unflag-p)
1558 "Mark files for which PREDICATE returns non-nil.
1559 With a prefix arg, unflag those files instead.
1580 to mark all zero length files."
1587 (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char))
1589 (dired-mark-if
1599 (if (dired-move-to-filename)
1602 ;; like in dired.el, but with subexpressions \1=inode, \2=s:
1603 (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?"))
1606 (if (looking-at dired-re-inode-size)
1621 (re-search-forward directory-listing-before-filename-regexp)
1636 (1- (dired-move-to-filename)))
1639 (dired-move-to-end-of-filename t)
1656 (defvar dired-x-hands-off-my-keys t
1657 "*Non-nil means don't bind `dired-x-find-file' over `find-file' on keyboard.
1658 Similarly for `dired-x-find-file-other-window' over `find-file-other-window'.
1659 If you change this variable after `dired-x.el' is loaded then do
1660 \\[dired-x-bind-find-file].")
1662 ;;; Bind `dired-x-find-file{-other-window}' over wherever
1664 (defun dired-x-bind-find-file ()
1665 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\).
1666 Similarly for `dired-x-find-file-other-window' and `find-file-other-window'.
1667 Binding direction based on `dired-x-hands-off-my-keys'.
1671 (setq dired-x-hands-off-my-keys
1672 (not (y-or-n-p "Bind dired-x-find-file over find-file? "))))
1673 (cond ((not dired-x-hands-off-my-keys)
1675 'dired-x-find-file
1678 'dired-x-find-file-other-window
1681 (substitute-key-definition 'dired-x-find-file
1684 (substitute-key-definition 'dired-x-find-file-other-window
1692 (dired-x-bind-find-file)
1693 (add-hook 'after-init-hook 'dired-x-bind-find-file)
1695 (defun dired-x-find-file (filename)
1707 (defun dired-x-find-file-other-window (filename)
1722 (defun dired-filename-at-point ()
1765 (let ((guess (dired-filename-at-point)))
1780 (defconst dired-x-help-address "bug-gnu-emacs@gnu.org"
1781 "Address(es) accepting submission of reports on dired-x.el.")
1783 (defconst dired-x-variable-list
1785 'dired-bind-vm
1786 'dired-vm-read-only-folders
1787 'dired-bind-jump
1788 'dired-bind-info
1789 'dired-bind-man
1790 'dired-find-subdir
1791 'dired-enable-local-variables
1792 'dired-local-variables-file
1793 'dired-guess-shell-gnutar
1794 'dired-guess-shell-gzip-quiet
1795 'dired-guess-shell-znew-switches
1796 'dired-guess-shell-alist-user
1797 'dired-clean-up-buffers-too
1798 'dired-omit-mode
1799 'dired-omit-files
1800 'dired-omit-extensions
1802 "List of variables to be appended to reports sent by `dired-x-submit-report'.")
1804 (defun dired-x-submit-report ()
1806 Send report on `dired-x-file' version `dired-x-version,' to
1807 `dired-x-maintainer' at address `dired-x-help-address' listing
1808 variables `dired-x-variable-list' in the message."
1812 dired-x-help-address ; address
1813 "dired-x" ; pkgname
1814 dired-x-variable-list ; varlist
1821 (provide 'dired-x)
1824 ;;; dired-x.el ends here