"/etc/chown"))
"Name of chown command (usually `chown' or `/etc/chown').")
-(defvar dired-chmod-program
- (if (eq system-type 'windows-nt)
- "chmode" "chmod")
- "Name of chmod command (usually `chmod' or `chmode').")
+(defvar dired-chmod-program "chmod"
+ "Name of chmod command (usually `chmod').")
;;;###autoload
(defcustom dired-ls-F-marks-symlinks nil
;; if it was the name of a directory at all.
(file-name-directory dirname))
(or switches (setq switches dired-listing-switches))
- (dired-mode dirname switches)
- (if mode (funcall mode))
+ (if mode (funcall mode)
+ (dired-mode dirname switches))
;; default-directory and dired-actual-switches are set now
;; (buffer-local), so we can call dired-readin:
(let ((failed t))
;; We need this to make the root dir have a header line as all
;; other subdirs have:
(goto-char (point-min))
- (dired-insert-headerline default-directory)
+ (if (not (looking-at "^ /.*:$"))
+ (dired-insert-headerline default-directory))
;; can't run dired-after-readin-hook here, it may depend on the subdir
;; alist to be OK.
)
(define-key map "%u" 'dired-upcase)
(define-key map "%l" 'dired-downcase)
(define-key map "%d" 'dired-flag-files-regexp)
+ (define-key map "%g" 'dired-mark-files-containing-regexp)
(define-key map "%m" 'dired-mark-files-regexp)
(define-key map "%r" 'dired-do-rename-regexp)
(define-key map "%C" 'dired-do-copy-regexp)
(define-key map "*\177" 'dired-unmark-backward)
(define-key map "*\C-n" 'dired-next-marked-file)
(define-key map "*\C-p" 'dired-prev-marked-file)
+ (define-key map "*t" 'dired-do-toggle)
;; Lower keys for commands not operating on all the marked files
(define-key map "d" 'dired-flag-file-deletion)
(define-key map "e" 'dired-find-file)
(define-key map "o" 'dired-find-file-other-window)
(define-key map "\C-o" 'dired-display-file)
(define-key map "p" 'dired-previous-line)
- (define-key map "q" 'dired-quit)
+ (define-key map "q" 'quit-window)
(define-key map "s" 'dired-sort-toggle-or-edit)
(define-key map "t" 'dired-do-toggle)
(define-key map "u" 'dired-unmark)
'("Flag..." . dired-flag-files-regexp))
(define-key map [menu-bar regexp mark]
'("Mark..." . dired-mark-files-regexp))
+ (define-key map [menu-bar regexp mark]
+ '("Mark Containing..." . dired-mark-files-containing-regexp))
(define-key map [menu-bar mark]
(cons "Mark" (make-sparse-keymap "Mark")))
\f
;; Idiosyncratic dired commands that don't deal with marks.
-(defun dired-quit ()
- "Bury the current dired buffer."
- (interactive)
- (bury-buffer))
-
(defun dired-summary ()
"Summarize basic Dired commands and show recent Dired errors."
(interactive)
"\"")))))
(and file buffer-file-coding-system
(not file-name-coding-system)
+ (not default-file-name-coding-system)
(setq file (encode-coding-string file buffer-file-coding-system)))
(if (eq localp 'no-dir)
file
(dd "[ 0-3][0-9]")
(HH:MM "[ 0-2][0-9]:[0-5][0-9]")
(western (concat "\\(" month s dd "\\|" dd s month "\\)"
- s "\\(" HH:MM "\\|" s yyyy "\\)"))
+ s "\\(" HH:MM "\\|" s yyyy "\\|" yyyy s "\\)"))
(japanese (concat mm k s dd k s "\\(" s HH:MM "\\|" yyyy k "\\)")))
;; Require the previous column to end in a digit.
;; This avoids recognizing `1 may 1997' as a date in the line:
(and fn (string-match regexp (file-name-nondirectory fn)))))
"matching file")))
+(defun dired-mark-files-containing-regexp (regexp &optional marker-char)
+ "Mark all files with contents containing REGEXP for use in later commands.
+A prefix argument means to unmark them instead.
+`.' and `..' are never marked."
+ (interactive
+ (list (dired-read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
+ " files containing (regexp): "))
+ (if current-prefix-arg ?\040)))
+ (let ((dired-marker-char (or marker-char dired-marker-char)))
+ (dired-mark-if
+ (and (not (looking-at dired-re-dot))
+ (not (eolp)) ; empty line
+ (let ((fn (dired-get-filename nil t)))
+ (and fn (save-excursion
+ ;; For now we do it inside emacs
+ ;; Grep might be better if there are a lot of files
+ (message "Checking %s" fn)
+ (let* ((prebuf (get-file-buffer fn)))
+ (find-file fn)
+ (goto-char (point-min))
+ (prog1
+ (re-search-forward regexp nil t)
+ (if (not prebuf) (kill-buffer nil))))
+ ))))
+ "matching file")))
+
(defun dired-flag-files-regexp (regexp)
"In dired, flag all files containing the specified REGEXP for deletion.
The match is against the non-directory part of the filename. Use `^'
"auto save file")))
(defvar dired-garbage-files-regexp
- "\\.log$\\|\\.toc$\\|.dvi$|\\.bak$\\|\\.orig$\\|\\.rej$"
+ "\\.log$\\|\\.toc$\\|\\.dvi$\\|\\.bak$\\|\\.orig$\\|\\.rej$"
"*Regular expression to match \"garbage\" files for `dired-flag-garbage-files'.")
(defun dired-flag-garbage-files ()
;; Toggle between sort by date/name. Reverts the buffer.
(setq dired-actual-switches
(let (case-fold-search)
- (concat
- "-l"
- (dired-replace-in-string (concat "[-lt"
- dired-ls-sorting-switches "]")
- ""
- dired-actual-switches)
- (if (string-match (concat "[t" dired-ls-sorting-switches "]")
- dired-actual-switches)
- ""
- "t"))))
+ (if (string-match " " dired-actual-switches)
+ ;; New toggle scheme: add/remove a trailing " -t"
+ (if (string-match " -t\\'" dired-actual-switches)
+ (dired-replace-in-string " -t\\'" "" dired-actual-switches)
+ (concat dired-actual-switches " -t"))
+ ;; old toggle scheme: look for some 't' switch and add/remove it
+ (concat
+ "-l"
+ (dired-replace-in-string (concat "[-lt"
+ dired-ls-sorting-switches "]")
+ ""
+ dired-actual-switches)
+ (if (string-match (concat "[t" dired-ls-sorting-switches "]")
+ dired-actual-switches)
+ ""
+ "t")))))
(dired-sort-set-modeline)
(revert-buffer))