annotate lisp/efs/dired-mob.el @ 199:169c0442b401 r20-3b26

Import from CVS: tag r20-3b26
author cvs
date Mon, 13 Aug 2007 10:00:33 +0200
parents 9f59509498e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;; File: dired-mob.el
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; RCS:
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 22
diff changeset
5 ;; Dired Version: #Revision: 7.9 $
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
6 ;; Description: Commands for marking files from another buffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;;; Requirements and provisions
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 (provide 'dired-mob)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 (require 'dired)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 (autoload 'compilation-buffer-p "compile")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 (autoload 'compile-reinitialize-errors "compile")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;; For the byte-compiler
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 (defvar compilation-error-list)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 ;;; Utilities
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21 (defun dired-mark-these-files (file-list from)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;; Mark the files in FILE-LIST. Relative filenames are taken to be
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;; in the current dired directory.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 ;; FROM is a string (used for logging) describing where FILE-LIST
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25 ;; came from.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;; Logs files that were not found and displays a success or failure
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 ;; message.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28 (message "Marking files %s..." from)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (let ((total (length file-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 (cur-dir (dired-current-directory))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 file failures)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 (while file-list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 (setq file (expand-file-name (car file-list) cur-dir)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 file-list (cdr file-list))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 ;;(message "Marking file `%s'" file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 (if (dired-goto-file file)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38 (dired-mark 1) ; supplying a prefix keeps it from checking
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 ; for a subdir.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 (setq failures (cons (dired-make-relative file) failures))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 (dired-log (buffer-name (current-buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 "Cannot mark this file (not found): %s\n" file))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 (dired-update-mode-line-modified t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 (if failures
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 (dired-log-summary
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 (buffer-name (current-buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 (format "Failed to mark %d of %d files %s %s"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 (length failures) total from failures) failures)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 (message "Marked %d file%s %s." total (dired-plural-s total) from))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 ;;; User commands
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 (defun dired-mark-files-from-other-dired-buffer (buf)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 "Mark files that are marked in the other Dired buffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 I.e, mark those files in this Dired buffer that have the same
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 non-directory part as the marked files in the Dired buffer in the other
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 window."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 (interactive (list (window-buffer (next-window))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59 (if (eq (get-buffer buf) (current-buffer))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60 (error "Other dired buffer is the same"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (or (stringp buf) (setq buf (buffer-name buf)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 (let ((other-files (save-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 (set-buffer buf)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 (or (eq major-mode 'dired-mode)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 (error "%s is not a dired buffer" buf))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 (dired-get-marked-files 'no-dir))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67 (dired-mark-these-files other-files (concat "from buffer " buf))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 (defun dired-mark-files-compilation-buffer (&optional buf)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 "Mark the files mentioned in the `*compilation*' buffer.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 With a prefix, you may specify the other buffer."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 (interactive
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 (list
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74 (let ((buff (let ((owin (selected-window))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 found)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76 (unwind-protect
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (other-window 1)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 (while (null (or found (eq (selected-window) owin)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
80 (if (compilation-buffer-p
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81 (window-buffer (selected-window)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 (setq found (current-buffer)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (other-window 1)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (select-window owin))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85 found)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 (if (or current-prefix-arg (null buff))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87 (let ((minibuffer-history
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 (delq nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 (mapcar
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (function
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (lambda (b)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (and (compilation-buffer-p b) (buffer-name b))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (buffer-list)))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (read-buffer "Use buffer: "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (or buff (car minibuffer-history))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 buff))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 (let ((dired-dir (directory-file-name default-directory))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 files)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (save-window-excursion
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (set-buffer buf)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (compile-reinitialize-errors nil (point-max))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 (let ((alist compilation-error-list)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 f d elt)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 (while alist
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 (setq elt (car alist)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 alist (cdr alist))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (and (consp (setq elt (car (cdr elt))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (stringp (setq d (car elt)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (stringp (setq f (cdr elt)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 (setq d (expand-file-name d))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 (dired-in-this-tree d dired-dir))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (progn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (setq f (expand-file-name f d))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (not (member f files)))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (setq files (cons f files))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 (dired-mark-these-files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 files
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 (concat "From compilation buffer "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 (if (stringp buf) buf (buffer-name buf))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 ;;; end of dired-mob.el