comparison lisp/efs/dired-help.el @ 22:8fc7fe29b841 r19-15b94

Import from CVS: tag r19-15b94
author cvs
date Mon, 13 Aug 2007 08:50:29 +0200
parents
children 7e54bd776075 9f59509498e1
comparison
equal deleted inserted replaced
21:b88636d63495 22:8fc7fe29b841
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;
3 ;; File: dired-help.el
4 ;; Dired Version: $Revision: 1.1 $
5 ;; RCS:
6 ;; Description: Obtaining help for dired
7 ;; Modified: Sun Nov 20 21:10:47 1994 by sandy on gandalf
8 ;;
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10
11 ;;; Requirements and provisions
12 (provide 'dired-help)
13 (require 'dired)
14 (autoload 'reporter-submit-bug-report "reporter")
15 (defvar reporter-version) ; For the byte-compiler.
16
17 ;;; Constants
18
19 (defconst dired-bug-address "efs-bugs@cuckoo.hpl.hp.com")
20
21 (defvar dired-documentation nil)
22
23 ;;; Functions
24
25 (defun dired-documentation ()
26 (or dired-documentation
27 (let ((18-p (string-equal "18." (substring emacs-version 0 3)))
28 (var-help-key (substitute-command-keys
29 (if (featurep 'ehelp)
30 "\\[electric-describe-variable]"
31 "\\[describe-variable]")))
32 (standard-output (get-buffer-create " dired-help-temp")))
33 (save-excursion
34 (set-buffer standard-output)
35 (unwind-protect
36 (setq dired-documentation
37 (substitute-command-keys
38 (format "\\<dired-mode-map>The Directory Editor:
39
40 For more detailed help, type \\[universal-argument] \\[dired-describe-mode] to start the info
41 documentation browser.
42
43 In dired, you can edit a list of the files in a directory \(and optionally
44 its subdirectories in the `ls -lR' format\).
45
46 Editing a directory means that you can visit, rename, copy, compress,
47 load, byte-compile files. You can change files' attributes, run shell
48 commands on files, or insert subdirectories into the edit buffer. You can
49 \"flag\" files for deletion or \"mark\" files for later commands, either one
50 file at a time or by all files matching certain criteria \(e.g., files that
51 match a certain regexp\).
52
53 You move throughout the buffer using the usual cursor motion commands.
54 Letters no longer insert themselves, but execute commands instead. The
55 digits (0-9) are prefix arguments.
56
57 Most commands operate either on all marked files or on the current file if
58 no files are marked. Use a numeric prefix argument to operate on the next
59 ARG files (or previous ARG if ARG < 0). Use the prefix argument `1' to
60 operate on the current file only. Prefix arguments override marks. Commands
61 which run a sub-process on a group of files will display a list of files
62 for which the sub-process failed. Typing \\[dired-why] will try to tell
63 you what went wrong.
64
65 When editing several directories in one buffer, each directory acts as a
66 page, so \\[backward-page] and \\[forward-page] can be used to move between directories.
67
68 Summary of commands:
69
70 Motion Commands
71 move up to previous line \\[dired-next-line]
72 move down to next line \\[dired-previous-line]
73 move up to previous directory line \\[dired-prev-dirline]
74 move down to next directory line \\[dired-next-dirline]
75 move up to previous subdirectory \\[dired-advertised-prev-subdir]
76 move down to next subdirectory \\[dired-advertised-next-subdir]
77 move to parent directory \\[dired-up-directory]
78 move to first child subdirectory \\[dired-down-directory]
79
80 Immediate Actions on Files
81 visit current file \\[dired-advertised-find-file]
82 visit current file in other window \\[dired-find-file-other-window]
83 visit current file in other frame %s
84 display current file \\[universal-argument] \\[dired-find-file-other-window]
85 create a new subdirectory \\[dired-create-directory]
86 recover file from auto-save \\[dired-recover-file]
87
88 Marking & Unmarking Files
89 mark a file or subdirectory for later commands \\[dired-mark]
90 unmark a file or all files of a subdirectory \\[dired-unmark]
91 unmark all marked files in a buffer \\[dired-unmark-all-files]
92 count marks in buffer 0 \\[dired-unmark-all-files]
93 mark all directories \\[dired-mark-directories]
94 mark all executable files \\[dired-mark-executables]
95 mark file names matching a regular expression \\[dired-mark-files-regexp]
96
97 Commands on Files Marked or Specified by the Prefix
98 rename a file or move files to another directory \\[dired-do-rename]
99 copy files \\[dired-do-copy]
100 delete marked (as opposed to flagged) files \\[dired-do-delete]
101 compress or uncompress files \\[dired-do-compress]
102 uuencode or uudecode files \\[dired-do-uucode]
103 grep files \\[dired-do-grep]
104 search for regular expression \\[dired-do-tags-search]
105 query replace by regular expression \\[dired-do-tags-query-replace]
106 byte-compile files \\[dired-do-byte-compile]
107 load files \\[dired-do-load]
108 shell command on files \\[dired-do-shell-command]
109 operate shell command separately on each file \\[universal-argument] \\[dired-do-shell-command]
110 do as above, but in each file's directory \\[universal-argument] \\[universal-argument] \\[dired-do-shell-command]
111
112 Flagging Files for Deletion (unmark commands remove delete flags)
113 flag file for deletion \\[dired-flag-file-deletion]
114 backup and remove deletion flag \\[dired-backup-unflag]
115 flag all backup files (file names ending in ~) \\[dired-flag-backup-files]
116 flag all auto-save files \\[dired-flag-auto-save-files]
117 clean directory of numeric backups \\[dired-clean-directory]
118 execute the deletions requested (flagged files) \\[dired-expunge-deletions]
119
120 Modifying the Dired Buffer
121 insert a subdirectory in this buffer \\[dired-maybe-insert-subdir]
122 removing a subdir listing \\[dired-kill-subdir]
123 relist single file, marked files, or subdir \\[dired-do-redisplay]
124 re-read all directories (retains all marks) \\[revert-buffer]
125 toggle sorting of current subdir by name/date \\[dired-sort-toggle-or-edit]
126 report on current ls switches 0 \\[dired-sort-toggle-or-edit]
127 edit ls switches for current subdir 1 \\[dired-sort-toggle-or-edit]
128 edit default ls switches for new subdirs 2 \\[dired-sort-toggle-or-edit]
129 sort all subdirs by name/date \\[universal-argument] \\[dired-sort-toggle-or-edit]
130 edit the ls switches for all subdirs \\[universal-argument] \\[universal-argument] \\[dired-sort-toggle-or-edit]
131
132 Hiding File Lines
133 toggle file omission in current subdir \\[dired-omit-toggle]
134 kill marked file lines \\[dired-do-kill-file-lines]
135
136 Help on Dired
137 dired help (what you're reading) \\[dired-describe-mode]
138 dired summary (short help) \\[dired-summary]
139 dired info (full dired info manual) \\[universal-argument] \\[dired-describe-mode]
140 apropos for dired commands \\[dired-apropos]
141 apropos for dired variables \\[universal-argument] \\[dired-apropos]
142
143 Regular Expression Commands
144 mark files with a regular expression \\[dired-mark-files-regexp]
145 copy marked files by regexp \\[dired-do-copy-regexp]
146 rename marked files by regexp \\[dired-do-rename-regexp]
147 omit files by regexp \\[dired-omit-expunge]
148 downcase file names (rename to lowercase) \\[dired-downcase]
149 upcase files names (rename to uppercase) \\[dired-upcase]
150
151 Comparing Files
152 diff file at point with file at mark \\[dired-diff]
153 diff file with its backup \\[dired-backup-diff]
154 merge file at point with file at mark \\[dired-emerge]
155 same as above but use a common ancestor \\[dired-emerge-with-ancestor]
156 ediff file at point with file at mark \\[dired-ediff]
157 patch file at point \\[dired-epatch]
158
159 Mouse Commands
160 %s
161
162 Miscellaneous
163 quit dired \\[dired-quit]
164 insert current directory in minibuffer \\[dired-get-target-directory]
165
166 If the dired buffer gets confused, you can either type \\[revert-buffer] to read all
167 directories again, type \\[dired-do-redisplay] to relist a single file, the marked
168 files, or a subdirectory, or type \\[dired-build-subdir-alist] to parse
169 the directory tree in the buffer again.
170
171 Customization Variables:
172 Use %s to obtain more information.
173
174 %s
175
176 Hook Variables:
177 Use %s to obtain more information.
178
179 %s
180
181 Keybindings:
182 \\{dired-mode-map}"
183
184 ;; arguments to format
185 (if 18-p
186 "Unavailable in Emacs 18"
187 " \\[dired-find-file-other-frame]")
188 (if 18-p
189 " Unavailable in Emacs 18"
190 "\
191 find file with mouse \\[dired-mouse-find-file]
192 mark file at mouse \\[dired-mouse-mark]
193 flag for deletion file at mouse \\[dired-mouse-flag]
194 menu of commands to visit a file \\[dired-visit-popup-menu]
195 menu of operations to do on a file \\[dired-do-popup-menu]
196 insert directory of mouse in minibuffer \\[dired-mouse-get-target]
197 ")
198 var-help-key
199 (progn
200 (erase-buffer)
201 (dired-format-columns-of-files
202 (sort
203 (all-completions
204 "dired-" obarray
205 (function
206 (lambda (sym)
207 (and (user-variable-p sym)
208 (not (dired-hook-variable-p
209 sym))))))
210 'string<) t)
211 (buffer-string))
212 var-help-key
213 (progn
214 (erase-buffer)
215 (dired-format-columns-of-files
216 (sort
217 (all-completions
218 "dired-" obarray
219 (function
220 (lambda (sym)
221 (dired-hook-variable-p sym))))
222 'string<) t)
223 (buffer-string)))))
224 (kill-buffer " dired-help-temp"))))))
225
226 ;;; Commands
227
228 (defun dired-describe-mode (&optional info)
229 "Detailed description of dired mode.
230 With a prefix, runs the info documentation browser for dired."
231 (interactive "P")
232 ;; Getting dired documentation can be a bit slow.
233 (if info
234 (info "dired")
235 (message "Building dired help...")
236 (let* ((buff (get-buffer-create "*Help*"))
237 (standard-output buff)
238 (mess (dired-documentation)))
239 (message "Building dired help... done")
240 (if (featurep 'ehelp)
241 (with-electric-help
242 (function
243 (lambda ()
244 (princ mess)
245 nil))) ; return nil so ehelp puts us at the top of the buffer.
246 (with-output-to-temp-buffer (buffer-name buff)
247 (princ mess)
248 (print-help-return-message))))))
249
250 (defun dired-apropos (string &optional var-p)
251 "Does command apropos for dired commands.
252 With prefix does apropos for dired variables."
253 (interactive
254 (list
255 (if current-prefix-arg
256 (read-string "Dired variable apropos (regexp): ")
257 (read-string "Dired command apropos (regexp): "))
258 current-prefix-arg))
259 (message "Doing dired %s apropos..." (if var-p "variable" "command"))
260 (if (featurep 'ehelp)
261 (with-electric-help
262 (function
263 (lambda ()
264 (dired-apropos-internal string var-p)
265 nil)))
266 (with-output-to-temp-buffer "*Help*"
267 (dired-apropos-internal string var-p)
268 (or (print-help-return-message)
269 (message "Doing dired %s apropos...done"
270 (if var-p "variable" "command"))))))
271
272 (defun dired-apropos-internal (string &optional var-p)
273 (let ((case-fold-search t)
274 (names (sort (all-completions "dired-" obarray
275 (if var-p
276 'user-variable-p
277 'commandp))
278 'string<))
279 doc)
280 (mapcar
281 (function
282 (lambda (x)
283 (and (if var-p (user-variable-p (intern x)) (commandp (intern x)))
284 (progn
285 (setq doc (if var-p
286 (get (intern x) 'variable-documentation)
287 (documentation (intern x))))
288 (and doc (setq doc (substring doc 0 (string-match "\n" doc))))
289 (or (string-match string x)
290 (and doc (string-match string doc))))
291 (progn
292 (princ x)
293 (if var-p (princ " <V>:")
294 (princ " <F>:")
295 (princ (make-string (max 2 (- 30 (length x))) ?\ ))
296 (princ (dired-help-key-description (intern x))))
297 (princ "\n ")
298 (princ doc)
299 (princ "\n")))))
300 names)))
301
302 (defun dired-help-key-description (fun)
303 ;; Returns a help string of keys for fun.
304 (let ((res (mapconcat 'key-description
305 (where-is-internal fun dired-mode-map) ", ")))
306 (if (string-equal res "")
307 "\(not on any keys\)"
308 res)))
309
310 (defun dired-summary ()
311 "Display summary of basic dired commands in the minibuffer."
312 (interactive)
313 (let ((del (where-is-internal 'dired-flag-file-deletion dired-mode-map))
314 (und (where-is-internal 'dired-unmark dired-mode-map))
315 (exp (where-is-internal 'dired-expunge-deletions dired-mode-map))
316 (fin (where-is-internal 'dired-advertised-find-file dired-mode-map))
317 (oth (where-is-internal 'dired-find-file-other-window dired-mode-map))
318 (ren (where-is-internal 'dired-do-rename dired-mode-map))
319 (cop (where-is-internal 'dired-do-copy dired-mode-map))
320 (hel (where-is-internal 'dired-describe-mode dired-mode-map)))
321 (if (member "d" del)
322 (setq del "d-elete")
323 (setq del (substitute-command-keys
324 "\\<dired-mode-map>\\[dired-flag-file-deletion] delete")))
325 (if (member "u" und)
326 (setq und "u-ndelete")
327 (setq und (substitute-command-keys
328 "\\<dired-mode-map>\\[dired-unmark] undelete")))
329 (if (member "x" exp)
330 (setq exp "x-punge")
331 (setq exp (substitute-command-keys
332 "\\<dired-mode-map>\\[dired-expunge-deletions] expunge")))
333 (if (member "f" fin)
334 (setq fin "f-ind")
335 (setq fin (substitute-command-keys
336 "\\<dired-mode-map>\\[dired-advertised-find-file] find")))
337 (if (member "o" oth)
338 (setq oth "o-ther window")
339 (setq oth
340 (substitute-command-keys
341 "\\<dired-mode-map>\\[dired-find-file-other-window] other window")
342 ))
343 (if (member "R" ren)
344 (setq ren "R-ename")
345 (setq ren (substitute-command-keys
346 "\\<dired-mode-map>\\[dired-do-rename] rename")))
347 (if (member "C" cop)
348 (setq cop "C-opy")
349 (setq cop (substitute-command-keys
350 "\\<dired-mode-map>\\[dired-do-copy] copy")))
351 (if (member "h" hel)
352 (setq hel "h-elp")
353 (setq hel (substitute-command-keys
354 "\\<dired-mode-map>\\[describe-mode] help")))
355 (message "%s, %s, %s, %s. %s, %s, %s, %s"
356 del und exp fin oth ren cop hel)))
357
358 (defun dired-hook-variable-p (sym)
359 ;; Returns t if SYM is a hook variable. Just looks at its name.
360 (let ((name (symbol-name sym)))
361 (and (>= (length name) 6)
362 (or (string-equal (substring name -5) "-hook")
363 (string-equal (substring name -6) "-hooks")))))
364
365 ;;; Submitting bug reports.
366
367 (defun dired-report-bug ()
368 "Submit a bug report for dired."
369 (interactive)
370 (let ((reporter-prompt-for-summary-p t))
371 (or (boundp 'reporter-version)
372 (setq reporter-version
373 "Your version of reporter is obsolete. Please upgrade."))
374 (reporter-submit-bug-report
375 dired-bug-address "Dired"
376 (cons
377 'dired-version
378 (nconc
379 (mapcar
380 'intern
381 (sort
382 (let (completion-ignore-case)
383 (all-completions "dired-" obarray 'user-variable-p))
384 'string-lessp))
385 (list 'reporter-version)))
386 (function
387 (lambda ()
388 (save-excursion
389 (mail-position-on-field "subject")
390 (beginning-of-line)
391 (skip-chars-forward "^:\n")
392 (if (looking-at ": Dired;")
393 (progn
394 (goto-char (match-end 0))
395 (delete-char -1)
396 (insert " " dired-version " bug:")))))))))
397
398 ;;; end of dired-help.el