1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; Description: Commands for marking files from another buffer.
8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10 ;;; Requirements and provisions
13 (autoload 'compilation-buffer-p "compile")
14 (autoload 'compile-reinitialize-errors "compile")
16 ;; For the byte-compiler
17 (defvar compilation-error-list)
21 (defun dired-mark-these-files (file-list from)
22 ;; Mark the files in FILE-LIST. Relative filenames are taken to be
23 ;; in the current dired directory.
24 ;; FROM is a string (used for logging) describing where FILE-LIST
26 ;; Logs files that were not found and displays a success or failure
28 (message "Marking files %s..." from)
29 (let ((total (length file-list))
30 (cur-dir (dired-current-directory))
33 (setq file (expand-file-name (car file-list) cur-dir)
34 file-list (cdr file-list))
35 ;;(message "Marking file `%s'" file)
37 (if (dired-goto-file file)
38 (dired-mark 1) ; supplying a prefix keeps it from checking
40 (setq failures (cons (dired-make-relative file) failures))
41 (dired-log (buffer-name (current-buffer))
42 "Cannot mark this file (not found): %s\n" file))))
43 (dired-update-mode-line-modified t)
46 (buffer-name (current-buffer))
47 (format "Failed to mark %d of %d files %s %s"
48 (length failures) total from failures) failures)
49 (message "Marked %d file%s %s." total (dired-plural-s total) from))))
54 (defun dired-mark-files-from-other-dired-buffer (buf)
55 "Mark files that are marked in the other Dired buffer.
56 I.e, mark those files in this Dired buffer that have the same
57 non-directory part as the marked files in the Dired buffer in the other
59 (interactive (list (window-buffer (next-window))))
60 (if (eq (get-buffer buf) (current-buffer))
61 (error "Other dired buffer is the same"))
62 (or (stringp buf) (setq buf (buffer-name buf)))
63 (let ((other-files (save-excursion
65 (or (eq major-mode 'dired-mode)
66 (error "%s is not a dired buffer" buf))
67 (dired-get-marked-files 'no-dir))))
68 (dired-mark-these-files other-files (concat "from buffer " buf))))
71 (defun dired-mark-files-compilation-buffer (&optional buf)
72 "Mark the files mentioned in the `*compilation*' buffer.
73 With a prefix, you may specify the other buffer."
76 (let ((buff (let ((owin (selected-window))
81 (while (null (or found (eq (selected-window) owin)))
82 (if (compilation-buffer-p
83 (window-buffer (selected-window)))
84 (setq found (current-buffer)))
88 (if (or current-prefix-arg (null buff))
89 (let ((minibuffer-history
94 (and (compilation-buffer-p b) (buffer-name b))))
96 (read-buffer "Use buffer: "
97 (or buff (car minibuffer-history))))
99 (let ((dired-dir (directory-file-name default-directory))
101 (save-window-excursion
103 (compile-reinitialize-errors nil (point-max))
104 (let ((alist compilation-error-list)
107 (setq elt (car alist)
109 (and (consp (setq elt (car (cdr elt))))
110 (stringp (setq d (car elt)))
111 (stringp (setq f (cdr elt)))
113 (setq d (expand-file-name d))
114 (dired-in-this-tree d dired-dir))
116 (setq f (expand-file-name f d))
117 (not (member f files)))
118 (setq files (cons f files))))))
119 (dired-mark-these-files
121 (concat "From compilation buffer "
122 (if (stringp buf) buf (buffer-name buf))))))
124 ;;; end of dired-mob.el