Changes
[emacs.git] / .emacs.d / elisp / local / dired+.el
1 ;;; dired+.el --- Extensions to Dired.
2 ;;
3 ;; Filename: dired+.el
4 ;; Description: Extensions to Dired.
5 ;; Author: Drew Adams
6 ;; Maintainer: Drew Adams (concat "drew.adams" "@" "oracle" ".com")
7 ;; Copyright (C) 1999-2018, Drew Adams, all rights reserved.
8 ;; Created: Fri Mar 19 15:58:58 1999
9 ;; Version: 2017.10.23
10 ;; Package-Requires: ()
11 ;; Last-Updated: Wed Jan 3 09:41:27 2018 (-0800)
12 ;; By: dradams
13 ;; Update #: 10621
14 ;; URL: https://www.emacswiki.org/emacs/download/dired%2b.el
15 ;; Doc URL: https://www.emacswiki.org/emacs/DiredPlus
16 ;; Keywords: unix, mouse, directories, diredp, dired
17 ;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x, 26.x
18 ;;
19 ;; Features that might be required by this library:
20 ;;
21 ;; `apropos', `apropos+', `autofit-frame', `avoid', `bookmark',
22 ;; `bookmark+', `bookmark+-1', `bookmark+-bmu', `bookmark+-key',
23 ;; `bookmark+-lit', `dired', `dired+', `dired-aux', `dired-x',
24 ;; `easymenu', `ffap', `fit-frame', `frame-fns', `help+20',
25 ;; `highlight', `image-dired', `image-file', `info', `info+20',
26 ;; `kmacro', `menu-bar', `menu-bar+', `misc-cmds', `misc-fns',
27 ;; `naked', `pp', `pp+', `second-sel', `strings', `subr-21',
28 ;; `thingatpt', `thingatpt+', `unaccent', `w32-browser',
29 ;; `w32browser-dlgopen', `wid-edit', `wid-edit+', `widget'.
30 ;;
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32 ;;
33 ;;; Commentary:
34 ;;
35 ;; Extensions to Dired.
36 ;;
37 ;; This file extends functionalities provided by standard GNU Emacs
38 ;; files `dired.el', `dired-aux.el', and `dired-x.el'.
39 ;;
40 ;; Key bindings changed. Menus redefined. `diredp-mouse-3-menu'
41 ;; popup menu added. New commands. Some commands enhanced.
42 ;;
43 ;; All of the new functions, variables, and faces defined here have
44 ;; the prefix `diredp-' (for Dired Plus) in their names.
45 ;;
46 ;;
47 ;; Wraparound Navigation
48 ;; ---------------------
49 ;;
50 ;; In vanilla Dired, `dired-next-marked-file' (`M-}' or `* C-n') and
51 ;; `dired-previous-marked-file' (`M-{' or `* C-p') wrap around when
52 ;; you get to the end or the beginning of the Dired buffer. Handy.
53 ;;
54 ;; But the other navigation commands do not wrap around. In `Dired+'
55 ;; they do, provided option `diredp-wrap-around-flag' is non-nil,
56 ;; which it is by default. This means the following commands:
57 ;;
58 ;; `diredp-next-line' - `n', `C-n', `down', `SPC'
59 ;; `diredp-previous-line' - `p', `C-p', `up'
60 ;; `diredp-next-dirline' - `>'
61 ;; `diredp-prev-dirline' - `<'
62 ;; `diredp-next-subdir' - `C-M-n'
63 ;; `diredp-prev-subdir' - `C-M-p'
64 ;;
65 ;;
66 ;; Font-Lock Highlighting
67 ;; ----------------------
68 ;;
69 ;; If you want a maximum or minimum fontification for Dired mode,
70 ;; then customize option `font-lock-maximum-decoration'. If you want
71 ;; a different fontification level for Dired than for other modes,
72 ;; you can do this too by customizing
73 ;; `font-lock-maximize-decoration'.
74 ;;
75 ;; A few of the user options defined here have an effect on
76 ;; font-locking, and this effect is established only when Dired+ is
77 ;; loaded, which defines the font-lock keywords for Dired. These
78 ;; options include `diredp-compressed-extensions',
79 ;; `diredp-ignore-compressed-flag', and `dired-omit-extensions'.
80 ;; This means that if you change the value of such an option then you
81 ;; will see the change only in a new Emacs session.
82 ;;
83 ;; (You can see the effect in the same session if you use `C-M-x' on
84 ;; the `defvar' sexp for `diredp-font-lock-keywords-1', and then you
85 ;; toggle font-lock off and back on.)
86 ;;
87 ;;
88 ;; Act on All Files
89 ;; ----------------
90 ;;
91 ;; Most of the commands (such as `C' and `M-g') that operate on the
92 ;; marked files have the added feature here that multiple `C-u' use
93 ;; not the files that are marked or the next or previous N files, but
94 ;; *all* of the files in the Dired buffer. Just what "all" files
95 ;; means changes with the number of `C-u', as follows:
96 ;;
97 ;; `C-u C-u' - Use all files present, but no directories.
98 ;; `C-u C-u C-u' - Use all files and dirs except `.' and `..'.
99 ;; `C-u C-u C-u C-u' - use all files and dirs, `.' and `..'.
100 ;;
101 ;; (More than four `C-u' act the same as two.)
102 ;;
103 ;; This feature can be particularly useful when you have a Dired
104 ;; buffer with files chosen from multiple directories.
105 ;;
106 ;; Note that in most cases this behavior is described only in the doc
107 ;; string of function `dired-get-marked-files'. It is generally
108 ;; *not* described in the doc strings of the various commands,
109 ;; because that would require redefining each command separately
110 ;; here. Instead, we redefine macro `dired-map-over-marks' and
111 ;; function `dired-get-filename' in order to achieve this effect.
112 ;;
113 ;; Commands such as `dired-do-load' for which it does not make sense
114 ;; to act on directories generally treat more than two `C-u' the same
115 ;; as two `C-u'.
116 ;;
117 ;; Exceptions to the general behavior described here are called out
118 ;; in the doc strings. In particular, the behavior of a prefix arg
119 ;; for `dired-do-query-replace-regexp' is different, so that you can
120 ;; use it also to specify word-delimited replacement.
121 ;;
122 ;;
123 ;; Act on Marked (or All) Files Here and Below
124 ;; -------------------------------------------
125 ;;
126 ;; The prefix argument behavior just described does not apply to the
127 ;; `diredp-*-recursive' commands. These commands act on the marked
128 ;; files in the current Dired buffer or on all files in the directory
129 ;; if none are marked.
130 ;;
131 ;; But these commands also handle marked subdirectories recursively,
132 ;; in the same way. That is, they act also on the marked files in
133 ;; any marked subdirectories, found recursively. If such a
134 ;; descendant directory is listed in a Dired buffer then its marked
135 ;; files and subdirs are handled the same way. If there is no Dired
136 ;; buffer that lists a given marked subdirectory then all of its
137 ;; files and subdirs are acted on.
138 ;;
139 ;; For most such here-and-below commands, a prefix argument means
140 ;; ignore all marks. The commands then act on all files in the
141 ;; current Dired buffer and all of its subdirectories, recursively.
142 ;;
143 ;; But here-and-below commands that unmark or change marks act
144 ;; differently for different kinds of prefix argument:
145 ;;
146 ;; * A non-positive prefix arg means ignore subdir markings and act
147 ;; instead on ALL subdirs.
148 ;;
149 ;; * A non-negative prefix arg means do not change marks on subdirs
150 ;; themselves.
151 ;;
152 ;; For example, `M-+ U' removes all marks, including from marked
153 ;; subdirs, recursively. `C-- M-+ U' removes them from all files in
154 ;; all subdirs (marked or not), recursively. `C-9 M-+ U' removes all
155 ;; marks, recursively, except the marks on subdirs themselves. `C-0
156 ;; M-+ U' acts like those two combined: it descends everywhere,
157 ;; ignoring which subdirs are marked, but it does not remove marks
158 ;; from subdirs themselves.
159 ;;
160 ;; All of the `diredp-*-recursive' commands are on prefix key `M-+',
161 ;; and all are available on submenu `Marked Here and Below' of the
162 ;; `Multiple' menu-bar menu. The commands that unmark and change
163 ;; marks are also in submenu `Here and Below' of menu-bar menu
164 ;; `Marks'.
165 ;;
166 ;; If you use library `Icicles' then you have the following
167 ;; additional commands/keys that act recursively on marked files.
168 ;; They are in the `Icicles' submenu of menu `Multiple' > `Marked
169 ;; Here and Below'.
170 ;;
171 ;; * `M-+ M-s M-s' or `M-s M-s m' - Use Icicles search (and its
172 ;; on-demand replace) on the marked files.
173 ;;
174 ;; * Save the names of the marked files:
175 ;;
176 ;; `M-+ C-M->' - Save as a completion set, for use during
177 ;; completion (e.g. with `C-x C-f').
178 ;;
179 ;; `M-+ C->' - Add marked names to the names in the current saved
180 ;; completion set.
181 ;;
182 ;; `M-+ C-}' - Save persistently to an Icicles cache file, for
183 ;; use during completion in another session.
184 ;;
185 ;; `icicle-dired-save-marked-to-fileset-recursive' - Like `M-+
186 ;; C-}', but save persistently to an Emacs fileset.
187 ;;
188 ;; `M-+ C-M-}' - Save to a Lisp variable.
189 ;;
190 ;;
191 ;; In the other direction, if you have a saved set of file names then
192 ;; you can use `C-M-<' (`icicle-dired-chosen-files-other-window') in
193 ;; Dired to open a Dired buffer for just those files. So you can
194 ;; mark some files and subdirs in a hierarchy of Dired buffers, use
195 ;; `M-+ C-}' to save their names persistently, then later use `C-{'
196 ;; to retrieve them, and `C-M-<' (in Dired) to open Dired on them.
197 ;;
198 ;;
199 ;; Image Files
200 ;; -----------
201 ;;
202 ;; `Dired+' provides several enhancements regarding image files.
203 ;; Most of these require standard library `image-dired.el'. One of
204 ;; them, command `diredp-do-display-images', which displays all of
205 ;; the marked image files, requires standard library `image-file.el'.
206 ;;
207 ;; `Dired+' loads these libraries automatically, if available, which
208 ;; means an Emacs version that supports image display (Emacs 22 or
209 ;; later). (You must of course have installed whatever else your
210 ;; Emacs version needs to display images.)
211 ;;
212 ;; Besides command `diredp-do-display-images', see the commands whose
213 ;; names have prefix `diredp-image-'. And see options
214 ;; `diredp-image-preview-in-tooltip' and
215 ;; `diredp-auto-focus-frame-for-thumbnail-tooltip-flag'.
216 ;;
217 ;;
218 ;; Inserted Subdirs, Multiple Dired Buffers, Files from Anywhere,...
219 ;; -----------------------------------------------------------------
220 ;;
221 ;; These three standard Dired features are worth pointing out. The
222 ;; third in particular is little known because (a) it is limited in
223 ;; vanilla Dired and (b) you cannot use it interactively.
224 ;;
225 ;; * You can pass a glob pattern with wildcards to `dired'
226 ;; interactively, as the file name.
227 ;;
228 ;; * You can insert multiple subdirectory listings into a single
229 ;; Dired buffer using `i' on each subdir line. Use `C-u i' to
230 ;; specify `ls' switches. Specifying switch `R' inserts the
231 ;; inserted subdirectory's subdirs also, recursively. You can
232 ;; also use `i' to bounce between a subdirectory line and its
233 ;; inserted-listing header line. You can delete a subdir listing
234 ;; using `C-u k' on its header line. You can hide/show an
235 ;; inserted subdir using `$'. You can use `C-_' to undo any of
236 ;; these operations.
237 ;;
238 ;; * You can open a Dired buffer for an arbitrary set of files from
239 ;; different directories. You do this by invoking `dired'
240 ;; non-interactively, passing it a cons of a Dired buffer name and
241 ;; the file names. Relative file names are interpreted relative
242 ;; to the value of `default-directory'. Use absolute file names
243 ;; when appropriate.
244 ;;
245 ;; `Dired+' makes these features more useful.
246 ;;
247 ;; `$' is improved: It is a simple toggle - it does not move the
248 ;; cursor forward. `M-$' advances the cursor, in addition to
249 ;; toggling like `$'. `C-u $' does hide/show all (what `M-$' does in
250 ;; vanilla Dired).
251 ;;
252 ;; `i' is improved in these ways:
253 ;;
254 ;; * Once a subdir has been inserted, `i' bounces between the subdir
255 ;; listing and the subdir line in the parent listing. If the
256 ;; parent dir is hidden, then `i' from a subdir opens the parent
257 ;; listing so it can move to the subdir line there (Emacs 24+).
258 ;;
259 ;; * Vanilla Dired lets you create a Dired listing with files and
260 ;; directories from arbitrary locations, but you cannot insert
261 ;; (`i') such a directory if it is not in the same directory tree
262 ;; as the `default-directory' used to create the Dired buffer.
263 ;; `Dired+' removes this limitation; you can insert any non-root
264 ;; directories (that is, not `/', `c:/', etc.).
265 ;;
266 ;; `Dired+' lets you create Dired buffers that contain arbitrary
267 ;; files and directories interactively, not just using Lisp. Just
268 ;; use a non-positive prefix arg (e.g., `C--') when invoking `dired'.
269 ;;
270 ;; You are then prompted for the Dired buffer name (anything you
271 ;; like, not necessarily a directory name) and the individual files
272 ;; and directories that you want listed.
273 ;;
274 ;; A non-negative prefix arg still prompts you for the `ls' switches
275 ;; to use. (So `C-0' does both: prompts for `ls' switches and for
276 ;; the Dired buffer name and the files to list.)
277 ;;
278 ;; `Dired+' adds commands for combining and augmenting Dired
279 ;; listings:
280 ;;
281 ;; * `diredp-add-to-dired-buffer', bound globally to `C-x D A', lets
282 ;; you add arbitrary file and directory names to an existing Dired
283 ;; buffer.
284 ;;
285 ;; * `diredp-dired-union', bound globally to `C-x D U', lets you
286 ;; take the union of multiple Dired listings, or convert an
287 ;; ordinary Dired listing to an explicit list of absolute file
288 ;; names. With a non-positive prefix arg, you can add extra file
289 ;; and directory names, just as for `diredp-add-to-dired-buffer'.
290 ;;
291 ;; You can optionally add a header line to a Dired buffer using
292 ;; toggle command `diredp-breadcrumbs-in-header-line-mode'. (A
293 ;; header line remains at the top of the window - no need to scroll
294 ;; to see it.) If you want to show the header line automatically in
295 ;; all Dired buffers, you can do this:
296 ;;
297 ;; (add-hook 'dired-before-readin-hook
298 ;; 'diredp-breadcrumbs-in-header-line-mode)
299 ;;
300 ;; Some other libraries, such as `Bookmark+' and `Icicles', make it
301 ;; easy to create or re-create Dired buffers that list specific files
302 ;; and have a particular set of markings. `Bookmark+' records Dired
303 ;; buffers persistently, remembering `ls' switches, markings, subdir
304 ;; insertions, and hidden subdirs. If you use `Icicles' then `dired'
305 ;; is a multi-command: you can open multiple Dired buffers with one
306 ;; `dired' invocation.
307 ;;
308 ;; Dired can help you manage projects. You might have multiple Dired
309 ;; buffers with quite specific contents. You might have some
310 ;; subdirectories inserted in the same Dired buffer, and you might
311 ;; have separate Dired buffers for some subdirectories. Sometimes it
312 ;; is useful to have both for the same subdirectory. And sometimes
313 ;; it is useful to move from one presentation to the other.
314 ;;
315 ;; This is one motivation for the `Dired+' `diredp-*-recursive'
316 ;; commands, which act on the marked files in marked subdirectories,
317 ;; recursively. In one sense, these commands are an alternative to
318 ;; using a single Dired buffer with inserted subdirectories. They
319 ;; let you use the same operations on the files in a set of Dired
320 ;; directories, without inserting those directories into an ancestor
321 ;; Dired buffer.
322 ;;
323 ;; You can use command `diredp-dired-inserted-subdirs' to open a
324 ;; separate Dired buffer for each of the subdirs that is inserted in
325 ;; the current Dired buffer. Markings and Dired switches are
326 ;; preserved.
327 ;;
328 ;; In the opposite direction, if you use `Icicles' then you can use
329 ;; multi-command `icicle-dired-insert-as-subdir', which lets you
330 ;; insert any number of directories you choose interactively into a
331 ;; Dired ancestor directory listing. If a directory you choose to
332 ;; insert already has its own Dired buffer, then its markings and
333 ;; switches are preserved for the new, subdirectory listing in the
334 ;; ancestor Dired buffer.
335 ;;
336 ;;
337 ;; Hide/Show Details
338 ;; -----------------
339 ;;
340 ;; Starting with Emacs 24.4, listing details are hidden by default.
341 ;; Note that this is different from the vanilla Emacs behavior, which
342 ;; is to show details by default.
343 ;;
344 ;; Use `(' anytime to toggle this hiding. You can use option
345 ;; `diredp-hide-details-initially-flag' to change the default/initial
346 ;; state. See also option `diredp-hide-details-propagate-flag'.
347 ;;
348 ;; NOTE: If you do not want to hide details initially then you must
349 ;; either (1) change `diredp-hide-details-initially-flag' using
350 ;; Customize (recommended) or (2) set it to `nil' (e.g., using
351 ;; `setq') *BEFORE* loading `dired+.el'.
352 ;;
353 ;; If you have an Emacs version older than 24.4, you can use library
354 ;; `dired-details+.el' (plus `dired-details.el') to get similar
355 ;; behavior.
356 ;;
357 ;;
358 ;; Mode-Line
359 ;; ---------
360 ;;
361 ;; The number of files and dirs that are marked with `*', and the
362 ;; number that are flagged for deletion (marked `D') are indicated in
363 ;; the mode-line. When the cursor is on such a line the indication
364 ;; tells you how many more there are. For example, if the cursor is
365 ;; on the line of the third file that is marked `*', and there are
366 ;; seven of them total, then the mode-line shows `3/7*'.
367 ;;
368 ;; The mode-line also indicates, for the current listing (which could
369 ;; be a subdir listing), how many files and dirs are listed. If the
370 ;; cursor is on the 27th file in a listing of 78 files then the
371 ;; mode-line shows 27/78.
372 ;;
373 ;; For counting files and dirs in a listing, option
374 ;; `diredp-count-.-and-..-flag' controls whether to count the lines
375 ;; for `.' and `..'. By default it is nil, meaning they are not
376 ;; counted.
377 ;;
378 ;;
379 ;; If You Use Dired+ in Terminal Mode
380 ;; ----------------------------------
381 ;;
382 ;; By default, Dired+ binds some keys that can be problematic in some
383 ;; terminals when you use Emacs in terminal mode (i.e., `emacs -nw').
384 ;; This is controlled by option
385 ;; `diredp-bind-problematic-terminal-keys'.
386 ;;
387 ;; In particular, keys that use modifiers Meta and Shift together can
388 ;; be problematic. If you use Dired+ in text-only terminal, and you
389 ;; find that your terminal does not support such keys, then you might
390 ;; want to customize the option to set the value to `nil', and then
391 ;; bind the commands to some other keys, which your terminal
392 ;; supports.
393 ;;
394 ;; The problematic keys used by Dired+ include these:
395 ;;
396 ;; `M-M' (aka `M-S-m') - `diredp-chmod-this-file'
397 ;; `M-O' (aka `M-S-o') - `diredp-chown-this-file'
398 ;; `M-T' (aka `M-S-t') - `diredp-touch-this-file'
399 ;; `C-M-B' (aka `C-M-S-b') - `diredp-do-bookmark-in-bookmark-file'
400 ;; `C-M-G' (aka `C-M-S-g') - `diredp-chgrp-this-file'
401 ;; `C-M-R' (aka `C-M-S-r') - `diredp-toggle-find-file-reuse-dir'
402 ;; `C-M-T' (aka `C-M-S-t') - `dired-do-touch'
403 ;; `M-+ M-B' (aka `M-+ M-S-b') -
404 ;; `diredp-do-bookmark-dirs-recursive'
405 ;; `M-+ C-M-B' (aka `M-+ C-M-S-b') -
406 ;; `diredp-do-bookmark-in-bookmark-file-recursive'
407 ;; `M-+ C-M-T' (aka `M-+ C-M-S-t') - `diredp-do-touch-recursive'
408 ;;
409 ;; (See also `(info "(org) TTY keys")' for more information about
410 ;; keys that can be problematic in a text-only terminal.)
411 ;;
412 ;;
413 ;; Faces defined here:
414 ;;
415 ;; `diredp-autofile-name', `diredp-compressed-file-suffix',
416 ;; `diredp-date-time', `diredp-deletion',
417 ;; `diredp-deletion-file-name', `diredp-dir-heading',
418 ;; `diredp-dir-priv', `diredp-exec-priv', `diredp-executable-tag',
419 ;; `diredp-file-name', `diredp-file-suffix', `diredp-flag-mark',
420 ;; `diredp-flag-mark-line', `diredp-get-file-or-dir-name',
421 ;; `diredp-ignored-file-name', `diredp-link-priv',
422 ;; `diredp-mode-line-flagged', `diredp-mode-line-marked'
423 ;; `diredp-no-priv', `diredp-number', `diredp-other-priv',
424 ;; `diredp-rare-priv', `diredp-read-priv', `diredp-symlink',
425 ;; `diredp-tagged-autofile-name', `diredp-write-priv'.
426 ;;
427 ;; Commands defined here:
428 ;;
429 ;; `diredp-add-to-dired-buffer', `diredp-add-to-this-dired-buffer',
430 ;; `diredp-do-apply-function',
431 ;; `diredp-do-apply-function-recursive',
432 ;; `diredp-async-shell-command-this-file',
433 ;; `diredp-bookmark-this-file',
434 ;; `diredp-breadcrumbs-in-header-line-mode' (Emacs 22+),
435 ;; `diredp-byte-compile-this-file', `diredp-capitalize',
436 ;; `diredp-capitalize-recursive', `diredp-capitalize-this-file',
437 ;; `diredp-change-marks-recursive' (Emacs 22+),
438 ;; `diredp-chgrp-this-file', `diredp-chmod-this-file',
439 ;; `diredp-chown-this-file',
440 ;; `diredp-compilation-files-other-window' (Emacs 24+),
441 ;; `diredp-compress-this-file',
442 ;; `diredp-copy-filename-as-kill-recursive',
443 ;; `diredp-copy-tags-this-file', `diredp-copy-this-file',
444 ;; `diredp-decrypt-this-file', `diredp-delete-this-file',
445 ;; `diredp-describe-autofile', `diredp-describe-file',
446 ;; `diredp-describe-marked-autofiles', `diredp-describe-mode',
447 ;; `diredp-dired-for-files', `diredp-dired-for-files-other-window',
448 ;; `diredp-dired-inserted-subdirs', `diredp-dired-plus-help',
449 ;; `diredp-dired-recent-dirs',
450 ;; `diredp-dired-recent-dirs-other-window',
451 ;; `diredp-dired-this-subdir', `diredp-dired-union',
452 ;; `diredp-do-async-shell-command-recursive', `diredp-do-bookmark',
453 ;; `diredp-do-bookmark-dirs-recursive',
454 ;; `diredp-do-bookmark-in-bookmark-file',
455 ;; `diredp-do-bookmark-in-bookmark-file-recursive',
456 ;; `diredp-do-bookmark-recursive', `diredp-do-chmod-recursive',
457 ;; `diredp-do-chgrp-recursive', `diredp-do-chown-recursive',
458 ;; `diredp-do-copy-recursive', `diredp-do-decrypt-recursive',
459 ;; `diredp-do-delete-recursive', `diredp-do-display-images' (Emacs
460 ;; 22+), `diredp-do-encrypt-recursive',
461 ;; `diredp-do-find-marked-files-recursive', `diredp-do-grep',
462 ;; `diredp-do-grep-recursive', `diredp-do-hardlink-recursive',
463 ;; `diredp-do-isearch-recursive',
464 ;; `diredp-do-isearch-regexp-recursive',
465 ;; `diredp-do-move-recursive', `diredp-do-paste-add-tags',
466 ;; `diredp-do-paste-replace-tags', `diredp-do-print-recursive',
467 ;; `diredp-do-query-replace-regexp-recursive',
468 ;; `diredp-do-redisplay-recursive',
469 ;; `diredp-do-relsymlink-recursive', `diredp-do-remove-all-tags',
470 ;; `diredp-do-search-recursive', `diredp-do-set-tag-value',
471 ;; `diredp-do-shell-command-recursive', `diredp-do-sign-recursive',
472 ;; `diredp-do-symlink-recursive', `diredp-do-tag',
473 ;; `diredp-do-touch-recursive', `diredp-do-untag',
474 ;; `diredp-do-verify-recursive', `diredp-downcase-recursive',
475 ;; `diredp-downcase-this-file', `diredp-ediff',
476 ;; `diredp-encrypt-this-file', `diredp-fileset',
477 ;; `diredp-fileset-other-window', `diredp-find-a-file',
478 ;; `diredp-find-a-file-other-frame',
479 ;; `diredp-find-a-file-other-window',
480 ;; `diredp-find-file-other-frame',
481 ;; `diredp-find-file-reuse-dir-buffer',
482 ;; `diredp-find-line-file-other-window',
483 ;; `diredp-flag-auto-save-files-recursive',
484 ;; `diredp-flag-region-files-for-deletion',
485 ;; `diredp-grepped-files-other-window', `diredp-grep-this-file',
486 ;; `diredp-hardlink-this-file', `diredp-highlight-autofiles-mode',
487 ;; `diredp-image-dired-comment-file',
488 ;; `diredp-image-dired-comment-files-recursive',
489 ;; `diredp-image-dired-copy-with-exif-name',
490 ;; `diredp-image-dired-create-thumb',
491 ;; `diredp-image-dired-delete-tag',
492 ;; `diredp-image-dired-delete-tag-recursive',
493 ;; `diredp-image-dired-display-thumb',
494 ;; `diredp-image-dired-display-thumbs-recursive',
495 ;; `diredp-image-dired-edit-comment-and-tags',
496 ;; `diredp-image-dired-tag-file',
497 ;; `diredp-image-dired-tag-files-recursive',
498 ;; `diredp-image-show-this-file', `diredp-insert-as-subdir',
499 ;; `diredp-insert-subdirs', `diredp-insert-subdirs-recursive',
500 ;; `diredp-kill-this-tree', `diredp-list-marked-recursive',
501 ;; `diredp-load-this-file', `diredp-mark-autofiles',
502 ;; `diredp-marked', `diredp-marked-other-window',
503 ;; `diredp-marked-recursive',
504 ;; `diredp-marked-recursive-other-window',
505 ;; `diredp-mark-extension-recursive',
506 ;; `diredp-mark-files-regexp-recursive',
507 ;; `diredp-mark-files-tagged-all', `diredp-mark-files-tagged-none',
508 ;; `diredp-mark-files-tagged-not-all',
509 ;; `diredp-mark-files-tagged-some',
510 ;; `diredp-mark-files-tagged-regexp', `diredp-mark-region-files',
511 ;; `diredp-mark/unmark-autofiles', `diredp-mark/unmark-extension',
512 ;; `diredp-mouse-3-menu', `diredp-mouse-backup-diff',
513 ;; `diredp-mouse-copy-tags', `diredp-mouse-describe-autofile',
514 ;; `diredp-mouse-describe-file', `diredp-mouse-diff',
515 ;; `diredp-mouse-do-bookmark', `diredp-mouse-do-byte-compile',
516 ;; `diredp-mouse-do-chgrp', `diredp-mouse-do-chmod',
517 ;; `diredp-mouse-do-chown', `diredp-mouse-do-compress',
518 ;; `diredp-mouse-do-copy', `diredp-mouse-do-delete',
519 ;; `diredp-mouse-do-grep', `diredp-mouse-do-hardlink',
520 ;; `diredp-mouse-do-load', `diredp-mouse-do-print',
521 ;; `diredp-mouse-do-remove-all-tags', `diredp-mouse-do-rename',
522 ;; `diredp-mouse-do-set-tag-value',
523 ;; `diredp-mouse-do-shell-command', `diredp-mouse-do-symlink',
524 ;; `diredp-mouse-do-tag', `diredp-mouse-do-untag',
525 ;; `diredp-mouse-downcase', `diredp-mouse-ediff',
526 ;; `diredp-mouse-find-line-file-other-window',
527 ;; `diredp-mouse-find-file-other-frame',
528 ;; `diredp-mouse-find-file-reuse-dir-buffer',
529 ;; `diredp-mouse-flag-file-deletion', `diredp-mouse-mark',
530 ;; `diredp-mouse-mark-region-files', `diredp-mouse-mark/unmark',
531 ;; `diredp-mouse-unmark', `diredp-mouse-upcase',
532 ;; `diredp-mouse-view-file',
533 ;; `diredp-multiple-w32-browser-recursive',
534 ;; `diredp-nb-marked-in-mode-name', `diredp-next-dirline',
535 ;; `diredp-next-line', `diredp-next-subdir', `diredp-omit-marked',
536 ;; `diredp-omit-unmarked', `diredp-paste-add-tags-this-file',
537 ;; `diredp-paste-replace-tags-this-file', `diredp-prev-dirline',
538 ;; `diredp-previous-line', `diredp-prev-subdir',
539 ;; `diredp-print-this-file', `diredp-relsymlink-this-file',
540 ;; `diredp-remove-all-tags-this-file', `diredp-rename-this-file',
541 ;; `diredp-send-bug-report',
542 ;; `diredp-set-bookmark-file-bookmark-for-marked',
543 ;; `diredp-set-bookmark-file-bookmark-for-marked-recursive',
544 ;; `diredp-set-tag-value-this-file',
545 ;; `diredp-shell-command-this-file', `diredp-show-metadata',
546 ;; `diredp-show-metadata-for-marked', `diredp-sign-this-file',
547 ;; `diredp-symlink-this-file', `diredp-tag-this-file',
548 ;; `diredp-toggle-find-file-reuse-dir',
549 ;; `diredp-toggle-marks-in-region', `diredp-touch-this-file',
550 ;; `diredp-unmark-all-files-recursive' (Emacs 22+),
551 ;; `diredp-unmark-all-marks-recursive' (Emacs 22+),
552 ;; `diredp-unmark-autofiles', `diredp-unmark-files-tagged-all',
553 ;; `diredp-unmark-files-tagged-none',
554 ;; `diredp-unmark-files-tagged-not-all',
555 ;; `diredp-unmark-files-tagged-some', `diredp-unmark-region-files',
556 ;; `diredp-untag-this-file', `diredp-upcase-recursive',
557 ;; `diredp-up-directory', `diredp-up-directory-reuse-dir-buffer',
558 ;; `diredp-upcase-this-file', `diredp-verify-this-file',
559 ;; `diredp-w32-drives', `diredp-w32-drives-mode',
560 ;; `global-dired-hide-details-mode' (Emacs 24.4+),
561 ;; `toggle-diredp-find-file-reuse-dir'.
562 ;;
563 ;; User options defined here:
564 ;;
565 ;; `diredp-auto-focus-frame-for-thumbnail-tooltip-flag',
566 ;; `diredp-bind-problematic-terminal-keys',
567 ;; `diredp-compressed-extensions', `diredp-count-.-and-..-flag'
568 ;; (Emacs 22+), `diredp-dwim-any-frame-flag' (Emacs 22+),
569 ;; `diredp-image-preview-in-tooltip', `diff-switches',
570 ;; `diredp-hide-details-initially-flag' (Emacs 24.4+),
571 ;; `diredp-highlight-autofiles-mode',
572 ;; `diredp-hide-details-propagate-flag' (Emacs 24.4+),
573 ;; `diredp-ignore-compressed-flag',
574 ;; `diredp-image-show-this-file-use-frame-flag' (Emacs 22+),
575 ;; `diredp-max-frames', `diredp-prompt-for-bookmark-prefix-flag',
576 ;; `diredp-w32-local-drives', `diredp-wrap-around-flag'.
577 ;;
578 ;; Non-interactive functions defined here:
579 ;;
580 ;; `derived-mode-p' (Emacs < 22), `diredp-all-files',
581 ;; `diredp-ancestor-dirs', `diredp-bookmark',
582 ;; `diredp-create-files-non-directory-recursive',
583 ;; `diredp-delete-dups', `diredp-directories-within',
584 ;; `diredp-dired-plus-description',
585 ;; `diredp-dired-plus-description+links',
586 ;; `diredp-dired-plus-help-link', `diredp-dired-union-1',
587 ;; `diredp-dired-union-interactive-spec', `diredp-display-image'
588 ;; (Emacs 22+), `diredp-do-chxxx-recursive',
589 ;; `diredp-do-create-files-recursive', `diredp-do-grep-1',
590 ;; `diredp-ensure-bookmark+', `diredp-ensure-mode',
591 ;; `diredp-existing-dired-buffer-p', `diredp-fewer-than-2-files-p',
592 ;; `diredp-fileset-1', `diredp-find-a-file-read-args',
593 ;; `diredp-file-for-compilation-hit-at-point' (Emacs 24+),
594 ;; `diredp-files-within', `diredp-files-within-1',
595 ;; `diredp-fit-frame-unless-buffer-narrowed' (Emacs 24.4+),
596 ;; `diredp-get-confirmation-recursive', `diredp-get-files',
597 ;; `diredp-get-files-for-dir', `diredp-get-subdirs',
598 ;; `diredp-hide-details-if-dired' (Emacs 24.4+),
599 ;; `diredp-hide/show-details' (Emacs 24.4+),
600 ;; `diredp-highlight-autofiles', `diredp-image-dired-required-msg',
601 ;; `diredp-get-image-filename', `diredp-internal-do-deletions',
602 ;; `diredp-list-files', `diredp-looking-at-p',
603 ;; `diredp-make-find-file-keys-reuse-dirs',
604 ;; `diredp-make-find-file-keys-not-reuse-dirs', `diredp-maplist',
605 ;; `diredp-marked-here', `diredp-mark-files-tagged-all/none',
606 ;; `diredp-mark-files-tagged-some/not-all',
607 ;; `diredp-nonempty-region-p', `diredp-parent-dir',
608 ;; `diredp-paste-add-tags', `diredp-paste-replace-tags',
609 ;; `diredp-read-bookmark-file-args', `diredp-read-include/exclude',
610 ;; `diredp-read-regexp', `diredp-recent-dirs',
611 ;; `diredp-refontify-buffer', `diredp-remove-if',
612 ;; `diredp-remove-if-not', `diredp--reuse-dir-buffer-helper',
613 ;; `diredp-root-directory-p', `diredp-set-header-line-breadcrumbs'
614 ;; (Emacs 22+), `diredp-set-tag-value', `diredp-set-union',
615 ;; `diredp--set-up-font-locking', `diredp-string-match-p',
616 ;; `diredp-tag', `diredp-this-file-marked-p',
617 ;; `diredp-this-file-unmarked-p', `diredp-this-subdir',
618 ;; `diredp-untag', `diredp-y-or-n-files-p'.
619 ;;
620 ;; Variables defined here:
621 ;;
622 ;; `diredp-bookmark-menu', `diredp-file-line-overlay',
623 ;; `diredp-files-within-dirs-done', `diredp-font-lock-keywords-1',
624 ;; `diredp-hide-details-last-state' (Emacs 24.4+),
625 ;; `diredp-hide-details-toggled' (Emacs 24.4+),
626 ;; `diredp-hide/show-menu', `diredp-images-recursive-menu',
627 ;; `diredp-list-files-map', `diredp-loaded-p',
628 ;; `diredp-marks-recursive-menu', `diredp-menu-bar-dir-menu',
629 ;; `diredp-menu-bar-marks-menu', `diredp-menu-bar-multiple-menu',
630 ;; `diredp-menu-bar-regexp-menu', `diredp-menu-bar-single-menu',
631 ;; `diredp-multiple-bookmarks-menu', `diredp-multiple-delete-menu',
632 ;; `diredp-multiple-dired-menu', `diredp-multiple-images-menu',
633 ;; `diredp-multiple-encryption-menu',
634 ;; `diredp-multiple-move-copy-link-menu',
635 ;; `diredp-multiple-omit-menu', `diredp-multiple-recursive-menu',
636 ;; `diredp-multiple-rename-menu', `diredp-multiple-search-menu',
637 ;; `diredp-navigate-menu', `diredp-regexp-recursive-menu',
638 ;; `diredp-re-no-dot', `diredp-single-bookmarks-menu',
639 ;; `diredp-single-encryption-menu', `diredp-single-image-menu',
640 ;; `diredp-single-move-copy-link-menu', `diredp-single-open-menu',
641 ;; `diredp-single-rename-menu', `diredp-w32-drives-mode-map'.
642 ;;
643 ;; Macros defined here:
644 ;;
645 ;; `diredp-with-help-window'.
646 ;;
647 ;;
648 ;; ***** NOTE: The following macros defined in `dired.el' have
649 ;; been REDEFINED HERE:
650 ;;
651 ;; `dired-map-over-marks' - Treat multiple `C-u' specially.
652 ;; `dired-mark-if' - Better initial msg - Emacs bug #8523.
653 ;;
654 ;;
655 ;; ***** NOTE: The following functions defined in `dired.el' have
656 ;; been REDEFINED or ADVISED HERE:
657 ;;
658 ;; `dired' - Handle non-positive prefix arg.
659 ;; `dired-do-delete' - Display message to warn that marked,
660 ;; not flagged, files will be deleted.
661 ;; `dired-do-flagged-delete' - Display message to warn that flagged,
662 ;; not marked, files will be deleted.
663 ;; `dired-dwim-target-directory' - Uses `diredp-dwim-any-frame-flag'.
664 ;; `dired-find-file' - Allow `.' and `..' (Emacs 20 only).
665 ;; `dired-get-filename' - Test `./' and `../' (like `.', `..').
666 ;; `dired-goto-file' - Fix Emacs bug #7126.
667 ;; Remove `/' from dir before compare.
668 ;; (Emacs < 24 only.)
669 ;; `dired-hide-details-mode' - Respect new user options:
670 ;; * `diredp-hide-details-initially-flag'
671 ;; * `diredp-hide-details-propagate-flag'
672 ;; (Emacs 24.4+)
673 ;; `dired-insert-directory' - Compute WILDCARD arg for
674 ;; `insert-directory' for individual file
675 ;; (don't just use nil). (Emacs 23+, and
676 ;; only for MS Windows)
677 ;; `dired-insert-set-properties' - `mouse-face' on whole line.
678 ;; `dired-mark-files-regexp' - Add regexp to `regexp-search-ring'.
679 ;; More matching possibilities.
680 ;; Added optional arg LOCALP.
681 ;; `dired-mark-pop-up' - Delete the window or frame popped up,
682 ;; afterward, and bury its buffer. Do not
683 ;; show a menu bar for pop-up frame.
684 ;; `dired-other-frame' - Handle non-positive prefix arg.
685 ;; `dired-other-window' - Handle non-positive prefix arg.
686 ;; `dired-pop-to-buffer' - Put window point at bob (bug #12281).
687 ;; (Emacs 22-24.1)
688 ;; `dired-read-dir-and-switches' - Non-positive prefix arg behavior.
689 ;;
690 ;;; NOT YET:
691 ;;; ;; `dired-readin-insert' - Use t as WILDCARD arg to
692 ;;; ;; `dired-insert-directory'. (Emacs 23+,
693 ;;; ;; and only for MS Windows)
694 ;;
695 ;; `dired-revert' - Reset `mode-line-process' to nil.
696 ;; `dired-switches-escape-p' - Made compatible with Emacs 20, 21.
697 ;;
698 ;;
699 ;; ***** NOTE: The following functions are included here with little
700 ;; or no change to their definitions. They are here to
701 ;; take advantage of the new definition of macro
702 ;; `dired-map-over-marks':
703 ;;
704 ;; `dired-do-redisplay', `dired-get-marked-files',
705 ;; `dired-map-over-marks-check',
706 ;; `image-dired-dired-insert-marked-thumbs',
707 ;; `image-dired-dired-toggle-marked-thumbs'.
708 ;;
709 ;;
710 ;; ***** NOTE: The following functions defined in `dired-aux.el' have
711 ;; been REDEFINED HERE:
712 ;;
713 ;; `dired-do-byte-compile', `dired-do-compress', `dired-do-load' -
714 ;; Redisplay only if at most one file is being treated.
715 ;; `dired-do-isearch', `dired-do-isearch-regexp',
716 ;; `dired-do-query-replace-regexp', `dired-do-search' -
717 ;; Use new `dired-get-marked-files'.
718 ;; `dired-insert-subdir-newpos' - If not a descendent, put at eob.
719 ;; `dired-insert-subdir-validate' - Do nothing: no restrictions.
720 ;; `dired-maybe-insert-subdir' - Go back to subdir line if in listing.
721 ;;
722 ;;
723 ;; ***** NOTE: The following functions defined in `dired-x.el' have
724 ;; been REDEFINED HERE:
725 ;;
726 ;; `dired-do-find-marked-files' -
727 ;; Doc string reflects new `dired-simultaneous-find-file'.
728 ;; `dired-do-run-mail' - Require confirmation.
729 ;; `dired-mark-sexp' - 1. Variable `s' -> `blks'.
730 ;; 2. Fixes to `uid' and `gid'.
731 ;; `dired-mark-unmarked-files' (Emacs < 24 only) - Emacs 24+ version.
732 ;; `dired-simultaneous-find-file' -
733 ;; Use separate frames instead of windows if `pop-up-frames' is
734 ;; non-nil, or if prefix arg < 0.
735 ;;
736 ;; ***** NOTE: (Emacs 20 only) The following variable defined in
737 ;; `dired.el' has been REDEFINED HERE:
738 ;;
739 ;; `dired-move-to-filename-regexp' - Recognize file size in k etc.
740 ;;
741 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
742 ;;
743 ;;; Change Log:
744 ;;
745 ;; 2018/01/03 dadams
746 ;; dired-mark-files-regexp: Corrected doc string wrt prefix args. Thx to John Mastro.
747 ;; diredp-do-grep-recursive: Removed unused optional arg IGNORE-MARKS-P.
748 ;; diredp-marked-recursive(-other-window): Moved handling of optional arg from interactive spec to body.
749 ;; 2018/01/02 dadams
750 ;; Added: diredp-flag-auto-save-files-recursive. Bound to M-+ #.
751 ;; diredp-get-file-or-dir-name, diredp-marked-here: Doubled backslashes to escape dots.
752 ;; diredp-marked-here: Fixed regexp to match only double-dot, not single-dot.
753 ;; diredp-flag-auto-save-files-recursive: Updated to include more M-+ keys.
754 ;; diredp-marks-recursive-menu: Added diredp-flag-auto-save-files-recursive.
755 ;; 2017/12/31 dadams
756 ;; diredp-get-files-for-dir: Pass non-nil NO-DOT-DOT-P arg to diredp-marked-here.
757 ;; dired-get-marked-files: Allow use of FILTER and DISTINGUISH-ONE-MARKED together.
758 ;; diredp-marked-here: Added optional arg NO-DOT-DOT-P.
759 ;; diredp-change-marks-recursive, diredp-unmark-all-files-recursive: Removed unused vars include-dirs, files.
760 ;; 2017/12/30 dadams
761 ;; Added: diredp-change-marks-recursive, diredp-unmark-all-files-recursive, diredp-unmark-all-marks-recursive.
762 ;; Bound to M-+ * c, M-+ M-DEL, M-+ U, respectively.
763 ;; diredp-menu-bar-marks-menu: Rename item Change Marks to Change Mark.
764 ;; diredp-marks-recursive-menu, diredp-multiple-recursive-menu:
765 ;; Added diredp-change-marks-recursive, diredp-unmark-all-(files|marks)-recursive.
766 ;; 2017/12/21 dadams
767 ;; Added: diredp-mark-recursive-1. Forgot to add it last June.
768 ;; 2017/12/17 dadams
769 ;; Removed: diredp-display-graphic-p.
770 ;; Do not use diredp-display-graphic-p to allow binding diredp-bind-problematic-terminal-keys by default.
771 ;; 2017/11/25 dadams
772 ;; diredp-nb-marked-in-mode-name: Wrap last :eval sexp in save-excursion.
773 ;; Protect Call dired-current-directory only when dired-subdir-alist.
774 ;; 2017/10/23 dadams
775 ;; Added: diredp-count-.-and-..-flag, diredp--reuse-dir-buffer-helper.
776 ;; Removed: diredp-mouse-find-file.
777 ;; diredp-find-file-reuse-dir-buffer, diredp-mouse-find-file-reuse-dir-buffer,
778 ;; diredp-up-directory-reuse-dir-buffer:
779 ;; Use diredp--reuse-dir-buffer-helper.
780 ;; diredp-find-file-reuse-dir-buffer: Changed logic: do find-alternate-file only if target is a dir not in
781 ;; Dired and current Dired buffer is in only this window.
782 ;; diredp-mouse-find-file-reuse-dir-buffer: Added optional args FIND-FILE-FUNC and FIND-DIR-FUNC.
783 ;; diredp-up-directory, diredp-up-directory-reuse-dir-buffer: Pass OTHER-WINDOW arg to diredp-w32-drives.
784 ;; diredp-nb-marked-in-mode-name: Show also number of lines in current listing, and listing-relative lineno,
785 ;; respecting diredp-count-.-and-..-flag.
786 ;; diredp-find-a-file*: Added autoload cookies.
787 ;; 2017/08/18 dadams
788 ;; Fixed emacswiki URLs everywhere. They changed the locations and changed http to https.
789 ;; 2017/06/30 dadams
790 ;; Added: diredp-bind-problematic-terminal-keys, diredp-display-graphic-p.
791 ;; Guard bindings of problematic keys with diredp-display-graphic-p & diredp-bind-problematic-terminal-keys.
792 ;; Documented problematic keys for terminal mode in commentary.
793 ;; 2017/06/23 dadams
794 ;; Added: diredp-read-regexp (removed alias to read-regexp), diredp-marks-recursive-menu,
795 ;; diredp-mark-executables-recursive (bound to M-+ * *),
796 ;; diredp-mark-directories-recursive (bound to M-+ * /),
797 ;; diredp-mark-extension-recursive (bound to M-+ * .),
798 ;; diredp-mark-autofiles-recursive (bound to M-+ * B),
799 ;; diredp-mark-executables-recursive (bound to M-+ * *),
800 ;; diredp-mark-directories-recursive (bound to M-+ * /),
801 ;; diredp-mark-symlinks-recursive (bound to M-+ * @),
802 ;; Bind diredp-mark-autofiles to * B.
803 ;; diredp-marked-here: Bind dired-marker-char to ?*.
804 ;; diredp-mark-files-regexp-recursive: Better msgs - show total count.
805 ;; Everywhere: Use diredp-looking-at, not looking-at. Use diredp-read-regexp, not dired-read-regexp.
806 ;; 2017/05/30 dadams
807 ;; Fixed typo: direp--set-up-font-locking -> diredp--set-up-font-locking.
808 ;; 2017/05/22 dadams
809 ;; Added: direp--set-up-font-locking.
810 ;; Use direp--set-up-font-locking instead of lambda in dired-mode-hook.
811 ;; 2017/04/09 dadams
812 ;; Version 2017.04.09.
813 ;; Added: diredp-multiple-move-copy-link-menu, diredp-multiple-rename-menu, diredp-multiple-dired-menu,
814 ;; diredp-multiple-omit-menu, diredp-multiple-delete-menu, diredp-single-bookmarks-menu,
815 ;; diredp-single-encryption-menu, diredp-single-image-menu, diredp-single-open-menu,
816 ;; diredp-single-move-copy-link-menu, diredp-single-rename-menu.
817 ;; Moved single menu items there.
818 ;; Renamed: diredp-menu-bar-encryption-menu to diredp-multiple-encryption-menu,
819 ;; diredp-menu-bar-mark-menu to diredp-menu-bar-marks-menu,
820 ;; diredp-menu-bar-operate-menu to diredp-menu-bar-multiple-menu,
821 ;; diredp-menu-bar-operate-bookmarks-menu to diredp-multiple-bookmarks-menu,
822 ;; diredp-menu-bar-operate-recursive-menu to diredp-multiple-recursive-menu,
823 ;; diredp-menu-bar-operate-search-menu to diredp-multiple-search-menu,
824 ;; diredp-menu-bar-images-menu to diredp-multiple-images-menu,
825 ;; diredp-menu-bar-images-recursive-menu to diredp-images-recursive-menu,
826 ;; diredp-menu-bar-immediate-menu to diredp-menu-bar-single-menu,
827 ;; diredp-menu-bar-regexp-recursive-menu to diredp-regexp-recursive-menu,
828 ;; diredp-menu-bar-subdir-menu to diredp-menu-bar-dir-menu.
829 ;; Added dired-do-rename to diredp-multiple-rename-menu.
830 ;; diredp-nonempty-region-p: Ensure (mark) also.
831 ;; 2017/03/30 dadams
832 ;; Moved key bindings to end of file. Moved defgroup before defcustoms.
833 ;; Bind dired-multiple-w32-browser to C-M-RET, diredp-multiple-w32-browser-recursive to M-+ C-M-RET.
834 ;; 2017/03/29 dadams
835 ;; Added: diredp-dired-union-other-window, diredp-add-to-dired-buffer-other-window.
836 ;; diredp-dired-union-1: Added optional arg OTHERWIN.
837 ;; diredp-dired-plus-description: Updated doc string.
838 ;; diredp-menu-bar-subdir-menu: Added diredp-dired-for-files.
839 ;; Bind diredp-w32-drives to :/, diredp-dired-inserted-subdirs to C-M-i.
840 ;; Bind diredp-add-to-dired-buffer to C-x D A (not C-x E), diredp-dired-union to C-x D U (not C-x D),
841 ;; diredp-fileset to C-x D S (not C-M-f), diredp-dired-recent-dirs to C-x D R (not C-x R),
842 ;; diredp-dired-for-files to C-x D F, plus other-window versions.
843 ;; 2017/03/24 dadams
844 ;; Added defalias for dired-read-regexp.
845 ;; diredp-mouse-3-menu: Removed second arg to mouse-save-then-kill.
846 ;; 2017/02/20 dadams
847 ;; diredp-(next|previous)-line, diredp-(next|prev)-dirline, diredp-(next|prev)-subdir:
848 ;; Update interactive spec to use (in effect) ^p for prefix arg (for shift-select-mode).
849 ;; 2017/01/12 dadams
850 ;; dired-mark-files-regexp: Swapped prefix-arg behavior for relative and absolute name matching.
851 ;; 2017/01/01 dadams
852 ;; dired-mark-files-regexp: Fix to prompt for no prefix arg.
853 ;; 2016/12/28 dadams
854 ;; dired-mark-files-regexp: Corrected prompt string for Mark/UNmark. Thx to Tino Calancha.
855 ;; 2016/11/20 dadams
856 ;; diredp-menu-bar-operate-search-menu: Added dired-do-find-regexp and dired-do-find-regexp-and-replace.
857 ;; Bind dired-do-search to M-a and dired-do-query(-replace)-regexp to M-q.
858 ;; diredp-dired-plus-description: Added dired-do-find-regexp and dired-do-find-regexp-and-replace.
859 ;; 2016/10/12 dadams
860 ;; diredp-compressed-extensions: Added extensions .xz and .lzma. Thx to xuhdev (https://www.topbug.net/).
861 ;; 2016/09/20 dadams
862 ;; Emacs 25.1: Bind M-z to dired-do-compress-to (replaces c). (Emacs bug #24484.)
863 ;; diredp-menu-bar-operate-menu: Added item: Compress to (dired-do-compress-to).
864 ;; 2016/09/15 dadams
865 ;; Added: diredp-max-frames.
866 ;; dired-do-find-marked-files: Pass non-nil ARG to dired-get-marked-files only if it is a cons.
867 ;; Clarified doc string wrt prefix arg.
868 ;; dired-simultaneous-find-file: Require confirmation if more files than diredp-max-frames.
869 ;; diredp-do-find-marked-files-recursive: Clarified doc string wrt prefix arg.
870 ;; Thx to Tino Calancha.
871 ;; 2016/09/14 dadams
872 ;; diredp-dired-plus-description: Added entry for dired-hide-details-mode - ( key.
873 ;; 2016/08/26 dadams
874 ;; diredp-y-or-n-files-p: pop-to-buffer only when the buffer was created.
875 ;; Update wrt vanilla (scroll actions).
876 ;; diredp-do-query-replace-regexp-recursive:
877 ;; Call diredp-get-confirmation-recursive.
878 ;; Use only diredp-get-files, not dired-get-marked-files.
879 ;; Non-positive prefix arg means DELIMITED.
880 ;; 2016/08/08 dadams
881 ;; diredp-menu-bar-mark-menu:
882 ;; Added: dired-mark-files-containing-regexp, dired-mark-sexp, image-dired-mark-tagged-files,
883 ;; 2016/05/28 dadams
884 ;; diredp-mark-files-regexp-recursive: Use nil for dired-get-filename LOCALP arg.
885 ;; dired-mark-files-regexp: Corrected doc string: absolute filename matching by default.
886 ;; 2016/05/24 dadams
887 ;; dired-mark-files-regexp: Added optional arg LOCALP, so can mark/unmark matching different file-name forms.
888 ;; 2016/05/15 dadams
889 ;; Added: diredp-bookmark-menu, diredp-hide/show-menu, diredp-navigate-menu.
890 ;; Move insert after revert and rename it to Insert/Move-To This Subdir. Move create-directory before revert.
891 ;; 2016/04/29 dadams
892 ;; diredp-next-line: Respect goal-column.
893 ;; 2016/01/24 dadams
894 ;; Added: diredp-ensure-bookmark+, diredp-mark-autofiles, diredp-unmark-autofiles,
895 ;; diredp-mark/unmark-autofiles, diredp-describe-autofile, diredp-show-metadata,
896 ;; diredp-mouse-describe-autofile, diredp-describe-marked-autofiles, diredp-show-metadata-for-marked
897 ;; Soft-require help-fns+.el (Emacs 22+) or help+20.el (Emacs 20-21).
898 ;; Add to menu-bar menus:
899 ;; diredp-(un)mark-autofiles, diredp-describe-autofile, diredp-describe-marked-autofiles.
900 ;; diredp-menu-bar-immediate-menu: Add diredp-describe-file only if defined.
901 ;; Bind diredp-describe-file to keys only if defined.
902 ;; Use diredp-ensure-bookmark+ everywhere, instead of its definition.
903 ;; diredp(-mouse)-describe-file: Define only if describe-file is defined. Removed raising error if not.
904 ;; diredp-mouse-3-menu: Use diredp-describe-autofile if diredp-describe-file is not defined.
905 ;; diredp-dired-plus-description: Add diredp-mouse-describe-autofile, when bound.
906 ;; dired-mark-if: Do not count non-changes.
907 ;; 2015/12/15 dadams
908 ;; diredp-font-lock-keywords-1: Follow # with optional [/ ], for face diredp-number. Thx to Tino Calancha.
909 ;; 2015/11/10 dadams
910 ;; diredp-fileset(-other-window): Separate error msgs for unloaded filesets.el and empty filesets-data.
911 ;; 2015/10/02 dadams
912 ;; dired-mark-sexp: Like vanilla, skip extended attributes marker before setting NLINK. Thx to Tino Calancha.
913 ;; 2015/09/29 dadams
914 ;; diredp-delete-this-file: Redefined to use delete-file instead of dired-do-delete.
915 ;; 2015/09/07 dadams
916 ;; diredp-font-lock-keywords-1: Do not test diredp-ignore-compressed-flag when highlighting file names.
917 ;; Use separate entries for compressed and non-compressed file names.
918 ;; Added missing \\| before ignored compressed extensions.
919 ;; 2015/09/06 dadams
920 ;; diredp-compressed-extensions: Added .tgz. Removed duplicate .gz.
921 ;; diredp-font-lock-keywords-1: Use regexp-opt where possible, instead of mapcar regexp-quote.
922 ;; 2015/09/05 dadams
923 ;; Added: diredp-compressed-extensions, diredp-ignore-compressed-flag, diredp-compressed-file-name,
924 ;; diredp-dir-name.
925 ;; diredp-font-lock-keywords-1:
926 ;; Allow spaces in symlink names. Highlight compressed-file names, if diredp-ignore-compressed-flag.
927 ;; Use diredp-compressed-extensions instead of hardcoding extensions.
928 ;; Highlight d with diredp-dir-priv (fix).
929 ;; Treat l in third column the same as - and d there.
930 ;; Highlight whole line for D-flagged files, with face diredp-deletion-file-name.
931 ;; Thx to Nick Helm.
932 ;; 2015/08/30 dadams
933 ;; dired-mark-sexp: Updated per Emacs 25 code.
934 ;; 2015/07/30 dadams
935 ;; diredp-fileset(-other-window): Changed key binding from C-x F to C-x C-M-f (conflicted with find-function).
936 ;; 2015/06/24 dadams
937 ;; Added: diredp-parent-dir, diredp-breadcrumbs-in-header-line-mode, diredp-set-header-line-breadcrumbs.
938 ;; 2015/06/06 dadams
939 ;; Added dired-other-(frame|window).
940 ;; diredp-font-lock-keywords-1:
941 ;; Use dired-re-maybe-mark and dired-re-inode-size for permission matchings and directory names.
942 ;; dired(-other-(frame|window)) advice:
943 ;; Add interactive spec, to handle arg <= 0 (broken by change to dired-read-dir-and-switches 2015/02/02).
944 ;; diredp-dired-for-files: Typo: pass empy string.
945 ;; 2015/06/05 dadams
946 ;; Added: diredp-grepped-files-other-window as alias for diredp-compilation-files-other-window.
947 ;; diredp-compilation-files-other-window: Added SWITCHES optional arg (prefix arg).
948 ;; 2015/06/04 dadams
949 ;; diredp-dired-for-files(-other-window):
950 ;; Updated to fit change to dired-read-dir-and-switches made 2015/02/02: addition of READ-EXTRA-FILES-P.
951 ;; Use prefix arg to prompt for switches.
952 ;; 2015/05/31 dadams
953 ;; Added: diredp-image-show-this-file,diredp-image-show-this-file-use-frame-flag, diredp-get-image-filename.
954 ;; image-dired-dired-toggle-marked-thumbs, diredp-menu-bar-immediate-menu [image]:
955 ;; Use diredp-get-image-filename.
956 ;; Bound diredp-image-show-this-file to C-t I.
957 ;; diredp-menu-bar-immediate-image-menu: Added diredp-image-show-this-file and dired-find-file.
958 ;; Added autoload cookies for image commands.
959 ;; 2015/04/16 dadams
960 ;; Added: diredp-do-apply-function, diredp-do-apply-function-recursive. Added to menus. Bind to @, M-+ @.
961 ;; dired-do-query-replace-regexp: Handle nil ARG properly.
962 ;; 2015/03/26 dadams
963 ;; Added: redefinitions of dired-do-isearch, dired-do-isearch-regexp, dired-do-query-replace-regexp,
964 ;; dired-do-search, to handle multi-C-u.
965 ;; Added: dired-nondirectory-p (Emacs 20), diredp-refontify-buffer.
966 ;; dired-do-byte-compile, dired-do-load, : Corrected interactive spec, to treat more than two C-u as two.
967 ;; dired-after-readin-hook: Add diredp-refontify-buffer. In particular, this ensures that reverting Dired
968 ;; for a listing of explicit file names gets refontified. (Just turn-on-font-lock does not refontify.)
969 ;; 2015/03/24 dadams
970 ;; Added: diredp-compilation-files-other-window, diredp-file-for-compilation-hit-at-point.
971 ;; 2015/03/06 dadams
972 ;; Renamed: diredp-menu-bar-recursive-marked-menu to diredp-menu-bar-operate-recursive-menu.
973 ;; Added: diredp-do-delete-recursive: M-+ D. Added to diredp-menu-bar-operate-recursive-menu.
974 ;; Added: diredp-mark-files-regexp-recursive: M-+ % m. Added to diredp-menu-bar-regexp-recursive-menu.
975 ;; 2015/03/04 dadams
976 ;; Added: diredp-dwim-any-frame-flag, (redefinition of) dired-dwim-target-directory.
977 ;; 2015/02/22 dadams
978 ;; diredp-bookmark: Corrected for use without Bookmark+ - bookmark-store signature.
979 ;; Pass correct value to bmkp-autofile-set for its MSG-P arg.
980 ;; diredp-mouse-do-bookmark: Do not pass non-nil NO-MSG-P arg to diredp-bookmark.
981 ;; 2015/02/03 dadams
982 ;; Added: diredp-add-to-this-dired-buffer.
983 ;; Removed: diredp-add-to-dired-buffer-other-window, diredp-dired-union-other-window.
984 ;; diredp-dired-union-1: Removed optional arg OTHER-WINDOW-P.
985 ;; diredp-menu-bar-subdir-menu: Added diredp-add-to-this-dired-buffer.
986 ;; dired-read-dir-and-switches, diredp-dired-union-interactive-spec:
987 ;; Added optional arg DIRED-BUFFER. If nil, use current buffer name as default when reading buffer name.
988 ;; 2015/02/02 dadams
989 ;; Added: diredp-add-to-dired-buffer, diredp-add-to-dired-buffer-other-window, diredp-set-union,
990 ;; diredp-existing-dired-buffer-p.
991 ;; Bind diredp-add-to-dired-buffer(-other-window) globally to C-x E, C-x 4 E.
992 ;; diredp-dired-union(-other-window):
993 ;; Added args DIRNAME and EXTRA. Pass them to diredp-dired-union-1. Moved "UNION" to *-interactive-spec.
994 ;; Pass values for new args NO-DIRED-BUFS and READ-EXTRA-FILES-P to diredp-dired-union-interactive-spec.
995 ;; diredp-dired-union-interactive-spec:
996 ;; Added args NO-DIRED-BUFS and READ-EXTRA-FILES-P. Use (updated) dired-read-dir-and-switches.
997 ;; Delete dead buffers from dired-buffers. Remove DIRNAME buffer as candidate.
998 ;; Apply expand-file-name to default-directory. Return list of DIRNAME BUFS SWITCHES EXTRA-FILES.
999 ;; diredp-dired-union-1:
1000 ;; Added args DIRED-NAME and EXTRA.
1001 ;; For existing Dired buffer whose dired-directory is a cons:
1002 ;; Include its current listing. Replace buffer with new one of same name, after deleting its window.
1003 ;; dired-read-dir-and-switches:
1004 ;; Added arg READ-EXTRA-FILES-P.
1005 ;; If chosen Dired buffer exists and is an ordinary listing then start out with its directory-files.
1006 ;; diredp-dired-union, diredp-fileset, diredp-dired-recent-dirs: Bind globally, not just in Dired mode.
1007 ;; 2015/01/30 dadams
1008 ;; dired-read-dir-and-switches: Remove any killed buffers from dired-buffers, before using for completion.
1009 ;; 2014/10/25 dadams
1010 ;; diredp-dired-union-interactive-spec: Typo: quote buffer-name-history. Pass other-window STRING.
1011 ;; diredp-dired-union-other-window: Pass other-window STRING.
1012 ;; dired-read-dir-and-switches: Include STRING for reading buffer name also.
1013 ;; dired (defadvice): Corrected doc string for prefix arg >= and <= 0.
1014 ;; 2014/10/15 dadams
1015 ;; diredp-hide-details-initially-flag:
1016 ;; Added :set, to ensure that diredp-hide-details-last-state is kept up-to-date.
1017 ;; 2014/09/28 dadams
1018 ;; Added: diredp-recent-dirs, diredp-read-include/exclude, diredp-root-directory-p, diredp-remove-if.
1019 ;; diredp-dired-recent-dirs(-other-window): Added optional ARG. Use diredp-recent-dirs. Pass SWITCHES.
1020 ;; dired-read-dir-and-switches: Use diredp-root-directory-p.
1021 ;; Bound diredp-dired-recent-dirs(-other-window) to C-x R and C-x 4 R.
1022 ;; Added diredp-dired-recent-dirs to Dir menu.
1023 ;; 2014/09/27 dadams
1024 ;; Added: diredp-dired-recent-dirs, diredp-dired-recent-dirs-other-window, diredp-delete-dups.
1025 ;; 2014/09/26 dadams
1026 ;; diredp-mouseover-help: dired-get-filename etc. has to be inside the save-excursion.
1027 ;; diredp-image-dired-create-thumb: Added FILE arg. Use numeric prefix arg as the new thumbnail size.
1028 ;; 2014/09/22 dadams
1029 ;; diredp-mouse-3-menu: Do not place overlay unless on a file/dir name (i.e., dired-get-filename).
1030 ;; 2014/09/15 dadams
1031 ;; dired-read-dir-and-switches: Made it (thus dired too) an Icicles multi-command.
1032 ;; dired (defadvice): Added doc about using it with Icicles.
1033 ;; 2014/09/14 dadams
1034 ;; Added: diredp-kill-this-tree.
1035 ;; Removed: diredp-dired-files(-other-window), diredp-dired-files-interactive-spec.
1036 ;; dired-read-dir-and-switches:
1037 ;; Based on diredp-dired-files-interactive-spec implementation now, but:
1038 ;; Moved unwind-protect outside call to list. completing-read, not read-string, for DIRBUF.
1039 ;; Do not allow inclusion of root directories. Protected icicle-sort-comparer with boundp.
1040 ;; dired-insert-subdir-validate: Make it a no-op.
1041 ;; dired advice (doc string): Mention wildcards, Icicles.
1042 ;; diredp-dired-for-files(-other-window):
1043 ;; Use dired-read-dir-and-switches and dired, not diredp-dired-files-interactive-spec and
1044 ;; diredp-dired-files.
1045 ;; diredp-menu-bar-immediate-menu, diredp-mouse-3-menu:
1046 ;; Added item for diredp-kill-this-tree.
1047 ;; Corrected visible condition: expand-file-name, so ~/ compares with its expansion.
1048 ;; diredp-font-lock-keywords-1: Include period (.) for diredp(-compressed)-file-suffix.
1049 ;; 2014/09/09 dadams
1050 ;; Added: dired-read-dir-and-switches.
1051 ;; Advise dired, for doc string.
1052 ;; dired-get-filename: Hack for Emacs 20-22, to expand ~/...
1053 ;; 2014/09/07 dadams
1054 ;; Added: redefinitions of dired-insert-subdir-newpos, dired-insert-subdir-validate.
1055 ;; 2014/07/26 dadams
1056 ;; diredp-do-find-marked-files-recursive:
1057 ;; Only ARG >= 0 ignores marks now. And ARG <= 0 means find but do not display.
1058 ;; 2014/07/13 dadams
1059 ;; diredp-mouseover-help: Wrap (goto-char pos) in save-excursion (Emacs bug #18011).
1060 ;; 2014/07/12 dadams
1061 ;; Faces diredp(-tagged)-autofile-name: Made paler/darker (less saturated).
1062 ;; Moved diredp-highlight-autofiles before diredp-highlight-autofiles-mode, so will be
1063 ;; defined for first revert.
1064 ;; diredp-mouse-3-menu: Renamed items Tag, Untag to Add Tags, Remove Tags.
1065 ;; diredp-dired-plus-description: Updated.
1066 ;; 2014/07/11 dadams
1067 ;; Added: diredp-highlight-autofiles-mode, diredp-highlight-autofiles,
1068 ;; diredp-autofile-name, diredp-tagged-autofile-name.
1069 ;; Soft-require bookmark+.el. Soft-require highlight.el if bookmark+.el is provided.
1070 ;; diredp-menu-bar-subdir-menu: Added item Toggle Autofile Highlighting.
1071 ;; Removed unused face: diredp-display-msg.
1072 ;; 2014/06/29 dadams
1073 ;; dired-get-marked-files, diredp-internal-do-deletions:
1074 ;; Remove nils from dired-map-over-marks result.
1075 ;; 2014/05/28 dadams
1076 ;; diredp-mode-line-marked: Use DarkViolet for both light and dark background modes.
1077 ;; 2014/05/23 dadams
1078 ;; Added: diredp-with-help-window.
1079 ;; diredp-list-files, diredp-dired-plus-help:
1080 ;; Use diredp-with-help-window, not with-output-to-temp-buffer. See Emacs bug #17109.
1081 ;; 2014/05/06 dadams
1082 ;; Added: diredp-image-dired-required-msg, diredp-list-files-map,
1083 ;; diredp-find-line-file-other-window, diredp-mouse-find-line-file-other-window,
1084 ;; image-dired-dired-toggle-marked-thumbs, diredp-list-marked.
1085 ;; Soft-require image-dired.el and image-file.el.
1086 ;; diredp-image-dired-create-thumb: Define unconditionally.
1087 ;; image-dired-dired-insert-marked-thumbs, diredp-image-dired-comment-file,
1088 ;; diredp-image-dired-tag-file, diredp-image-dired-delete-tag,
1089 ;; diredp-image-dired-display-thumb, diredp-image-dired-copy-with-exif-name,
1090 ;; diredp-image-dired-edit-comment-and-tags, diredp-do-display-images:
1091 ;; Define unconditionally and raise error if no image-(dired|file).el.
1092 ;; diredp-menu-bar-immediate-image-menu, diredp-menu-bar-images-menu,
1093 ;; diredp-menu-bar-images-recursive-menu, image-dired-mark-tagged-files:
1094 ;; Define unconditionally and use :enable.
1095 ;; diredp-menu-bar-images-menu, diredp-menu-bar-images-recursive-menu:
1096 ;; Add defalias so can use menu-item with :enable.
1097 ;; diredp-list-files: Add properties mouse-face, keymap, and help-echo.
1098 ;; diredp-mouseover-help: Make it work also for diredp-list-files listings.
1099 ;; image-dired-dired-insert-marked-thumbs: Add autoload cookie.
1100 ;; dired-get-marked-files: Pass non-nil 2nd arg to dired-get-filename, to include . and .. .
1101 ;; Bind diredp-list-marked to C-M-l and diredp-list-marked-recursive to M+ C-M-l.
1102 ;; diredp-insert-subdirs: Exclude . and .., as dired-get-marked-files can now include them.
1103 ;; diredp-menu-bar-operate-menu: Add diredp-menu-bar-operate-menu to menu.
1104 ;; diredp-dired-plus-description: Mention diredp-list-marked*.
1105 ;; 2014/05/03 dadams
1106 ;; dired-switches-escape-p: Use dired-switches-check if available, based on bug #17218 fix.
1107 ;; 2014/04/25 dadams
1108 ;; diredp-image-dired-create-thumb:
1109 ;; Do not call diredp-image-dired-create-thumb twice: reuse THUMB-NAME.
1110 ;; 2014/04/24 dadams
1111 ;; Added: diredp-mouseover-help, diredp-auto-focus-frame-for-thumbnail-tooltip-flag,
1112 ;; diredp-image-preview-in-tooltip.
1113 ;; dired-insert-set-properties: Show image-file preview in tooltip.
1114 ;; diredp-image-dired-create-thumb: Return thumbnail file name or nil.
1115 ;; 2014/04/23 dadams
1116 ;; Added: diredp-looking-at-p.
1117 ;; dired-insert-set-properties: Applied fix for bug #17228.
1118 ;; 2014/04/05 dadams
1119 ;; Added: diredp-do-bookmark-dirs-recursive.
1120 ;; Renamed from bmkp-create-dired-bookmarks-recursive in bookmark+-1.el (removed).
1121 ;; Bound to M-B (aka M-S-b).
1122 ;; Added to menus *-subdir-menu, *-operate-bookmarks-menu, *-bookmarks-menu.
1123 ;; diredp-get-confirmation-recursive: Added optional TYPE arg.
1124 ;; diredp-insert-subdirs-recursive: Call diredp-get-confirmation-recursive with TYPE arg.
1125 ;; 2014/02/16 dadams
1126 ;; dired-pop-to-buffer: Do not redefine for Emacs > 24.1.
1127 ;; dired-mark-pop-up: Updated doc string.
1128 ;; 2014/02/13 dadams
1129 ;; Added: diredp-fileset-other-window, diredp-fileset-1.
1130 ;; diredp-fileset: Use diredp-fileset-1.
1131 ;; Bind diredp-dired-union(-other-window) to C-x D, C-x 4 D,
1132 ;; diredp-fileset(-other-window) to C-x F, C-x 4 F.
1133 ;; Use diredp-fileset-other-window, not diredp-fileset, in menu.
1134 ;; 2014/02/03 dadams
1135 ;; Added: diredp-hide-subdir-nomove.
1136 ;; Added: dired-goto-file for Emacs 24+ - open hidden parent dir, so can goto destination.
1137 ;; Replace bindings for dired-hide-subdir with diredp-hide-subdir-nomove.
1138 ;; Bind dired-hide-subdir to M-$ (not $).
1139 ;; 2014/02/02 dadams
1140 ;; dired-goto-file: Redefine only for Emacs < 24.
1141 ;; 2014/01/15 dadams
1142 ;; Bind diredp-toggle-find-file-reuse-dir to C-M-R (aka C-M-S-r).
1143 ;; 2014/01/05 dadams
1144 ;; Bind dired-omit-mode (aka dired-omit-toggle) to C-x M-o.
1145 ;; 2013/12/05 dadams
1146 ;; diredp-do-grep-1: Call grep-default-command with arg, if grep+.el is loaded.
1147 ;; 2013/11/05 dadams
1148 ;; Added: diredp-get-subdirs.
1149 ;; diredp-get-files, diredp-get-files-for-dir, diredp-marked-here:
1150 ;; Added optional arg NIL-IF-NONE-P.
1151 ;; diredp-get-files: Pass INCLUDE-DIRS-P to diredp-files-within.
1152 ;; 2013/11/04 dadams
1153 ;; Renamed Bookmarks submenus to Bookmark.
1154 ;; Added Bookmark Dired Buffer to Dir menu.
1155 ;; Alias dired-toggle-marks to dired-do-toggle for Emacs 20, instead of backwards for others.
1156 ;; Use dired-toggle-marks everywhere instead of dired-do-toggle.
1157 ;; 2013/11/03 dadams
1158 ;; Created submenus of Multiple menu: Bookmarks, Search.
1159 ;; Created submenus of Multiple > Marked Here and Below menu:
1160 ;; Images, Encryption, Search, Bookmarks.
1161 ;; Reordered menus.
1162 ;; 2013/09/26 dadams
1163 ;; diredp-next-line: Use let*, so line-move sees let bindings.
1164 ;; 2013/08/11 dadams
1165 ;; diredp-dired-files-interactive-spec:
1166 ;; Protect icicle-file-sort with boundp. Thx to Vladimir Lomov.
1167 ;; 2013/08/06 dadams
1168 ;; diredp-display-image,diredp-menu-bar-immediate-image-menu (:enable's):
1169 ;; Protect diredp-string-match-p from nil argument.
1170 ;; 2013/07/24 dadams
1171 ;; Added: diredp-nonempty-region-p. Use everywhere, in place of its definition.
1172 ;; 2013/07/21 dadams
1173 ;; Added: diredp-image-dired-(comment-file|copy-with-exif-name|(create|display)-thumb|
1174 ;; delete-tag|edit-comment-and-tags|tag-file),
1175 ;; diredp-string-match-p, diredp-menu-bar-immediate-image-menu.
1176 ;; Put this-file image commands on new menu diredp-menu-bar-immediate-image-menu.
1177 ;; diredp-menu-bar-images-menu: Added diredp-do-display-images.
1178 ;; Use diredp-string-match-p instead of string-match where appropriate.
1179 ;; diredp-find-a-file-read-args: Removed #' from lambda.
1180 ;; 2013/07/19 dadams
1181 ;; Added redefinition of dired-hide-details-mode.
1182 ;; Added: diredp-hide-details-propagate-flag, diredp-hide-details-initially-flag,
1183 ;; diredp-hide-details-last-state, diredp-hide-details-toggled,
1184 ;; diredp-hide-details-if-dired, global-dired-hide-details-mode,
1185 ;; diredp-fit-frame-unless-buffer-narrowed, diredp-hide/show-details,
1186 ;; diredp-do-display-images, diredp-display-image.
1187 ;; On dired-after-readin-hook: diredp-hide/show-details.
1188 ;; On dired-hide-details-mode-hook: diredp-fit-frame-unless-buffer-narrowed.
1189 ;; diredp-maplist: Use diredp-maplist, not maplist, in recursive call.
1190 ;; diredp-next-line: Added bobp test for negative ARG.
1191 ;; Emacs 20 line-move returns nil, so use (progn ... t).
1192 ;; Soft-require autofit-frame.el.
1193 ;; 2013/07/18 dadams
1194 ;; diredp-next-line: Protect visible-p with fboundp for Emacs 20.
1195 ;; 2013/07/17 dadams
1196 ;; Added: diredp-menu-bar-encryption-menu, diredp-menu-bar-images-menu,
1197 ;; diredp-menu-bar-immediate-encryption-menu,
1198 ;; diredp-(decrypt|verify|sign|encrypt)-this-file.
1199 ;; Added diredp-(decrypt|verify|sign|encrypt)-this-file to *-immediate-encryption-menu.
1200 ;; Moved encryption and image-dired items to the new Multiple submenus from Multiple menu.
1201 ;; 2013/07/15 dadams
1202 ;; Added: diredp-async-shell-command-this-file, diredp-do-async-shell-command-recursive.
1203 ;; Added them to menus. Bind diredp-do-async-shell-command-recursive to M-+ &.
1204 ;; diredp-menu-bar-mark-menu, diredp-dired-plus-description: Added dired-mark-omitted.
1205 ;; diredp-menu-bar-subdir-menu: Added dired-omit-mode, dired-hide-details-mode.
1206 ;; diredp-menu-bar-regexp-menu: Added image-dired-mark-tagged-files.
1207 ;; diredp-menu-bar-subdir-menu: Added dired-hide-details-mode.
1208 ;; diredp-shell-command-this-file: Corrected: provide file list to dired-do-shell-command.
1209 ;; 2013/07/13 dadams
1210 ;; diredp-font-lock-keywords-1:
1211 ;; Ensure diredp-dir-priv is not used for directory header of d:/... (Windows drive name).
1212 ;; dired-insert-directory:
1213 ;; Update wrt Emacs 24.4: Do dired-insert-set-properties last; use saved CONTENT-POINT.
1214 ;; dired-insert-set-properties: Updated for Emacs 24.4, for dired-hide-details-mode.
1215 ;; Add frame-fitting to dired-hide-details-mode-hook.
1216 ;; dired-mouse-find-file(-other-window): Error msg if click off a file name.
1217 ;; 2013/07/12 dadams
1218 ;; Added: diredp-wrap-around-flag, diredp-(next|previous)-(subdir|(dir)line).
1219 ;; Renamed dired-up-directory to diredp-up-directory.
1220 ;; Replaced vanilla commands by these new commands everywhere.
1221 ;; 2013/07/11 dadams
1222 ;; Added: diredp-up-directory-reuse-dir-buffer.
1223 ;; diredp-make-find-file-keys(-not)-reuse-dirs: Added diredp-up-directory-reuse-dir-buffer.
1224 ;; 2013/02/06 dadams
1225 ;; dired-mark-pop-up: goto point-min, so show start of file list. Thx to Michael Heerdegen.
1226 ;; 2013/01/28 dadams
1227 ;; Added redefinition of dired-do-run-mail. Fixes Emacs bug #13561.
1228 ;; 2012/12/18 dadams
1229 ;; diredp-ediff: Better default for FILE2. Thx to Michael Heerdegen.
1230 ;; Require subr-21.el for Emacs 20.
1231 ;; 2012/11/17 dadams
1232 ;; Added: derived-mode-p (for Emacs < 22), diredp-ensure-mode.
1233 ;; Use diredp-ensure-mode everywhere for mode, so compatible with Sunrise Commander etc.
1234 ;; 2012/11/01 dadams
1235 ;; Do not require ediff.el. It is required in diredp-ediff itself.
1236 ;; 2012/10/06 dadams
1237 ;; Added: minibuffer-with-setup-hook for code byte-compiled using Emacs < 22.
1238 ;; 2012/09/28 dadams
1239 ;; Moved dired-*w32* bindings after normal mouse bindings, so they override them.
1240 ;; 2012/09/05 dadams
1241 ;; diredp-(rename|copy|(rel)symlink|hardlink)-this-file: Bind use-file-dialog to nil.
1242 ;; 2012/08/26 dadams
1243 ;; Set font-lock-defaults to a 3-element list, so it works with font-menus(-da).el.
1244 ;; 2012/08/25 dadams
1245 ;; Added: redefinition of dired-pop-to-buffer (fix for bug #12281).
1246 ;; dired-mark-pop-up: If buffer is shown in a separate frame, do not show menu bar.
1247 ;; 2012/07/10 dadams
1248 ;; Removed unneeded substitute-key-definition for (next|previous)-line.
1249 ;; 2012/07/09 dadams
1250 ;; Added redefinition of dired-mark-files-regexp: Push REGEXP onto regexp-search-ring.
1251 ;; 2012/06/21 dadams
1252 ;; diredp-nb-marked-in-mode-name:
1253 ;; Add marker numbers regardless of name match.
1254 ;; Use text property dired+-mode-name to tell whether mode-name was already changed.
1255 ;; 2012/06/20 dadams
1256 ;; Added: diredp-nb-marked-in-mode-name, diredp-mode-line-(flagged|marked). Added to hooks.
1257 ;; Thx to Michael Heerdegen.
1258 ;; 2012/06/14 dadams
1259 ;; dired-mark-pop-up: Wrap save-excursion around window/frame deletion.
1260 ;; dired-do-redisplay: Updated wrt Emacs 23: bind, (then run) dired-after-readin-hook.
1261 ;; diredp-y-or-n-files-p: Corrected construction of prompt wrt final SPC.
1262 ;; 2012/06/13 dadams
1263 ;; dired-buffers-for-dir: Updated wrt Emacs 23:
1264 ;; If dired-directory is a list then expand FILE in DIR & check whether in cdr of list.
1265 ;; diredp-get-files-for-dir, diredp-files-within-1, diredp-insert-as-subdir:
1266 ;; Expand dir name before passing it to dired-buffers-for-dir.
1267 ;; 2012/06/05 dadams
1268 ;; MS Windows: Just do not define commands that are inappropriate for Windows (instead of
1269 ;; defining them to raise an error or making them invisible in menus).
1270 ;; 2012/06/02 dadams
1271 ;; Added: diredp-do-(print|encrypt|decrypt|sign|verify)-recursive. Menus. Keys.
1272 ;; diredp-do-move-recursive: Corrected to use dired-rename-file, not dired-copy-file.
1273 ;; 2012/05/30 dadams
1274 ;; diredp-insert-as-subdir: Added optional arg IN-DIRED-NOW-P. Pick up markings & switches
1275 ;; from sole Dired buffer for CHILD if not in Dired now.
1276 ;; 2012/05/29 dadams
1277 ;; Added: diredp-do-(chxxx|chgrp|chown|touch)-recursive, diredp-touch-this-file,
1278 ;; diredp-menu-bar-(immediate|operate)-bookmarks-menu. Added to menus. Bound to keys.
1279 ;; Factored bookmark stuff into Bookmark(s) submenus.
1280 ;; diredp-menu-bar-immediate-menu: Added dired-kill-subdir, [goto-subdir].
1281 ;; diredp-dired-this-subdir, dired-maybe-insert-subdir: Corrected :visible/enable.
1282 ;; diredp-dired-inserted-subdirs: Do dired-(remember-marks|mark-rememberd) in this-buff.
1283 ;; diredp-mouse-3-menu:
1284 ;; Do not use save-excursion, because some commands move point on purpose. Just return to
1285 ;; original point unless command intends to MOVEP.
1286 ;; Added to menu dired-maybe-insert-subdir (two entries), dired-kill-subdir.
1287 ;; Use *-this-file*, not *-do-*: copy|symlink|shell-command|grep|load (don't use :keys).
1288 ;; 2012/05/26 dadams
1289 ;; diredp-dired-inserted-subdirs, diredp-insert-as-subdir:
1290 ;; Preserve markings and switches in target buffer.
1291 ;; dired-mark-pop-up: Use unwind-protect. Bury buffer too.
1292 ;; diredp-do-chmod-recursive: Use only 5 args if < Emacs 23.
1293 ;; 2012/05/25 dadams
1294 ;; Added: diredp-insert-as-subdir, diredp-ancestor-dirs, diredp-maplist,
1295 ;; diredp-do-redisplay-recursive, diredp-do-chmod-recursive.
1296 ;; Bound diredp-do-chmod-recursive. to M-+ M and added to menu.
1297 ;; diredp-get-files: Added optional arg DONT-ASKP.
1298 ;; diredp-y-or-n-files-p: Kill list buffer if it was never shown.
1299 ;; dired-mark-pop-up: ignore error when delete frame/window.
1300 ;; 2012/05/22 dadams
1301 ;; diredp-get-files(-for-dir): Added optional arg INCLUDE-DIRS-P.
1302 ;; Added: diredp-insert-subdirs(-recursive), diredp(-this)-dired-inserted-subdir(s).
1303 ;; Added to menus. Bound diredp-insert-subdirs* to (M-+) M-i.
1304 ;; Bound diredp-capitalize(-recursive) to (M-+) %c.
1305 ;; Added diredp-dired-union-other-window to Dirs menu.
1306 ;; Updated diredp-dired-plus-description.
1307 ;; 2012/05/19 dadams
1308 ;; Added: diredp-image-dired-*-recursive, diredp-*link-recursive,
1309 ;; diredp-do-isearch(-regexp)-recursive, diredp-do-query-replace-regexp-recursive,
1310 ;; diredp-do-search-recursive, diredp-(capitalize|(up|down)case)-recursive,
1311 ;; diredp-create-files-non-directory-recursive.
1312 ;; Bound on M-+ prefix key. Added to menus.
1313 ;; diredp-get-files, diredp-y-or-n-files-p, diredp-list-files, diredp-list-marked-recursive:
1314 ;; Added optional arg PREDICATE.
1315 ;; diredp-do-create-files-recursive: Removed MARKER-CHAR arg. Hard-code to keep markings.
1316 ;; diredp-do-(copy|move)-recursive: Use arg IGNORE-MARKS-P (forgot to use it).
1317 ;; Removed MARKER-CHAR arg in call to d-d-c-f-r.
1318 ;; Added missing autoload cookies.
1319 ;; 2012/05/06 dadsms
1320 ;; diredp-y-or-n-files-p: Do not kill buffer *Files* - just bury it.
1321 ;; 2012/05/05 dadams
1322 ;; Added: diredp-do-bookmark-recursive, diredp-do-bookmark-in-bookmark-file-recursive,
1323 ;; diredp-set-bookmark-file-bookmark-for-marked-recursive.
1324 ;; Bound to M-+ M-b, M-+ C-M-B (aka C-M-S-b), M-+ C-M-b, respectively. Added to menus.
1325 ;; diredp-bookmark: Added optional arg FILE.
1326 ;; diredp-do-bookmark-in-bookmark-file: Added optional arg FILES.
1327 ;; diredp-dired-plus-description: Updated.
1328 ;; diredp-get-confirmation-recursive: Raise error if not in Dired.
1329 ;; diredp-do-bookmark-recursive, diredp-marked-recursive(-other-window),
1330 ;; diredp-multiple-w32-browser-recursive:
1331 ;; Use diredp-get-confirmation-recursive.
1332 ;; 2012/05/04 dadams
1333 ;; Added: dired-mark-unmarked-files for Emacs < 24.
1334 ;; diredp-do-create-files-recursive: Corrected for Emacs < 24.
1335 ;; diredp-do-create-files-recursive, diredp-(un)mark-files-tagged-regexp,
1336 ;; diredp(-mouse)-do-(un)tag, diredp(-mouse)-do-remove-all-tags,
1337 ;; diredp(-mouse)-do-paste-(add|replace)-tags, diredp(-mouse)-do-set-tag-value,
1338 ;; diredp(-mouse)-do-bookmark(-in-bookmark-file), diredp-find-a-file-read-args,
1339 ;; diredp-mouse-do-shell-command:
1340 ;; Use lexical-let(*), to get closures for free vars in lambdas.
1341 ;; 2012/04/28 dadams
1342 ;; Added:
1343 ;; diredp-copy-filename-as-kill-recursive, diredp-do-copy-recursive,
1344 ;; diredp-do-find-marked-files-recursive, diredp-do-grep-recursive,
1345 ;; diredp-do-move-recursive, diredp-do-shell-command-recursive,
1346 ;; diredp-list-marked-recursive, diredp-marked-recursive(-other-window),
1347 ;; diredp-multiple-w32-browser-recursive, diredp-do-create-files-recursive,
1348 ;; diredp-get-confirmation-recursive, diredp-list-files, diredp-y-or-n-files-p,
1349 ;; diredp-menu-bar-recursive-marked-menu.
1350 ;; diredp-get-files: Use diredp-y-or-n-files-p, not y-or-n-p.
1351 ;; Commented out dired-readin-insert - see comment.
1352 ;; Moved bookmark menu items to submenu Bookmarks.
1353 ;; Added keys (with M-+ prefix) and menu items for new (*-recursive) commands.
1354 ;; Reordered w32-browser stuff in menus.
1355 ;; diredp-do-grep: Combined defs for diff Emacs versions - do version test at runtime.
1356 ;; 2012/04/25 dadams
1357 ;; dired-insert-directory: Updated per Emacs 24.
1358 ;; 2012/04/23 dadams
1359 ;; Added (moved here from Icicles, and renamed prefix):
1360 ;; diredp-re-no-dot, diredp-get-files, diredp-get-files-for-dir, diredp-files-within,
1361 ;; diredp-files-within-dirs-done.
1362 ;; 2012/04/05 dadams
1363 ;; Added redefinition of dired-mark-pop-up, to fix Emacs bug #7533. If they ever fix it
1364 ;; then remove this hack.
1365 ;; 2012/03/13 dadams
1366 ;; diredp-dired(-for)-files(-other-window):
1367 ;; Bind: icicle-sort-comparer, icicle-all-candidates-list-alt-action-fn.
1368 ;; Use icicle-(un)bind-file-candidate-keys.
1369 ;; diredp-dired-files-interactive-spec: Updated doc strings accordingly.
1370 ;; 2012/03/07 dadams
1371 ;; Added: dired-switches-escape-p.
1372 ;; dired-get-filename: Updated wrt Emacs 24:
1373 ;; whitespace quoting for bug #10469, filename quoting per Emacs 23.3+,
1374 ;; MS Windows conversion of \ to / per Emacs 23.3+.
1375 ;; dired-goto-file: Escape whitespace, per Emacs 24 (for bug #10469).
1376 ;; 2012/03/02 dadams
1377 ;; Require cl.el at compile time even for Emacs 22+, for case macro.
1378 ;; 2012/02/28 dadams
1379 ;; Do not bother to soft-require mkhtml.el anymore.
1380 ;; 2012/02/18 dadams
1381 ;; Swapped keys for dired-w32(-browser|explore), so the former is M-RET, as in Bookmark+.
1382 ;; 2012/01/10 dadams
1383 ;; diredp-font-lock-keywords-1: Corrected for date/time when locale is used, not iso.
1384 ;; 2011/12/19 dadams
1385 ;; dired-insert-set-properties, dired-mark-sexp, diredp-(un)mark-region-files,
1386 ;; diredp-flag-region-files-for-deletion, diredp-mouse-3-menu:
1387 ;; Use line-(beginning|end)-position.
1388 ;; 2011/12/16 dadams
1389 ;; diredp-menu-bar-mark-menu: Removed Revert item.
1390 ;; diredp-menu-bar-subdir-menu: Add image-dired-dired-toggle-marked-thumbs.
1391 ;; diredp-mouse-3-menu:
1392 ;; Use commands bound to keys, so the keys show up in the menu. Prefer *-this-file.
1393 ;; Correct the mark/unmark/flag menu-item visibility. Added Capitalize.
1394 ;; 2011/12/09 dadams
1395 ;; diredp-w32-drives: Use dolist, not mapcar.
1396 ;; diredp-mouse-3-menu: Use easymenu to build the menu. Conditionalize some items.
1397 ;; Bind down-mouse-3, not mouse-3, to diredp-mouse-3-menu. (bind mouse-3 to ignore).
1398 ;; Added eval-when-compile for easymenu.el.
1399 ;; 2011/12//02 dadams
1400 ;; Added diredp-internal-do-deletions.
1401 ;; dired(-mouse)-do(-flagged)-delete, : Use diredp-internal-do-deletions, for trash.
1402 ;; 2011/11/29 dadams
1403 ;; diredp-read-bookmark-file-args: Corrected use of list of default file names: > Emacs 23.1.
1404 ;; 2011/10/31 dadams
1405 ;; dired-mode-hook: Call font-lock-refresh-defaults - see Emacs 24 bugs #6662 and #9919.
1406 ;; 2011/10/24 dadams
1407 ;; Protect dired-show-file-type with fboundp.
1408 ;; 2011/09/03 dadams
1409 ;; diredp-do-grep-1: Map shell-quote-argument over file names. Thx to Joe Bloggs.
1410 ;; 2011/08/07 dadams
1411 ;; diredp-bookmark (need to keep in sync with bmkp-make-record-for-target-file):
1412 ;; Instead of image-bookmark-make-record, use explicit function that includes file, type.
1413 ;; 2011/07/25 dadams
1414 ;; Changed featurep to eval-after-load, for bookmark+-1.el and w32-browser.el.
1415 ;; 2011/07/01 dadams
1416 ;; Fixed typo: dired-toggle-find-file-reuse-dir -> ...diredp.... Thx to pasja on Emacs Wiki.
1417 ;; 2011/06/18 dadams
1418 ;; Added: diredp-describe-mode, diredp-dired-plus-help(-link), diredp-help-button,
1419 ;; diredp-dired-plus-description(+links), diredp-send-bug-report.
1420 ;; Bound diredp-describe-mode to whatever describe-mode is bound to.
1421 ;; All menus, :enable with mark-active: Added transient-mark-mode and mark != point.
1422 ;; toggle-diredp-find-file-reuse-dir: Swapped which one is the alias.
1423 ;; diredp-w32-list-mapped-drives: Display *Shell Command Output* at end.
1424 ;; diredp-mouse-(describe-file|3-menu|mark/unmark|(find|view)-file(-other-window)):
1425 ;; save-excursion set-buffer -> with-current-buffer.
1426 ;; 2011/06/08 dadams
1427 ;; Added: diredp-dired-for-files(-other-window).
1428 ;; 2011/06/07 dadams
1429 ;; Bound dired-show-file-type to _, since y is diredp-relsymlink-this-file.
1430 ;; 2011/04/25 dadams
1431 ;; Added (from files+.el): dired(-mouse)-describe-file. Bound to C-h (C-)RET, added to menus.
1432 ;; 2011/04/23 dadams
1433 ;; Added, bound (T c, T M-w, T 0, T v, T p, T C-y, T q), and added to menus:
1434 ;; diredp-copy-tags-this-file, diredp-mouse-copy-tags,
1435 ;; diredp(-mouse)(-do)-remove-all-tags(-this-file),
1436 ;; diredp(-mouse)(-do)-set-tag-value(-this-file),
1437 ;; diredp(-mouse)(-do)-paste-(add|replace)-tags(-this-file).
1438 ;; diredp-mark-files-tagged-(all/none|some/not-all): Bound free var presentp.
1439 ;; dired-map-over-marks: Corrected: Bind NEWARG and use that, not ARG.
1440 ;; dired-get-marked-files: let* -> let.
1441 ;; dired-do-redisplay, diredp-mouse-diff: when/if -> and.
1442 ;; dired-readin-insert, dired-get-filename: if -> unless/when.
1443 ;; diredp-mouse-find-file-reuse-dir-buffer: with-current-buffer, not save...
1444 ;; diredp-mouse-mark/unmark: Removed unused bol/eol vars.
1445 ;; 2011/04/19 dadams
1446 ;; Added: diredp-(un)mark-files-tagged-((not-)all|none|some|regexp|all/none|some/not-all),
1447 ;; dired-mark-if. Added Tagged submenu for Mark menu.
1448 ;; Put tags commands on prefix key T, as in Bookmark+. Removed C-(M-)+/- tags-cmd bindings.
1449 ;; diredp-untag-this-file: Added prefix-arg behavior.
1450 ;; 2011/04/18 dadams
1451 ;; Added: diredp-prompt-for-bookmark-prefix-flag.
1452 ;; Use it in diredp(-mouse)-do-(un)tag, diredp-read-bookmark-file-args,
1453 ;; diredp(-mouse)-do-bookmark, diredp-(bookmark|(un)tag)-this-file.
1454 ;; diredp-(bookmark|(un)tag)-this-file, diredp(-do)-bookmark, diredp-(un)tag,
1455 ;; diredp-do-bookmark-in-bookmark-file, diredp-set-bookmark-file-bookmark-for-marked:
1456 ;; Made PREFIX arg optional.
1457 ;; 2011/04/17 dadams
1458 ;; Added: diredp-(bookmark|(un)tag)-this-file, diredp(-mouse)(-do)-(un)tag.
1459 ;; diredp-mouse-3-menu: Added: diredp-mouse-do-(un)tag.
1460 ;; diredp-menu-bar-immediate-menu: Added diredp-(un)tag-this-file, diredp-bookmark-this-file.
1461 ;; diredp-menu-bar-operate-menu: Added diredp-do-(un)tag.
1462 ;; Bound diredp-do-tag to C-+, diredp-tag-this-file to C-M-+, diredp-do-untag to C--,
1463 ;; diredp-untag-this-file to C-M--, diredp-bookmark-this-file to C-B.
1464 ;; diredp-bookmark: Use bmkp-autofile-set, not bmkp-file-target-set, so get autofile.
1465 ;; diredp-read-bookmark-file-args, diredp(-mouse)-do-bookmark:
1466 ;; Default for prefix is now an empty string, not the directory.
1467 ;; diredp-mouse-do-bookmark: Removed optional second arg.
1468 ;; Corrected typo: direp-read-bookmark-file-args -> diredp-read-bookmark-file-args.
1469 ;; 2011/03/25 dadams
1470 ;; diredp-bookmark: Fixed typo: bmkp-file-indirect-set -> bmkp-file-target-set.
1471 ;; 2011/02/11 dadams
1472 ;; diredp-deletion, diredp-deletion-file-name, diredp-executable-tag:
1473 ;; Made default the same for dark background as for light.
1474 ;; diredp-ignored-file-name: Made default a bit darker for dark background.
1475 ;; 2011/02/03 dadams
1476 ;; All deffaces: Provided default values for dark-background screens too.
1477 ;; 2011/01/12 dadams
1478 ;; dired-do-flagged-delete: Removed sit-for added on 1/02.
1479 ;; 2011/01/04 dadams
1480 ;; defsubst -> defun everywhere.
1481 ;; Removed autoload cookies from non def* sexps, defvar, and non-interactive functions.
1482 ;; Added some missing autoload cookies for defcustom and commands.
1483 ;; 2011/01/02 dadams
1484 ;; Added: diredp-this-file-(un)marked-p, diredp-toggle-marks-in-region.
1485 ;; diredp-(un)mark-region-files, diredp-flag-region-files-for-deletion:
1486 ;; Act only on marked/unmarked files (opposite). Fix 2nd arg to dired-mark-if.
1487 ;; diredp-mouse-3-menu:
1488 ;; If region is active and mouse3.el was loaded, then use its popup.
1489 ;; Fix Toggle Marked/Unmarked:
1490 ;; Use diredp-toggle-marks-in-region, so widen, show details and use bol/eol.
1491 ;; dired-do-flagged-delete: Added sit-for.
1492 ;; 2010/11/28 dadams
1493 ;; diredp-mouse-3-menu: Added Toggle Marked/Unmarked for region menu.
1494 ;; 2010/10/20 dadams
1495 ;; Moved Emacs 20 tweak to recognize k in file sizes to var dired-move-to-filename-regexp.
1496 ;; Added diredp-loaded-p.
1497 ;; 2010/10/19 dadams
1498 ;; diredp-font-lock-keywords-1:
1499 ;; Handle decimal pt in file size. Thx to Michael Heerdegen.
1500 ;; Enable Emacs 20/21 to handle -h option (decimal point size).
1501 ;; Renamed: face diredp-inode+size to diredp-number.
1502 ;; 2010/10/01 dadams
1503 ;; dired-goto-file: Avoid infloop from looking for dir line. Thx to not-use.dilines.net.
1504 ;; 2010/09/29 dadams
1505 ;; Added: diredp-dired-union(-1|-other-window|-interactive-spec).
1506 ;; dired-goto-file: fix for Emacs bug #7126.
1507 ;; 2010/09/27 dadams
1508 ;; Renamed diredp-dired-interactive-spec to diredp-dired-files-interactive-spec.
1509 ;; diredp-dired-files-interactive-spec: Respect file-list arg: kill existing Dired buffer.
1510 ;; Fix use of prefix arg for switches.
1511 ;; 2010/09/26 dadams
1512 ;; Added: dired-insert-directory: Compute WILDCARD arg for individual files.
1513 ;; Added: dired-readin-insert: Use t as WILDCARD arg to dired-insert-directory.
1514 ;; Added: diredp-dired-files(-other-window), diredp-dired-interactive-spec.
1515 ;; 2010/08/27 dadams
1516 ;; Use diredp-font-lock-keywords-1 properly as a second level of fontification.
1517 ;; Added: diredp-w32-drives(-mode(-map)), dired-up-directory.
1518 ;; 2010/08/07 dadams
1519 ;; dired-map-over-marks: Removed loop that used dired-between-files.
1520 ;; diredp-get-file-or-dir-name: test against subdir/..? also.
1521 ;; dired-do-find-marked-files: Pass original ARG to dired-get-marked-files.
1522 ;; 2010/08/05 dadams
1523 ;; diredp-bookmark:
1524 ;; Handle image files (and sound files, if Bookmark+ is used).
1525 ;; Use bmkp-file-indirect-set if available.
1526 ;; Use error-message-string to get failure msg.
1527 ;; 2010/07/11 dadams
1528 ;; Added: diredp-set-bookmark-file-bookmark-for-marked (C-M-b), diredp-mouse-do-bookmark,
1529 ;; diredp-do-bookmark-in-bookmark-file (C-M-B, aka C-M-S-b), diredp-read-bookmark-file-args.
1530 ;; Added them to the operate menu. Added diredp-do-bookmark to mouse-3 menu.
1531 ;; 2010/07/07 dadams
1532 ;; dired-do-*: Updated doc strings for prefix arg treatment from dired-map-over-marks-check.
1533 ;; Added missing autoload cookies.
1534 ;; 2010/05/29 dadams
1535 ;; diredp-bookmark: Use relative file name in bookmark name.
1536 ;; Removed defvar of directory-listing-before-filename-regexp.
1537 ;; 2010/05/28 dadams
1538 ;; Changed menu item for dired-create-directory to New Directory. Moved it before Up Dir.
1539 ;; 2010/03/19 dadams
1540 ;; diredp-font-lock-keywords-1: Handle date+time wrt regexp changes for Emacs 23.2.
1541 ;; 2010/01/31 dadams
1542 ;; diredp-bookmark:
1543 ;; Don't use bookmark-set or find-file-noselect - inline the needed bookmark-store code.
1544 ;; Call bookmark-maybe-load-default-file. Use rudimentary bookmark-make-record-function.
1545 ;; 2010/01/21 dadams
1546 ;; Renamed:
1547 ;; diredp-subst-find-alternate-for-find to diredp-make-find-file-keys-reuse-dirs
1548 ;; diredp-subst-find-for-find-alternate to diredp-make-find-file-keys-not-reuse-dirs.
1549 ;; diredp-make-find-file-keys(-not)-reuse-dirs: Handle also dired(-mouse)-w32-browser.
1550 ;; 2010/01/10 dadams
1551 ;; Added: face diredp-inode+size. Use in diredp-font-lock-keywords-1.
1552 ;; diredp-font-lock-keywords-1: Allow decimal point in file size. Thx to Regis.
1553 ;; 2010/01/05 dadams
1554 ;; dired-insert-set-properties:
1555 ;; Add text property dired-filename to the file name (for Emacs 23).
1556 ;; 2009/10/23 dadams
1557 ;; diredp-font-lock-keywords-1: Override `l' and `t' matches in headings with default face.
1558 ;; 2009/10/13 dadams
1559 ;; Added: diredp(-do)-bookmark. Added to Multiple menu, and bound to M-b.
1560 ;; 2009/10/11 dadams
1561 ;; diredp-menu-bar-immediate-menu:
1562 ;; Added items: image display items, dired-maybe-insert-subdir.
1563 ;; Test dired-do-relsymlink, not diredp-relsymlink-this-file.
1564 ;; diredp-menu-bar-operate-menu:
1565 ;; Added items: epa encryption items, image items, isearch items.
1566 ;; diredp-menu-bar-subdir-menu:
1567 ;; Added items: revert, isearch file names, dired-compare-directories.
1568 ;; Removed macro menu-item-any-version - use menu-item everywhere (works for Emacs 20+).
1569 ;; Added wdired-change-to-wdired-mode to subdir menu even for Emacs 20, if defined.
1570 ;; 2009/07/09 dadams
1571 ;; dired-goto-file: Make sure we have a string before calling directory-file-name.
1572 ;; 2009/05/08 dadams
1573 ;; dired-find-file (Emacs 20): Raise error if dired-get-filename returns nil.
1574 ;; 2009/04/26 dadams
1575 ;; dired-insert-set-properties, diredp-(un)mark-region-files,
1576 ;; diredp-flag-region-files-for-deletion, diredp-mouse-3-menu, diredp-mouse-mark/unmark:
1577 ;; Bind inhibit-field-text-motion to t, to ensure real eol.
1578 ;; 2008/12/17 dadams
1579 ;; diredp-font-lock-keywords-1: Don't do diredp-deletion, diredp-flag-mark for empty lines.
1580 ;; 2008/09/22 dadams
1581 ;; Added: diredp-fileset, diredp-get-file-or-dir-name, and redefinitions of
1582 ;; dired-map-over-marks, dired-find-file, and dired-mouse-find-file-other-window.
1583 ;; Added vanilla code to pick up macro dired-map-over-marks:
1584 ;; dired-get-marked-files, dired-do-delete, dired-map-over-marks-check,
1585 ;; dired-do-redisplay, image-dired-dired-insert-marked-thumbs.
1586 ;; diredp-find-file-other-frame, diredp-mouse-(find|view)-file:
1587 ;; Added nil t args to dired-get-filename calls.
1588 ;; diredp-do-grep(-1): Use new dired-get-marked-files instead of ad-hoc treatment of C-u.
1589 ;; 2008/09/21 dadams
1590 ;; diredp-marked(-other-window): Don't treat zero prefix arg as numerical (no empty Dired).
1591 ;; Added dired-find-file redefinition for Emacs 20.
1592 ;; 2008/09/11 dadams
1593 ;; diredp-do-grep: Plain C-u means grep all files in Dired buffer.
1594 ;; diredp-do-grep-1: Treat 'all value of FILES arg.
1595 ;; Added: diredp-all-files.
1596 ;; 2008/09/09 dadams
1597 ;; Added: diredp-marked(-other-window). Added to menus. Bound *-other-window to C-M-*.
1598 ;; 2008/09/07 dadams
1599 ;; Added: diredp(-mouse)-do-grep(-1), diredp-grep-this-file.
1600 ;; Bound diredp-do-grep to M-g. Added grep commands to menus.
1601 ;; 2008/07/18 dadams
1602 ;; Soft-require w32-browser.el. Bind its commands in Dired map and menus.
1603 ;; 2008/03/08 dadams
1604 ;; dired-maybe-insert-subdir: Fit one-window frame after inserting subdir.
1605 ;; 2008/03/07 dadams
1606 ;; Added: redefinitions of dired-maybe-insert-subdir, dired-goto-file, dired-get-filename.
1607 ;; Added: diredp-this-subdir.
1608 ;; 2007/11/27 dadams
1609 ;; diredp-mouse(-backup)-diff: If available, use icicle-read-string-completing.
1610 ;; 2007/09/23 dadams
1611 ;; Removed second arg to undefine-killer-commands.
1612 ;; 2007/07/27 dadams
1613 ;; diredp-font-lock-keywords-1: Allow also for bz2 compressed files - Thx to Andreas Eder.
1614 ;; 2006/09/03 dadams
1615 ;; diredp-font-lock-keywords-1: Corrected file size and inode number. Thx to Peter Barabas.
1616 ;; 2006/08/20 dadams
1617 ;; Added: diredp-find-a-file*.
1618 ;; 2006/06/18 dadams
1619 ;; diredp-font-lock-keywords-1: Highlight file name (also) of flagged files.
1620 ;; Use dired-del-marker instead of literal D.
1621 ;; Added: diredp-deletion-file-name.
1622 ;; 2006/03/31 dadams
1623 ;; No longer use display-in-minibuffer.
1624 ;; 2006/01/07 dadams
1625 ;; Added: link for sending bug report.
1626 ;; 2006/01/06 dadams
1627 ;; Added defgroup Dired-Plus and used it. Added :link.
1628 ;; 2006/01/04 dadams
1629 ;; Added defvar of directory-listing-before-filename-regexp, for Emacs 22 compatibility.
1630 ;; 2005/12/29 dadams
1631 ;; Added: diredp-mouse-mark/unmark-mark-region-files.
1632 ;; 2005/12/26 dadams
1633 ;; Updated groups.
1634 ;; 2005/12/05 dadams
1635 ;; diredp-ignored-file-name: Made it slightly darker.
1636 ;; 2005/11/05 dadams
1637 ;; Renamed all stuff defined here to have diredp- prefix.
1638 ;; diredp-relsymlink-this-file: Protected with fboundp.
1639 ;; Changed to soft require: dired-x.el.
1640 ;; Removed comment to require this inside eval-after-load.
1641 ;; 2005/11/03 dadams
1642 ;; Added: dired-display-msg. Replace blue-foreground-face with it.
1643 ;; Alias dired-do-toggle to dired-toggle-marks, if defined.
1644 ;; 2005/11/02 dadams
1645 ;; Added: dired-get-file-for-visit, dired(-mouse)-find-alternate-file*,
1646 ;; togglep-dired-find-file-reuse-dir, dired+-subst-find-*.
1647 ;; Use defface for all faces. Renamed without "-face". No longer require def-face-const.
1648 ;; dired-simultaneous-find-file: Minor bug fix (typo).
1649 ;; 2005/07/10 dadams
1650 ;; dired-unmark-all-files-no-query -> dired-unmark-all-marks
1651 ;; (thanks to Sivaram Neelakantan for bug report).
1652 ;; 2005/05/25 dadams
1653 ;; string-to-int -> string-to-number everywhere.
1654 ;; 2005/05/17 dadams
1655 ;; Updated to work with Emacs 22.x.
1656 ;; 2005/02/16 dadams
1657 ;; Added dired-mark/unmark-extension. Replaced dired-mark-extension with it everywhere.
1658 ;; 2005/01/08 dadams
1659 ;; Bind [S-mouse-1], instead of [S-down-mouse-1], to dired-mouse-mark-region-files.
1660 ;; 2004/11/20 dadams
1661 ;; dired-mark-sexp: Search for literal month names only for versions before Emacs 20.
1662 ;; Refined to deal with Emacs 21 < 21.3.50 (soon to be 22.x)
1663 ;; 2004/11/14 dadams
1664 ;; Bound dired-no-confirm to non-nil for dired-mouse-*.
1665 ;; Updated for Emacs 21 and improved highlighting:
1666 ;; Spaces OK in file and directory names. Highlight date/time and size.
1667 ;; 2004/10/17 dadams
1668 ;; Require cl only for Emacs 20, and only when compile.
1669 ;; 2004/10/01 dadams
1670 ;; Updated to work with Emacs 21 also.
1671 ;; 2004/04/02 dadams
1672 ;; dired-font-lock-keywords-1: Prefer using dired-omit-extensions
1673 ;; to completion-ignored-extensions, if available.
1674 ;; 2004/03/22 dadams
1675 ;; Added dired-mouse-mark-region-files and dired-mouse-mark/unmark.
1676 ;; 2000/09/27 dadams
1677 ;; 1. dired-font-lock-keywords-1: fixed for spaces in dir names.
1678 ;; 2. Added: dired-buffers-for-dir.
1679 ;; 1999/09/06 dadams
1680 ;; Added S-*-mouse-2 bindings (same as C-*-mouse-2).
1681 ;; 1999/08/26 dadams
1682 ;; 1. Added *-face vars and dired-font-lock-keywords-1.
1683 ;; 2. Added possibility to use dired-font-lock-keywords-1 via hook.
1684 ;; 1999/08/26 dadams
1685 ;; Changed key binding of dired-mouse-find-file from down-mouse-2 to mouse-2.
1686 ;; 1999/08/25 dadams
1687 ;; Changed (C-)(M-)mouse-2 bindings.
1688 ;; 1999/08/25 dadams
1689 ;; 1. Added cmds & menu bar and key bindings: (dired-)find-file-other-frame.
1690 ;; 2. Changed binding for dired-display-file.
1691 ;; 1999/03/26 dadams
1692 ;; 1. Get rid of Edit menu-bar menu.
1693 ;; 2. dired-mouse-3-menu: Changed popup titles and item names.
1694 ;;
1695 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1696 ;;
1697 ;; This program is free software; you can redistribute it and/or modify
1698 ;; it under the terms of the GNU General Public License as published by
1699 ;; the Free Software Foundation; either version 2, or (at your option)
1700 ;; any later version.
1701
1702 ;; This program is distributed in the hope that it will be useful,
1703 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1704 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1705 ;; GNU General Public License for more details.
1706
1707 ;; You should have received a copy of the GNU General Public License
1708 ;; along with this program; see the file COPYING. If not, write to
1709 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
1710 ;; Floor, Boston, MA 02110-1301, USA.
1711 ;;
1712 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1713 ;;
1714 ;;; Code:
1715
1716 (eval-when-compile (require 'cl)) ;; case (plus, for Emacs 20: dolist, pop, push)
1717 (eval-when-compile (require 'easymenu)) ;; easy-menu-create-menu
1718
1719 (require 'dired) ;; dired-revert
1720 (require 'dired-aux) ;; dired-bunch-files, dired-do-chxxx, dired-do-create-files,
1721 ;; dired-mark-read-string, dired-read-shell-command,
1722 ;; dired-run-shell-command, dired-shell-stuff-it
1723 (require 'dired-x nil t) ;; (no error if not found) dired-do-relsymlink
1724 (require 'autofit-frame nil t) ;; (no error if not found) fit-frame-if-one-window
1725 (require 'bookmark+ nil t) ;; (no error if not found)
1726 ;; bmkp-autofile-add-tags, bmkp-autofile-remove-tags, bmkp-autofile-set, bmkp-copied-tags,
1727 ;; bmkp-current-bookmark-file, bmkp-describe-bookmark, bmkp-empty-file, bmkp-get-autofile-bookmark,
1728 ;; bmkp-get-bookmark-in-alist, bmkp-get-tags, bmkp-read-tag-completing,
1729 ;; bmkp-read-tags-completing, bmkp-refresh/rebuild-menu-list, bmkp-remove-all-tags,
1730 ;; bmkp-same-file-p, bmkp-set-bookmark-file-bookmark, bmkp-set-sequence-bookmark,
1731 ;; bmkp-set-tag-value, bmkp-some, bmkp-switch-bookmark-file, bmkp-tag-name
1732
1733 ;; For now at least, `highlight.el' is needed only if you use `bookmark+.el'.
1734 (when (featurep 'bookmark+) (require 'highlight nil t)) ;; (no error if not found):
1735 ;; hlt-highlight-region
1736
1737 (if (> emacs-major-version 21) (require 'help-fns+ nil t) (require 'help+20 nil t)) ;; (no error if not found):
1738 ;; describe-file
1739
1740 (require 'misc-fns nil t) ;; (no error if not found): undefine-killer-commands
1741 (require 'image-file nil t) ;; (no error if not found): image-file-name-regexp
1742 (require 'image-dired nil t) ;; (no error if not found):
1743 ;; image-dired-create-thumb, image-dired-create-thumbnail-buffer,
1744 ;; image-dired-dired-after-readin-hook, image-dired-delete-tag, image-dired-dired-comment-files,
1745 ;; image-dired-dired-display-external, image-dired-dired-display-image,
1746 ;; image-dired-display-thumbs, image-dired-get-comment, image-dired-get-exif-file-name,
1747 ;; image-dired-get-thumbnail-image, image-dired-insert-thumbnail, image-dired-line-up,
1748 ;; image-dired-line-up-dynamic, image-dired-line-up-interactive, image-dired-line-up-method,
1749 ;; image-dired-list-tags, image-dired-main-image-directory, image-dired-mark-tagged-files,
1750 ;; image-dired-read-comment, image-dired-remove-tag, image-dired-save-information-from-widgets,
1751 ;; image-dired-tag-files, image-dired-thumb-height, image-dired-thumbnail-buffer,
1752 ;; image-dired-thumb-name, image-dired-thumb-size, image-dired-thumb-width,
1753 ;; image-dired-widget-list, image-dired-write-comments, image-dired-write-tags
1754 (when (memq system-type '(windows-nt ms-dos))
1755 ;; (no error if not found):
1756 (require 'w32-browser nil t));; dired-w32explore, dired-w32-browser, dired-mouse-w32-browser,
1757 ;; dired-multiple-w32-browser
1758 (when (< emacs-major-version 21) (require 'subr-21)) ;; replace-regexp-in-string
1759
1760 ;; Provide macro for code byte-compiled using Emacs < 22.
1761 (eval-when-compile
1762 (when (< emacs-major-version 22)
1763 (defmacro minibuffer-with-setup-hook (fun &rest body)
1764 "Temporarily add FUN to `minibuffer-setup-hook' while executing BODY.
1765 BODY should use the minibuffer at most once.
1766 Recursive uses of the minibuffer are unaffected (FUN is not
1767 called additional times).
1768
1769 This macro actually adds an auxiliary function that calls FUN,
1770 rather than FUN itself, to `minibuffer-setup-hook'."
1771 ;; (declare (indent 1) (debug t))
1772 (let ((hook (make-symbol "setup-hook")))
1773 `(let (,hook)
1774 (setq ,hook (lambda ()
1775 ;; Clear out this hook so it does not interfere
1776 ;; with any recursive minibuffer usage.
1777 (remove-hook 'minibuffer-setup-hook ,hook)
1778 (funcall ,fun)))
1779 (unwind-protect
1780 (progn (add-hook 'minibuffer-setup-hook ,hook) ,@body)
1781 (remove-hook 'minibuffer-setup-hook ,hook)))))))
1782
1783 ;; Define these for Emacs 20 and 21.
1784 (unless (fboundp 'dired-get-file-for-visit) ; Emacs 22+
1785 (defun dired-get-file-for-visit () ; Not bound
1786 "Get the current line's file name, with an error if file does not exist."
1787 (interactive)
1788 (let ((raw (dired-get-filename nil t)) ; Pass t for second arg so no error for `.' and `..'.
1789 file-name)
1790 (unless raw (error "No file on this line"))
1791 (setq file-name (file-name-sans-versions raw t))
1792 (if (file-exists-p file-name)
1793 file-name
1794 (if (file-symlink-p file-name)
1795 (error "File is a symlink to a nonexistent target")
1796 (error "File no longer exists; type `g' to update Dired buffer")))))
1797
1798 (defun dired-find-alternate-file () ; Not bound
1799 "In Dired, visit this file or directory instead of the Dired buffer."
1800 (interactive)
1801 (set-buffer-modified-p nil)
1802 (find-alternate-file (dired-get-file-for-visit))))
1803
1804 ;;;;;;;;;;;;;;;;;;;;;;;
1805
1806
1807 (provide 'dired+)
1808 (require 'dired+) ; Ensure loaded before compile this.
1809
1810 ;; Quiet the byte-compiler.
1811 (defvar bmkp-copied-tags) ; In `bookmark+-1.el'
1812 (defvar bmkp-current-bookmark-file) ; In `bookmark+-1.el'
1813 (defvar bookmark-default-file) ; In `bookmark.el'
1814 (defvar compilation-current-error) ; In `compile.el'
1815 (defvar delete-by-moving-to-trash) ; Built-in, Emacs 23+
1816 (defvar dired-auto-revert-buffer) ; In `dired.el', Emacs 23+
1817 (defvar dired-details-state) ; In `dired-details+.el'
1818 (defvar dired-keep-marker-hardlink) ; In `dired-x.el'
1819 (defvar dired-recursive-deletes) ; In `dired.el', Emacs 22+
1820 (defvar dired-shrink-to-fit) ; In `dired.el'
1821 (defvar dired-switches-alist) ; In `dired.el'
1822 (defvar dired-subdir-switches) ; In `dired.el'
1823 (defvar dired-touch-program) ; Emacs 22+
1824 (defvar dired-use-ls-dired) ; Emacs 22+
1825 (defvar diredp-count-.-and-..-flag) ; Here, Emacs 22+
1826 (defvar diredp-hide-details-initially-flag) ; Here, Emacs 24.4+
1827 (defvar diredp-hide-details-last-state) ; Here, Emacs 24.4+
1828 (defvar diredp-hide-details-propagate-flag) ; Here, Emacs 24.4+
1829 (defvar diredp-hide-details-toggled) ; Here, Emacs 24.4+
1830 (defvar diredp-highlight-autofiles-mode) ; Here, Emacs 22+
1831 (defvar diredp-menu-bar-encryption-menu) ; Here, Emacs 23+
1832 (defvar diredp-menu-bar-images-recursive-menu) ; Here (old name)
1833 (defvar diredp-menu-bar-regexp-recursive-menu) ; Here (old name)
1834 (defvar diredp-menu-bar-subdir-menu) ; Here (old name)
1835 (defvar diredp-single-bookmarks-menu) ; Here, if Bookmark+ is available
1836 (defvar filesets-data) ; In `filesets.el'
1837 (defvar grep-use-null-device) ; In `grep.el'
1838 (defvar header-line-format) ; Emacs 22+
1839 (defvar icicle-file-sort) ; In `icicles-opt.el'
1840 (defvar icicle-file-sort-first-time-p) ; In `icicles-var.el'
1841 (defvar icicle-files-ido-like-flag) ; In `icicles-opt.el'
1842 (defvar icicle-ignored-directories) ; In `icicles-opt.el'
1843 (defvar icicle-sort-comparer) ; In `icicles-opt.el'
1844 (defvar image-dired-display-image-buffer) ; In `image-dired.el'
1845 (defvar image-dired-line-up-method) ; In `image-dired.el'
1846 (defvar image-dired-main-image-directory) ; In `image-dired.el'
1847 (defvar image-dired-thumbnail-buffer) ; In `image-dired.el'
1848 (defvar image-dired-thumb-height) ; In `image-dired.el'
1849 (defvar image-dired-thumb-width) ; In `image-dired.el'
1850 (defvar image-dired-widget-list) ; In `image-dired.el'
1851 (defvar ls-lisp-use-insert-directory-program) ; In `ls-lisp.el'
1852 (defvar minibuffer-default-add-function) ; In `simple.el', Emacs 23+
1853 (defvar mouse3-dired-function) ; In `mouse3.el'
1854 (defvar read-file-name-completion-ignore-case) ; In `minibuffer.el', Emacs 23+. In C code, Emacs 22.
1855 (defvar recentf-list) ; In `recentf.el'
1856 (defvar switch-to-buffer-preserve-window-point) ; In `window.el', Emacs 24+
1857 (defvar tooltip-mode) ; In `tooltip.el'
1858 (defvar vc-directory-exclusion-list) ; In `vc'
1859 (defvar w32-browser-wait-time) ; In `w32-browser.el'
1860
1861 ;;;;;;;;;;;;;;;;;;;;;;;
1862
1863 (defgroup Dired-Plus nil
1864 "Various enhancements to Dired."
1865 :prefix "diredp-" :group 'dired
1866 :link `(url-link :tag "Send Bug Report"
1867 ,(concat "mailto:" "drew.adams" "@" "oracle" ".com?subject=\
1868 dired+.el bug: \
1869 &body=Describe bug here, starting with `emacs -q'. \
1870 Don't forget to mention your Emacs and library versions."))
1871 :link '(url-link :tag "Other Libraries by Drew"
1872 "https://www.emacswiki.org/emacs/DrewsElispLibraries")
1873 :link '(url-link :tag "Download"
1874 "https://www.emacswiki.org/emacs/download/dired%2b.el")
1875 :link '(url-link :tag "Description"
1876 "https://www.emacswiki.org/emacs/DiredPlus")
1877 :link '(emacs-commentary-link :tag "Commentary" "dired+"))
1878
1879 ;;; Variables
1880
1881 ;; `dired-do-toggle' was renamed to `dired-toggle-marks' after Emacs 20.
1882 (unless (fboundp 'dired-toggle-marks) (defalias 'dired-toggle-marks 'dired-do-toggle))
1883
1884 ;;; This is duplicated in `diff.el' and `vc.el'.
1885 ;;;###autoload
1886 (defcustom diff-switches "-c"
1887 "*A string or list of strings specifying switches to be passed to diff."
1888 :type '(choice string (repeat string))
1889 :group 'dired :group 'diff)
1890
1891 ;;;###autoload
1892 (defcustom diredp-auto-focus-frame-for-thumbnail-tooltip-flag nil
1893 "*Non-nil means automatically focus the frame for a thumbnail tooltip.
1894 If nil then you will not see a thumbnail image tooltip when you
1895 mouseover an image-file name in Dired, unless you first give the frame
1896 the input focus (e.g., by clicking its title bar).
1897
1898 This option has no effect if `diredp-image-preview-in-tooltip' is nil.
1899 It also has no effect for Emacs versions prior to Emacs 22."
1900 :type 'boolean :group 'Dired-Plus)
1901
1902 ;;;###autoload
1903 (defcustom diredp-bind-problematic-terminal-keys t
1904 "*Non-nil means bind some keys that might not work in a text-only terminal.
1905 This applies to keys that use modifiers Meta and Shift together.
1906 If you use Emacs in text-only terminal and your terminal does not
1907 support the use of such keys then customize this option to nil."
1908 :type 'boolean :group 'Dired-Plus)
1909
1910 ;;;###autoload
1911 (defcustom diredp-compressed-extensions '(".tar" ".taz" ".tgz" ".arj" ".lzh"
1912 ".lzma" ".xz" ".zip" ".z" ".Z" ".gz" ".bz2")
1913 "*List of compressed-file extensions, for highlighting."
1914 :type '(repeat string) :group 'Dired-Plus)
1915
1916 (when (> emacs-major-version 21) ; Emacs 22+
1917 (defcustom diredp-count-.-and-..-flag nil
1918 "Non-nil means count `.' and `..' when counting files for mode-line."
1919 :type 'boolean :group 'Dired-Plus))
1920
1921 ;;;###autoload
1922 (defcustom diredp-dwim-any-frame-flag pop-up-frames
1923 "*Non-nil means the target directory can be in a window in another frame.
1924 Only visible frames are considered.
1925 This is used by ``dired-dwim-target-directory'.
1926 This option has no effect for Emacs versions before Emacs 22."
1927 :type 'boolean :group 'Dired-Plus)
1928
1929 (when (fboundp 'dired-hide-details-mode) ; Emacs 24.4+
1930 (defcustom diredp-hide-details-initially-flag t
1931 "*Non-nil means hide details in Dired from the outset."
1932 :type 'boolean :group 'Dired-Plus
1933 :set (lambda (sym defs)
1934 (custom-set-default sym defs)
1935 (setq diredp-hide-details-last-state diredp-hide-details-initially-flag)))
1936
1937 (defcustom diredp-hide-details-propagate-flag t
1938 "*Non-nil means display the next Dired buffer the same way as the last.
1939 The last `dired-hide-details-mode' value set is used by the next Dired
1940 buffer created."
1941 :type 'boolean :group 'Dired-Plus))
1942
1943 ;; Emacs 20 only.
1944 ;;;###autoload
1945 (unless (fboundp 'define-minor-mode)
1946 (defcustom diredp-highlight-autofiles-mode t
1947 "*Non-nil means highlight names of files that are autofile bookmarks.
1948 Autofiles that have tags are highlighted using face
1949 `diredp-tagged-autofile-name'. Those with no tags are highlighted
1950 using face `diredp-autofile-name'.
1951
1952 Setting this option directly does not take effect; use either
1953 \\[customize] or command `diredp-highlight-autofiles-mode'.
1954
1955 NOTE: When `dired+.el' is loaded (for the first time per Emacs
1956 session), the highlighting is turned ON, regardless of the option
1957 value. To prevent this and have the highlighting OFF by default, you
1958 must do one of the following:
1959
1960 * Put (diredp-highlight-autofiles-mode -1) in your init file, AFTER
1961 it loads `dired+.el'.
1962
1963 * Customize the option to `nil', AND ensure that your `custom-file'
1964 (or the `custom-saved-variables' part of your init file) is
1965 evaluated before `dired+.el' is loaded.
1966
1967 This option has no effect unless you use libraries `Bookmark and
1968 `highlight.el'."
1969 :set (lambda (symbol value) (diredp-highlight-autofiles-mode (if value 1 -1)))
1970 :initialize 'custom-initialize-default
1971 :type 'boolean :group 'Dired-Plus :require 'dired+))
1972
1973 ;;;###autoload
1974 (defcustom diredp-ignore-compressed-flag t
1975 "*Non-nil means to font-lock names of compressed files as ignored files.
1976 This applies to filenames whose extensions are in
1977 `diredp-compressed-extensions'. If nil they are highlighted using
1978 face `diredp-compressed-file-name'."
1979 :type 'boolean :group 'Dired-Plus)
1980
1981 ;;;###autoload
1982 (defcustom diredp-image-preview-in-tooltip (or (and (boundp 'image-dired-thumb-size) image-dired-thumb-size)
1983 100)
1984 "*Whether and what kind of image preview to show in a tooltip.
1985 The possible values are:
1986
1987 `nil' : do not show a tooltip preview
1988 integer N>0 : show a thumbnail preview of that size
1989 `full' : show a full-size preview of the image
1990
1991 To enable tooltip image preview you must turn on `tooltip-mode' and
1992 load library `image-dired.el'. See also option
1993 `diredp-auto-focus-frame-for-thumbnail-tooltip-flag'.
1994
1995 This option has no effect for Emacs versions prior to Emacs 22."
1996 :type '(choice
1997 (restricted-sexp :tag "Show a thumnail image of size"
1998 :match-alternatives ((lambda (x) (and (wholenump x) (not (zerop x))))))
1999 (const :tag "Show a full-size image preview" full)
2000 (const :tag "OFF: Do not show an image preview" nil))
2001 :group 'Dired-Plus)
2002
2003 ;;;###autoload
2004 (defcustom diredp-image-show-this-file-use-frame-flag t
2005 "Non-nil means `diredp-image-show-this-file' uses another frame.
2006 If nil then it uses another window. Using another frame means you
2007 have more control over the image size when you use a prefix arg.
2008
2009 If it uses another window then the prefix arg controls only the
2010 minimum window height, not necessarily the image scale (height).
2011
2012 \(If the buffer displaying the image is already considered a
2013 special-display buffer by your Emacs setup, then a nil value of this
2014 option has no effect.)"
2015 :type 'boolean :group 'Dired-Plus)
2016
2017 ;;;###autoload
2018 (defcustom diredp-max-frames 200
2019 "*Max number of frames, for commands that find files in separate frames.
2020 These commands are `dired-do-find-marked-files' and
2021 `diredp-do-find-marked-files-recursive'. See their descriptions for
2022 the circumstances in which they show the files in separate frames."
2023 :type '(restricted-sexp :match-alternatives ((lambda (x) (and (wholenump x) (not (zerop x))))))
2024 :group 'Dired-Plus)
2025
2026 ;;;###autoload
2027 (defcustom diredp-prompt-for-bookmark-prefix-flag nil
2028 "*Non-nil means prompt for a prefix string for bookmark names."
2029 :type 'boolean :group 'Dired-Plus)
2030
2031 ;;;###autoload
2032 (defcustom diredp-w32-local-drives '(("C:" "Local disk"))
2033 "*Local MS Windows drives that you want to use for `diredp-w32-drives'.
2034 Each entry is a list (DRIVE DESCRIPTION), where DRIVE is the drive
2035 name and DESCRIPTION describes DRIVE."
2036 :type '(alist
2037 :key-type (string :tag "Drive name")
2038 :value-type (group (string :tag "Drive description")))
2039 :group 'Dired-Plus)
2040
2041 ;;;###autoload
2042 (defcustom diredp-wrap-around-flag t
2043 "*Non-nil means Dired \"next\" commands wrap around to buffer beginning."
2044 :type 'boolean :group 'Dired-Plus)
2045
2046 (when (fboundp 'dired-hide-details-mode) ; Emacs 24.4+
2047 (defvar diredp-hide-details-last-state diredp-hide-details-initially-flag
2048 "Last `dired-hide-details-mode' value.
2049 Initialized to the value of option `diredp-hide-details-initially-flag'.")
2050
2051 (defvar diredp-hide-details-toggled nil
2052 "Non-nil means you have already toggled hiding details in this buffer.")
2053 (make-variable-buffer-local 'diredp-hide-details-toggled))
2054
2055 ;; Same value as the default value of `icicle-re-no-dot'.
2056 (defvar diredp-re-no-dot "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"
2057 "Regexp that matches anything except `.' and `..'.")
2058
2059 (defvar diredp-w32-drives-mode-map (let ((map (make-sparse-keymap)))
2060 (define-key map "q" 'bury-buffer)
2061 (define-key map "\r" 'widget-button-press)
2062 (define-key map [mouse-2] 'widget-button-click)
2063 map)
2064 "Keymap for `diredp-w32-drives-mode'.")
2065
2066 ;;; $$$$$$ Starting with Emacs 22, *-move-to* is defvaraliased to *-listing-before*.
2067 ;;; But `files+.el' defines *-listing-before*, so we define it here too.
2068 ;;; (unless (> emacs-major-version 21)
2069 ;;; (defvar directory-listing-before-filename-regexp dired-move-to-filename-regexp
2070 ;;; "Regular expression to match up to the file name in a directory listing.
2071 ;;; The default value is designed to recognize dates and times
2072 ;;; regardless of the language."))
2073
2074 ;;; Macros
2075
2076
2077 ;; REPLACE ORIGINAL in `dired.el'.
2078 ;;
2079 ;; Do not count lines that satisfy predicate if they already have `dired-marker-char'.
2080 ;;
2081 (defmacro dired-mark-if (predicate msg)
2082 "Mark files for PREDICATE, according to `dired-marker-char'.
2083 PREDICATE is evaluated on each line, with point at beginning of line.
2084 MSG is a noun phrase for the type of files being marked.
2085 It should end with a noun that can be pluralized by adding `s'.
2086 Return value is the number of files marked, or nil if none were marked."
2087 `(let ((inhibit-read-only t)
2088 count)
2089 (save-excursion
2090 (setq count 0)
2091 (when ,msg (message "%s %ss%s..."
2092 (cond ((eq dired-marker-char ?\040) "Unmarking")
2093 ((eq dired-del-marker dired-marker-char) "Flagging")
2094 (t "Marking"))
2095 ,msg
2096 (if (eq dired-del-marker dired-marker-char) " for deletion" "")))
2097 (goto-char (point-min))
2098 (while (not (eobp))
2099 (when ,predicate
2100 (unless (diredp-looking-at-p (char-to-string dired-marker-char))
2101 (delete-char 1) (insert dired-marker-char) (setq count (1+ count))))
2102 (forward-line 1))
2103 (when ,msg (message "%s %s%s %s%s" count ,msg
2104 (dired-plural-s count)
2105 (if (eq dired-marker-char ?\040) "un" "")
2106 (if (eq dired-marker-char dired-del-marker) "flagged" "marked"))))
2107 (and (> count 0) count)))
2108
2109
2110 ;; Just a helper function for `dired-map-over-marks'.
2111 (defun diredp-get-file-or-dir-name (arg)
2112 "Return name of next file or directory or nil if none.
2113 Argument ARG:
2114 `all-files-no-dirs' or nil means skip directories.
2115 `all-files-no-dots' means skip `.' and `..'."
2116 (let ((fname nil))
2117 (while (and (not fname) (not (eobp)))
2118 (setq fname (dired-get-filename t t))
2119 (when (and fname (or (not arg) (eq arg 'all-files-no-dirs)) (file-directory-p fname))
2120 (setq fname nil))
2121 (when (and fname (eq arg 'all-files-no-dots) (or (member fname '("." ".."))
2122 (diredp-string-match-p "/\\.\\.?$" fname)))
2123 (setq fname nil))
2124 (forward-line 1))
2125 (forward-line -1)
2126 fname))
2127
2128
2129 ;; REPLACE ORIGINAL in `dired.el'.
2130 ;;
2131 ;; Treat multiple `C-u' specially.
2132 ;;
2133 (defmacro dired-map-over-marks (body arg &optional show-progress
2134 distinguish-one-marked)
2135 "Eval BODY with point on each marked line. Return a list of BODY's results.
2136 If no marked file could be found, execute BODY on the current line.
2137 ARG, if non-nil, specifies the files to use instead of the marked files.
2138 If ARG is an integer, use the next ARG files (previous -ARG, if < 0).
2139 In that case, point is dragged along. This is so that commands on
2140 the next ARG (instead of the marked) files can be easily chained.
2141 If ARG is a cons with element 16, 64, or 256, corresponding to
2142 `C-u C-u', `C-u C-u C-u', or `C-u C-u C-u C-u', then use all files
2143 in the Dired buffer, where:
2144 16 includes NO directories (including `.' and `..')
2145 64 includes directories EXCEPT `.' and `..'
2146 256 includes ALL directories (including `.' and `..')
2147 If ARG is otherwise non-nil, use the current file.
2148 If optional third arg SHOW-PROGRESS evaluates to non-nil,
2149 redisplay the Dired buffer after each file is processed.
2150
2151 No guarantee is made about the position on the marked line. BODY must
2152 ensure this itself, if it depends on this.
2153
2154 Search starts at the beginning of the buffer, thus the car of the list
2155 corresponds to the line nearest the end of the buffer. This is also
2156 true for (positive and negative) integer values of ARG.
2157
2158 BODY should not be too long, because it is expanded four times.
2159
2160 If DISTINGUISH-ONE-MARKED is non-nil, then return (t FILENAME) instead
2161 of (FILENAME), if only one file is marked."
2162 ;; WARNING: BODY must not add new lines before point - this may cause an
2163 ;; endless loop. This warning should not apply any longer, sk 2-Sep-1991 14:10.
2164 `(prog1
2165 (let ((inhibit-read-only t)
2166 (newarg ,arg)
2167 multi-C-u case-fold-search found results)
2168 (when (and (consp newarg) (> (prefix-numeric-value newarg) 4))
2169 (setq newarg (case (prefix-numeric-value newarg)
2170 (16 'all-files-no-dirs) ; `C-u C-u'
2171 (64 'all-files-no-dots) ; `C-u C-u C-u'
2172 (256 'all-files) ; `C-u C-u C-u C-u'
2173 (t 'all-files-no-dirs))
2174 multi-C-u t))
2175 (if (and newarg (not multi-C-u))
2176 (if (integerp newarg)
2177 (progn ; No `save-excursion', want to move point.
2178 (dired-repeat-over-lines newarg #'(lambda ()
2179 (when ,show-progress (sit-for 0))
2180 (setq results (cons ,body results))))
2181 (if (< newarg 0) (nreverse results) results))
2182 ;; Non-nil, non-integer ARG means use current file:
2183 (list ,body))
2184 (let ((regexp (dired-marker-regexp))
2185 next-position)
2186 (save-excursion
2187 (goto-char (point-min))
2188 ;; Remember position of next marked file before BODY can insert lines before the
2189 ;; just found file, confusing us by finding the same marked file again and again...
2190 (setq next-position (and (if multi-C-u
2191 (diredp-get-file-or-dir-name newarg)
2192 (re-search-forward regexp nil t))
2193 (point-marker))
2194 found (not (null next-position)))
2195 (while next-position
2196 (goto-char next-position)
2197 (when ,show-progress (sit-for 0))
2198 (setq results (cons ,body results))
2199 ;; move after last match
2200 (goto-char next-position)
2201 (forward-line 1)
2202 (set-marker next-position nil)
2203 (setq next-position (and (if multi-C-u
2204 (diredp-get-file-or-dir-name newarg)
2205 (re-search-forward regexp nil t))
2206 (point-marker)))))
2207 (when (and ,distinguish-one-marked (= (length results) 1))
2208 (setq results (cons t results)))
2209 (if found results (list ,body)))))
2210 ;; `save-excursion' loses, again
2211 (dired-move-to-filename)))
2212
2213 ;; Same as `icicle-with-help-window' in `icicles-mac.el'
2214 ;; and `bmkp-with-help-window' in `bookmark+-mac.el'.
2215 (defmacro diredp-with-help-window (buffer &rest body)
2216 "`with-help-window', if available; else `with-output-to-temp-buffer'."
2217 (if (fboundp 'with-help-window)
2218 `(with-help-window ,buffer ,@body)
2219 `(with-output-to-temp-buffer ,buffer ,@body)))
2220
2221 (put 'diredp-with-help-window 'common-lisp-indent-function '(4 &body))
2222
2223 ;;; Utility functions
2224
2225 ;; Same as `tap-string-match-p' in `thingatpt+.el'.
2226 (if (fboundp 'string-match-p)
2227 (defalias 'diredp-string-match-p 'string-match-p) ; Emacs 23+
2228 (defun diredp-string-match-p (regexp string &optional start)
2229 "Like `string-match', but this saves and restores the match data."
2230 (save-match-data (string-match regexp string start))))
2231
2232 (if (fboundp 'looking-at-p)
2233 (defalias 'diredp-looking-at-p 'looking-at-p) ; Emacs 23+
2234 (defun diredp-looking-at-p (regexp)
2235 "Like `looking-at', but this saves and restores the match data."
2236 (save-match-data (looking-at regexp))))
2237
2238 ;; `dired-read-regexp' does not accept DEFAULT and HISTORY for older Emacsen, so use this.
2239 (defun diredp-read-regexp (prompt &optional default history)
2240 "Read a regexp.
2241 HISTORY defaults to `dired-regexp-history'."
2242 (setq history (or history 'dired-regexp-history))
2243 (if (fboundp 'read-regexp)
2244 (read-regexp prompt default history)
2245 (read-from-minibuffer prompt nil nil nil history default)))
2246
2247 (if (fboundp 'delete-dups)
2248 (defalias 'diredp-delete-dups (symbol-function 'delete-dups))
2249 (defun diredp-delete-dups (list)
2250 "Destructively remove `equal' duplicates from LIST.
2251 Store the result in LIST and return it. LIST must be a proper list.
2252 Of several `equal' occurrences of an element in LIST, the first
2253 one is kept."
2254 (let ((tail list))
2255 (while tail
2256 (setcdr tail (delete (car tail) (cdr tail)))
2257 (setq tail (cdr tail))))
2258 list))
2259
2260 (defun diredp-nonempty-region-p ()
2261 "Return non-nil if region is active and non-empty."
2262 (and transient-mark-mode mark-active (mark) (> (region-end) (region-beginning))))
2263
2264 (defun diredp-get-image-filename (&optional localp no-error-if-not-filep)
2265 "Return the image-file name on this line, or nil if no image file.
2266 If not in Dired (or a mode derived from Dired), then test the entire
2267 text of the current line as the file name.
2268
2269 The optional args are the same as for `dired-get-filename'. They are
2270 ignored if not in a Dired mode.
2271
2272 \(Prior to Emacs 22, this function just returns nil.)"
2273 (let ((file (if (derived-mode-p 'dired-mode)
2274 (dired-get-filename localp no-error-if-not-filep)
2275 ;; Make it work also for `diredp-list-files' listings.
2276 (buffer-substring-no-properties (line-beginning-position) (line-end-position)))))
2277 (and file
2278 (fboundp 'image-file-name-regexp) ; Emacs 22+, `image-file.el'.
2279 (diredp-string-match-p (image-file-name-regexp) file)
2280 file)))
2281
2282 (defun diredp-root-directory-p (file)
2283 "Return non-nil if FILE is a root directory."
2284 (if (fboundp 'ange-ftp-root-dir-p)
2285 (ange-ftp-root-dir-p (file-name-as-directory file))
2286 ;; This is essentially `ange-ftp-root-dir-p' applied to `file-name-as-directory'.
2287 ;; If `ange-ftp-root-dir-p' changes, update this code.
2288 (or (and (eq system-type 'windows-nt) (diredp-string-match-p "\\`[a-zA-Z]:[/\\]\\'"
2289 (file-name-as-directory file)))
2290 (string= "/" file))))
2291
2292 (defun diredp-parent-dir (file &optional relativep)
2293 "Return the parent directory of FILE, or nil if none.
2294 Optional arg RELATIVEP non-nil means return a relative name, that is,
2295 just the parent component."
2296 (let ((parent (file-name-directory (directory-file-name (expand-file-name file))))
2297 relparent)
2298 (when relativep (setq relparent (file-name-nondirectory (directory-file-name parent))))
2299 (and (not (equal parent file)) (or relparent parent))))
2300
2301 (unless (fboundp 'derived-mode-p) ; Emacs 20, 21.
2302 (defun derived-mode-p (&rest modes)
2303 "Non-nil if the current major mode is derived from one of MODES.
2304 Uses the `derived-mode-parent' property of the symbol to trace backwards."
2305 (let ((parent major-mode))
2306 (while (and (not (memq parent modes)) (setq parent (get parent 'derived-mode-parent))))
2307 parent)))
2308
2309 (defun diredp-ensure-mode ()
2310 (unless (derived-mode-p 'dired-mode)
2311 (error "You must be in Dired or a mode derived from it to use this command")))
2312
2313 (defun diredp-ensure-bookmark+ ()
2314 (unless (require 'bookmark+ nil t) (error "This command requires library `bookmark+.el'")))
2315
2316
2317 (unless (fboundp 'dired-nondirectory-p) ; Emacs 20, 21.
2318 (defun dired-nondirectory-p (file)
2319 "Return non-nil if FILE is not a directory."
2320 (not (file-directory-p file))))
2321
2322
2323 ;;; Some of the redefinitions that follow are essentially unaltered vanilla Emacs code to be
2324 ;;; reloaded, to use the new definition of `dired-map-over-marks' here.
2325
2326
2327 ;; REPLACE ORIGINAL in `dired.el'.
2328 ;;
2329 ;; 1. Pass non-nil second arg to `dired-get-filename' so we can include `.' and `..'.
2330 ;; 2. Doc string is updated to reflect the new ARG behavior.
2331 ;; 3. Allow, unlike vanilla Emacs, use of FILTER and DISTINGUISH-ONE-MARKED together.
2332 ;;
2333 (defun dired-get-marked-files (&optional localp arg filter distinguish-one-marked)
2334 "Return names of the marked files and directories as a list of strings.
2335 The list is in the same order as the buffer, that is, the car is the
2336 first marked file.
2337 Values returned are normally absolute file names.
2338 Optional arg LOCALP as in `dired-get-filename'.
2339 Optional second argument ARG specifies files to use instead of marked.
2340 Usually ARG comes from the command's prefix arg.
2341 If ARG is an integer, use the next ARG files (previous -ARG, if < 0).
2342 If ARG is a cons with element 16, 64, or 256, corresponding to
2343 `C-u C-u', `C-u C-u C-u', or `C-u C-u C-u C-u', then use all files
2344 in the Dired buffer, where:
2345 16 includes NO directories (including `.' and `..')
2346 64 includes directories EXCEPT `.' and `..'
2347 256 includes ALL directories (including `.' and `..')
2348 If ARG is otherwise non-nil, use the current file.
2349 Optional third argument FILTER, if non-nil, is a function to select
2350 some of the files: those for which (funcall FILTER FILENAME) is
2351 non-nil.
2352 If DISTINGUISH-ONE-MARKED is non-nil, then return (t FILENAME) instead
2353 of (FILENAME) if only one file is marked (after any filtering by
2354 FILTER).
2355
2356 Note that the Dired+ version of this function differs from the vanilla
2357 version in these respects:
2358
2359 * There are more possibilities for argument ARG (prefix argument).
2360 * Directories `.' and `..' can be included as marked.
2361 * You can use arguments FILTER and DISTINGUISH-ONE-MARKED together."
2362 (let ((all (delq nil (save-excursion
2363 (dired-map-over-marks (dired-get-filename localp t)
2364 arg nil distinguish-one-marked))))
2365 result)
2366 (if (and distinguish-one-marked (eq (car all) t))
2367 (if (not filter)
2368 all
2369 (and (funcall filter (cadr all)) (list t (cadr all))))
2370 (dolist (file all)
2371 (when (or (not filter) (funcall filter file)) (push file result)))
2372 (if (and distinguish-one-marked (= 1 (length result)))
2373 (cons t result)
2374 result))))
2375
2376
2377 ;; REPLACE ORIGINAL in `dired-aux.el'.
2378 ;;
2379 (defun dired-map-over-marks-check (fun arg op-symbol &optional show-progress)
2380 "Map FUN over marked lines and display failures.
2381 FUN takes zero args. It returns non-nil (the offending object, e.g.
2382 the short form of the filename) for a failure and probably logs a
2383 detailed error explanation using function `dired-log'.
2384
2385 ARG is as in `dired-map-over-marks'.
2386
2387 OP-SYMBOL is a symbol describing the operation performed (e.g.
2388 `compress'). It is used with `dired-mark-pop-up' to prompt the user
2389 \(e.g. with `Compress * [2 files]? ') and to display errors (e.g.
2390 `Failed to compress 1 of 2 files - type W to see why (\"foo\")')
2391
2392 SHOW-PROGRESS if non-nil means redisplay Dired after each file."
2393 (and (dired-mark-confirm op-symbol arg)
2394 (let* ((total-list (dired-map-over-marks (funcall fun) arg show-progress)) ; Return vals.
2395 (total (length total-list))
2396 (failures (delq nil total-list))
2397 (count (length failures))
2398 (string (if (eq op-symbol 'compress)
2399 "Compress or uncompress"
2400 (capitalize (symbol-name op-symbol)))))
2401 (if (not failures)
2402 (message "%s: %d file%s." string total (dired-plural-s total))
2403 ;; end this bunch of errors:
2404 (dired-log-summary (format "Failed to %s %d of %d file%s"
2405 (downcase string) count total (dired-plural-s total))
2406 failures)))))
2407
2408
2409 ;; REPLACE ORIGINAL in `dired-aux.el'.
2410 ;;
2411 (when (boundp 'dired-subdir-switches) ; Emacs 22+
2412 (defun dired-do-redisplay (&optional arg test-for-subdir) ; Bound to `l'
2413 "Redisplay all marked (or next ARG) files.
2414 If on a subdir line, redisplay that subdirectory. In that case,
2415 a prefix arg lets you edit the `ls' switches used for the new listing.
2416
2417 Dired remembers switches specified with a prefix arg, so that reverting
2418 the buffer will not reset them. However, using `dired-undo' to re-insert
2419 or delete subdirectories can bypass this machinery. Hence, you sometimes
2420 may have to reset some subdirectory switches after a `dired-undo'.
2421 You can reset all subdirectory switches to the default using
2422 \\<dired-mode-map>\\[dired-reset-subdir-switches].
2423 See Info node `(emacs)Subdir switches' for more details."
2424 ;; Moves point if the next ARG files are redisplayed.
2425 (interactive "P\np")
2426 (if (and test-for-subdir (dired-get-subdir))
2427 (let* ((dir (dired-get-subdir))
2428 (switches (cdr (assoc-string dir dired-switches-alist))))
2429 (dired-insert-subdir dir (and arg (read-string "Switches for listing: "
2430 (or switches
2431 dired-subdir-switches
2432 dired-actual-switches)))))
2433 (message "Redisplaying...")
2434 ;; `message' is much faster than making `dired-map-over-marks' show progress
2435 (dired-uncache (if (consp dired-directory) (car dired-directory) dired-directory))
2436 (dired-map-over-marks (let ((fname (dired-get-filename))
2437 ;; Postpone readin hook map over all marked files (Bug#6810).
2438 (dired-after-readin-hook nil))
2439 (message "Redisplaying... `%s'" fname)
2440 (dired-update-file-line fname))
2441 arg)
2442 (run-hooks 'dired-after-readin-hook)
2443 (dired-move-to-filename)
2444 (message "Redisplaying...done"))))
2445
2446
2447 ;; REPLACE ORIGINAL in `dired-aux.el'.
2448 ;;
2449 (unless (boundp 'dired-subdir-switches) ; Emacs 20, 21
2450 (defun dired-do-redisplay (&optional arg test-for-subdir) ; Bound to `l'
2451 "Redisplay all marked (or next ARG) files.
2452 If on a subdir line, redisplay that subdirectory. In that case,
2453 a prefix arg lets you edit the `ls' switches used for the new listing."
2454 ;; Moves point if the next ARG files are redisplayed.
2455 (interactive "P\np")
2456 (if (and test-for-subdir (dired-get-subdir))
2457 (dired-insert-subdir (dired-get-subdir)
2458 (and arg (read-string "Switches for listing: " dired-actual-switches)))
2459 (message "Redisplaying...")
2460 ;; `message' is much faster than making dired-map-over-marks show progress
2461 (dired-uncache (if (consp dired-directory) (car dired-directory) dired-directory))
2462 (dired-map-over-marks (let ((fname (dired-get-filename)))
2463 (message "Redisplaying... `%s'" fname)
2464 (dired-update-file-line fname))
2465 arg)
2466 (dired-move-to-filename)
2467 (message "Redisplaying...done"))))
2468
2469
2470 ;; REPLACE ORIGINAL in `dired.el'.
2471 ;;
2472 (when (fboundp 'get-window-with-predicate) ; Emacs 22+
2473 (defun dired-dwim-target-directory ()
2474 "Guess a target directory to use for Dired.
2475 If there is a Dired buffer displayed in another window, use its
2476 current subdir, else use current subdir of this Dired buffer."
2477 (let ((this-dir (and (eq major-mode 'dired-mode) (dired-current-directory))))
2478 ;; Non-dired buffer may want to profit from this function, e.g. `vm-uudecode'.
2479 (if dired-dwim-target
2480 (let* ((other-win (get-window-with-predicate (lambda (window)
2481 (with-current-buffer (window-buffer window)
2482 (eq major-mode 'dired-mode)))
2483 nil
2484 (and diredp-dwim-any-frame-flag 'visible)))
2485 (other-dir (and other-win (with-current-buffer (window-buffer other-win)
2486 (and (eq major-mode 'dired-mode) (dired-current-directory))))))
2487 (or other-dir this-dir))
2488 this-dir))))
2489
2490
2491 ;; REPLACE ORIGINAL in `dired.el'.
2492 ;;
2493 ;; 1. Added behavior for non-positive prefix arg:
2494 ;; * Construct a cons DIRNAME arg.
2495 ;; * Read a Dired buffer name (not a directory) for its car.
2496 ;; * If READ-EXTRA-FILES-P is non-nil then read any number of file and dir names, to be included as its cdr.
2497 ;; * If chosen Dired buffer exists and is an ordinary listing then start out with its `directory-files'.
2498 ;;
2499 ;; 2. If you use Icicles then this is a multi-command - see doc for `dired' defadvice.
2500 ;;
2501 (defun dired-read-dir-and-switches (string &optional read-extra-files-p dired-buffer)
2502 "Read arguments for `dired' commands.
2503 STRING is added to the prompt after \"Dired \". If not \"\", it should
2504 end with a space.
2505
2506 With a non-negative prefix arg, read the `ls' switches.
2507 With a non-negative prefix arg or none, read the directory to Dired.
2508
2509 With a non-positive prefix arg:
2510 * If DIRED-BUFFER is non-nil, it is the name of the Dired buffer to
2511 use. Otherwise, read it (it is not necessarily a directory name).
2512 If in Dired now, the current buffer name is the default.
2513 * If READ-EXTRA-FILES-P is non-nil then read any number of directory
2514 or file names, to make up the Dired arbitrary-files listing. You
2515 can use file-name wildcards (i.e., `*' for globbing), to include the
2516 matching files and directories. Use `C-g' when done entering the
2517 files and directories to list.
2518
2519 Return a list of arguments for `dired': (DIRNAME SWITCHES). DIRNAME
2520 here has the same form as `dired-directory'. When a non-positive
2521 prefix arg is used, DIRNAME is a cons of the buffer name and the list
2522 of file names.
2523
2524 If you use Icicles then reading uses Icicles completion, with
2525 additional multi-command keys. See `dired' (defadvice doc)."
2526 (let* ((switchs (and current-prefix-arg
2527 (natnump (prefix-numeric-value current-prefix-arg))
2528 (read-string "Dired listing switches: "
2529 dired-listing-switches)))
2530 (icicle-candidate-action-fn
2531 (lambda (cand)
2532 (dired-other-window cand (and current-prefix-arg (read-string "Dired listing switches: "
2533 dired-listing-switches)))
2534 (select-window (minibuffer-window))
2535 (select-frame-set-input-focus (selected-frame))))
2536 ;;; $$$$$$ Alternative: Could choose no-op for non-dir candidate.
2537 ;;; (icicle-candidate-action-fn
2538 ;;; (lambda (cand)
2539 ;;; (cond ((file-directory-p cand)
2540 ;;; (dired-other-window cand (and current-prefix-arg (read-string "Dired listing switches: "
2541 ;;; dired-listing-switches)))
2542 ;;; (select-window (minibuffer-window))
2543 ;;; (select-frame-set-input-focus (selected-frame)))
2544 ;;; (t
2545 ;;; (message "Not a directory: `%s'" cand) (sit-for 2)))))
2546 (icicle-all-candidates-list-alt-action-fn ; M-|'
2547 (lambda (files)
2548 (let ((enable-recursive-minibuffers t))
2549 (dired-other-window (cons (read-string (format "Dired %s(buffer name): " string)) files)))))
2550 (icicle-sort-comparer (or (and (boundp 'icicle-file-sort) ; If not reading files
2551 icicle-file-sort) ; then dirs first.
2552 (and (> (prefix-numeric-value current-prefix-arg) 0)
2553 'icicle-dirs-first-p)
2554 (and (boundp 'icicle-sort-comparer)
2555 icicle-sort-comparer)))
2556
2557 ;; The rest of the bindings are from `icicle-file-bindings', in `icicles-mac.el'.
2558 (completion-ignore-case
2559 (or (and (boundp 'read-file-name-completion-ignore-case) read-file-name-completion-ignore-case)
2560 completion-ignore-case))
2561 (icicle-show-Completions-initially-flag (and (boundp 'icicle-show-Completions-initially-flag)
2562 (or icicle-show-Completions-initially-flag
2563 icicle-files-ido-like-flag)))
2564 (icicle-top-level-when-sole-completion-flag (and (boundp 'icicle-top-level-when-sole-completion-flag)
2565 (or icicle-top-level-when-sole-completion-flag
2566 icicle-files-ido-like-flag)))
2567 (icicle-default-value (and (boundp 'icicle-default-value)
2568 (if (and icicle-files-ido-like-flag
2569 icicle-default-value)
2570 icicle-files-ido-like-flag
2571 ;; Get default via `M-n', but do not insert it.
2572 (and (memq icicle-default-value '(t nil))
2573 icicle-default-value))))
2574 (icicle-must-match-regexp (and (boundp 'icicle-file-match-regexp)
2575 icicle-file-match-regexp))
2576 (icicle-must-not-match-regexp (and (boundp 'icicle-file-no-match-regexp)
2577 icicle-file-no-match-regexp))
2578 (icicle-must-pass-after-match-predicate (and (boundp 'icicle-file-predicate)
2579 icicle-file-predicate))
2580 (icicle-require-match-flag (and (boundp 'icicle-file-require-match-flag)
2581 icicle-file-require-match-flag))
2582 (icicle-file-completing-p t)
2583 (icicle-extra-candidates (and (boundp 'icicle-file-extras) icicle-file-extras))
2584 (icicle-transform-function 'icicle-remove-dups-if-extras)
2585 ;; Put `icicle-file-sort' first. If already in the list, move it, else add it, to beginning.
2586 (icicle--temp-orders (and (boundp 'icicle-sort-orders-alist)
2587 (copy-sequence icicle-sort-orders-alist)))
2588 (icicle-candidate-help-fn (lambda (cand)
2589 (icicle-describe-file cand current-prefix-arg t)))
2590 (icicle-candidate-alt-action-fn (and (boundp 'icicle-candidate-alt-action-fn)
2591 (or icicle-candidate-alt-action-fn
2592 (icicle-alt-act-fn-for-type "file"))))
2593 (icicle-delete-candidate-object 'icicle-delete-file-or-directory)
2594 (icicle-sort-orders-alist
2595 (and (boundp 'icicle-sort-orders-alist)
2596 (progn (when (and icicle-file-sort-first-time-p icicle-file-sort)
2597 (setq icicle-sort-comparer icicle-file-sort
2598 icicle-file-sort-first-time-p nil))
2599 (if icicle-file-sort
2600 (let ((already-there (rassq icicle-file-sort icicle--temp-orders)))
2601 (if already-there
2602 (cons already-there (setq icicle--temp-orders (delete already-there
2603 icicle--temp-orders)))
2604 (cons `("by `icicle-file-sort'" ,@icicle-file-sort) icicle--temp-orders)))
2605 icicle--temp-orders)))))
2606 (when (fboundp 'icicle-bind-file-candidate-keys) (icicle-bind-file-candidate-keys))
2607 (unwind-protect
2608 (list
2609 (if (> (prefix-numeric-value current-prefix-arg) 0)
2610 ;; If a dialog box is about to be used, call `read-directory-name' so the dialog
2611 ;; code knows we want directories. Some dialog boxes can only select directories
2612 ;; or files when popped up, not both. If no dialog box is used, call `read-file-name'
2613 ;; because the user may want completion of file names for use in a wildcard pattern.
2614 (funcall (if (and (fboundp 'read-directory-name) (next-read-file-uses-dialog-p))
2615 #'read-directory-name
2616 #'read-file-name)
2617 (format "Dired %s(directory): " string) nil default-directory nil)
2618 (dolist (db dired-buffers) ; Remove any killed buffers from `dired-buffers' (even if DIRED-BUFFER).
2619 (unless (buffer-name (cdr db)) (setq dired-buffers (delq db dired-buffers))))
2620 (let* ((dbufs (and (not dired-buffer)
2621 (mapcar (lambda (db) (list (buffer-name (cdr db)))) dired-buffers)))
2622 (dirbuf (or dired-buffer
2623 (completing-read (format "Dired %s(buffer name): " string) dbufs nil nil nil nil
2624 (and (derived-mode-p 'dired-mode) (buffer-name)))))
2625 (files (and (diredp-existing-dired-buffer-p dirbuf)
2626 (with-current-buffer (get-buffer dirbuf)
2627 (and (not (consp dired-directory))
2628 (directory-files dired-directory 'FULL diredp-re-no-dot)))))
2629 file)
2630 (when read-extra-files-p
2631 (while (condition-case nil ; Use lax completion, to allow wildcards.
2632 (setq file (read-file-name "File or dir (C-g when done): "))
2633 (quit nil))
2634 ;; Do not allow root dir (`/' or a Windows drive letter, e.g. `d:/').
2635 (if (diredp-root-directory-p file)
2636 (progn (message "Cannot choose root directory") (sit-for 1))
2637 (push file files))))
2638 (cons dirbuf files)))
2639 switchs)
2640 (when (fboundp 'icicle-unbind-file-candidate-keys) (icicle-unbind-file-candidate-keys)))))
2641
2642
2643 ;;; $$$$$$$$ An alternative implementation - different behavior.
2644 ;;;
2645 ;;; ;; REPLACE ORIGINAL in `dired.el'.
2646 ;;; ;;
2647 ;;; ;; Non-positive prefix arg means construct cons DIRNAME arg: Read Dired name and files/dirs.
2648 ;;; ;;
2649 ;;; (defun dired-read-dir-and-switches (string)
2650 ;;; "Read arguments for `dired'.
2651 ;;; With a non-negative prefix arg, prompt first for `ls' switches.
2652 ;;; With a non-positive prefix arg, read the Dired buffer name and then
2653 ;;; read any number of dir or file names, to make up the Dired listing.
2654
2655 ;;; STRING is appended to the prompt, unless prefix arg is non-positive.
2656 ;;; If non-empty, STRING should begin with a SPC."
2657 ;;; (let ((switches (and current-prefix-arg
2658 ;;; (>= (prefix-numeric-value current-prefix-arg) 0)
2659 ;;; (read-string "Dired listing switches: " dired-listing-switches)))
2660 ;;; (formt (format "Dired %s(directory): " string))
2661 ;;; (entries ())
2662 ;;; (curr-entry ""))
2663 ;;; (when (and current-prefix-arg (<= (prefix-numeric-value current-prefix-arg) 0))
2664 ;;; (push (completing-read "Dired buffer name: " dired-buffers) entries)
2665 ;;; (setq curr-entry (read-file-name (format "Dir or file: ") nil "" 'MUST-MATCH))
2666 ;;; (while (not (equal "" curr-entry))
2667 ;;; (push curr-entry entries)
2668 ;;; (setq curr-entry (read-file-name (format "Dir or file: ") nil "" 'MUST-MATCH)))
2669 ;;; (unless (cadr entries) (push default-directory entries)))
2670 ;;; (list (or (nreverse entries) (if (and (fboundp 'next-read-file-uses-dialog-p)
2671 ;;; (next-read-file-uses-dialog-p))
2672 ;;; (read-directory-name formt nil default-directory nil)
2673 ;;; (read-file-name formt nil default-directory nil)))
2674 ;;; switches)))
2675
2676
2677 ;; ADVISE ORIGINAL in `dired.el'.
2678 ;;
2679 ;; Add to doc string, to document non-positive prefix arg.
2680 ;;
2681 (defadvice dired (before diredp-doc-cons-arg activate)
2682 "Interactively, a prefix argument changes the behavior as follows:
2683
2684 * If >= 0, you are first prompted for the `ls' switches to use.
2685
2686 * If <= 0, you are prompted first for the name of the Dired buffer.
2687 Then you are prompted repeatedly for the names of the directories
2688 or files to list in the buffer. You can use file-name wildcards
2689 (i.e., `*' for globbing), to include the matching files and
2690 directories. Use `C-g' to end.
2691
2692 In other words, instead of listing a single directory, the Dired
2693 buffer can list any number of directories and file names, which can
2694 even belong to different directory trees.
2695
2696 The rest of this description applies only if you use Icicles.
2697
2698 In Icicle mode this is a multi-command: You can cycle among file-name
2699 completion candidates and act individually on those that name
2700 directories. The action is to open Dired for the directory. While
2701 cycling, these keys are active:
2702
2703 \\<minibuffer-local-completion-map>\
2704 `C-mouse-2', `C-return' - Act on current completion candidate only
2705 `C-down', `C-wheel-down' - Move to next completion candidate and act
2706 `C-up', `C-wheel-up' - Move to previous completion candidate and act
2707 `C-next' - Move to next apropos-completion candidate and act
2708 `C-prior' - Move to previous apropos-completion candidate and act
2709 `C-end' - Move to next prefix-completion candidate and act
2710 `C-home' - Move to previous prefix-completion candidate and act
2711 `\\[icicle-all-candidates-action]' - Act on *all* candidates, successively (careful!)
2712 `\\[icicle-all-candidates-list-alt-action]' - Open Dired on all candidates
2713
2714 When candidate action and cycling are combined (e.g. `C-next'), user
2715 option `icicle-act-before-cycle-flag' determines which occurs first.
2716
2717 With prefix `C-M-' instead of `C-', the same keys (`C-M-mouse-2',
2718 `C-M-RET', `C-M-down', and so on) provide help about candidates.
2719
2720 Use `mouse-2', `RET', or `S-RET' to finally choose a candidate, or
2721 `C-g' to quit.
2722
2723 These keys are also bound in the minibuffer during completion (`*'
2724 means the key requires library `Bookmark+'):
2725
2726 S-delete - Delete candidate file or (empty) dir
2727 C-c + - Create a new directory
2728 C-backspace - Go up one directory level
2729 * C-x C-t * - Narrow to files with all of the tags you specify
2730 * C-x C-t + - Narrow to files with some of the tags you specify
2731 * C-x C-t % * - Narrow to files with all tags matching a regexp
2732 * C-x C-t % + - Narrow to files with some tags matching a regexp
2733 * C-x a + - Add tags to the current-candidate file
2734 * C-x a - - Remove tags from the current-candidate file
2735 * C-x m - Access file bookmarks (not just autofiles)"
2736 (interactive (dired-read-dir-and-switches "" 'READ-EXTRA-FILES-P)))
2737
2738
2739 ;; ADVISE ORIGINAL in `dired.el'.
2740 ;;
2741 ;; Add to doc string, to document non-positive prefix arg.
2742 ;;
2743 (defadvice dired-other-window (before diredp-doc-cons-arg activate)
2744 "Interactively, a prefix argument changes the behavior.
2745 A non-positive prefix arg lets you choose an explicit set of files and
2746 directories to list. See the advice for `dired' for more information."
2747 (interactive (dired-read-dir-and-switches "" 'READ-EXTRA-FILES-P)))
2748
2749
2750 ;; ADVISE ORIGINAL in `dired.el'.
2751 ;;
2752 ;; Add to doc string, to document non-positive prefix arg.
2753 ;;
2754 (defadvice dired-other-frame (before diredp-doc-cons-arg activate)
2755 "Interactively, a prefix argument changes the behavior.
2756 A non-positive prefix arg lets you choose an explicit set of files and
2757 directories to list. See the advice for `dired' for more information."
2758 (interactive (dired-read-dir-and-switches "" 'READ-EXTRA-FILES-P)))
2759
2760
2761 ;; REPLACE ORIGINAL in `dired.el'.
2762 ;;
2763 ;; Made compatible with Emacs 20, 21, which do not have [:alnum].
2764 ;; Also, this is defined here because it is used elsewhere in the file.
2765 ;;
2766 (defun dired-switches-escape-p (switches)
2767 "Return non-nil if the string SWITCHES contains `-b' or `--escape'."
2768 (if (fboundp 'dired-switches-check) ; Emacs 24.4+ - see Emacs bug #17218.
2769 (dired-switches-check switches "escape" "b")
2770 ;; Do not match things like "--block-size" that happen to contain "b".
2771 (if (> emacs-major-version 21) ; SWITCHES must be a string here, not nil.
2772 (diredp-string-match-p "\\(\\`\\| \\)-[[:alnum:]]*b\\|--escape\\>" switches)
2773 (diredp-string-match-p "\\(\\`\\| \\)-\\(\w\\|[0-9]\\)*b\\|--escape\\>" switches))))
2774
2775
2776 ;; From `dired.el'
2777
2778 (when (and (> emacs-major-version 22) (featurep 'ls-lisp+))
2779
2780 ;;; 2012/04/26: Commented this out.
2781 ;;; Might need it again when update `ls-lisp+.el' to fix other things.
2782 ;;;
2783 ;;; ;; Use t as WILDCARD arg to `dired-insert-directory'.
2784 ;;; ;;
2785 ;;; (defun dired-readin-insert ()
2786 ;;; ;; Insert listing for the specified dir (and maybe file list)
2787 ;;; ;; already in dired-directory, assuming a clean buffer.
2788 ;;; (let (dir file-list)
2789 ;;; (if (consp dired-directory)
2790 ;;; (setq dir (car dired-directory)
2791 ;;; file-list (cdr dired-directory))
2792 ;;; (setq dir dired-directory
2793 ;;; file-list ()))
2794 ;;; (setq dir (expand-file-name dir))
2795 ;;; (if (and (equal "" (file-name-nondirectory dir)) (not file-list))
2796 ;;; ;; If we are reading a whole single directory...
2797 ;;; (dired-insert-directory dir dired-actual-switches nil nil t)
2798 ;;; (unless (file-readable-p (directory-file-name (file-name-directory dir)))
2799 ;;; (error "Directory `%s' inaccessible or nonexistent" dir))
2800 ;;; ;; Else treat it as a wildcard spec.
2801 ;;; (dired-insert-directory dir dired-actual-switches file-list t t))))
2802
2803
2804 ;; REPLACE ORIGINAL in `dired.el'.
2805 ;;
2806 ;; Compute WILDCARD arg for `insert-directory' for individual file (don't just use nil).
2807 ;;
2808 (defun dired-insert-directory (dir switches &optional file-list wildcard hdr)
2809 "Insert a directory listing of DIR, Dired style.
2810 Use SWITCHES to make the listings.
2811 If FILE-LIST is non-nil, list only those files.
2812 Otherwise, if WILDCARD is non-nil, expand wildcards;
2813 in that case, DIR should be a file name that uses wildcards.
2814 In other cases, DIR should be a directory name or a directory filename.
2815 If HDR is non-nil, insert a header line with the directory name."
2816 (let ((opoint (point))
2817 (process-environment (copy-sequence process-environment))
2818 end)
2819 (when (and
2820 ;; Do not try to invoke `ls' if on DOS/Windows, where `ls-lisp' is used, unless
2821 ;; the user really wants to use `ls', as indicated by
2822 ;; `ls-lisp-use-insert-directory-program'.
2823 (or (not (featurep 'ls-lisp)) ls-lisp-use-insert-directory-program)
2824 (or (if (eq dired-use-ls-dired 'unspecified)
2825 ;; Check if "ls --dired" gives exit code 0. Put it in `dired-use-ls-dired'.
2826 (or (setq dired-use-ls-dired (eq 0 (call-process insert-directory-program
2827 nil nil nil "--dired")))
2828 (progn (message "Command `ls' does not support switch `--dired' - see \
2829 `dired-use-ls-dired'.")
2830 nil))
2831 dired-use-ls-dired)
2832 (file-remote-p dir)))
2833 (setq switches (concat "--dired " switches)))
2834 ;; We used to specify the C locale here, to force English month names. This should not be
2835 ;; necessary any more with the new value of `directory-listing-before-filename-regexp'.
2836 (if file-list
2837 (dolist (f file-list)
2838 (let ((beg (point)))
2839 ;; Compute wildcard arg for this file.
2840 (insert-directory f switches (diredp-string-match-p "[[?*]" f) nil)
2841 ;; Re-align fields, if necessary.
2842 (dired-align-file beg (point))))
2843 (insert-directory dir switches wildcard (not wildcard)))
2844 ;; Quote certain characters, unless `ls' quoted them for us.
2845 (unless (dired-switches-escape-p dired-actual-switches)
2846 (save-excursion
2847 (setq end (point-marker))
2848 (goto-char opoint)
2849 (while (search-forward "\\" end t)
2850 (replace-match (apply #'propertize "\\\\" (text-properties-at (match-beginning 0)))
2851 nil t))
2852 (goto-char opoint)
2853 (while (search-forward "\^m" end t)
2854 (replace-match (apply #'propertize "\\015" (text-properties-at (match-beginning 0)))
2855 nil t))
2856 (set-marker end nil))
2857 ;; Comment in original, from some Emacs Dev developer:
2858 ;;
2859 ;; Replace any newlines in DIR with literal "\n" for the sake of the header line. To
2860 ;; disambiguate a literal "\n" in the actual dirname, we also replace "\" with "\\".
2861 ;; I think this should always be done, irrespective of the value of
2862 ;; dired-actual-switches, because:
2863 ;; i) Dired does not work with an unescaped newline in the directory name used in the
2864 ;; header (bug=10469#28), and
2865 ;; ii) "\" is always replaced with "\\" in the listing, so doing it in the header as
2866 ;; well makes things consistent.
2867 ;; But at present it is done only if "-b" is in ls-switches, because newlines in dirnames
2868 ;; are uncommon, and people may have gotten used to seeing unescaped "\" in the headers.
2869 ;; Note: adjust `dired-build-subdir-alist' if you change this.
2870 (setq dir (replace-regexp-in-string "\\\\" "\\\\" dir nil t)
2871 dir (replace-regexp-in-string "\n" "\\n" dir nil t)))
2872 ;; If we used `--dired' and it worked, the lines are already indented. Else indent them.
2873 (unless (save-excursion (goto-char opoint) (diredp-looking-at-p " "))
2874 (let ((indent-tabs-mode nil)) (indent-rigidly opoint (point) 2)))
2875 ;; Insert text at the beginning to standardize things.
2876 (let ((content-point opoint))
2877 (save-excursion
2878 (goto-char opoint)
2879 (when (and (or hdr wildcard) (not (and (looking-at "^ \\(.*\\):$")
2880 (file-name-absolute-p (match-string 1)))))
2881 ;; `dired-build-subdir-alist' will replace the name by its expansion, so it does not
2882 ;; matter whether what we insert here is fully expanded, but it should be absolute.
2883 (insert " " (directory-file-name (file-name-directory dir)) ":\n")
2884 (setq content-point (point)))
2885 (when wildcard
2886 ;; Insert "wildcard" line where "total" line would be for a full dir.
2887 (insert " wildcard " (file-name-nondirectory dir) "\n")))
2888 (dired-insert-set-properties content-point (point))))))
2889
2890
2891 ;;; Image stuff.
2892
2893 (defun diredp-image-dired-required-msg ()
2894 "Raise an error if `image-dired.el' is not loaded."
2895 (unless (require 'image-dired nil t) (error "This command requires library `image-dired.el'")))
2896
2897 ;; See `image-dired-create-thumb'.
2898 ;; Define this even if `image-dired.el' is not loaded.
2899 ;; Do NOT raise an error if not loaded, because this is used in `diredp-mouseover-help'.
2900 ;;;###autoload
2901 (defun diredp-image-dired-create-thumb (file &optional arg)
2902 "Create thumbnail image file for FILE (default: file on current line).
2903 With a prefix arg, replace any existing thumbnail for FILE.
2904 With a numeric prefix arg (not a cons), use it as the thumbnail size.
2905 Return the name of the thumbnail image file, or nil if none."
2906 (interactive (list (if (derived-mode-p 'dired-mode)
2907 (dired-get-filename nil 'NO-ERROR)
2908 ;; Make it work also for `diredp-list-files' listings.
2909 (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
2910 current-prefix-arg))
2911 (and (fboundp 'image-dired-thumb-name) ; No-op (return nil) if `image-dired.el' not loaded.
2912 (let ((thumb-name (image-dired-thumb-name file)))
2913 (when arg (clear-image-cache))
2914 (when (or arg (not (file-exists-p thumb-name)))
2915 (let ((image-dired-thumb-width (or (and arg (atom arg) arg) image-dired-thumb-width))
2916 (image-dired-thumb-height (or (and arg (atom arg) arg) image-dired-thumb-height)))
2917 (unless (zerop (image-dired-create-thumb file thumb-name))
2918 (error "Thumbnail image file could not be created"))))
2919 (and (file-exists-p thumb-name) thumb-name))))
2920
2921
2922 ;; REPLACE ORIGINAL in `image-dired.el' (Emacs 22-23).
2923 ;;
2924 ;; 1. Raise an error if `image-dired.el' is not available.
2925 ;; 2. Repro it here so it picks up `Dired+' version of `dired-map-over-marks'.
2926 ;;
2927 ;;;###autoload
2928 (defun image-dired-dired-insert-marked-thumbs () ; Bound to `C-t C-t' (Emacs 22-23)
2929 "Insert thumbnails before file names of marked files in the Dired buffer."
2930 (interactive (progn (diredp-image-dired-required-msg) ()))
2931 (dired-map-over-marks
2932 (let* ((image-pos (dired-move-to-filename))
2933 (image-file (dired-get-filename))
2934 (thumb-file (image-dired-get-thumbnail-image image-file))
2935 overlay)
2936 ;; If image is not already added, then add it.
2937 (unless (delq nil (mapcar (lambda (o) (overlay-get o 'put-image))
2938 ;; Can't use (overlays-at (point)), BUG?
2939 (overlays-in (point) (1+ (point)))))
2940 (put-image thumb-file image-pos)
2941 (setq overlay (car (delq nil (mapcar (lambda (ov) (and (overlay-get ov 'put-image) ov))
2942 (overlays-in (point) (1+ (point)))))))
2943 (overlay-put overlay 'image-file image-file)
2944 (overlay-put overlay 'thumb-file thumb-file)))
2945 nil)
2946 (add-hook 'dired-after-readin-hook 'image-dired-dired-after-readin-hook nil t))
2947
2948
2949 ;; REPLACE ORIGINAL in `image-dired.el' (Emacs 24+).
2950 ;;
2951 ;; 1. Raise an error if `image-dired.el' is not available.
2952 ;; 2. Repro it here so it picks up `Dired+' version of `dired-map-over-marks'.
2953 ;;
2954 ;;;###autoload
2955 (defun image-dired-dired-toggle-marked-thumbs (&optional arg) ; Bound to `C-t C-t' (Emacs 24+)
2956 "Toggle thumbnails in front of file names in Dired.
2957 If no files are marked, insert or hide thumbnails on the current line.
2958 With a numeric prefix arg N, ignore marked files and act on the next N
2959 files (previous -N files, if N < 0)."
2960 (interactive (progn (diredp-image-dired-required-msg) (list current-prefix-arg)))
2961 (dired-map-over-marks
2962 (let* ((image-pos (dired-move-to-filename))
2963 (image-file (diredp-get-image-filename nil 'NO-ERROR))
2964 thumb-file overlay)
2965 (when image-file
2966 (setq thumb-file (image-dired-get-thumbnail-image image-file))
2967 ;; If image is not already added, then add it.
2968 (let* ((cur-ovs (overlays-in (point) (1+ (point))))
2969 (thumb-ov (car (diredp-remove-if-not (lambda (ov) (overlay-get ov 'thumb-file))
2970 cur-ovs))))
2971 (if thumb-ov
2972 (delete-overlay thumb-ov)
2973 (put-image thumb-file image-pos)
2974 (setq overlay (car (delq nil (mapcar (lambda (ov) (and (overlay-get ov 'put-image) ov))
2975 (overlays-in (point) (1+ (point)))))))
2976 (overlay-put overlay 'image-file image-file)
2977 (overlay-put overlay 'thumb-file thumb-file)))))
2978 arg
2979 'SHOW-PROGRESS)
2980 (add-hook 'dired-after-readin-hook 'image-dired-dired-after-readin-hook nil t))
2981
2982 ;; Corresponds to `image-dired-dired-comment-files'.
2983 ;;;###autoload
2984 (defun diredp-image-dired-comment-file ()
2985 "Add comment to this image file."
2986 (interactive (progn (diredp-image-dired-required-msg) ()))
2987 (image-dired-write-comments (cons (dired-get-filename) (image-dired-read-comment))))
2988
2989 ;; Corresponds to `image-dired-tag-files'.
2990 ;;;###autoload
2991 (defun diredp-image-dired-tag-file ()
2992 "Tag this image file with an `image-dired' tag."
2993 (interactive (progn (diredp-image-dired-required-msg) ()))
2994 (image-dired-write-tags (cons (dired-get-filename)
2995 (read-string "Tags to add (use `;' to separate): "))))
2996
2997 ;; Corresponds to `image-dired-delete-tag'.
2998 ;;;###autoload
2999 (defun diredp-image-dired-delete-tag ()
3000 "Remove an `image-dired' tag from this image file."
3001 (interactive (progn (diredp-image-dired-required-msg) ()))
3002 (image-dired-remove-tag (list (dired-get-filename)) (read-string "Tag to remove: ")))
3003
3004 ;; Corresponds to `image-dired-display-thumbs'.
3005 ;;;###autoload
3006 (defun diredp-image-dired-display-thumb (&optional append)
3007 "Pop to thumbnail of this image file, in `image-dired-thumbnail-buffer'.
3008 If a thumbnail image does not yet exist for this file, create it.
3009 With a prefix arg, append the thumbnail to the thumbnails buffer,
3010 instead of clearing the buffer first."
3011 (interactive (progn (diredp-image-dired-required-msg) (list current-prefix-arg)))
3012 (let* ((dired-buf (current-buffer))
3013 (curr-file (dired-get-filename))
3014 (thumb-name (image-dired-thumb-name curr-file)))
3015 (with-current-buffer (image-dired-create-thumbnail-buffer)
3016 (let ((inhibit-read-only t))
3017 (if (not append) (erase-buffer) (goto-char (point-max)))
3018 (if (and (not (file-exists-p thumb-name))
3019 (not (zerop (image-dired-create-thumb curr-file thumb-name))))
3020 (message "Cannot create thumbnail image for file `%s'" curr-file)
3021 (image-dired-insert-thumbnail thumb-name curr-file dired-buf)))
3022 (cond ((eq 'dynamic image-dired-line-up-method) (image-dired-line-up-dynamic))
3023 ((eq 'fixed image-dired-line-up-method) (image-dired-line-up))
3024 ((eq 'interactive image-dired-line-up-method) (image-dired-line-up-interactive))
3025 ((eq 'none image-dired-line-up-method) nil)
3026 (t (image-dired-line-up-dynamic))))
3027 (pop-to-buffer image-dired-thumbnail-buffer)))
3028
3029 ;; Corresponds to `image-dired-copy-with-exif-file-name'.
3030 ;;;###autoload
3031 (defun diredp-image-dired-copy-with-exif-name ()
3032 "Copy this image file to your main image directory.
3033 Uses `image-dired-get-exif-file-name' to name the new file."
3034 (interactive (progn (diredp-image-dired-required-msg) ()))
3035 (let* ((curr-file (dired-get-filename))
3036 (new-name (format "%s/%s" (file-name-as-directory
3037 (expand-file-name image-dired-main-image-directory))
3038 (image-dired-get-exif-file-name curr-file))))
3039 (message "Copying `%s' to `%s'..." curr-file new-name)
3040 (copy-file curr-file new-name)
3041 (message "Copying `%s' to `%s'...done" curr-file new-name)))
3042
3043 ;; Corresponds to `image-dired-dired-edit-comment-and-tags'.
3044 ;;;###autoload
3045 (defun diredp-image-dired-edit-comment-and-tags ()
3046 "Edit comment and tags for this image file."
3047 (interactive (progn (diredp-image-dired-required-msg) ()))
3048 (setq image-dired-widget-list ())
3049 (let ((file (dired-get-filename)))
3050 (switch-to-buffer "*Image-Dired Edit Meta Data*")
3051 (kill-all-local-variables)
3052 (make-local-variable 'widget-example-repeat)
3053 (let ((inhibit-read-only t))
3054 (erase-buffer)
3055 (remove-overlays)
3056 (widget-insert
3057 "\nEdit comment and tags for the image. Separate multiple tags
3058 with a comma (`,'). Move forward among fields using `TAB' or `RET'.
3059 Move backward using `S-TAB'. Click `Save' to save your edits or
3060 `Cancel' to abandon them.\n\n")
3061 (let* ((thumb-file (image-dired-thumb-name file))
3062 (img (create-image thumb-file))
3063 comment-widget tag-widget)
3064 (insert-image img)
3065 (widget-insert "\n\nComment: ")
3066 (setq comment-widget (widget-create 'editable-field :size 60 :format "%v "
3067 :value (or (image-dired-get-comment file) "")))
3068 (widget-insert "\nTags: ")
3069 (setq tag-widget (widget-create 'editable-field :size 60 :format "%v "
3070 :value (or (mapconcat #'identity (image-dired-list-tags file) ",") "")))
3071 ;; Save info in widgets to use when the user saves the form.
3072 (setq image-dired-widget-list (append image-dired-widget-list
3073 (list (list file comment-widget tag-widget))))
3074 (widget-insert "\n\n")))
3075 (widget-insert "\n")
3076 (widget-create 'push-button :notify (lambda (&rest _ignore)
3077 (image-dired-save-information-from-widgets)
3078 (bury-buffer)
3079 (message "Done"))
3080 "Save")
3081 (widget-insert " ")
3082 (widget-create 'push-button :notify (lambda (&rest _ignore)
3083 (bury-buffer)
3084 (message "Operation canceled"))
3085 "Cancel")
3086 (widget-insert "\n")
3087 (use-local-map widget-keymap)
3088 (widget-setup)
3089 (widget-forward 1))) ; Jump to the first widget.
3090
3091 ;;;###autoload
3092 (defun diredp-do-display-images (&optional arg)
3093 "Display the marked image files.
3094 A prefix argument ARG specifies files to use instead of those marked.
3095 An integer means use the next ARG files (previous -ARG, if < 0).
3096 `C-u': Use the current file (whether or not any files are marked).
3097 More than one `C-u' means use all files in the Dired buffer, as if
3098 they were all marked."
3099 (interactive (progn (unless (require 'image-file nil t)
3100 (error "This command requires library `image-file.el'"))
3101 (diredp-ensure-mode)
3102 (list current-prefix-arg)))
3103 (dired-map-over-marks-check #'diredp-display-image arg 'display\ image
3104 (diredp-fewer-than-2-files-p arg)))
3105
3106 (defun diredp-display-image ()
3107 (let ((file (dired-get-filename 'LOCAL 'NO-ERROR))
3108 (failure nil))
3109 (save-excursion
3110 (if (let ((inhibit-changing-match-data t))
3111 (and file (diredp-string-match-p (image-file-name-regexp) file)))
3112 (condition-case err
3113 (let ((find-file-run-dired nil)) (find-file-other-window file))
3114 (error (setq failure (error-message-string err))))
3115 (dired-log (format "Not an image file: `%s'" file))
3116 (setq failure t)))
3117 (and failure ; Return nil for success.
3118 (prog1 file ; Return file name for failure.
3119 (unless (eq t failure) (dired-log "Cannot display image file `%s':\n%s\n" file failure) t)))))
3120
3121 ;;;###autoload
3122 (defun diredp-image-show-this-file (&optional arg)
3123 "Show the image file named on this line in another frame or window.
3124 Option `diredp-image-show-this-file-use-frame-flag' which is used.
3125
3126 With a prefix arg, shrink the image to fit a frame that many lines
3127 high or a window at least that many lines high.
3128 Otherwise, show the image full size.
3129 Note:
3130 * To show the image full size, you can also use `\\<dired-mode-map>\\[dired-find-file]'.
3131 * To show the image in another window, at whatever scale fits there,
3132 you can use `\\[image-dired-dired-display-image]'."
3133 (interactive (progn (diredp-image-dired-required-msg) (list current-prefix-arg)))
3134 (image-dired-create-display-image-buffer)
3135 (let ((fit-frame-inhibit-fitting-flag t) ; In `fit-frame.el'.
3136 (img-file (diredp-get-image-filename)))
3137 (if img-file
3138 (with-current-buffer image-dired-display-image-buffer
3139 (let* ((window-min-height (if arg
3140 (prefix-numeric-value arg)
3141 (ceiling (cdr (image-size (create-image img-file))))))
3142 (special-display-frame-alist (if diredp-image-show-this-file-use-frame-flag
3143 (cons `(height . ,window-min-height)
3144 special-display-frame-alist)
3145 special-display-frame-alist))
3146 (special-display-buffer-names (if diredp-image-show-this-file-use-frame-flag
3147 (cons image-dired-display-image-buffer
3148 special-display-buffer-names)
3149 special-display-buffer-names)))
3150 (display-buffer image-dired-display-image-buffer)
3151 (image-dired-display-image img-file (not arg))))
3152 (message "No image file here")))) ; An error is handled by `diredp-get-image-filename'.
3153
3154 ;;; Face Definitions
3155
3156 (defface diredp-autofile-name
3157 '((((background dark)) (:background "#111313F03181")) ; Very dark blue
3158 (t (:background "#EEECEC0FCE7E"))) ; Very pale goldenrod
3159 "*Face used in Dired for names of files that are autofile bookmarks."
3160 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3161 (defvar diredp-autofile-name 'diredp-autofile-name)
3162
3163 (defface diredp-compressed-file-name
3164 '((((background dark)) (:foreground "Blue"))
3165 (t (:foreground "Brown")))
3166 "*Face used for compressed file names."
3167 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3168 (defvar diredp-compressed-file-name 'diredp-compressed-file-name)
3169
3170 (defface diredp-compressed-file-suffix
3171 '((((background dark)) (:foreground "Blue"))
3172 (t (:foreground "Yellow")))
3173 "*Face used for compressed file suffixes in Dired buffers.
3174 This means the `.' plus the file extension. Example: `.zip'."
3175 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3176 (defvar diredp-compressed-file-suffix 'diredp-compressed-file-suffix)
3177
3178 (defface diredp-date-time
3179 '((((background dark)) (:foreground "#74749A9AF7F7")) ; ~ med blue
3180 (t (:foreground "DarkGoldenrod4")))
3181 "*Face used for date and time in Dired buffers."
3182 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3183 (defvar diredp-date-time 'diredp-date-time)
3184
3185 (defface diredp-deletion
3186 '((t (:foreground "Yellow" :background "Red")))
3187 "*Face used for deletion flags (D) in Dired buffers."
3188 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3189 (defvar diredp-deletion 'diredp-deletion)
3190
3191 (defface diredp-deletion-file-name
3192 '((t (:foreground "Red")))
3193 "*Face used for names of deleted files in Dired buffers."
3194 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3195 (defvar diredp-deletion-file-name 'diredp-deletion-file-name)
3196
3197 (defface diredp-dir-heading
3198 '((((background dark)) (:foreground "Yellow" :background "#00003F3F3434")) ; ~ dark green
3199 (t (:foreground "Blue" :background "Pink")))
3200 "*Face used for directory headings in Dired buffers."
3201 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3202 (defvar diredp-dir-heading 'diredp-dir-heading)
3203
3204 (defface diredp-dir-name
3205 '((((background dark))
3206 (:foreground "#7474FFFFFFFF" :background "#2C2C2C2C2C2C")) ; ~ cyan, dark gray
3207 (t (:foreground "DarkRed" :background "LightGray")))
3208 "*Face used for directory names."
3209 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3210 (defvar diredp-dir-name 'diredp-dir-name)
3211
3212 (defface diredp-dir-priv
3213 '((((background dark))
3214 (:foreground "#7474FFFFFFFF" :background "#2C2C2C2C2C2C")) ; ~ cyan, dark gray
3215 (t (:foreground "DarkRed" :background "LightGray")))
3216 "*Face used for directory privilege indicator (d) in Dired buffers."
3217 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3218 (defvar diredp-dir-priv 'diredp-dir-priv)
3219
3220 (defface diredp-exec-priv
3221 '((((background dark)) (:background "#4F4F3B3B2121")) ; ~ dark brown
3222 (t (:background "LightSteelBlue")))
3223 "*Face used for execute privilege indicator (x) in Dired buffers."
3224 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3225 (defvar diredp-exec-priv 'diredp-exec-priv)
3226
3227 ;; For this to show up, you need `F' among the options in `dired-listing-switches'.
3228 ;; For example, I use "-alF" for `dired-listing-switches'.
3229 (defface diredp-executable-tag
3230 '((t (:foreground "Red")))
3231 "*Face used for executable tag (*) on file names in Dired buffers."
3232 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3233 (defvar diredp-executable-tag 'diredp-executable-tag)
3234
3235 (defface diredp-file-name
3236 '((((background dark)) (:foreground "Yellow"))
3237 (t (:foreground "Blue")))
3238 "*Face used for file names (without suffixes) in Dired buffers.
3239 This means the base name. It does not include the `.'."
3240 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3241 (defvar diredp-file-name 'diredp-file-name)
3242
3243 (defface diredp-file-suffix
3244 '((((background dark)) (:foreground "#7474FFFF7474")) ; ~ light green
3245 (t (:foreground "DarkMagenta")))
3246 "*Face used for file suffixes in Dired buffers.
3247 This means the `.' plus the file extension. Example: `.elc'."
3248 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3249 (defvar diredp-file-suffix 'diredp-file-suffix)
3250
3251 (defface diredp-flag-mark
3252 '((((background dark)) (:foreground "Blue" :background "#7575D4D41D1D")) ; ~ olive green
3253 (t (:foreground "Yellow" :background "Blueviolet")))
3254 "*Face used for flags and marks (except D) in Dired buffers."
3255 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3256 (defvar diredp-flag-mark 'diredp-flag-mark)
3257
3258 (defface diredp-flag-mark-line
3259 '((((background dark)) (:background "#787831311414")) ; ~ dark red brown
3260 (t (:background "Skyblue")))
3261 "*Face used for flagged and marked lines in Dired buffers."
3262 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3263 (defvar diredp-flag-mark-line 'diredp-flag-mark-line)
3264
3265 (defface diredp-ignored-file-name
3266 '(;; (((background dark)) (:foreground "#FFFF921F921F")) ; ~ salmon
3267 ;; (((background dark)) (:foreground "#A71F5F645F64")) ; ~ dark salmon
3268 (((background dark)) (:foreground "#C29D6F156F15")) ; ~ salmon
3269 (t (:foreground "#00006DE06DE0"))) ; ~ dark cyan
3270 "*Face used for ignored file names in Dired buffers."
3271 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3272 (defvar diredp-ignored-file-name 'diredp-ignored-file-name)
3273
3274 (defface diredp-link-priv
3275 '((((background dark)) (:foreground "#00007373FFFF")) ; ~ blue
3276 (t (:foreground "DarkOrange")))
3277 "*Face used for link privilege indicator (l) in Dired buffers."
3278 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3279 (defvar diredp-link-priv 'diredp-link-priv)
3280
3281 (when (> emacs-major-version 21)
3282 (defface diredp-mode-line-marked
3283 '((t (:foreground "DarkViolet")))
3284 "*Face for marked number in mode-line `mode-name' for Dired buffers."
3285 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3286
3287 (defface diredp-mode-line-flagged
3288 '((t (:foreground "Red")))
3289 "*Face for flagged number in mode-line `mode-name' for Dired buffers."
3290 :group 'Dired-Plus :group 'font-lock-highlighting-faces))
3291
3292 (defface diredp-no-priv
3293 '((((background dark)) (:background "#2C2C2C2C2C2C")) ; ~ dark gray
3294 (t (:background "LightGray")))
3295 "*Face used for no privilege indicator (-) in Dired buffers."
3296 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3297 (defvar diredp-no-priv 'diredp-no-priv)
3298
3299 (defface diredp-number
3300 '((((background dark)) (:foreground "#FFFFFFFF7474")) ; ~ light yellow
3301 (t (:foreground "DarkBlue")))
3302 "*Face used for numerical fields in Dired buffers.
3303 In particular, inode number, number of hard links, and file size."
3304 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3305 (defvar diredp-number 'diredp-number)
3306
3307 (defface diredp-other-priv
3308 '((((background dark)) (:background "#111117175555")) ; ~ dark blue
3309 (t (:background "PaleGoldenrod")))
3310 "*Face used for l,s,S,t,T privilege indicators in Dired buffers."
3311 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3312 (defvar diredp-other-priv 'diredp-other-priv)
3313
3314 (defface diredp-rare-priv
3315 '((((background dark)) (:foreground "Green" :background "#FFFF00008080")) ; ~ hot pink
3316 (t (:foreground "Magenta" :background "SpringGreen")))
3317 "*Face used for rare privilege indicators (b,c,s,m,p,S) in Dired buffers."
3318 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3319 (defvar diredp-rare-priv 'diredp-rare-priv)
3320
3321 (defface diredp-read-priv
3322 '((((background dark)) (:background "#999932325555")) ; ~ burgundy / dark magenta
3323 (t (:background "MediumAquamarine")))
3324 "*Face used for read privilege indicator (w) in Dired buffers."
3325 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3326 (defvar diredp-read-priv 'diredp-read-priv)
3327
3328 (defface diredp-symlink
3329 '((((background dark)) (:foreground "#00007373FFFF")) ; ~ blue
3330 (t (:foreground "DarkOrange")))
3331 "*Face used for symbolic links in Dired buffers."
3332 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3333 (defvar diredp-symlink 'diredp-symlink)
3334
3335 (defface diredp-tagged-autofile-name
3336 '((((background dark)) (:background "#328C0411328C")) ; Very dark magenta
3337 (t (:background "#CD73FBEECD73"))) ; Very pale green
3338 "*Face used in Dired for names of files that are autofile bookmarks."
3339 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3340 (defvar diredp-tagged-autofile-name 'diredp-tagged-autofile-name)
3341
3342 (defface diredp-write-priv
3343 '((((background dark)) (:background "#25258F8F2929")) ; ~ dark green
3344 (t (:background "Orchid")))
3345 "*Face used for write privilege indicator (w) in Dired buffers."
3346 :group 'Dired-Plus :group 'font-lock-highlighting-faces)
3347 (defvar diredp-write-priv 'diredp-write-priv)
3348
3349 ;; Fix Emacs 20 recognition of fields up through file name when size is expressed using `k' etc.
3350 (when (and (< emacs-major-version 21) (not (boundp 'diredp-loaded-p))
3351 dired-move-to-filename-regexp ; These last two checks are just in case.
3352 (eq (aref dired-move-to-filename-regexp 7) ?\ ))
3353 (setq dired-move-to-filename-regexp (concat "[0-9][BkKMGTPEZY]?"
3354 (substring dired-move-to-filename-regexp 7))))
3355
3356 ;;; Define second level of fontifying.
3357 (defvar diredp-font-lock-keywords-1
3358 (list
3359 '("^ \\(.+:\\)$" 1 diredp-dir-heading) ; Directory headers
3360 '("^ wildcard.*$" 0 'default) ; Override others, e.g. `l' for `diredp-other-priv'.
3361 '("^ (No match).*$" 0 'default) ; Override others, e.g. `t' for `diredp-other-priv'.
3362 '("[^ .]\\(\\.[^. /]+\\)$" 1 diredp-file-suffix) ; Suffix, including `.'.
3363 '("\\([^ ]+\\) -> .+$" 1 diredp-symlink) ; Symbolic links
3364
3365 ;; 1) Date/time and 2) filename w/o suffix.
3366 ;; This is a bear, and it is fragile - Emacs can change `dired-move-to-filename-regexp'.
3367 (if (or (not (fboundp 'version<)) (version< emacs-version "23.2"))
3368 (list dired-move-to-filename-regexp
3369 (list 1 'diredp-date-time t t) ; Date/time
3370 (list (concat "\\(.+\\)\\(" (concat (funcall #'regexp-opt diredp-compressed-extensions)
3371 "\\)[*]?$")) ; Compressed-file name
3372 nil nil (list 0 diredp-compressed-file-name 'keep t)))
3373 `(,dired-move-to-filename-regexp
3374 (7 diredp-date-time t t) ; Date/time, locale (western or eastern)
3375 (2 diredp-date-time t t) ; Date/time, ISO
3376 (,(concat "\\(.+\\)\\(" (concat (funcall #'regexp-opt diredp-compressed-extensions)
3377 "\\)[*]?$"))
3378 nil nil (0 diredp-compressed-file-name keep t)))) ; Compressed-file suffix
3379 (if (or (not (fboundp 'version<)) (version< emacs-version "23.2"))
3380 (list dired-move-to-filename-regexp
3381 (list 1 'diredp-date-time t t) ; Date/time
3382 (list "\\(.+\\)$" nil nil (list 0 diredp-file-name 'keep t))) ; Filename
3383 `(,dired-move-to-filename-regexp
3384 (7 diredp-date-time t t) ; Date/time, locale (western or eastern)
3385 (2 diredp-date-time t t) ; Date/time, ISO
3386 ("\\(.+\\)$" nil nil (0 diredp-file-name keep t)))) ; Filename (not a compressed file)
3387
3388 ;; Files to ignore
3389 (list (concat "^ \\(.*\\("
3390 (mapconcat #'regexp-quote (or (and (boundp 'dired-omit-extensions) dired-omit-extensions)
3391 completion-ignored-extensions)
3392 "[*]?\\|")
3393 (and diredp-ignore-compressed-flag
3394 (concat "\\|" (mapconcat #'regexp-quote diredp-compressed-extensions "[*]?\\|")))
3395 "[*]?\\)\\)$") ; Allow for executable flag (*).
3396 1 diredp-ignored-file-name t)
3397
3398 ;; Compressed-file (suffix)
3399 (list (concat "\\(" (concat (funcall #'regexp-opt diredp-compressed-extensions) "\\)[*]?$"))
3400 1 diredp-compressed-file-suffix t)
3401 '("\\([*]\\)$" 1 diredp-executable-tag t) ; Executable (*)
3402
3403 ;; Inode, hard-links, & file size (. and , are for the decimal point, depending on locale)
3404 ;; See comment for `directory-listing-before-filename-regexp' in `files.el' or `files+.el'.
3405 '("\\(\\([0-9]+\\([.,][0-9]+\\)?\\)[BkKMGTPEZY]?[ /]?\\)" 1 diredp-number)
3406
3407 ;; Directory names - exclude d:/..., Windows drive letter in a dir heading.
3408 (list (concat dired-re-maybe-mark dired-re-inode-size "\\(d\\)[^:]")
3409 '(1 diredp-dir-priv t) '(".+" (dired-move-to-filename) nil (0 diredp-dir-name t)))
3410
3411 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]........\\(x\\)") ; o x
3412 '(1 diredp-exec-priv))
3413 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]........\\([lsStT]\\)") ; o misc
3414 '(1 diredp-other-priv))
3415 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].......\\(w\\).") ; o w
3416 '(1 diredp-write-priv))
3417 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]......\\(r\\)..") ; o r
3418 '(1 diredp-read-priv))
3419 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].....\\(x\\)...") ; g x
3420 '(1 diredp-exec-priv))
3421 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].....\\([lsStT]\\)...") ; g misc
3422 '(1 diredp-other-priv))
3423 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]....\\(w\\)....") ; g w
3424 '(1 diredp-write-priv))
3425 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]...\\(r\\).....") ; g r
3426 '(1 diredp-read-priv))
3427 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]..\\(x\\)...") ; u x
3428 '(1 diredp-exec-priv))
3429 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]..\\([lsStT]\\)...") ; u misc
3430 '(1 diredp-other-priv))
3431 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].\\(w\\)....") ; u w
3432 '(1 diredp-write-priv))
3433 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]\\(r\\).....") ; u r
3434 '(1 diredp-read-priv))
3435
3436 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]........\\([-rwxlsStT]\\)") ; o -
3437 '(1 diredp-no-priv keep))
3438 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].......\\([-rwxlsStT]\\).") ; g -
3439 '(1 diredp-no-priv keep))
3440 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]......\\([-rwxlsStT]\\)..") ; u -
3441 '(1 diredp-no-priv keep))
3442 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].....\\([-rwxlsStT]\\)...") ; o -
3443 '(1 diredp-no-priv keep))
3444 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]....\\([-rwxlsStT]\\)....") ; g -
3445 '(1 diredp-no-priv keep))
3446 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]...\\([-rwxlsStT]\\).....") ; u -
3447 '(1 diredp-no-priv keep))
3448 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]..\\([-rwxlsStT]\\)......") ; o -
3449 '(1 diredp-no-priv keep))
3450 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl].\\([-rwxlsStT]\\).......") ; g -
3451 '(1 diredp-no-priv keep))
3452 (list (concat dired-re-maybe-mark dired-re-inode-size "[-dl]\\([-rwxlsStT]\\)........") ; u -
3453 '(1 diredp-no-priv keep))
3454
3455 (list (concat dired-re-maybe-mark dired-re-inode-size "\\([bcsmpS]\\)") ; (rare)
3456 '(1 diredp-rare-priv keep))
3457 (list (concat dired-re-maybe-mark dired-re-inode-size "\\(l\\)[-rwxlsStT]") ; l
3458 '(1 diredp-rare-priv keep))
3459
3460 (list (concat "^\\([^\n " (char-to-string dired-del-marker) "].*$\\)")
3461 1 diredp-flag-mark-line t) ; Flag/mark lines
3462 (list (concat "^\\([^\n " (char-to-string dired-del-marker) "]\\)") ; Flags, marks (except D)
3463 1 diredp-flag-mark t)
3464
3465 (list (concat "^\\([" (char-to-string dired-del-marker) "].*$\\)") ; Deletion-flagged lines
3466 1 diredp-deletion-file-name t)
3467 (list (concat "^\\([" (char-to-string dired-del-marker) "]\\)") ; Deletion flags (D)
3468 1 diredp-deletion t)
3469
3470 ) "2nd level of Dired highlighting. See `font-lock-maximum-decoration'.")
3471
3472
3473 (defun diredp--set-up-font-locking ()
3474 "Add this to `dired-mode-hook' to provide for second-level fontifying."
3475 (set (make-local-variable 'font-lock-defaults)
3476 ;; Two levels. Use 3-element list, since it is standard to have one more
3477 ;; than the number of levels. This is necessary for it to work with
3478 ;; `font(-lock)-menus.el'.
3479 '((dired-font-lock-keywords
3480 dired-font-lock-keywords
3481 diredp-font-lock-keywords-1)
3482 t nil nil beginning-of-line))
3483 ;; Refresh `font-lock-keywords' from `font-lock-defaults'
3484 (when (fboundp 'font-lock-refresh-defaults) (font-lock-refresh-defaults)))
3485
3486 ;;; Provide for the second level of fontifying.
3487 (add-hook 'dired-mode-hook 'diredp--set-up-font-locking)
3488
3489 ;; Ensure that Dired buffers are refontified when you use `g' or otherwise read in the file list.
3490 (defun diredp-refontify-buffer ()
3491 "Turn `font-lock-mode' off, then on."
3492 (setq font-lock-mode nil)
3493 (font-lock-mode))
3494 (add-hook 'dired-after-readin-hook 'diredp-refontify-buffer)
3495
3496 ;;; Function Definitions
3497
3498 ;;; $$$$$$$$
3499 ;;; (defun diredp-dired-files (arg &optional switches) ; Not bound
3500 ;;; "Like `dired', but non-positive prefix arg prompts for files to list.
3501 ;;; This is like `dired' unless you use a non-positive prefix arg.
3502 ;;; In that case, you are prompted for names of files and directories to
3503 ;;; list, and then you are prompted for the name of the Dired buffer that
3504 ;;; lists them. Use `C-g' when you are done entering file names to list.
3505
3506 ;;; In all cases, when inputting a file or directory name you can use
3507 ;;; shell wildcards.
3508
3509 ;;; If you use Icicles, then in Icicle mode the following keys are bound
3510 ;;; in the minibuffer during completion (`*' means the key requires
3511 ;;; library `Bookmark+'):
3512
3513 ;;; M-| - Open Dired on the file names matching your input
3514 ;;; C-c + - Create a new directory
3515 ;;; *C-x a + - Add tags to the current-candidate file
3516 ;;; *C-x a - - Remove tags from the current-candidate file
3517 ;;; *C-x m - Access file bookmarks (not just autofiles)"
3518 ;;; (interactive (diredp-dired-files-interactive-spec ""))
3519 ;;; (when (consp arg)
3520 ;;; (let ((buf (dired-find-buffer-nocreate (car arg)))) ; Respect file list.
3521 ;;; (when buf (kill-buffer buf))))
3522 ;;; (switch-to-buffer (dired-noselect arg switches)))
3523
3524 ;;; (defun diredp-dired-files-other-window (arg &optional switches) ; Not bound
3525 ;;; "Same as `diredp-dired-files' except uses another window."
3526 ;;; (interactive (diredp-dired-files-interactive-spec "in other window "))
3527 ;;; (when (consp arg)
3528 ;;; (let ((buf (dired-find-buffer-nocreate (car arg)))) ; Respect file list.
3529 ;;; (when buf (kill-buffer buf))))
3530 ;;; (dired-other-window arg switches))
3531
3532 ;;;###autoload
3533 (defun diredp-dired-for-files (arg &optional switches) ; Bound to `C-x D F'
3534 "Dired file names that you enter, in a Dired buffer that you name.
3535 You are prompted for the name of the Dired buffer to use.
3536 You are then prompted for names of files and directories to list,
3537 which can be located anywhere.
3538 Use `C-g' when you are done.
3539
3540 With a prefix arg you are first prompted for the `ls' switches to use.
3541
3542 See also `dired' (including the advice)."
3543 (interactive (let ((current-prefix-arg (if current-prefix-arg 0 -1)))
3544 (dired-read-dir-and-switches "" 'READ-EXTRA-FILES-P)))
3545 (dired arg switches))
3546
3547 ;;;###autoload
3548 (defun diredp-dired-for-files-other-window (arg &optional switches) ; Bound to `C-x 4 D F'
3549 "Same as `diredp-dired-for-files', except uses another window."
3550 (interactive (let ((current-prefix-arg (if current-prefix-arg 0 -1)))
3551 (dired-read-dir-and-switches "in other window " 'READ-EXTRA-FILES-P)))
3552 (dired-other-window arg switches))
3553
3554 ;;;###autoload
3555 (defun diredp-dired-recent-dirs (buffer &optional arg) ; Bound to `C-x D R'
3556 "Open Dired in BUFFER, showing recently used directories.
3557 You are prompted for BUFFER.
3558
3559 No prefix arg or a plain prefix arg (`C-u', `C-u C-u', etc.) means
3560 list all of the recently used directories.
3561
3562 With a prefix arg:
3563 * If 0, `-', or plain (`C-u') then you are prompted for the `ls'
3564 switches to use.
3565 * If not plain (`C-u') then:
3566 * If >= 0 then the directories to include are read, one by one.
3567 * If < 0 then the directories to exclude are read, one by one.
3568
3569 When entering directories to include or exclude, use `C-g' to end."
3570 (interactive (list (completing-read "Dired buffer name: " dired-buffers) current-prefix-arg))
3571 (unless (require 'recentf nil t) (error "This command requires library `recentf.el'"))
3572 (let ((switches (and (or (zerop (prefix-numeric-value arg)) (consp arg))
3573 (read-string "Dired listing switches: " dired-listing-switches))))
3574 (dired (cons (generate-new-buffer-name buffer) (diredp-recent-dirs arg)) switches)))
3575
3576 ;;;###autoload
3577 (defun diredp-dired-recent-dirs-other-window (buffer &optional arg) ; Bound to `C-x 4 D R'
3578 "Same as `diredp-dired-recent-dirs', but use other window."
3579 (interactive (list (completing-read "Dired buffer name: " dired-buffers) current-prefix-arg))
3580 (unless (require 'recentf nil t) (error "This command requires library `recentf.el'"))
3581 (let ((switches (and (or (zerop (prefix-numeric-value arg)) (consp arg) (eq '- arg))
3582 (read-string "Dired listing switches: " dired-listing-switches))))
3583 (dired-other-window (cons (generate-new-buffer-name buffer) (diredp-recent-dirs arg)) switches)))
3584
3585 (defun diredp-recent-dirs (arg)
3586 "Return a list of recently used directories.
3587 ARG is as for `diredp-dired-recent-dirs'."
3588 (let ((recent-dirs (diredp-remove-if #'diredp-root-directory-p
3589 (diredp-delete-dups
3590 (mapcar (lambda (f/d)
3591 (if (file-directory-p f/d) f/d (file-name-directory f/d)))
3592 recentf-list)))))
3593 (if (and arg (atom arg))
3594 (diredp-read-include/exclude 'Dir recent-dirs (not (natnump (prefix-numeric-value arg))))
3595 recent-dirs)))
3596
3597 (defun diredp-read-include/exclude (thing things &optional exclude)
3598 "Read which THINGs to include (or to EXCLUDE, if non-nil) from list THINGS.
3599 The things are read one by one. `C-g' stops reading.
3600
3601 THING is a string or symbol naming the type of thing to read, e.g.,
3602 `File' or `Directory'. It is used only in the prompt, which is THING
3603 followed by \" to exclude\" or \" to include\" and a reminder about `C-g'.
3604
3605 A new list is returned - list THINGS is not modified."
3606 (let* ((thgs (if exclude (copy-sequence things) ()))
3607 (prompt (format "%s to %s (C-g when done): " thing (if exclude 'EXCLUDE 'INCLUDE)))
3608 (completion-ignore-case (or (and (boundp 'read-file-name-completion-ignore-case)
3609 (memq thing '(Dir Directory File "Dir" "Directory" "File")) ; Hack
3610 read-file-name-completion-ignore-case)
3611 completion-ignore-case))
3612 thing)
3613 (while (condition-case nil
3614 (setq thing (completing-read prompt (mapcar #'list things) nil t))
3615 (quit nil))
3616 (if exclude (delete thing thgs)
3617 (push thing thgs)))
3618 thgs))
3619
3620 ;;; $$$$$$$$
3621 ;;; (defun diredp-dired-files-interactive-spec (str)
3622 ;;; "`interactive' spec for `diredp-dired-files' commands.
3623 ;;; STR is a string appended to the prompt.
3624 ;;; With non-negative prefix arg, read switches.
3625 ;;; With non-positive prefix arg, read files and dirs to list and then the
3626 ;;; Dired buffer name. User uses `C-g' when done reading files and dirs.
3627
3628 ;;; If you use Icicles, then in Icicle mode the following keys are bound
3629 ;;; in the minibuffer during completion (`*' means the key requires
3630 ;;; library `Bookmark+'):
3631
3632 ;;; M-| - Open Dired on the file names matching your input
3633 ;;; C-c + - Create a new directory
3634 ;;; *C-x a + - Add tags to the current-candidate file
3635 ;;; *C-x a - - Remove tags from the current-candidate file
3636 ;;; *C-x m - Access file bookmarks (not just autofiles)"
3637 ;;; (list
3638 ;;; (unwind-protect
3639 ;;; (let ((icicle-sort-comparer (or (and (boundp 'icicle-file-sort) ;; If not reading files
3640 ;;; icicle-file-sort) ;; then dirs first.
3641 ;;; (and (> (prefix-numeric-value current-prefix-arg) 0)
3642 ;;; 'icicle-dirs-first-p)
3643 ;;; icicle-sort-comparer))
3644 ;;; (icicle-all-candidates-list-alt-action-fn ; M-|'
3645 ;;; (lambda (files)
3646 ;;; (let ((enable-recursive-minibuffers t))
3647 ;;; (dired-other-window (cons (read-string "Dired buffer name: ") files))))))
3648 ;;; (when (fboundp 'icicle-bind-file-candidate-keys) (icicle-bind-file-candidate-keys))
3649 ;;; (if (> (prefix-numeric-value current-prefix-arg) 0)
3650 ;;; ;; If a dialog box is about to be used, call `read-directory-name' so the dialog
3651 ;;; ;; code knows we want directories. Some dialog boxes can only select directories
3652 ;;; ;; or files when popped up, not both.
3653 ;;; (if (and (fboundp 'read-directory-name) (next-read-file-uses-dialog-p))
3654 ;;; (read-directory-name (format "Dired %s(directory): " str) nil
3655 ;;; default-directory nil)
3656 ;;; (read-file-name (format "Dired %s(directory): " str) nil default-directory nil))
3657 ;;; (let ((insert-default-directory nil)
3658 ;;; (files ())
3659 ;;; file)
3660 ;;; (while (condition-case nil ; Use lax completion, to allow wildcards.
3661 ;;; (setq file (read-file-name "File or dir (C-g when done): "))
3662 ;;; (quit nil))
3663 ;;; (push file files))
3664 ;;; (cons (read-string "Dired buffer name: " nil nil default-directory) files))))
3665 ;;; (when (fboundp 'icicle-unbind-file-candidate-keys)
3666 ;;; (icicle-unbind-file-candidate-keys)))
3667 ;;; (and current-prefix-arg (natnump (prefix-numeric-value current-prefix-arg))
3668 ;;; (read-string "Dired listing switches: " dired-listing-switches))))
3669
3670 ;;;###autoload
3671 (defun diredp-dired-union (dired-name dirbufs &optional switches extra) ; Bound to `C-x 4 D U'
3672 "Create a Dired buffer that is the union of some existing Dired buffers.
3673 With a non-negative prefix arg, you are prompted for `ls' switches.
3674 With a non-positive prefix arg, you are prompted for file and dir
3675 names to add to the listing - see below.
3676
3677 You are prompted for the name of the Dired union buffer. Completion
3678 against names of existing Dired buffers is available, but you can
3679 enter any other name to create a new Dired buffer of that name.
3680
3681 If the union buffer name you choose names an existing Dired buffer,
3682 then what happens depends on whether that buffer is an ordinary Dired
3683 directory listing or a list of arbitrary file names. That is, it
3684 depends on whether `dired-directory' is a directory name or a cons of
3685 a Dired buffer name plus file names.
3686
3687 * If the buffer is an ordinary Dired listing, then it is converted to
3688 an explicit list of absolute file names, just as if these had been
3689 chosen individually. The existing buffer and window are replaced by
3690 new ones that show the explicit listing. (This replacement is
3691 necessary because the list of files contained in an ordinary Dired
3692 listing cannot be modified.)
3693
3694 * If the buffer lists arbitrary file names explicitly, then it is
3695 updated to include also the files from any Dired buffers and any
3696 additional files that you specify.
3697
3698 If the union buffer name you choose does not name an existing Dired
3699 buffer, then its `default-directory' is the same as the
3700 `default-directory' before invoking the command.
3701
3702 If you use a non-positive prefix arg, then you can next choose
3703 additional file and directory names to add to the listing. Use `C-g'
3704 when done choosing them.
3705
3706 Any directory names you choose this way are included as single entries
3707 in the listing - the directory contents are not included (these
3708 directories are not unioned). To instead include the contents of a
3709 directory chosen this way, use a glob pattern: `/*' after the
3710 directory name.
3711
3712 You are then prompted for the Dired buffers to union. Use `C-g' when
3713 done choosing them. These Dired listings to union are included in the
3714 order that you chose them, and each entry is listed only once in the
3715 new Dired buffer.
3716
3717 The new Dired listing respects the markings, subdirectory insertions,
3718 and hidden subdirectories of the selected Dired listings. However, in
3719 case of conflict between marked or unmarked status for the same entry,
3720 the entry is marked. Similarly, in case of conflict over an included
3721 subdirectory between it being hidden or shown, it is hidden, but its
3722 contained files are also listed.
3723
3724 See also command `diredp-add-to-dired-buffer'.
3725
3726 From Lisp:
3727 DIRED-NAME is the name of the resulting Dired union buffer.
3728 DIRBUFS is a list of the names of Dired buffers to union.
3729 SWITCHES is a string of `ls' switches.
3730 EXTRA is a list of files & directories to be included in the listing."
3731 (interactive (diredp-dired-union-interactive-spec "UNION "
3732 nil
3733 (and current-prefix-arg
3734 (<= (prefix-numeric-value current-prefix-arg) 0))))
3735 (diredp-dired-union-1 dired-name dirbufs switches extra))
3736
3737 ;;;###autoload
3738 (defun diredp-dired-union-other-window (dired-name dirbufs &optional switches extra) ; Bound to `C-x 4 D U'
3739 "Same as `diredp-dired-union', except use other window."
3740 (interactive (diredp-dired-union-interactive-spec "UNION "
3741 nil
3742 (and current-prefix-arg
3743 (<= (prefix-numeric-value current-prefix-arg) 0))))
3744 (diredp-dired-union-1 dired-name dirbufs switches extra 'OTHERWIN))
3745
3746 ;;;###autoload
3747 (defun diredp-add-to-dired-buffer (dired-name to-add &optional switches) ; Bound to `C-x D A'
3748 "Add individual file and directory names to a Dired buffer.
3749 You are prompted for the buffer name.
3750 With a prefix arg, you are also prompted for the `ls' switches.
3751
3752 The buffer must either not exist yet or must list arbitrary file and
3753 directory names. That is, it cannot be an ordinary Dired directory
3754 listing - those cannot be modified.
3755
3756 Any directory names you choose this way are included as single entries
3757 in the listing - the directory contents are not included (these
3758 directories are not unioned). To instead include the contents of a
3759 directory chosen this way, use a glob pattern: `/*' after the
3760 directory name.
3761
3762 See also command `diredp-dired-union'.
3763
3764 From Lisp:
3765 DIRED-NAME is the name of the Dired buffer to modify.
3766 TO-ADD is the list of files and dirs to add to it.
3767 SWITCHES is the string of `ls' switches."
3768 ;; Bind `current-prefix-arg' to force reading file/dir names.
3769 ;; Read `ls' switches too, if user used prefix arg.
3770 (interactive
3771 (let* ((current-prefix-arg (if current-prefix-arg 0 -1))
3772 (all (diredp-dired-union-interactive-spec "add files/dirs "
3773 'NO-DIRED-BUFS
3774 'READ-EXTRA-FILES-P)))
3775 (list (nth 0 all) (nth 3 all) (nth 2 all))))
3776 (diredp-dired-union-1 dired-name () switches to-add))
3777
3778 ;;;###autoload
3779 (defun diredp-add-to-dired-buffer-other-window (dired-name to-add &optional switches) ; Bound to `C-x 4 D A'
3780 "Same as `diredp-add-to-dired-buffer', except use other window."
3781 ;; Bind `current-prefix-arg' to force reading file/dir names.
3782 ;; Read `ls' switches too, if user used prefix arg.
3783 (interactive
3784 (let* ((current-prefix-arg (if current-prefix-arg 0 -1))
3785 (all (diredp-dired-union-interactive-spec "add files/dirs "
3786 'NO-DIRED-BUFS
3787 'READ-EXTRA-FILES-P)))
3788 (list (nth 0 all) (nth 3 all) (nth 2 all))))
3789 (diredp-dired-union-1 dired-name () switches to-add 'OTHERWIN))
3790
3791 ;;;###autoload
3792 (defun diredp-add-to-this-dired-buffer (dired-name to-add &optional switches) ; Not bound by default
3793 "Same as `diredp-add-to-dired-buffer' for this Dired buffer."
3794 ;; Bind `current-prefix-arg' to force reading file/dir names.
3795 ;; Read `ls' switches too, if user used prefix arg.
3796 (interactive
3797 (progn (unless (derived-mode-p 'dired-mode) (error "Not in a Dired buffer"))
3798 (let* ((current-prefix-arg (if current-prefix-arg 0 -1))
3799 (all (diredp-dired-union-interactive-spec "add files/dirs here "
3800 'NO-DIRED-BUFS
3801 'READ-EXTRA-FILES-P
3802 (buffer-name))))
3803 (list (nth 0 all) (nth 3 all) (nth 2 all)))))
3804 (diredp-dired-union-1 dired-name () switches to-add))
3805
3806 ;; $$$$$ Maybe I should set `dired-sort-inhibit' to t for now (?),
3807 ;; since there is an Emacs bug (at least on Windows) that prevents
3808 ;; sorting from working for a Dired buffer with an explicit file list.
3809 (defun diredp-dired-union-1 (dired-name dirbufs switches extra &optional otherwin)
3810 "Helper for `diredp-dired-union' and `diredp-add-to-dired-buffer'.
3811 Non-nil optional OTHERWIN means use other window for the Dired buffer.
3812 See `diredp-dired-union' for the other argument descriptions."
3813 (let ((dbuf (get-buffer dired-name))
3814 (files extra)
3815 (marked ())
3816 (subdirs ())
3817 (hidden-dirs ())
3818 hid-here files-here)
3819 (dolist (buf (reverse dirbufs))
3820 (with-current-buffer buf
3821 (unwind-protect
3822 (progn (setq hid-here (save-excursion (dired-remember-hidden))
3823 files-here (if (consp dired-directory)
3824 (reverse (cdr dired-directory)) ; Reverse bc will push.
3825 ()))
3826 (unless files-here
3827 (save-excursion ; This bit is more or less from `dired-toggle-marks'.