Mercurial > emacs
annotate lisp/dired-x.el @ 25465:1b6d98e8c3ac
Remove unused bitmaps.
(continued_bits, continuation_bits, overlay_bits): Change images.
(x_draw_vertical_border): Use FRAME_X_RIGHT_FLAGS_AREA_WIDTH
instead of FRAME_X_FLAGS_AREA_WIDTH.
(x_after_update_window_line): Ditto.
(x_draw_bitmap): Likewise.
(x_draw_row_bitmaps): Likewise.
(x_draw_glyph_string_box): Likewise.
(x_draw_glyphs): Likewise.
(x_scroll_run): Likewise.
(expose_window_tree): Likewise.
(note_mode_line_highlight): Likewise.
(XTset_vertical_scroll_bar): Likewise.
(x_clip_to_row): Likewise.
(x_set_window_size): Likewise.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 30 Aug 1999 23:14:36 +0000 |
parents | d414a697a646 |
children | ee92c3ce100d |
rev | line source |
---|---|
5426 | 1 ;;; dired-x.el --- Sebastian Kremer's Extra DIRED hacked up for GNU Emacs19 |
2 | |
3 ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de> | |
4 ;; Lawrence R. Dodd <dodd@roebling.poly.edu> | |
5 ;; Maintainer: Lawrence R. Dodd <dodd@roebling.poly.edu> | |
8713
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
6 ;; Version: 2.37+ |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
7 ;; Date: 1994/08/18 19:27:42 |
5426 | 8 ;; Keywords: dired extensions |
9 | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
10 ;; Copyright (C) 1993, 1994, 1997 Free Software Foundation, Inc. |
5426 | 11 |
12 ;; This file is part of GNU Emacs. | |
13 | |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
15 ;; it under the terms of the GNU General Public License as published by | |
7189 | 16 ;; the Free Software Foundation; either version 2, or (at your option) |
5426 | 17 ;; any later version. |
18 | |
19 ;; GNU Emacs is distributed in the hope that it will be useful, | |
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 ;; GNU General Public License for more details. | |
23 | |
24 ;; You should have received a copy of the GNU General Public License | |
14169 | 25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
27 ;; Boston, MA 02111-1307, USA. | |
5426 | 28 |
6694 | 29 ;;; Commentary: |
5426 | 30 |
14169 | 31 ;; This is Sebastian Kremer's excellent dired-x.el (Dired Extra), version |
32 ;; 1.191, hacked up for GNU Emacs 19. Redundant or conflicting material | |
33 ;; has been removed or renamed in order to work properly with dired of | |
34 ;; GNU Emacs 19. All suggestions or comments are most welcomed. | |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
35 |
14169 | 36 ;; |
37 ;; Please, PLEASE, *PLEASE* see the info pages. | |
38 ;; | |
39 | |
40 ;; BUGS: Type M-x dired-x-submit-report and a report will be generated. | |
5426 | 41 |
14169 | 42 ;; INSTALLATION: In your ~/.emacs, |
43 ;; | |
44 ;; (add-hook 'dired-load-hook | |
45 ;; (function (lambda () | |
46 ;; (load "dired-x") | |
47 ;; ;; Set global variables here. For example: | |
48 ;; ;; (setq dired-guess-shell-gnutar "gtar") | |
49 ;; ))) | |
50 ;; (add-hook 'dired-mode-hook | |
51 ;; (function (lambda () | |
52 ;; ;; Set buffer-local variables here. For example: | |
53 ;; ;; (setq dired-omit-files-p t) | |
54 ;; ))) | |
55 ;; | |
56 ;; At load time dired-x.el will install itself, redefine some functions, and | |
57 ;; bind some dired keys. *Please* see the info pages for more details. | |
5426 | 58 |
14169 | 59 ;; CAUTION: If you are using a version of GNU Emacs earlier than 19.20 than |
60 ;; you may have to edit dired.el. The copy of dired.el in GNU Emacs versions | |
61 ;; earlier than 19.20 incorrectly had the call to run-hooks *before* the call | |
62 ;; to provide. In such a case, it is possible that byte-compiling and/or | |
63 ;; loading dired can cause an infinite loop. To prevent this, make sure the | |
64 ;; line of code | |
65 ;; | |
66 ;; (run-hooks 'dired-load-hook) | |
67 ;; | |
68 ;; is the *last* executable line in the file dired.el. That is, make sure it | |
69 ;; comes *after* the line | |
70 ;; | |
71 ;; (provide 'dired) | |
72 ;; | |
73 ;; *Please* see the info pages for more details. | |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
74 |
14169 | 75 ;; User defined variables: |
76 ;; | |
77 ;; dired-bind-vm | |
78 ;; dired-vm-read-only-folders | |
79 ;; dired-bind-jump | |
80 ;; dired-bind-info | |
81 ;; dired-bind-man | |
82 ;; dired-x-hands-off-my-keys | |
83 ;; dired-find-subdir | |
84 ;; dired-enable-local-variables | |
85 ;; dired-local-variables-file | |
86 ;; dired-guess-shell-gnutar | |
87 ;; dired-guess-shell-gzip-quiet | |
88 ;; dired-guess-shell-znew-switches | |
89 ;; dired-guess-shell-alist-user | |
90 ;; dired-clean-up-buffers-too | |
91 ;; dired-omit-files-p | |
92 ;; dired-omit-files | |
93 ;; dired-omit-extensions | |
16617
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
94 ;; dired-omit-size-limit |
14169 | 95 ;; |
96 ;; To find out more about these variables, load this file, put your cursor at | |
97 ;; the end of any of the variable names, and hit C-h v [RET]. *Please* see | |
98 ;; the info pages for more details. | |
5426 | 99 |
14169 | 100 ;; When loaded this code redefines the following functions of GNU Emacs |
101 ;; | |
102 ;; Function Found in this file of GNU Emacs | |
103 ;; -------- ------------------------------- | |
104 ;; dired-clean-up-after-deletion ../lisp/dired.el | |
105 ;; dired-find-buffer-nocreate ../lisp/dired.el | |
106 ;; dired-initial-position ../lisp/dired.el | |
107 ;; | |
108 ;; dired-add-entry ../lisp/dired-aux.el | |
109 ;; dired-read-shell-command ../lisp/dired-aux.el | |
110 ;; | |
111 ;; One drawback is that dired-x.el will load dired-aux.el as soon as dired is | |
112 ;; loaded. Thus, the advantage of separating out non-essential dired stuff | |
113 ;; into dired-aux.el and only loading when necessary will be lost. Please | |
114 ;; note also that some of the comments in dired.el and dired-aux.el are | |
115 ;; Kremer's that referred to the old dired-x.el. This now should be referring | |
116 ;; to this program. (This is also a good reason to call this dired-x.el | |
117 ;; instead of dired-x19.el.) | |
5426 | 118 |
119 | |
14169 | 120 ;;; Code: |
5426 | 121 |
14169 | 122 ;; LOAD. |
5426 | 123 |
14169 | 124 ;; This is a no-op if dired-x is being loaded via `dired-load-hook'. It is |
125 ;; here in case the user has autoloaded dired-x via the dired-jump key binding | |
126 ;; (instead of autoloading to dired as is suggested in the info-pages). | |
6694 | 127 |
7839
eb9d06dba04b
Require dired and dired-aux in the standard way.
Richard M. Stallman <rms@gnu.org>
parents:
7700
diff
changeset
|
128 (require 'dired) |
6694 | 129 |
14169 | 130 ;; We will redefine some functions and also need some macros so we need to |
131 ;; load dired stuff of GNU Emacs. | |
5426 | 132 |
7839
eb9d06dba04b
Require dired and dired-aux in the standard way.
Richard M. Stallman <rms@gnu.org>
parents:
7700
diff
changeset
|
133 (require 'dired-aux) |
6694 | 134 |
14169 | 135 ;;; User-defined variables. |
5426 | 136 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
137 (defgroup dired-x nil |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
138 "Extended directory editing (dired-x)." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
139 :group 'dired) |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
140 |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
141 (defgroup dired-keys nil |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
142 "Dired keys customizations." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
143 :prefix "dired-" |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
144 :group 'dired-x) |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
145 |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
146 (defcustom dired-bind-vm nil |
5426 | 147 "*t says \"V\" in dired-mode will `dired-vm', otherwise \"V\" is `dired-rmail'. |
148 Also, RMAIL files contain -*- rmail -*- at the top so \"f\", | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
149 `dired-advertised-find-file', will run rmail." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
150 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
151 :group 'dired-keys) |
5426 | 152 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
153 (defcustom dired-bind-jump t |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
154 "*t says bind `dired-jump' to C-x C-j, otherwise do not." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
155 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
156 :group 'dired-keys) |
5426 | 157 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
158 (defcustom dired-bind-man t |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
159 "*t says bind `dired-man' to \"N\" in dired-mode, otherwise do not." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
160 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
161 :group 'dired-keys) |
5426 | 162 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
163 (defcustom dired-bind-info t |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
164 "*t says bind `dired-info' to \"I\" in dired-mode, otherwise do not." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
165 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
166 :group 'dired-keys) |
5426 | 167 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
168 (defcustom dired-vm-read-only-folders nil |
5426 | 169 "*If t, \\[dired-vm] will visit all folders read-only. |
170 If neither nil nor t, e.g. the symbol `if-file-read-only', only | |
171 files not writable by you are visited read-only. | |
172 | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
173 Read-only folders only work in VM 5, not in VM 4." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
174 :type '(choice (const :tag "off" nil) |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
175 (const :tag "on" t) |
22574
3c7216baafaf
(dired-vm-read-only-folders): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
22177
diff
changeset
|
176 (other :tag "non-writable only" if-file-read-only)) |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
177 :group 'dired-x) |
5426 | 178 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
179 (defcustom dired-omit-files-p nil |
5426 | 180 "*If non-nil, \"uninteresting\" files are not listed (buffer-local). |
181 Use \\[dired-omit-toggle] to toggle its value. | |
182 Uninteresting files are those whose filenames match regexp `dired-omit-files', | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
183 plus those ending with extensions in `dired-omit-extensions'." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
184 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
185 :group 'dired-x) |
11500
1bae87dcd653
Change the instructions in the INSTALLATION
Karl Heuer <kwzh@gnu.org>
parents:
11035
diff
changeset
|
186 (make-variable-buffer-local 'dired-omit-files-p) |
5426 | 187 |
18838
6f9fa4c8e92a
(dired-omit-files): Add ".#foo" lock files to omissions.
Richard M. Stallman <rms@gnu.org>
parents:
17944
diff
changeset
|
188 (defcustom dired-omit-files "^\\.?#\\|^\\.$\\|^\\.\\.$" |
11500
1bae87dcd653
Change the instructions in the INSTALLATION
Karl Heuer <kwzh@gnu.org>
parents:
11035
diff
changeset
|
189 "*Filenames matching this regexp will not be displayed. |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
190 This only has effect when `dired-omit-files-p' is t. See interactive function |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
191 `dired-omit-toggle' \(\\[dired-omit-toggle]\) and variable |
18838
6f9fa4c8e92a
(dired-omit-files): Add ".#foo" lock files to omissions.
Richard M. Stallman <rms@gnu.org>
parents:
17944
diff
changeset
|
192 `dired-omit-extensions'. The default is to omit `.', `..', auto-save |
6f9fa4c8e92a
(dired-omit-files): Add ".#foo" lock files to omissions.
Richard M. Stallman <rms@gnu.org>
parents:
17944
diff
changeset
|
193 files and lock files." |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
194 :type 'regexp |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
195 :group 'dired-x) |
5426 | 196 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
197 (defcustom dired-find-subdir nil ; t is pretty near to DWIM... |
9707
6349d2705e2a
(dired-find-subdir): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9061
diff
changeset
|
198 "*If non-nil, Dired always finds a directory in a buffer of its own. |
6349d2705e2a
(dired-find-subdir): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9061
diff
changeset
|
199 If nil, Dired finds the directory as a subdirectory in some other buffer |
6349d2705e2a
(dired-find-subdir): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
9061
diff
changeset
|
200 if it is present as one. |
5426 | 201 |
202 If there are several Dired buffers for a directory, the most recently | |
203 used is chosen. | |
204 | |
205 Dired avoids switching to the current buffer, so that if you have | |
206 a normal and a wildcard buffer for the same directory, C-x d RET will | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
207 toggle between those two." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
208 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
209 :group 'dired-x) |
5426 | 210 |
22688
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
211 (defcustom dired-omit-size-limit 30000 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
212 "*Maximum size for the \"omitting\" feature. |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
213 If nil, there is no maximum size." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
214 :type '(choice (const :tag "no maximum" nil) integer) |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
215 :group 'dired-x) |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
216 |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
217 (defcustom dired-enable-local-variables t |
5426 | 218 "*Control use of local-variables lists in dired. |
219 The value can be t, nil or something else. | |
220 A value of t means local-variables lists are obeyed; | |
221 nil means they are ignored; anything else means query. | |
222 | |
223 This temporarily overrides the value of `enable-local-variables' when listing | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
224 a directory. See also `dired-local-variables-file'." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
225 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
226 :group 'dired-x) |
5426 | 227 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
228 (defcustom dired-guess-shell-gnutar nil |
5426 | 229 "*If non-nil, name of GNU tar executable (e.g., \"tar\" or \"gtar\") and `z' |
230 switch will be used for compressed or gzip'ed tar files. If no GNU tar, set | |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
231 to nil: a pipe using `zcat' or `gunzip -c' will be used." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
232 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
233 :group 'dired-x) |
5426 | 234 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
235 (defcustom dired-guess-shell-gzip-quiet t |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
236 "*non-nil says pass -q to gzip overriding verbose GZIP environment." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
237 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
238 :group 'dired-x) |
5426 | 239 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
240 (defcustom dired-guess-shell-znew-switches nil |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
241 "*If non-nil, then string of switches passed to `znew', example: \"-K\"" |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
242 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
243 :group 'dired-x) |
5426 | 244 |
17944
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
245 (defcustom dired-clean-up-buffers-too t |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
246 "*t says offer to kill buffers visiting files and dirs deleted in dired." |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
247 :type 'boolean |
0714535d0e28
Use defgroup and defcustom.
Richard M. Stallman <rms@gnu.org>
parents:
16959
diff
changeset
|
248 :group 'dired-x) |
5426 | 249 |
14169 | 250 ;;; KEY BINDINGS. |
5426 | 251 |
252 (define-key dired-mode-map "\M-o" 'dired-omit-toggle) | |
253 (define-key dired-mode-map "\M-(" 'dired-mark-sexp) | |
16499
821597d16a55
(dired-mode-map): Put dired-mark-extension on *.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
254 (define-key dired-mode-map "*(" 'dired-mark-sexp) |
821597d16a55
(dired-mode-map): Put dired-mark-extension on *.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
255 (define-key dired-mode-map "*." 'dired-mark-extension) |
5426 | 256 (define-key dired-mode-map "\M-!" 'dired-smart-shell-command) |
257 (define-key dired-mode-map "w" 'dired-copy-filename-as-kill) | |
258 (define-key dired-mode-map "\M-g" 'dired-goto-file) | |
259 (define-key dired-mode-map "\M-G" 'dired-goto-subdir) | |
260 (define-key dired-mode-map "F" 'dired-do-find-marked-files) | |
261 (define-key dired-mode-map "Y" 'dired-do-relsymlink) | |
262 (define-key dired-mode-map "%Y" 'dired-do-relsymlink-regexp) | |
263 (define-key dired-mode-map "V" 'dired-do-run-mail) | |
264 | |
265 (if dired-bind-man | |
266 (define-key dired-mode-map "N" 'dired-man)) | |
267 | |
268 (if dired-bind-info | |
269 (define-key dired-mode-map "I" 'dired-info)) | |
270 | |
6694 | 271 ;;; GLOBAL BINDING. |
5426 | 272 (if dired-bind-jump |
273 (progn | |
274 (define-key global-map "\C-x\C-j" 'dired-jump) | |
275 (define-key global-map "\C-x4\C-j" 'dired-jump-other-window))) | |
276 | |
277 | |
14169 | 278 ;;; Install into appropriate hooks. |
5426 | 279 |
280 (add-hook 'dired-mode-hook 'dired-extra-startup) | |
281 (add-hook 'dired-after-readin-hook 'dired-omit-expunge) | |
282 | |
283 (defun dired-extra-startup () | |
284 "Automatically put on dired-mode-hook to get extra dired features: | |
285 \\<dired-mode-map> | |
286 | |
287 \\[dired-do-run-mail]\t-- run mail on folder (see `dired-bind-vm') | |
288 \\[dired-info]\t-- run info on file | |
289 \\[dired-man]\t-- run man on file | |
290 \\[dired-do-find-marked-files]\t-- visit all marked files simultaneously | |
291 \\[dired-omit-toggle]\t-- toggle omitting of files | |
292 \\[dired-mark-sexp]\t-- mark by lisp expression | |
293 \\[dired-copy-filename-as-kill]\t-- copy the file or subdir names into the kill ring. | |
294 \t You can feed it to other commands using \\[yank]. | |
295 | |
296 For more features, see variables | |
297 | |
298 dired-bind-vm | |
299 dired-bind-jump | |
300 dired-bind-info | |
301 dired-bind-man | |
302 dired-vm-read-only-folders | |
303 dired-omit-files-p | |
304 dired-omit-files | |
305 dired-omit-extensions | |
16617
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
306 dired-omit-size-limit |
5426 | 307 dired-find-subdir |
308 dired-enable-local-variables | |
309 dired-local-variables-file | |
310 dired-guess-shell-gnutar | |
311 dired-guess-shell-gzip-quiet | |
312 dired-guess-shell-znew-switches | |
313 dired-guess-shell-alist-user | |
6694 | 314 dired-clean-up-buffers-too |
5426 | 315 |
316 See also functions | |
317 | |
318 dired-flag-extension | |
319 dired-virtual | |
320 dired-jump | |
321 dired-man | |
322 dired-vm | |
323 dired-rmail | |
324 dired-info | |
325 dired-do-find-marked-files | |
326 " | |
327 (interactive) | |
328 | |
329 ;; These must be done in each new dired buffer. | |
330 (dired-hack-local-variables) | |
331 (dired-omit-startup)) | |
332 | |
333 | |
14169 | 334 ;;; BUFFER CLEANING. |
5426 | 335 |
14169 | 336 ;; REDEFINE. |
5426 | 337 (defun dired-clean-up-after-deletion (fn) |
338 | |
339 ;; Clean up after a deleted file or directory FN. | |
340 ;; Remove expanded subdir of deleted dir, if any. | |
341 (save-excursion (and (cdr dired-subdir-alist) | |
342 (dired-goto-subdir fn) | |
343 (dired-kill-subdir))) | |
344 | |
345 ;; Offer to kill buffer of deleted file FN. | |
346 (if dired-clean-up-buffers-too | |
347 (progn | |
348 (let ((buf (get-file-buffer fn))) | |
349 (and buf | |
350 (funcall (function y-or-n-p) | |
351 (format "Kill buffer of %s, too? " | |
352 (file-name-nondirectory fn))) | |
353 (save-excursion ; you never know where kill-buffer leaves you | |
354 (kill-buffer buf)))) | |
8792
d85424a6fb85
(dired-clean-up-after-deletion): Expand fn.
Richard M. Stallman <rms@gnu.org>
parents:
8713
diff
changeset
|
355 (let ((buf-list (dired-buffers-for-dir (expand-file-name fn))) |
5426 | 356 (buf nil)) |
357 (and buf-list | |
358 (y-or-n-p (format "Kill dired buffer%s of %s, too? " | |
359 (dired-plural-s (length buf-list)) | |
360 (file-name-nondirectory fn))) | |
361 (while buf-list | |
362 (save-excursion (kill-buffer (car buf-list))) | |
363 (setq buf-list (cdr buf-list))))))) | |
6694 | 364 ;; Anything else? |
5426 | 365 ) |
366 | |
367 | |
14169 | 368 ;;; EXTENSION MARKING FUNCTIONS. |
5426 | 369 |
6694 | 370 ;;; Mark files with some extension. |
5426 | 371 (defun dired-mark-extension (extension &optional marker-char) |
372 "Mark all files with a certain extension for use in later commands. | |
373 A `.' is not automatically prepended to the string entered." | |
374 ;; EXTENSION may also be a list of extensions instead of a single one. | |
375 ;; Optional MARKER-CHAR is marker to use. | |
376 (interactive "sMarking extension: \nP") | |
377 (or (listp extension) | |
378 (setq extension (list extension))) | |
379 (dired-mark-files-regexp | |
380 (concat ".";; don't match names with nothing but an extension | |
381 "\\(" | |
382 (mapconcat 'regexp-quote extension "\\|") | |
383 "\\)$") | |
384 marker-char)) | |
385 | |
386 (defun dired-flag-extension (extension) | |
387 "In dired, flag all files with a certain extension for deletion. | |
388 A `.' is *not* automatically prepended to the string entered." | |
389 (interactive "sFlagging extension: ") | |
390 (dired-mark-extension extension dired-del-marker)) | |
391 | |
392 ;;; Define some unpopular file extensions. Used for cleaning and omitting. | |
393 | |
394 (defvar dired-patch-unclean-extensions | |
395 '(".rej" ".orig") | |
396 "List of extensions of dispensable files created by the `patch' program.") | |
397 | |
398 (defvar dired-tex-unclean-extensions | |
399 '(".toc" ".log" ".aux");; these are already in completion-ignored-extensions | |
400 "List of extensions of dispensable files created by TeX.") | |
401 | |
402 (defvar dired-latex-unclean-extensions | |
403 '(".idx" ".lof" ".lot" ".glo") | |
404 "List of extensions of dispensable files created by LaTeX.") | |
405 | |
406 (defvar dired-bibtex-unclean-extensions | |
407 '(".blg" ".bbl") | |
408 "List of extensions of dispensable files created by BibTeX.") | |
409 | |
410 (defvar dired-texinfo-unclean-extensions | |
411 '(".cp" ".cps" ".fn" ".fns" ".ky" ".kys" ".pg" ".pgs" | |
412 ".tp" ".tps" ".vr" ".vrs") | |
413 "List of extensions of dispensable files created by texinfo.") | |
414 | |
415 (defun dired-clean-patch () | |
416 "Flag dispensable files created by patch for deletion. | |
417 See variable `dired-patch-unclean-extensions'." | |
418 (interactive) | |
419 (dired-flag-extension dired-patch-unclean-extensions)) | |
420 | |
421 (defun dired-clean-tex () | |
6694 | 422 "Flag dispensable files created by [La]TeX etc. for deletion. |
423 See variables `dired-texinfo-unclean-extensions', | |
424 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and | |
425 `dired-texinfo-unclean-extensions'." | |
5426 | 426 (interactive) |
427 (dired-flag-extension (append dired-texinfo-unclean-extensions | |
428 dired-latex-unclean-extensions | |
429 dired-bibtex-unclean-extensions | |
430 dired-tex-unclean-extensions))) | |
431 | |
6694 | 432 (defun dired-very-clean-tex () |
433 "Flag dispensable files created by [La]TeX *and* \".dvi\" for deletion. | |
434 See variables `dired-texinfo-unclean-extensions', | |
435 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions' and | |
436 `dired-texinfo-unclean-extensions'." | |
5426 | 437 (interactive) |
6694 | 438 (dired-flag-extension (append dired-texinfo-unclean-extensions |
439 dired-latex-unclean-extensions | |
440 dired-bibtex-unclean-extensions | |
441 dired-tex-unclean-extensions | |
442 (list ".dvi")))) | |
5426 | 443 |
14169 | 444 ;;; JUMP. |
5426 | 445 |
7700
311f42f91dbd
(dired-jump): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents:
7189
diff
changeset
|
446 ;;;###autoload |
5426 | 447 (defun dired-jump (&optional other-window) |
448 "Jump to dired buffer corresponding to current buffer. | |
449 If in a file, dired the current directory and move to file's line. | |
450 If in dired already, pop up a level and goto old directory's line. | |
451 In case the proper dired file line cannot be found, refresh the dired | |
452 buffer and try again." | |
453 (interactive "P") | |
454 (let* ((file buffer-file-name) | |
455 (dir (if file (file-name-directory file) default-directory))) | |
456 (if (eq major-mode 'dired-mode) | |
457 (progn | |
458 (setq dir (dired-current-directory)) | |
459 (dired-up-directory other-window) | |
460 (or (dired-goto-file dir) | |
461 ;; refresh and try again | |
6694 | 462 (progn |
5426 | 463 (dired-insert-subdir (file-name-directory dir)) |
464 (dired-goto-file dir)))) | |
465 (if other-window | |
466 (dired-other-window dir) | |
467 (dired dir)) | |
468 (if file | |
469 (or (dired-goto-file file) | |
470 ;; refresh and try again | |
6694 | 471 (progn |
5426 | 472 (dired-insert-subdir (file-name-directory file)) |
16558
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
473 (dired-goto-file file)) |
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
474 ;; Toggle omitting, if it is on, and try again. |
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
475 (if dired-omit-files-p |
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
476 (progn |
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
477 (dired-omit-toggle) |
40a1e1451821
(dired-jump): Never turn omitting *on*.
Richard M. Stallman <rms@gnu.org>
parents:
16499
diff
changeset
|
478 (dired-goto-file file)))))))) |
5426 | 479 |
480 (defun dired-jump-other-window () | |
481 "Like \\[dired-jump] (dired-jump) but in other window." | |
482 (interactive) | |
483 (dired-jump t)) | |
484 | |
14169 | 485 ;;; COPY NAMES OF MARKED FILES INTO KILL-RING. |
6694 | 486 |
5426 | 487 (defun dired-copy-filename-as-kill (&optional arg) |
488 "Copy names of marked (or next ARG) files into the kill ring. | |
489 The names are separated by a space. | |
490 With a zero prefix arg, use the complete pathname of each marked file. | |
491 With \\[universal-argument], use the relative pathname of each marked file. | |
492 | |
493 If on a subdir headerline, use subdirname instead; prefix arg is ignored | |
494 in this case. | |
495 | |
496 You can then feed the file name(s) to other commands with \\[yank]." | |
497 (interactive "P") | |
498 (let ((string | |
499 (or (dired-get-subdir) | |
500 (mapconcat (function identity) | |
501 (if arg | |
502 (cond ((zerop (prefix-numeric-value arg)) | |
503 (dired-get-marked-files)) | |
504 ((integerp arg) | |
505 (dired-get-marked-files 'no-dir arg)) | |
506 (t ; else a raw arg | |
507 (dired-get-marked-files t))) | |
508 (dired-get-marked-files 'no-dir)) | |
509 " ")))) | |
510 (kill-new string) | |
511 (message "%s" string))) | |
512 | |
513 | |
14169 | 514 ;;; OMITTING. |
5426 | 515 |
516 ;;; Enhanced omitting of lines from directory listings. | |
517 ;;; Marked files are never omitted. | |
518 | |
519 ;; should probably get rid of this and always use 'no-dir. | |
520 ;; sk 28-Aug-1991 09:37 | |
521 (defvar dired-omit-localp 'no-dir | |
522 "The LOCALP argument dired-omit-expunge passes to dired-get-filename. | |
523 If it is 'no-dir, omitting is much faster, but you can only match | |
524 against the basename of the file. Set it to nil if you need to match the | |
525 whole pathname.") | |
526 | |
527 ;; \017=^O for Omit - other packages can chose other control characters. | |
528 (defvar dired-omit-marker-char ?\017 | |
529 "Temporary marker used by by dired-omit. | |
530 Should never be used as marker by the user or other packages.") | |
531 | |
532 (defun dired-omit-startup () | |
533 (or (assq 'dired-omit-files-p minor-mode-alist) | |
534 (setq minor-mode-alist | |
535 (append '((dired-omit-files-p " Omit")) minor-mode-alist)))) | |
536 | |
537 (defun dired-omit-toggle (&optional flag) | |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
538 "Toggle omitting files matching `dired-omit-files' and `dired-omit-extensions'. |
5426 | 539 With an arg, and if omitting was off, don't toggle and just mark the |
540 files but don't actually omit them. | |
541 With an arg, and if omitting was on, turn it off but don't refresh the buffer." | |
542 (interactive "P") | |
543 (if flag | |
544 (if dired-omit-files-p | |
545 (setq dired-omit-files-p (not dired-omit-files-p)) | |
546 (dired-mark-unmarked-files (dired-omit-regexp) nil nil | |
547 dired-omit-localp)) | |
548 ;; no FLAG | |
549 (setq dired-omit-files-p (not dired-omit-files-p)) | |
550 (if (not dired-omit-files-p) | |
551 (revert-buffer) | |
552 ;; this will mention how many were omitted: | |
16617
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
553 (let ((dired-omit-size-limit nil)) |
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
554 (dired-omit-expunge))))) |
5426 | 555 |
556 (defvar dired-omit-extensions | |
557 (append completion-ignored-extensions | |
558 dired-latex-unclean-extensions | |
559 dired-bibtex-unclean-extensions | |
560 dired-texinfo-unclean-extensions) | |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
561 "If non-nil, a list of extensions \(strings\) to omit from Dired listings. |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
562 Defaults to elements of `completion-ignored-extensions', |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
563 `dired-latex-unclean-extensions', `dired-bibtex-unclean-extensions', and |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
564 `dired-texinfo-unclean-extensions'. |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
565 |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
566 See interactive function `dired-omit-toggle' \(\\[dired-omit-toggle]\) and |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
567 variables `dired-omit-files-p' and `dired-omit-files'.") |
5426 | 568 |
569 (defun dired-omit-expunge (&optional regexp) | |
570 "Erases all unmarked files matching REGEXP. | |
16617
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
571 Does nothing if global variable `dired-omit-files-p' is nil, or if called |
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
572 non-interactively and buffer is bigger than `dired-omit-size-limit'. |
5426 | 573 If REGEXP is nil or not specified, uses `dired-omit-files', and also omits |
574 filenames ending in `dired-omit-extensions'. | |
575 If REGEXP is the empty string, this function is a no-op. | |
576 | |
577 This functions works by temporarily binding `dired-marker-char' to | |
578 `dired-omit-marker-char' and calling `dired-do-kill-lines'." | |
579 (interactive "sOmit files (regexp): ") | |
16617
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
580 (if (and dired-omit-files-p |
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
581 (or (interactive-p) |
19b2aeb694d1
(dired-omit-size-limit): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
16558
diff
changeset
|
582 (not dired-omit-size-limit) |
22688
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
583 (< (buffer-size) dired-omit-size-limit) |
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
584 (progn |
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
585 (message "Not omitting: directory larger than %d characters." |
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
586 dired-omit-size-limit) |
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
587 (setq dired-omit-files-p nil) |
c952205ba590
(dired-omit-expunge): Message if skipping omitting
Richard M. Stallman <rms@gnu.org>
parents:
22574
diff
changeset
|
588 nil))) |
5426 | 589 (let ((omit-re (or regexp (dired-omit-regexp))) |
8713
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
590 (old-modified-p (buffer-modified-p)) |
5426 | 591 count) |
592 (or (string= omit-re "") | |
593 (let ((dired-marker-char dired-omit-marker-char)) | |
594 (message "Omitting...") | |
595 (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp) | |
596 (progn | |
597 (setq count (dired-do-kill-lines nil "Omitted %d line%s.")) | |
11588
3ddbf9b31cf0
(dired-omit-expunge): Use force-mode-line-update.
Karl Heuer <kwzh@gnu.org>
parents:
11500
diff
changeset
|
598 (force-mode-line-update)) |
5426 | 599 (message "(Nothing to omit)")))) |
8713
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
600 ;; Try to preserve modified state of buffer. So `%*' doesn't appear |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
601 ;; in mode-line of omitted buffers. |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
602 (set-buffer-modified-p (and old-modified-p |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
603 (save-excursion |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
604 (goto-char (point-min)) |
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
605 (re-search-forward dired-re-mark nil t)))) |
5426 | 606 count))) |
607 | |
608 (defun dired-omit-regexp () | |
609 (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") | |
610 (if (and dired-omit-files dired-omit-extensions) "\\|" "") | |
611 (if dired-omit-extensions | |
612 (concat ".";; a non-extension part should exist | |
613 "\\(" | |
614 (mapconcat 'regexp-quote dired-omit-extensions "\\|") | |
615 "\\)$") | |
616 ""))) | |
617 | |
618 ;; Returns t if any work was done, nil otherwise. | |
619 (defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp) | |
620 "Marks unmarked files matching REGEXP, displaying MSG. | |
621 REGEXP is matched against the complete pathname. | |
622 Does not re-mark files which already have a mark. | |
623 With prefix argument, unflag all those files. | |
624 Second optional argument LOCALP is as in `dired-get-filename'." | |
625 (interactive "P") | |
626 (let ((dired-marker-char (if unflag-p ?\ dired-marker-char))) | |
627 (dired-mark-if | |
628 (and | |
629 ;; not already marked | |
630 (looking-at " ") | |
631 ;; uninteresting | |
632 (let ((fn (dired-get-filename localp t))) | |
633 (and fn (string-match regexp fn)))) | |
634 msg))) | |
635 | |
6694 | 636 ;;; REDEFINE. |
18917
347133072016
(dired-omit-new-add-entry): Take new arg RELATIVE
Richard M. Stallman <rms@gnu.org>
parents:
18838
diff
changeset
|
637 (defun dired-omit-new-add-entry (filename &optional marker-char relative) |
5426 | 638 ;; This redefines dired-aux.el's dired-add-entry to avoid calling ls for |
639 ;; files that are going to be omitted anyway. | |
640 (if dired-omit-files-p | |
641 ;; perhaps return t without calling ls | |
642 (let ((omit-re (dired-omit-regexp))) | |
643 (if (or (string= omit-re "") | |
644 (not | |
645 (string-match omit-re | |
646 (cond | |
647 ((eq 'no-dir dired-omit-localp) | |
648 filename) | |
649 ((eq t dired-omit-localp) | |
650 (dired-make-relative filename)) | |
651 (t | |
652 (dired-make-absolute | |
653 filename | |
654 (file-name-directory filename))))))) | |
655 ;; if it didn't match, go ahead and add the entry | |
18917
347133072016
(dired-omit-new-add-entry): Take new arg RELATIVE
Richard M. Stallman <rms@gnu.org>
parents:
18838
diff
changeset
|
656 (dired-omit-old-add-entry filename marker-char relative) |
5426 | 657 ;; dired-add-entry returns t for success, perhaps we should |
658 ;; return file-exists-p | |
659 t)) | |
660 ;; omitting is not turned on at all | |
18917
347133072016
(dired-omit-new-add-entry): Take new arg RELATIVE
Richard M. Stallman <rms@gnu.org>
parents:
18838
diff
changeset
|
661 (dired-omit-old-add-entry filename marker-char relative))) |
5426 | 662 |
6694 | 663 ;;; REDEFINE. |
5426 | 664 ;;; Redefine dired-aux.el's version of `dired-add-entry' |
665 ;;; Save old defun if not already done: | |
666 (or (fboundp 'dired-omit-old-add-entry) | |
667 (fset 'dired-omit-old-add-entry (symbol-function 'dired-add-entry))) | |
668 ;; Redefine it. | |
669 (fset 'dired-add-entry 'dired-omit-new-add-entry) | |
670 | |
671 | |
14169 | 672 ;;; VIRTUAL DIRED MODE. |
5426 | 673 |
674 ;;; For browsing `ls -lR' listings in a dired-like fashion. | |
675 | |
676 (fset 'virtual-dired 'dired-virtual) | |
677 (defun dired-virtual (dirname &optional switches) | |
678 "Put this buffer into Virtual Dired mode. | |
679 | |
680 In Virtual Dired mode, all commands that do not actually consult the | |
681 filesystem will work. | |
682 | |
683 This is useful if you want to peruse and move around in an ls -lR | |
684 output file, for example one you got from an ftp server. With | |
685 ange-ftp, you can even dired a directory containing an ls-lR file, | |
686 visit that file and turn on virtual dired mode. But don't try to save | |
687 this file, as dired-virtual indents the listing and thus changes the | |
688 buffer. | |
689 | |
690 If you have save a Dired buffer in a file you can use \\[dired-virtual] to | |
691 resume it in a later session. | |
692 | |
693 Type \\<dired-mode-map>\\[revert-buffer] in the | |
694 Virtual Dired buffer and answer `y' to convert the virtual to a real | |
695 dired buffer again. You don't have to do this, though: you can relist | |
696 single subdirs using \\[dired-do-redisplay]. | |
697 " | |
698 | |
699 ;; DIRNAME is the top level directory of the buffer. It will become | |
700 ;; its `default-directory'. If nil, the old value of | |
701 ;; default-directory is used. | |
702 | |
703 ;; Optional SWITCHES are the ls switches to use. | |
704 | |
705 ;; Shell wildcards will be used if there already is a `wildcard' | |
706 ;; line in the buffer (thus it is a saved Dired buffer), but there | |
707 ;; is no other way to get wildcards. Insert a `wildcard' line by | |
708 ;; hand if you want them. | |
709 | |
710 (interactive | |
711 (list (read-string "Virtual Dired directory: " (dired-virtual-guess-dir)))) | |
712 (goto-char (point-min)) | |
713 (or (looking-at " ") | |
714 ;; if not already indented, do it now: | |
715 (indent-region (point-min) (point-max) 2)) | |
716 (or dirname (setq dirname default-directory)) | |
717 (setq dirname (expand-file-name (file-name-as-directory dirname))) | |
718 (setq default-directory dirname) ; contains no wildcards | |
719 (let ((wildcard (save-excursion | |
720 (goto-char (point-min)) | |
721 (forward-line 1) | |
722 (and (looking-at "^ wildcard ") | |
723 (buffer-substring (match-end 0) | |
724 (progn (end-of-line) (point))))))) | |
725 (if wildcard | |
726 (setq dirname (expand-file-name wildcard default-directory)))) | |
727 ;; If raw ls listing (not a saved old dired buffer), give it a | |
728 ;; decent subdir headerline: | |
729 (goto-char (point-min)) | |
730 (or (looking-at dired-subdir-regexp) | |
731 (dired-insert-headerline default-directory)) | |
732 (dired-mode dirname (or switches dired-listing-switches)) | |
733 (setq mode-name "Virtual Dired" | |
734 revert-buffer-function 'dired-virtual-revert) | |
735 (set (make-local-variable 'dired-subdir-alist) nil) | |
736 (dired-build-subdir-alist) | |
737 (goto-char (point-min)) | |
738 (dired-initial-position dirname)) | |
739 | |
740 (defun dired-virtual-guess-dir () | |
741 | |
742 ;; Guess and return appropriate working directory of this buffer, | |
743 ;; assumed to be in Dired or ls -lR format. | |
744 ;; The guess is based upon buffer contents. | |
745 ;; If nothing could be guessed, returns nil. | |
746 | |
747 (let ((regexp "^\\( \\)?\\([^ \n\r]*\\)\\(:\\)[\n\r]") | |
748 (subexpr 2)) | |
749 (goto-char (point-min)) | |
750 (cond ((looking-at regexp) | |
751 ;; If a saved dired buffer, look to which dir and | |
752 ;; perhaps wildcard it belongs: | |
753 (let ((dir (buffer-substring (match-beginning subexpr) | |
754 (match-end subexpr)))) | |
755 (file-name-as-directory dir))) | |
756 ;; Else no match for headerline found. It's a raw ls listing. | |
757 ;; In raw ls listings the directory does not have a headerline | |
758 ;; try parent of first subdir, if any | |
759 ((re-search-forward regexp nil t) | |
760 (file-name-directory | |
761 (directory-file-name | |
762 (file-name-as-directory | |
763 (buffer-substring (match-beginning subexpr) | |
764 (match-end subexpr)))))) | |
765 (t ; if all else fails | |
766 nil)))) | |
767 | |
768 | |
769 (defun dired-virtual-revert (&optional arg noconfirm) | |
770 (if (not | |
771 (y-or-n-p "Cannot revert a Virtual Dired buffer - switch to Real Dired mode? ")) | |
772 (error "Cannot revert a Virtual Dired buffer.") | |
773 (setq mode-name "Dired" | |
774 revert-buffer-function 'dired-revert) | |
775 (revert-buffer))) | |
776 | |
777 ;; A zero-arg version of dired-virtual. | |
778 ;; You need my modified version of set-auto-mode for the | |
779 ;; `buffer-contents-mode-alist'. | |
780 ;; Or you use infer-mode.el and infer-mode-alist, same syntax. | |
781 (defun dired-virtual-mode () | |
782 "Put current buffer into virtual dired mode (see `dired-virtual'). | |
783 Useful on `buffer-contents-mode-alist' (which see) with the regexp | |
784 | |
785 \"^ \\(/[^ /]+\\)/?+:$\" | |
786 | |
787 to put saved dired buffers automatically into virtual dired mode. | |
788 | |
789 Also useful for `auto-mode-alist' (which see) like this: | |
790 | |
9061
10b791eec6dc
(dired-virtual-mode): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
8792
diff
changeset
|
791 \(setq auto-mode-alist (cons '(\"[^/]\\.dired\\'\" . dired-virtual-mode) |
5426 | 792 auto-mode-alist)\)" |
793 (interactive) | |
794 (dired-virtual (dired-virtual-guess-dir))) | |
795 | |
796 | |
14169 | 797 ;;; SMART SHELL. |
5426 | 798 |
799 ;;; An Emacs buffer can have but one working directory, stored in the | |
800 ;;; buffer-local variable `default-directory'. A Dired buffer may have | |
801 ;;; several subdirectories inserted, but still has but one working directory: | |
802 ;;; that of the top level Dired directory in that buffer. For some commands | |
803 ;;; it is appropriate that they use the current Dired directory instead of | |
804 ;;; `default-directory', e.g., `find-file' and `compile'. This is a general | |
805 ;;; mechanism is provided for special handling of the working directory in | |
806 ;;; special major modes. | |
807 | |
808 ;; It's easier to add to this alist than redefine function | |
809 ;; default-directory while keeping the old information. | |
810 (defconst default-directory-alist | |
811 '((dired-mode . (if (fboundp 'dired-current-directory) | |
812 (dired-current-directory) | |
813 default-directory))) | |
814 "Alist of major modes and their opinion on default-directory, as a | |
815 lisp expression to evaluate. A resulting value of nil is ignored in | |
816 favor of default-directory.") | |
817 | |
818 (defun default-directory () | |
819 "Usage like variable `default-directory', but knows about the special | |
820 cases in variable `default-directory-alist' (which see)." | |
821 (or (eval (cdr (assq major-mode default-directory-alist))) | |
822 default-directory)) | |
823 | |
824 (defun dired-smart-shell-command (cmd &optional insert) | |
825 "Like function `shell-command', but in the current Tree Dired directory." | |
826 (interactive "sShell command: \nP") | |
827 (let ((default-directory (default-directory))) | |
828 (shell-command cmd insert))) | |
829 | |
830 | |
14169 | 831 ;;; LOCAL VARIABLES FOR DIRED BUFFERS. |
5426 | 832 |
6694 | 833 ;;; Brief Description: |
834 ;;; | |
835 ;;; * `dired-extra-startup' is part of the `dired-mode-hook'. | |
836 ;;; | |
5426 | 837 ;;; * `dired-extra-startup' calls `dired-hack-local-variables' |
6694 | 838 ;;; |
5426 | 839 ;;; * `dired-hack-local-variables' checks the value of |
6694 | 840 ;;; `dired-local-variables-file' |
841 ;;; | |
5426 | 842 ;;; * Check if `dired-local-variables-file' is a non-nil string and is a |
843 ;;; filename found in the directory of the Dired Buffer being created. | |
6694 | 844 ;;; |
5426 | 845 ;;; * If `dired-local-variables-file' satisfies the above, then temporarily |
846 ;;; include it in the Dired Buffer at the bottom. | |
6694 | 847 ;;; |
5426 | 848 ;;; * Set `enable-local-variables' temporarily to the user variable |
849 ;;; `dired-enable-local-variables' and run `hack-local-variables' on the | |
850 ;;; Dired Buffer. | |
851 | |
13904
d9bf85b9c19e
(dired-local-variables-file): Use convert-standard-filename.
Richard M. Stallman <rms@gnu.org>
parents:
13033
diff
changeset
|
852 (defvar dired-local-variables-file (convert-standard-filename ".dired") |
5426 | 853 "Filename, as string, containing local dired buffer variables to be hacked. |
854 If this file found in current directory, then it will be inserted into dired | |
855 buffer and `hack-local-variables' will be run. See Emacs Info pages for more | |
856 information on local variables. See also `dired-enable-local-variables'.") | |
857 | |
858 (defun dired-hack-local-variables () | |
859 "Evaluate local variables in `dired-local-variables-file' for dired buffer." | |
860 (if (and dired-local-variables-file | |
861 (stringp dired-local-variables-file) | |
862 (file-exists-p dired-local-variables-file)) | |
863 (let ((opoint (point-max)) | |
864 buffer-read-only | |
865 ;; In case user has `enable-local-variables' set to nil we | |
866 ;; override it locally with dired's variable. | |
867 (enable-local-variables dired-enable-local-variables)) | |
868 ;; Insert 'em. | |
869 (save-excursion | |
870 (goto-char opoint) | |
871 (insert "\^L\n") | |
872 (insert-file-contents dired-local-variables-file)) | |
873 ;; Hack 'em. | |
874 (let ((buffer-file-name dired-local-variables-file)) | |
875 (hack-local-variables)) | |
876 ;; Make sure that the modeline shows the proper information. | |
877 (dired-sort-set-modeline) | |
878 ;; Delete this stuff: `eobp' is used to find last subdir by dired.el. | |
6694 | 879 (delete-region opoint (point-max))))) |
5426 | 880 |
6694 | 881 (defun dired-omit-here-always () |
5426 | 882 "Creates `dired-local-variables-file' for omitting and reverts directory. |
883 Sets dired-omit-file-p to t in a local variables file that is readable by | |
884 dired." | |
6694 | 885 (interactive) |
5426 | 886 (if (file-exists-p dired-local-variables-file) |
887 (message "File `./%s' already exists." dired-local-variables-file) | |
888 | |
889 ;; Create `dired-local-variables-file'. | |
890 (save-excursion | |
891 (set-buffer (get-buffer-create " *dot-dired*")) | |
892 (erase-buffer) | |
893 (insert "Local Variables:\ndired-omit-files-p: t\nEnd:\n") | |
894 (write-file dired-local-variables-file) | |
895 (kill-buffer (current-buffer))) | |
896 | |
897 ;; Run extra-hooks and revert directory. | |
898 (dired-extra-startup) | |
899 (dired-revert))) | |
900 | |
901 | |
14169 | 902 ;;; GUESS SHELL COMMAND. |
5426 | 903 |
6694 | 904 ;;; Brief Description: |
905 ;;; | |
906 ;;; `dired-do-shell-command' is bound to `!' by dired.el. | |
907 ;;; | |
5426 | 908 ;;; * Redefine `dired-do-shell-command' so it calls |
909 ;;; `dired-guess-shell-command'. | |
6694 | 910 ;;; |
5426 | 911 ;;; * `dired-guess-shell-command' calls `dired-guess-default' with list of |
912 ;;; marked files. | |
6694 | 913 ;;; |
5426 | 914 ;;; * Parse `dired-guess-shell-alist-user' and |
915 ;;; `dired-guess-shell-alist-default' (in that order) for the first REGEXP | |
916 ;;; that matches the first file in the file list. | |
6694 | 917 ;;; |
5426 | 918 ;;; * If the REGEXP matches all the entries of the file list then evaluate |
11035 | 919 ;;; COMMAND, which is either a string or a Lisp expression returning a |
5426 | 920 ;;; string. COMMAND may be a list of commands. |
6694 | 921 ;;; |
5426 | 922 ;;; * Return this command to `dired-guess-shell-command' which prompts user |
13975 | 923 ;;; with it. The list of commands is temporarily put into the history list. |
5426 | 924 ;;; If a command is used successfully then it is stored permanently in |
925 ;;; `dired-shell-command-history'. | |
926 | |
927 ;;; Guess what shell command to apply to a file. | |
928 (defvar dired-shell-command-history nil | |
929 "History list for commands that read dired-shell commands.") | |
930 | |
6694 | 931 ;;; Default list of shell commands. |
5426 | 932 |
933 ;;; NOTE: Use `gunzip -c' instead of `zcat' on `.gz' files. Some do not | |
934 ;;; install GNU zip's version of zcat. | |
935 | |
936 (defvar dired-guess-shell-alist-default | |
937 (list | |
938 (list "\\.tar$" '(if dired-guess-shell-gnutar | |
939 (concat dired-guess-shell-gnutar " xvf") | |
940 "tar xvf")) | |
941 | |
942 ;; REGEXPS for compressed archives must come before the .Z rule to | |
943 ;; be recognized: | |
944 (list "\\.tar\\.Z$" | |
945 ;; Untar it. | |
946 '(if dired-guess-shell-gnutar | |
947 (concat dired-guess-shell-gnutar " zxvf") | |
948 (concat "zcat * | tar xvf -")) | |
949 ;; Optional conversion to gzip format. | |
950 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | |
951 " " dired-guess-shell-znew-switches)) | |
952 | |
953 ;; gzip'ed archives | |
23108
0005f4030460
(dired-guess-shell-alist-default): Fix regexp.
Karl Heuer <kwzh@gnu.org>
parents:
22688
diff
changeset
|
954 (list "\\.t\\(ar\\.\\)?gz$" |
5426 | 955 '(if dired-guess-shell-gnutar |
956 (concat dired-guess-shell-gnutar " zxvf") | |
957 (concat "gunzip -qc * | tar xvf -")) | |
958 ;; Optional decompression. | |
959 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))) | |
25409
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
960 ;; bzip2'ed archives |
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
961 (list "\\.tar\\.bz2$" |
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
962 "bunzip2 -c * | tar xvf -" |
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
963 ;; Optional decompression. |
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
964 "bunzip2") |
5426 | 965 |
966 '("\\.shar.Z$" "zcat * | unshar") | |
967 '("\\.shar.g?z$" "gunzip -qc * | unshar") | |
968 | |
16959
d04999ad25b9
(dired-guess-shell-alist-default): Make .eps
Richard M. Stallman <rms@gnu.org>
parents:
16617
diff
changeset
|
969 '("\\.e?ps$" "ghostview" "xv" "lpr") |
d04999ad25b9
(dired-guess-shell-alist-default): Make .eps
Richard M. Stallman <rms@gnu.org>
parents:
16617
diff
changeset
|
970 (list "\\.e?ps.g?z$" "gunzip -qc * | ghostview -" |
5426 | 971 ;; Optional decompression. |
972 '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | |
16959
d04999ad25b9
(dired-guess-shell-alist-default): Make .eps
Richard M. Stallman <rms@gnu.org>
parents:
16617
diff
changeset
|
973 (list "\\.e?ps.Z$" "zcat * | ghostview -" |
5426 | 974 ;; Optional conversion to gzip format. |
975 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | |
976 " " dired-guess-shell-znew-switches)) | |
977 '("\\.patch$" "cat * | patch") | |
978 '("\\.patch.g?z$" "gunzip -qc * | patch") | |
979 (list "\\.patch.Z$" "zcat * | patch" | |
980 ;; Optional conversion to gzip format. | |
981 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | |
982 " " dired-guess-shell-znew-switches)) | |
983 | |
984 '("\\.dvi$" "xdvi" "dvips") ; preview and printing | |
6694 | 985 '("\\.au$" "play") ; play Sun audiofiles |
5426 | 986 '("\\.mpg$" "mpeg_play") |
987 '("\\.uu$" "uudecode") ; for uudecoded files | |
988 '("\\.hqx$" "mcvert") | |
989 '("\\.sh$" "sh") ; execute shell scripts | |
990 '("\\.xbm$" "bitmap") ; view X11 bitmaps | |
991 '("\\.gp$" "gnuplot") | |
992 '("\\.p[bgpn]m$" "xv") | |
993 '("\\.gif$" "xv") ; view gif pictures | |
994 '("\\.tif$" "xv") | |
995 '("\\.jpg$" "xv") | |
996 '("\\.fig$" "xfig") ; edit fig pictures | |
997 '("\\.out$" "xgraph") ; for plotting purposes. | |
998 '("\\.tex$" "latex" "tex") | |
999 '("\\.texi\\(nfo\\)?$" "makeinfo" "texi2dvi") | |
22177
306578297d44
(dired-guess-shell-alist-default): Handle .tgz files. Handle .pdf files.
Richard M. Stallman <rms@gnu.org>
parents:
20990
diff
changeset
|
1000 '("\\.pdf$" "acroread") ; edit PDF files |
5426 | 1001 |
1002 ;; Some other popular archivers. | |
1003 '("\\.zoo$" "zoo x//") | |
1004 '("\\.zip$" "unzip") | |
1005 '("\\.lzh$" "lharc x") | |
1006 '("\\.arc$" "arc x") | |
1007 '("\\.shar$" "unshar") | |
1008 | |
1009 ;; Compression. | |
1010 (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) | |
25409
d414a697a646
(dired-guess-shell-alist-default): Support bzip2 format.
Karl Heuer <kwzh@gnu.org>
parents:
23108
diff
changeset
|
1011 (list "\\.bz2$" "bunzip2") |
5426 | 1012 (list "\\.Z$" "uncompress" |
1013 ;; Optional conversion to gzip format. | |
1014 '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") | |
1015 " " dired-guess-shell-znew-switches)) | |
1016 ) | |
6694 | 1017 |
5426 | 1018 "Default alist used for shell command guessing. |
1019 See `dired-guess-shell-alist-user'") | |
1020 | |
1021 (defvar dired-guess-shell-alist-user nil | |
1022 "User-defined alist of rules for suggested commands. These rules take | |
1023 precedence over the predefined rules in the variable | |
1024 `dired-guess-shell-alist-default' (to which they are prepended). | |
1025 | |
1026 Each element of this list looks like | |
1027 | |
1028 \(REGEXP COMMAND...\) | |
1029 | |
1030 where each COMMAND can either be a string or a lisp expression that evaluates | |
1031 to a string. If several COMMANDs are given, the first one will be the default | |
1032 and the rest will be added temporarily to the history and can be retrieved | |
1033 with \\[previous-history-element] (M-p) . | |
1034 | |
1035 You can set this variable in your ~/.emacs. For example, to add rules for | |
1036 `.foo' and `.bar' files, write | |
1037 | |
1038 \(setq dired-guess-shell-alist-user | |
1039 (list (list \"\\\\.foo$\" \"FOO-COMMAND\");; fixed rule | |
1040 ;; possibly more rules ... | |
1041 (list \"\\\\.bar$\";; rule with condition test | |
1042 '(if condition | |
1043 \"BAR-COMMAND-1\" | |
1044 \"BAR-COMMAND-2\")))\) | |
1045 ") | |
1046 | |
1047 (defun dired-guess-default (files) | |
1048 | |
6694 | 1049 ;; Guess a shell commands for FILES. Return command or list of commands. |
1050 ;; See `dired-guess-shell-alist-user'. | |
5426 | 1051 |
1052 (let* ((case-fold-search nil) ; case-sensitive matching | |
1053 ;; Prepend the user's alist to the default alist. | |
1054 (alist (append dired-guess-shell-alist-user | |
1055 dired-guess-shell-alist-default)) | |
1056 (file (car files)) | |
1057 (flist (cdr files)) | |
1058 elt regexp cmds) | |
1059 | |
1060 ;; Find the first match in the alist for first file in FILES. | |
1061 (while alist | |
1062 (setq elt (car alist) | |
1063 regexp (car elt) | |
1064 alist (cdr alist)) | |
1065 (if (string-match regexp file) | |
1066 (setq cmds (cdr elt) | |
1067 alist nil))) | |
1068 | |
1069 ;; If more than one file, see if all of FILES match regular expression. | |
1070 (while (and flist | |
1071 (string-match regexp (car flist))) | |
1072 (setq flist (cdr flist))) | |
6694 | 1073 |
5426 | 1074 ;; If flist is still non-nil, then do not guess since this means that not |
1075 ;; all the files in FILES were matched by the regexp. | |
1076 (setq cmds (and (not flist) cmds)) | |
1077 | |
6694 | 1078 ;; Return commands or nil if flist is still non-nil. |
1079 ;; Evaluate the commands in order that any logical testing will be done. | |
5426 | 1080 (cond ((not (cdr cmds)) |
1081 (eval (car cmds))) ; single command | |
1082 (t | |
1083 (mapcar (function eval) cmds))))) | |
1084 | |
1085 (defun dired-guess-shell-command (prompt files) | |
1086 | |
1087 ;; Ask user with PROMPT for a shell command, guessing a default from FILES. | |
1088 | |
1089 (let ((default (dired-guess-default files)) | |
1090 default-list old-history val (failed t)) | |
1091 | |
1092 (if (null default) | |
1093 ;; Nothing to guess | |
1094 (read-from-minibuffer prompt nil nil nil 'dired-shell-command-history) | |
1095 | |
1096 ;; Save current history list | |
1097 (setq old-history dired-shell-command-history) | |
1098 | |
1099 (if (listp default) | |
1100 | |
1101 ;; More than one guess | |
1102 (setq default-list default | |
1103 default (car default) | |
1104 prompt (concat | |
1105 prompt | |
1106 (format "{%d guesses} " (length default-list)))) | |
1107 | |
1108 ;; Just one guess | |
1109 (setq default-list (list default))) | |
1110 | |
1111 ;; Push all guesses onto history so that they can be retrieved with M-p | |
1112 ;; and put the first guess in the prompt but not in the initial value. | |
1113 (setq dired-shell-command-history | |
1114 (append default-list dired-shell-command-history) | |
1115 prompt (concat prompt (format "[%s] " default))) | |
1116 | |
1117 ;; The unwind-protect returns VAL, and we too. | |
1118 (unwind-protect | |
1119 ;; BODYFORM | |
1120 (progn | |
1121 (setq val (read-from-minibuffer prompt nil nil nil | |
1122 'dired-shell-command-history) | |
1123 failed nil) | |
1124 ;; If we got a return, then use default. | |
1125 (if (equal val "") | |
1126 (setq val default)) | |
1127 val) | |
1128 | |
1129 ;; UNWINDFORMS | |
1130 ;; Undo pushing onto the history list so that an aborted | |
1131 ;; command doesn't get the default in the next command. | |
1132 (setq dired-shell-command-history old-history) | |
1133 (if (not failed) | |
1134 (or (equal val (car-safe dired-shell-command-history)) | |
1135 (setq dired-shell-command-history | |
1136 (cons val dired-shell-command-history)))))))) | |
1137 | |
1138 | |
6694 | 1139 ;;; REDEFINE. |
5426 | 1140 ;;; Redefine dired-aux.el's version: |
1141 (defun dired-read-shell-command (prompt arg files) | |
1142 ;; "Read a dired shell command prompting with PROMPT (using read-string). | |
1143 ;;ARG is the prefix arg and may be used to indicate in the prompt which | |
1144 ;; files are affected. | |
1145 ;;This is an extra function so that you can redefine it, e.g., to use gmhist." | |
1146 (dired-mark-pop-up | |
1147 nil 'shell files | |
1148 'dired-guess-shell-command | |
1149 (format prompt (dired-mark-prompt arg files)) ; PROMPT | |
1150 files)) ; FILES | |
1151 | |
1152 | |
14169 | 1153 ;;; RELATIVE SYMBOLIC LINKS. |
5426 | 1154 |
1155 (defvar dired-keep-marker-relsymlink ?S | |
1156 "See variable `dired-keep-marker-move'.") | |
1157 | |
1158 (defun dired-make-relative-symlink (file1 file2 &optional ok-if-already-exists) | |
1159 "Three arguments: FILE1 FILE2 &optional OK-IF-ALREADY-EXISTS | |
1160 Make a symbolic link (pointing to FILE1) in FILE2. | |
1161 The link is relative (if possible), for example | |
1162 | |
1163 \"/vol/tex/bin/foo\" \"/vol/local/bin/foo\" | |
1164 | |
1165 results in | |
1166 | |
1167 \"../../tex/bin/foo\" \"/vol/local/bin/foo\" | |
1168 " | |
1169 (interactive "FRelSymLink: \nFRelSymLink %s: \np") | |
1170 (let (name1 name2 len1 len2 (index 0) sub) | |
1171 (setq file1 (expand-file-name file1) | |
1172 file2 (expand-file-name file2) | |
1173 len1 (length file1) | |
1174 len2 (length file2)) | |
1175 ;; Find common initial pathname components: | |
1176 (let (next) | |
1177 (while (and (setq next (string-match "/" file1 index)) | |
1178 (setq next (1+ next)) | |
1179 (< next (min len1 len2)) | |
1180 ;; For the comparison, both substrings must end in | |
1181 ;; `/', so NEXT is *one plus* the result of the | |
1182 ;; string-match. | |
1183 ;; E.g., consider the case of linking "/tmp/a/abc" | |
13975 | 1184 ;; to "/tmp/abc" erroneously giving "/tmp/a" instead |
5426 | 1185 ;; of "/tmp/" as common initial component |
1186 (string-equal (substring file1 0 next) | |
1187 (substring file2 0 next))) | |
1188 (setq index next)) | |
1189 (setq name2 file2 | |
1190 sub (substring file1 0 index) | |
1191 name1 (substring file1 index))) | |
1192 (if (string-equal sub "/") | |
1193 ;; No common initial pathname found | |
1194 (setq name1 file1) | |
1195 ;; Else they have a common parent directory | |
1196 (let ((tem (substring file2 index)) | |
1197 (start 0) | |
1198 (count 0)) | |
1199 ;; Count number of slashes we must compensate for ... | |
1200 (while (setq start (string-match "/" tem start)) | |
1201 (setq count (1+ count) | |
1202 start (1+ start))) | |
1203 ;; ... and prepend a "../" for each slash found: | |
1204 (while (> count 0) | |
1205 (setq count (1- count) | |
1206 name1 (concat "../" name1))))) | |
1207 (make-symbolic-link | |
1208 (directory-file-name name1) ; must not link to foo/ | |
1209 ; (trailing slash!) | |
1210 name2 ok-if-already-exists))) | |
1211 | |
1212 (defun dired-do-relsymlink (&optional arg) | |
1213 "Relative symlink all marked (or next ARG) files into a directory, | |
1214 or make a relative symbolic link to the current file. | |
1215 This creates relative symbolic links like | |
1216 | |
1217 foo -> ../bar/foo | |
1218 | |
1219 not absolute ones like | |
1220 | |
1221 foo -> /ugly/path/that/may/change/any/day/bar/foo" | |
1222 (interactive "P") | |
1223 (dired-do-create-files 'relsymlink (function dired-make-relative-symlink) | |
1224 "RelSymLink" arg dired-keep-marker-relsymlink)) | |
1225 | |
1226 (defun dired-do-relsymlink-regexp (regexp newname &optional whole-path) | |
1227 "RelSymlink all marked files containing REGEXP to NEWNAME. | |
1228 See functions `dired-do-rename-regexp' and `dired-do-relsymlink' | |
1229 for more info." | |
1230 (interactive (dired-mark-read-regexp "RelSymLink")) | |
1231 (dired-do-create-files-regexp | |
1232 (function dired-make-relative-symlink) | |
1233 "RelSymLink" nil regexp newname whole-path dired-keep-marker-relsymlink)) | |
1234 | |
1235 | |
14169 | 1236 ;;; VISIT ALL MARKED FILES SIMULTANEOUSLY. |
5426 | 1237 |
6694 | 1238 ;;; Brief Description: |
1239 ;;; | |
1240 ;;; `dired-do-find-marked-files' is bound to `F' by dired-x.el. | |
1241 ;;; | |
5426 | 1242 ;;; * Use `dired-get-marked-files' to collect the marked files in the current |
6694 | 1243 ;;; Dired Buffer into a list of filenames `FILE-LIST'. |
1244 ;;; | |
5426 | 1245 ;;; * Pass FILE-LIST to `dired-simultaneous-find-file' all with |
1246 ;;; `dired-do-find-marked-files''s prefix argument NOSELECT. | |
6694 | 1247 ;;; |
5426 | 1248 ;;; * `dired-simultaneous-find-file' runs through FILE-LIST decrementing the |
1249 ;;; list each time. | |
6694 | 1250 ;;; |
5426 | 1251 ;;; * If NOSELECT is non-nil then just run `find-file-noselect' on each |
1252 ;;; element of FILE-LIST. | |
6694 | 1253 ;;; |
5426 | 1254 ;;; * If NOSELECT is nil then calculate the `size' of the window for each file |
1255 ;;; by dividing the `window-height' by length of FILE-LIST. Thus, `size' is | |
1256 ;;; cognizant of the window-configuration. | |
6694 | 1257 ;;; |
5426 | 1258 ;;; * If `size' is too small abort, otherwise run `find-file' on each element |
1259 ;;; of FILE-LIST giving each a window of height `size'. | |
1260 | |
1261 (defun dired-do-find-marked-files (&optional noselect) | |
1262 "Find all marked files displaying all of them simultaneously. | |
1263 With optional NOSELECT just find files but do not select them. | |
1264 | |
1265 The current window is split across all files marked, as evenly as possible. | |
1266 Remaining lines go to bottom-most window. The number of files that can be | |
1267 displayed this way is restricted by the height of the current window and | |
1268 `window-min-height'. | |
1269 | |
6694 | 1270 To keep dired buffer displayed, type \\[split-window-vertically] first. |
5426 | 1271 To display just marked files, type \\[delete-other-windows] first." |
1272 | |
1273 (interactive "P") | |
1274 (dired-simultaneous-find-file (dired-get-marked-files) noselect)) | |
1275 | |
1276 (defun dired-simultaneous-find-file (file-list noselect) | |
1277 | |
1278 ;; Visit all files in FILE-LIST and display them simultaneously. The | |
1279 ;; current window is split across all files in FILE-LIST, as evenly as | |
1280 ;; possible. Remaining lines go to the bottom-most window. The number of | |
1281 ;; files that can be displayed this way is restricted by the height of the | |
1282 ;; current window and the variable `window-min-height'. With non-nil | |
1283 ;; NOSELECT the files are merely found but not selected. | |
6694 | 1284 |
5426 | 1285 ;; We don't make this function interactive because it is usually too clumsy |
1286 ;; to specify FILE-LIST interactively unless via dired. | |
1287 | |
1288 (let (size) | |
1289 | |
1290 (if noselect | |
1291 ;; Do not select the buffer. | |
1292 (find-file-noselect (car file-list)) | |
1293 | |
1294 ;; We will have to select the buffer. Calculate and check window size. | |
1295 (setq size (/ (window-height) (length file-list))) | |
1296 (or (<= window-min-height size) | |
1297 (error "Too many files to visit simultaneously. Try C-u prefix.")) | |
1298 (find-file (car file-list))) | |
1299 | |
1300 ;; Decrement. | |
1301 (setq file-list (cdr file-list)) | |
1302 | |
1303 (while file-list | |
1304 | |
1305 (if noselect | |
1306 ;; Do not select the buffer. | |
1307 (find-file-noselect (car file-list)) | |
1308 | |
1309 ;; Vertically split off a window of desired size. Upper window will | |
1310 ;; have SIZE lines. Select lower (larger) window. We split it again. | |
1311 (select-window (split-window nil size)) | |
1312 (find-file (car file-list))) | |
1313 | |
1314 ;; Decrement. | |
1315 (setq file-list (cdr file-list))))) | |
1316 | |
1317 | |
14169 | 1318 ;;; MISCELLANEOUS COMMANDS. |
5426 | 1319 |
6694 | 1320 ;;; Run man on files. |
1321 | |
5426 | 1322 (defun dired-man () |
6694 | 1323 "Run man on this file. Display old buffer if buffer name matches filename. |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
1324 Uses ../lisp/man.el of \\[manual-entry] fame." |
5426 | 1325 (interactive) |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
1326 (require 'man) |
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
1327 (let ((file (dired-get-filename)) |
8713
fad4e60c964d
(dired-omit-expunge): Avoid setting buffer modified
Richard M. Stallman <rms@gnu.org>
parents:
8078
diff
changeset
|
1328 (manual-program "nroff -man -h")) |
7865
d3e50535e6da
(dired-man): Use internal function from man.el.
Richard M. Stallman <rms@gnu.org>
parents:
7839
diff
changeset
|
1329 (Man-getpage-in-background file))) |
5426 | 1330 |
1331 ;;; Run Info on files. | |
1332 | |
1333 (defun dired-info () | |
1334 "Run info on this file." | |
1335 (interactive) | |
1336 (info (dired-get-filename))) | |
1337 | |
1338 ;;; Run mail on mail folders. | |
1339 | |
6694 | 1340 ;;; (and (not (fboundp 'vm-visit-folder)) |
1341 ;;; (defun vm-visit-folder (file &optional arg) | |
1342 ;;; nil)) | |
1343 | |
5426 | 1344 (defun dired-vm (&optional read-only) |
1345 "Run VM on this file. | |
1346 With prefix arg, visit folder read-only (this requires at least VM 5). | |
1347 See also variable `dired-vm-read-only-folders'." | |
1348 (interactive "P") | |
1349 (let ((dir (dired-current-directory)) | |
1350 (fil (dired-get-filename))) | |
1351 ;; take care to supply 2nd arg only if requested - may still run VM 4! | |
1352 (cond (read-only (vm-visit-folder fil t)) | |
1353 ((eq t dired-vm-read-only-folders) (vm-visit-folder fil t)) | |
1354 ((null dired-vm-read-only-folders) (vm-visit-folder fil)) | |
1355 (t (vm-visit-folder fil (not (file-writable-p fil))))) | |
1356 ;; so that pressing `v' inside VM does prompt within current directory: | |
1357 (set (make-local-variable 'vm-folder-directory) dir))) | |
1358 | |
1359 (defun dired-rmail () | |
1360 "Run RMAIL on this file." | |
1361 (interactive) | |
1362 (rmail (dired-get-filename))) | |
1363 | |
1364 (defun dired-do-run-mail () | |
1365 "If `dired-bind-vm' is t, then function `dired-vm', otherwise `dired-rmail'." | |
1366 (interactive) | |
1367 (if dired-bind-vm | |
1368 ;; Read mail folder using vm. | |
1369 (dired-vm) | |
1370 ;; Read mail folder using rmail. | |
1371 (dired-rmail))) | |
1372 | |
1373 | |
14169 | 1374 ;;; MISCELLANEOUS INTERNAL FUNCTIONS. |
5426 | 1375 |
1376 (or (fboundp 'dired-old-find-buffer-nocreate) | |
1377 (fset 'dired-old-find-buffer-nocreate | |
1378 (symbol-function 'dired-find-buffer-nocreate))) | |
1379 | |
6694 | 1380 ;;; REDEFINE. |
5426 | 1381 ;;; Redefines dired.el's version of `dired-find-buffer-nocreate' |
13033
216edf9576ea
(dired-up-directory): Add optional argument `other-window' to obviate
Erik Naggum <erik@naggum.no>
parents:
11933
diff
changeset
|
1382 (defun dired-find-buffer-nocreate (dirname &optional mode) |
11933
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1383 (if (and dired-find-subdir |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1384 ;; don't try to find a wildcard as a subdirectory |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1385 (string-equal dirname (file-name-directory dirname))) |
5426 | 1386 (let* ((cur-buf (current-buffer)) |
11933
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1387 (buffers (nreverse |
8792
d85424a6fb85
(dired-clean-up-after-deletion): Expand fn.
Richard M. Stallman <rms@gnu.org>
parents:
8713
diff
changeset
|
1388 (dired-buffers-for-dir (expand-file-name dirname)))) |
11933
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1389 (cur-buf-matches (and (memq cur-buf buffers) |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1390 ;; wildcards must match, too: |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1391 (equal dired-directory dirname)))) |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1392 ;; We don't want to switch to the same buffer--- |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1393 (setq buffers (delq cur-buf buffers));;need setq with delq |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1394 (or (car (sort buffers (function dired-buffer-more-recently-used-p))) |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1395 ;; ---unless it's the only possibility: |
9b53ce243465
(dired-find-buffer-nocreate): Don't try to find a
Karl Heuer <kwzh@gnu.org>
parents:
11588
diff
changeset
|
1396 (and cur-buf-matches cur-buf))) |
13033
216edf9576ea
(dired-up-directory): Add optional argument `other-window' to obviate
Erik Naggum <erik@naggum.no>
parents:
11933
diff
changeset
|
1397 (dired-old-find-buffer-nocreate dirname mode))) |
5426 | 1398 |
1399 ;; This should be a builtin | |
1400 (defun dired-buffer-more-recently-used-p (buffer1 buffer2) | |
1401 "Return t if BUFFER1 is more recently used than BUFFER2." | |
1402 (if (equal buffer1 buffer2) | |
1403 nil | |
1404 (let ((more-recent nil) | |
1405 (list (buffer-list))) | |
1406 (while (and list | |
1407 (not (setq more-recent (equal buffer1 (car list)))) | |
1408 (not (equal buffer2 (car list)))) | |
1409 (setq list (cdr list))) | |
1410 more-recent))) | |
1411 | |
1412 ;;; Same thing as `dired-buffers-for-dir' of dired.el? - lrd 11/23/93 | |
1413 ;;; (defun dired-buffers-for-dir-exact (dir) | |
1414 ;;; ;; Return a list of buffers that dired DIR (a directory or wildcard) | |
1415 ;;; ;; at top level, or as subdirectory. | |
1416 ;;; ;; Top level matches must match the wildcard part too, if any. | |
1417 ;;; ;; The list is in reverse order of buffer creation, most recent last. | |
1418 ;;; ;; As a side effect, killed dired buffers for DIR are removed from | |
1419 ;;; ;; dired-buffers. | |
1420 ;;; (let ((alist dired-buffers) result elt) | |
1421 ;;; (while alist | |
1422 ;;; (setq elt (car alist) | |
1423 ;;; alist (cdr alist)) | |
1424 ;;; (let ((buf (cdr elt))) | |
1425 ;;; (if (buffer-name buf) | |
1426 ;;; ;; Top level must match exactly against dired-directory in | |
1427 ;;; ;; case one of them is a wildcard. | |
1428 ;;; (if (or (equal dir (save-excursion (set-buffer buf) | |
1429 ;;; dired-directory)) | |
1430 ;;; (assoc dir (save-excursion (set-buffer buf) | |
1431 ;;; dired-subdir-alist))) | |
1432 ;;; (setq result (cons buf result))) | |
1433 ;;; ;; else buffer is killed - clean up: | |
1434 ;;; (setq dired-buffers (delq elt dired-buffers))))) | |
1435 ;;; result)) | |
1436 | |
6694 | 1437 ;;; REDEFINE. |
5426 | 1438 ;;; Redefines dired.el's version of `dired-initial-position' |
1439 (defun dired-initial-position (dirname) | |
1440 (end-of-line) | |
1441 (if dired-find-subdir (dired-goto-subdir dirname)) ; new | |
1442 (if dired-trivial-filenames (dired-goto-next-nontrivial-file))) | |
1443 | |
1444 | |
1445 ;; Does anyone use this? - lrd 6/29/93. | |
20513
6044f0be20eb
(dired-mark-sexp): Skip leading space in defining `uid'.
Richard M. Stallman <rms@gnu.org>
parents:
18917
diff
changeset
|
1446 ;; Apparently people do use it. - lrd 12/22/97. |
5426 | 1447 (defun dired-mark-sexp (predicate &optional unflag-p) |
1448 "Mark files for which PREDICATE returns non-nil. | |
1449 With a prefix arg, unflag those files instead. | |
1450 | |
1451 PREDICATE is a lisp expression that can refer to the following symbols: | |
1452 | |
1453 inode [integer] the inode of the file (only for ls -i output) | |
1454 s [integer] the size of the file for ls -s output | |
13975 | 1455 (usually in blocks or, with -k, in KByte) |
5426 | 1456 mode [string] file permission bits, e.g. \"-rw-r--r--\" |
1457 nlink [integer] number of links to file | |
1458 uid [string] owner | |
1459 gid [string] group (If the gid is not displayed by ls, | |
1460 this will still be set (to the same as uid)) | |
1461 size [integer] file size in bytes | |
1462 time [string] the time that ls displays, e.g. \"Feb 12 14:17\" | |
1463 name [string] the name of the file | |
1464 sym [string] if file is a symbolic link, the linked-to name, else \"\" | |
1465 | |
1466 For example, use | |
1467 | |
1468 (equal 0 size) | |
1469 | |
1470 to mark all zero length files." | |
1471 ;; Using sym="" instead of nil avoids the trap of | |
1472 ;; (string-match "foo" sym) into which a user would soon fall. | |
1473 ;; Give `equal' instead of `=' in the example, as this works on | |
1474 ;; integers and strings. | |
1475 (interactive "xMark if (lisp expr): \nP") | |
1476 (message "%s" predicate) | |
1477 (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)) | |
1478 inode s mode nlink uid gid size time name sym) | |
1479 (dired-mark-if | |
1480 (save-excursion | |
1481 (and | |
1482 ;; Sets vars | |
1483 ;; inode s mode nlink uid gid size time name sym | |
1484 | |
1485 ;; according to current file line. Returns t for success, nil if | |
1486 ;; there is no file line. Upon success, all variables are set, either | |
1487 ;; to nil or the appropriate value, so they need not be initialized. | |
1488 ;; Moves point within the current line. | |
1489 (if (dired-move-to-filename) | |
1490 (let (pos | |
1491 (mode-len 10) ; length of mode string | |
1492 ;; like in dired.el, but with subexpressions \1=inode, \2=s: | |
1493 (dired-re-inode-size "\\s *\\([0-9]*\\)\\s *\\([0-9]*\\) ?")) | |
1494 (beginning-of-line) | |
1495 (forward-char 2) | |
1496 (if (looking-at dired-re-inode-size) | |
1497 (progn | |
1498 (goto-char (match-end 0)) | |
1499 (setq inode (string-to-int (buffer-substring (match-beginning 1) | |
1500 (match-end 1))) | |
1501 s (string-to-int (buffer-substring (match-beginning 2) | |
1502 (match-end 2))))) | |
1503 (setq inode nil | |
1504 s nil)) | |
1505 (setq mode (buffer-substring (point) (+ mode-len (point)))) | |
1506 (forward-char mode-len) | |
1507 (setq nlink (read (current-buffer))) | |
20513
6044f0be20eb
(dired-mark-sexp): Skip leading space in defining `uid'.
Richard M. Stallman <rms@gnu.org>
parents:
18917
diff
changeset
|
1508 ;; Karsten Wenger <kw@cis.uni-muenchen.de> fixed uid. |
6044f0be20eb
(dired-mark-sexp): Skip leading space in defining `uid'.
Richard M. Stallman <rms@gnu.org>
parents:
18917
diff
changeset
|
1509 (setq uid (buffer-substring (+ (point) 1) (progn (forward-word 1) (point)))) |
5426 | 1510 (re-search-forward "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct\\|Nov\\|Dec\\)") |
1511 (goto-char (match-beginning 1)) | |
1512 (forward-char -1) | |
1513 (setq size (string-to-int (buffer-substring (save-excursion | |
1514 (backward-word 1) | |
1515 (setq pos (point))) | |
1516 (point)))) | |
1517 (goto-char pos) | |
1518 (backward-word 1) | |
1519 ;; if no gid is displayed, gid will be set to uid | |
1520 ;; but user will then not reference it anyway in PREDICATE. | |
1521 (setq gid (buffer-substring (save-excursion (forward-word 1) (point)) | |
1522 (point)) | |
1523 time (buffer-substring (match-beginning 1) | |
1524 (1- (dired-move-to-filename))) | |
1525 name (buffer-substring (point) | |
1526 (or (dired-move-to-end-of-filename t) | |
1527 (point))) | |
1528 sym (progn | |
1529 (if (looking-at " -> ") | |
1530 (buffer-substring (progn (forward-char 4) (point)) | |
1531 (progn (end-of-line) (point))) | |
1532 ""))) | |
1533 t) | |
1534 nil) | |
1535 (eval predicate))) | |
1536 (format "'%s file" predicate)))) | |
1537 | |
1538 | |
14169 | 1539 ;;; FIND FILE AT POINT. |
5426 | 1540 |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1541 (defvar dired-x-hands-off-my-keys t |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1542 "*t means don't bind `dired-x-find-file' over `find-file' on keyboard. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1543 Similarly for `dired-x-find-file-other-window' over `find-file-other-window'. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1544 If you change this variable after dired-x.el is loaded then do |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1545 \\[dired-x-bind-find-file].") |
5426 | 1546 |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1547 ;;; Bind `dired-x-find-file{-other-window}' over wherever |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1548 ;;; `find-file{-other-window}' is bound? |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1549 (defun dired-x-bind-find-file () |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1550 "Bind `dired-x-find-file' in place of `find-file' \(or reverse\). |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1551 Similarly for `dired-x-find-file-other-window' and `find-file-other-window'. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1552 Binding direction based on `dired-x-hands-off-my-keys'. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1553 This function part of `after-init-hook'." |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1554 (interactive) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1555 (if (interactive-p) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1556 (setq dired-x-hands-off-my-keys |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1557 (not (y-or-n-p "Bind dired-x-find-file over find-file? ")))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1558 (cond ((not dired-x-hands-off-my-keys) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1559 (substitute-key-definition 'find-file |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1560 'dired-x-find-file |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1561 (current-global-map)) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1562 (substitute-key-definition 'find-file-other-window |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1563 'dired-x-find-file-other-window |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1564 (current-global-map))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1565 (t |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1566 (substitute-key-definition 'dired-x-find-file |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1567 'find-file |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1568 (current-global-map)) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1569 (substitute-key-definition 'dired-x-find-file-other-window |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1570 'find-file-other-window |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1571 (current-global-map)))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1572 ;; Clear mini-buffer. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1573 (message nil)) |
5426 | 1574 |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1575 ;;; Now call it so binding is correct and put on `after-init-hook' in case |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1576 ;;; user changes binding. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1577 (dired-x-bind-find-file) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1578 (add-hook 'after-init-hook 'dired-x-bind-find-file) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1579 |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1580 (defun dired-x-find-file (filename) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1581 "Edit file FILENAME. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1582 May create a new window, or reuse an existing one. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1583 See the function `display-buffer'. |
5426 | 1584 |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1585 Identical to `find-file' except when called interactively, with a prefix arg |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1586 \(e.g., \\[universal-argument]\), in which case it guesses filename near |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1587 point. Useful for editing file mentioned in buffer you are viewing, or to |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1588 test if that file exists. Use minibuffer after snatching filename." |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1589 (interactive (list (read-filename-at-point "Find file: "))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1590 (find-file (expand-file-name filename))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1591 |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1592 (defun dired-x-find-file-other-window (filename) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1593 "Edit file FILENAME, in another window. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1594 May create a new window, or reuse an existing one. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1595 See the function `display-buffer'. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1596 |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1597 Identical to `find-file-other-window' except when called interactively, with a |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1598 prefix arg \(e.g., \\[universal-argument]\), in which case it guesses filename |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1599 near point. Useful for editing file mentioned in buffer you are viewing, or |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1600 to test if that file exists. Use minibuffer after snatching filename." |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1601 (interactive (list (read-filename-at-point "Find file: "))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1602 (find-file-other-window (expand-file-name filename))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1603 |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1604 ;;; Internal functions. |
5426 | 1605 (defun dired-filename-at-point () |
1606 | |
1607 ;; Get the filename closest to point, but do not change position. Has a | |
1608 ;; preference for looking backward when not directly on a symbol. Not | |
1609 ;; perfect - point must be in middle of or end of filename. | |
1610 | |
6694 | 1611 (let ((filename-chars ".a-zA-Z0-9---_/:$+") |
5426 | 1612 (bol (save-excursion (beginning-of-line) (point))) |
1613 (eol (save-excursion (end-of-line) (point))) | |
1614 start end filename) | |
1615 | |
1616 (save-excursion | |
1617 ;; First see if just past a filename. | |
1618 (if (not (eobp)) | |
1619 (if (looking-at "[] \t\n[{}()]") ; whitespace or some parens | |
1620 (progn | |
1621 (skip-chars-backward " \n\t\r({[]})") | |
1622 (if (not (bobp)) | |
1623 (backward-char 1))))) | |
6694 | 1624 |
5426 | 1625 (if (string-match (concat "[" filename-chars "]") |
1626 (char-to-string (following-char))) | |
1627 (progn | |
1628 (skip-chars-backward filename-chars) | |
1629 (setq start (point)) | |
1630 (if (string-match "[/~]" (char-to-string (preceding-char))) | |
1631 (setq start (1- start))) | |
1632 (skip-chars-forward filename-chars)) | |
1633 | |
1634 (error "No file found around point!")) | |
1635 | |
6694 | 1636 ;; Return string. |
5426 | 1637 (expand-file-name (buffer-substring start (point)))))) |
1638 | |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1639 (defun read-filename-at-point (prompt) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1640 ;;; Returns filename prompting with PROMPT with completion. If |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1641 ;;; `current-prefix-arg' is non-nil, uses name at point as guess. |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1642 (if current-prefix-arg |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1643 (let ((guess (dired-filename-at-point))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1644 (read-file-name prompt |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1645 (file-name-directory guess) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1646 guess |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1647 nil (file-name-nondirectory guess))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1648 (read-file-name prompt default-directory))) |
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1649 |
5426 | 1650 |
14169 | 1651 ;;; BUG REPORTS |
5426 | 1652 |
1653 ;;; This section is provided for reports. It uses Barry A. Warsaw's | |
1654 ;;; reporter.el which is bundled with GNU Emacs v19. | |
1655 | |
8078
1dd92ac02141
(dired-x-hands-off-my-keys): New user-defined variable.
Richard M. Stallman <rms@gnu.org>
parents:
7865
diff
changeset
|
1656 (defconst dired-x-version "2.37" |
5426 | 1657 "Revision number of dired-x.el -- dired extra for GNU Emacs v19. |
6694 | 1658 Type \\[dired-x-submit-report] to send a bug report. Available via anonymous |
5426 | 1659 ftp in |
1660 | |
1661 /roebling.poly.edu:/pub/packages/dired-x.tar.gz") | |
1662 | |
1663 (defconst dired-x-help-address "dodd@roebling.poly.edu" | |
1664 "Address(es) accepting submission of reports on dired-x.el.") | |
1665 | |
1666 (defconst dired-x-maintainer "Larry" | |
1667 "First name(s) of people accepting submission of reports on dired-x.el.") | |
1668 | |
1669 (defconst dired-x-file "dired-x.el" | |
1670 "Name of file containing emacs lisp code.") | |
1671 | |
1672 (defconst dired-x-variable-list | |
6694 | 1673 (list |
5426 | 1674 'dired-bind-vm |
1675 'dired-vm-read-only-folders | |
1676 'dired-bind-jump | |
1677 'dired-bind-info | |
1678 'dired-bind-man | |
1679 'dired-find-subdir | |
1680 'dired-enable-local-variables | |
1681 'dired-local-variables-file | |
1682 'dired-guess-shell-gnutar | |
1683 'dired-guess-shell-gzip-quiet | |
1684 'dired-guess-shell-znew-switches | |
1685 'dired-guess-shell-alist-user | |
1686 'dired-clean-up-buffers-too | |
1687 'dired-omit-files-p | |
1688 'dired-omit-files | |
1689 'dired-omit-extensions | |
1690 ) | |
1691 "List of variables to be appended to reports sent by `dired-x-submit-report.'") | |
1692 | |
1693 (defun dired-x-submit-report () | |
1694 "Submit via reporter.el a bug report on program. Send report on `dired-x-file' | |
1695 version `dired-x-version,' to `dired-x-maintainer' at address `dired-x-help-address' | |
1696 listing variables `dired-x-variable-list' in the message." | |
1697 (interactive) | |
1698 | |
1699 ;; In case we can't find reporter... | |
1700 (condition-case err | |
1701 (progn | |
1702 ;; Get it if we can. | |
1703 (require 'reporter) | |
1704 | |
1705 (reporter-submit-bug-report | |
1706 dired-x-help-address ; address | |
1707 (concat dired-x-file " (" dired-x-version ")") ; pkgname | |
1708 dired-x-variable-list ; varlist | |
1709 nil nil ; pre-/post-hooks | |
1710 (concat dired-x-maintainer ","))) ; salutation | |
1711 | |
1712 ;; ...fail gracefully. | |
6694 | 1713 (error |
5426 | 1714 (beep) |
1715 (message "Sorry, reporter.el not found.")))) | |
1716 | |
1717 | |
1718 ;; As Barry Warsaw would say: "This might be useful..." | |
1719 (provide 'dired-x) | |
1720 | |
1721 ;;; dired-x.el ends here |