aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-04-11 19:01:31 +0000
committerStefan Monnier2005-04-11 19:01:31 +0000
commita8f8c39013d510311c8bdcab9a943e23526372ae (patch)
tree47f730e0edbc4ff96f81b5539bc6f8caa05b8dd6
parent7dbe67a41259108693fa6fc4149bbdd9ebf236b3 (diff)
downloademacs-a8f8c39013d510311c8bdcab9a943e23526372ae.tar.gz
emacs-a8f8c39013d510311c8bdcab9a943e23526372ae.zip
Doc fixes.
(wdired-confirm-overwrite): Rename from wdired-is-ok-overwrite. (wdired-use-dired-vertical-movement): Rename from wdired-always-move-to-filename-beginning. (wdired-mode-map): Use `ignore' instead of `wdired-newline'. (wdired-change-to-wdired-mode): Change mode name. (wdired-newline): Delete.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/wdired.el173
2 files changed, 68 insertions, 115 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0d861923260..46598c5bf58 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12005-04-11 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * wdired.el: Doc fixes.
4 (wdired-confirm-overwrite): Rename from wdired-is-ok-overwrite.
5 (wdired-use-dired-vertical-movement): Rename from
6 wdired-always-move-to-filename-beginning.
7 (wdired-mode-map): Use `ignore' instead of `wdired-newline'.
8 (wdired-change-to-wdired-mode): Change mode name.
9 (wdired-newline): Delete.
10
12005-04-11 Richard M. Stallman <rms@gnu.org> 112005-04-11 Richard M. Stallman <rms@gnu.org>
2 12
3 * whitespace.el (whitespace-highlight-the-space): 13 * whitespace.el (whitespace-highlight-the-space):
diff --git a/lisp/wdired.el b/lisp/wdired.el
index 4b37bc33659..3941fd681df 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -31,8 +31,8 @@
31;; 31;;
32;; Have you ever wished to use C-x r t (string-rectangle), M-% 32;; Have you ever wished to use C-x r t (string-rectangle), M-%
33;; (query-replace), M-c (capitalize-word), etc. to change the name of 33;; (query-replace), M-c (capitalize-word), etc. to change the name of
34;; the files in a "dired" buffer? Now you can do this. All the power 34;; the files in a "dired" buffer? Now you can do this. All the power
35;; of emacs commands are available to renaming files! 35;; of Emacs commands are available to renaming files!
36;; 36;;
37;; This package provides a function that makes the filenames of a a 37;; This package provides a function that makes the filenames of a a
38;; dired buffer editable, by changing the buffer mode (which inhibits 38;; dired buffer editable, by changing the buffer mode (which inhibits
@@ -40,7 +40,7 @@
40;; one or more files and directories, and when you press C-c C-c, the 40;; one or more files and directories, and when you press C-c C-c, the
41;; renaming takes effect and you are back to dired mode. 41;; renaming takes effect and you are back to dired mode.
42;; 42;;
43;; Another things you can do with wdired: 43;; Another things you can do with WDired:
44;; 44;;
45;; - To move files to another directory (by typing their path, 45;; - To move files to another directory (by typing their path,
46;; absolute or relative, as a part of the new filename). 46;; absolute or relative, as a part of the new filename).
@@ -49,21 +49,16 @@
49;; 49;;
50;; - To change the permission bits of the filenames (in systems with a 50;; - To change the permission bits of the filenames (in systems with a
51;; working unix-alike `dired-chmod-program'). See and customize the 51;; working unix-alike `dired-chmod-program'). See and customize the
52;; variable `wdired-allow-to-change-permissions'. To change a single 52;; variable `wdired-allow-to-change-permissions'. To change a single
53;; char (toggling between its two more usual values) you can press 53;; char (toggling between its two more usual values) you can press
54;; the space bar over it or left-click the mouse. To set any char to 54;; the space bar over it or left-click the mouse. To set any char to
55;; an specific value (this includes the SUID, SGID and STI bits) you 55;; an specific value (this includes the SUID, SGID and STI bits) you
56;; can use the key labeled as the letter you want. Please note that 56;; can use the key labeled as the letter you want. Please note that
57;; permissions of the links cannot be changed in that way, because 57;; permissions of the links cannot be changed in that way, because
58;; the change would affect to their targets, and this would not be 58;; the change would affect to their targets, and this would not be
59;; WYSIWYG :-). 59;; WYSIWYG :-).
60;; 60;;
61;; - To mark files for deletion, by deleting their whole filename. 61;; - To mark files for deletion, by deleting their whole filename.
62;;
63;; I do not have a URL to hang wdired, but you can use the one below
64;; to find the latest version:
65;;
66;; http://groups.google.com/groups?as_ugroup=gnu.emacs.sources&as_q=wdired
67 62
68;;; Installation: 63;;; Installation:
69 64
@@ -75,21 +70,19 @@
75;; (require 'wdired) 70;; (require 'wdired)
76;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) 71;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
77;; 72;;
78;; This is recommended way for faster emacs startup time and lower 73;; This is the recommended way for faster Emacs startup time and lower
79;; memory consumption, but remind to add these lines before dired.el 74;; memory consumption:
80;; gets loaded (i.e., near the beginning of your .emacs file):
81;; 75;;
82;; (autoload 'wdired-change-to-wdired-mode "wdired") 76;; (autoload 'wdired-change-to-wdired-mode "wdired")
83;; (add-hook 'dired-load-hook 77;; (eval-after-load "dired"
84;; '(lambda () 78;; '(lambda ()
85;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) 79;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode)
86;; (define-key dired-mode-map 80;; (define-key dired-mode-map
87;; [menu-bar immediate wdired-change-to-wdired-mode] 81;; [menu-bar immediate wdired-change-to-wdired-mode]
88;; '("Edit File Names" . wdired-change-to-wdired-mode)))) 82;; '("Edit File Names" . wdired-change-to-wdired-mode))))
89;; 83;;
90;; 84;; Type "M-x customize-group RET wdired" if you want to make changes
91;; Type "M-x customize-group RET wdired" if you want make changes to 85;; to the default behavior.
92;; the default behavior.
93 86
94;;; Usage: 87;;; Usage:
95 88
@@ -103,60 +96,12 @@
103 96
104;;; Change Log: 97;;; Change Log:
105 98
106;; From 1.9 to 1.91 99;; Google is your friend (previous versions with complete changelogs
107;; 100;; were posted to gnu.emacs.sources)
108;; - Fixed a bug (introduced in 1.9) so now files can be marked for
109;; deletion again, by deleting their whole filename.
110
111;; From 1.8 to 1.9
112;;
113;; - Another alternative way of editing permissions allowed, see
114;; `wdired-allow-to-change-permissions' for details.
115;;
116;; - Now wdired doesn't rely on regexp so much. As a consequence of
117;; this, you can add newlines to filenames and symlinks targets
118;; (although this is not very usual, IMHO). Please note that dired
119;; (at least in Emacs 21.1 and previous) does not work very well
120;; with filenames with newlines in them, so RET is deactivated in
121;; wdired mode. But you can activate it if you want.
122;;
123;; - Now `upcase-word' `capitalize-word' and `downcase-word' are not
124;; advised to work better with wdired mode, but the keys bound to
125;; them use wdired versions of those commands.
126;;
127;; - Now "undo" actions are not inherited from wdired mode when
128;; changing to dired mode.
129;;
130;; - Code and documentation cleanups.
131;;
132;; - Fixed a bug that was making wdired to fail on users with
133;; `dired-backup-overwrite' set to t.
134;;
135;; - C-c C-[ now abort changes.
136
137;; From 1.7 to 1.8
138;;
139;; - Now permission (access-control) bits of the files can be changed.
140;; Please see the commentary section and the custom variable
141;; `wdired-allow-to-change-permissions' for details.
142;;
143;; - Added another possible value for the variable
144;; `wdired-always-move-to-filename-beginning', useful to change
145;; permission bits of several files without the cursor jumping to
146;; filenames when changing lines.
147
148;; From 0.1 to 1.7
149
150;; - I've moved the list of changes to another file, because it was
151;; huge. Ask me for it or search older versions in google.
152
153;;; TODO:
154
155;; - Make it to work in XEmacs. Any volunteer?
156 101
157;;; Code: 102;;; Code:
158 103
159(defvar dired-backup-overwrite) ; Only in emacs 20.x this is a custom var 104(defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var
160(eval-when-compile 105(eval-when-compile
161 (set (make-local-variable 'byte-compile-dynamic) t)) 106 (set (make-local-variable 'byte-compile-dynamic) t))
162 107
@@ -170,22 +115,22 @@
170 :group 'dired) 115 :group 'dired)
171 116
172(defcustom wdired-use-interactive-rename nil 117(defcustom wdired-use-interactive-rename nil
173 "*If t, confirmation is required before actually rename the files. 118 "*If non-nil, WDired requires confirmation before actually renaming files.
174Confirmation is required also for overwriting files. If nil, no 119If nil, WDired doesn't require confirmation to change the file names,
175confirmation is required for change the file names, and the variable 120and the variable `wdired-confirm-overwrite' controls whether it is ok
176`wdired-is-ok-overwrite' is used to see if it is ok to overwrite files 121to overwrite files without asking."
177without asking."
178 :type 'boolean 122 :type 'boolean
179 :group 'wdired) 123 :group 'wdired)
180 124
181(defcustom wdired-is-ok-overwrite nil 125(defcustom wdired-confirm-overwrite t
182 "*If non-nil the renames can overwrite files without asking. 126 "*If nil the renames can overwrite files without asking.
183This variable is used only if `wdired-use-interactive-rename' is nil." 127This variable has no effect at all if `wdired-use-interactive-rename'
128is not nil."
184 :type 'boolean 129 :type 'boolean
185 :group 'wdired) 130 :group 'wdired)
186 131
187(defcustom wdired-always-move-to-filename-beginning nil 132(defcustom wdired-use-dired-vertical-movement nil
188 "*If t the \"up\" and \"down\" movement is done as in dired mode. 133 "*If t, the \"up\" and \"down\" movement works as in Dired mode.
189That is, always move the point to the beginning of the filename at line. 134That is, always move the point to the beginning of the filename at line.
190 135
191If `sometimes, only move to the beginning of filename if the point is 136If `sometimes, only move to the beginning of filename if the point is
@@ -199,20 +144,20 @@ If nil, \"up\" and \"down\" movement is done as in any other buffer."
199 :group 'wdired) 144 :group 'wdired)
200 145
201(defcustom wdired-allow-to-redirect-links t 146(defcustom wdired-allow-to-redirect-links t
202 "*If non-nil, the target of the symbolic links can be changed also. 147 "*If non-nil, the target of the symbolic links are editable.
203In systems without symbolic links support, this variable has no effect 148In systems without symbolic links support, this variable has no effect
204at all." 149at all."
205 :type 'boolean 150 :type 'boolean
206 :group 'wdired) 151 :group 'wdired)
207 152
208(defcustom wdired-allow-to-change-permissions nil 153(defcustom wdired-allow-to-change-permissions nil
209 "*If non-nil, the permissions bits of the files can be changed also. 154 "*If non-nil, the permissions bits of the files are editable.
210 155
211If t, to change a single bit, put the cursor over it and press the 156If t, to change a single bit, put the cursor over it and press the
212space bar, or left click over it. You can also hit the letter you want 157space bar, or left click over it. You can also hit the letter you want
213to set: if this value is allowed, the character in the buffer will be 158to set: if this value is allowed, the character in the buffer will be
214changed. Anyway, the point is advanced one position, so, for example, 159changed. Anyway, the point is advanced one position, so, for example,
215you can keep the \"x\" key pressed to give execution permissions to 160you can keep the <x> key pressed to give execution permissions to
216everybody to that file. 161everybody to that file.
217 162
218If `advanced, the bits are freely editable. You can use 163If `advanced, the bits are freely editable. You can use
@@ -220,7 +165,7 @@ If `advanced, the bits are freely editable. You can use
220newlines), but if you want your changes to be useful, you better put a 165newlines), but if you want your changes to be useful, you better put a
221intelligible value. 166intelligible value.
222 167
223Anyway, the real change of the permissions is done with the external 168Anyway, the real change of the permissions is done by the external
224program `dired-chmod-program', which must exist." 169program `dired-chmod-program', which must exist."
225 :type '(choice (const :tag "Not allowed" nil) 170 :type '(choice (const :tag "Not allowed" nil)
226 (const :tag "Toggle/set bits" t) 171 (const :tag "Toggle/set bits" t)
@@ -233,9 +178,9 @@ program `dired-chmod-program', which must exist."
233 (define-key map "\C-c\C-c" 'wdired-finish-edit) 178 (define-key map "\C-c\C-c" 'wdired-finish-edit)
234 (define-key map "\C-c\C-k" 'wdired-abort-changes) 179 (define-key map "\C-c\C-k" 'wdired-abort-changes)
235 (define-key map "\C-c\C-[" 'wdired-abort-changes) 180 (define-key map "\C-c\C-[" 'wdired-abort-changes)
236 (define-key map "\C-m" 'wdired-newline) 181 (define-key map "\C-m" 'ignore)
237 (define-key map "\C-j" 'wdired-newline) 182 (define-key map "\C-j" 'ignore)
238 (define-key map "\C-o" 'wdired-newline) 183 (define-key map "\C-o" 'ignore)
239 (define-key map [up] 'wdired-previous-line) 184 (define-key map [up] 'wdired-previous-line)
240 (define-key map "\C-p" 'wdired-previous-line) 185 (define-key map "\C-p" 'wdired-previous-line)
241 (define-key map [down] 'wdired-next-line) 186 (define-key map [down] 'wdired-next-line)
@@ -261,7 +206,7 @@ program `dired-chmod-program', which must exist."
261 map)) 206 map))
262 207
263(defvar wdired-mode-hook nil 208(defvar wdired-mode-hook nil
264 "Hook run when changing to wdired mode.") 209 "Hooks run when changing to WDired mode.")
265 210
266;; Local variables (put here to avoid compilation gripes) 211;; Local variables (put here to avoid compilation gripes)
267(defvar wdired-col-perm) ;; Column where the permission bits start 212(defvar wdired-col-perm) ;; Column where the permission bits start
@@ -271,15 +216,15 @@ program `dired-chmod-program', which must exist."
271(defun wdired-mode () 216(defun wdired-mode ()
272 "\\<wdired-mode-map>File Names Editing mode. 217 "\\<wdired-mode-map>File Names Editing mode.
273 218
274Press \\[wdired-finish-edit] to make the changes to take effect and 219Press \\[wdired-finish-edit] to make the changes to take effect
275exit. To abort the edit, use \\[wdired-abort-changes]. 220and exit. To abort the edit, use \\[wdired-abort-changes].
276 221
277In this mode you can edit the names of the files, the target of the 222In this mode you can edit the names of the files, the target of
278links and the permission bits of the files. You can `customize-group' 223the links and the permission bits of the files. You can use
279wdired. 224\\[customize-group] RET wdired to customize WDired behavior.
280 225
281Editing things out of the filenames, or adding or deleting lines is 226The only editable texts in a WDired buffer are filenames,
282not allowed, because the rest of the buffer is read-only." 227symbolic link targets, and filenames permission."
283 (interactive) 228 (interactive)
284 (error "This mode can be enabled only by `wdired-change-to-wdired-mode'")) 229 (error "This mode can be enabled only by `wdired-change-to-wdired-mode'"))
285(put 'wdired-mode 'mode-class 'special) 230(put 'wdired-mode 'mode-class 'special)
@@ -288,8 +233,10 @@ not allowed, because the rest of the buffer is read-only."
288;;;###autoload 233;;;###autoload
289(defun wdired-change-to-wdired-mode () 234(defun wdired-change-to-wdired-mode ()
290 "Put a dired buffer in a mode in which filenames are editable. 235 "Put a dired buffer in a mode in which filenames are editable.
291In this mode the names of the files can be changed, and after 236\\<wdired-mode-map>
292typing C-c C-c the files and directories in disk are renamed. 237This mode allows the user to change the names of the files, and after
238typing \\[wdired-finish-edit] Emacs renames the files and directories
239in disk.
293 240
294See `wdired-mode'." 241See `wdired-mode'."
295 (interactive) 242 (interactive)
@@ -302,7 +249,7 @@ See `wdired-mode'."
302 (dired-unadvertise default-directory) 249 (dired-unadvertise default-directory)
303 (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t) 250 (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t)
304 (setq major-mode 'wdired-mode) 251 (setq major-mode 'wdired-mode)
305 (setq mode-name "Edit filenames") 252 (setq mode-name "Editable Dired")
306 (setq revert-buffer-function 'wdired-revert) 253 (setq revert-buffer-function 'wdired-revert)
307 ;; I temp disable undo for performance: since I'm going to clear the 254 ;; I temp disable undo for performance: since I'm going to clear the
308 ;; undo list, it can save more than a 9% of time with big 255 ;; undo list, it can save more than a 9% of time with big
@@ -359,7 +306,7 @@ or \\[wdired-abort-changes] to abort changes")))
359(defun wdired-get-filename (&optional no-dir old) 306(defun wdired-get-filename (&optional no-dir old)
360 "Return the filename at line. 307 "Return the filename at line.
361Similar to `dired-get-filename' but it doesn't rely on regexps. It 308Similar to `dired-get-filename' but it doesn't rely on regexps. It
362relies on wdired buffer's properties. Optional arg NO-DIR with value 309relies on WDired buffer's properties. Optional arg NO-DIR with value
363non-nil means don't include directory. Optional arg OLD with value 310non-nil means don't include directory. Optional arg OLD with value
364non-nil means return old filename." 311non-nil means return old filename."
365 ;; FIXME: Use dired-get-filename's new properties. 312 ;; FIXME: Use dired-get-filename's new properties.
@@ -411,7 +358,7 @@ non-nil means return old filename."
411 "Actually rename files based on your editing in the Dired buffer." 358 "Actually rename files based on your editing in the Dired buffer."
412 (interactive) 359 (interactive)
413 (wdired-change-to-dired-mode) 360 (wdired-change-to-dired-mode)
414 (let ((overwrite (or wdired-is-ok-overwrite 1)) 361 (let ((overwrite (or (not wdired-confirm-overwrite) 1))
415 (changes nil) 362 (changes nil)
416 (files-deleted nil) 363 (files-deleted nil)
417 (errors 0) 364 (errors 0)
@@ -510,12 +457,13 @@ non-nil means return old filename."
510 (forward-line))))) 457 (forward-line)))))
511 458
512(defun wdired-customize () 459(defun wdired-customize ()
513 "Customize wdired options." 460 "Customize WDired options."
514 (interactive) 461 (interactive)
515 (customize-apropos "wdired" 'groups)) 462 (customize-apropos "wdired" 'groups))
516 463
517(defun wdired-revert (&optional arg noconfirm) 464(defun wdired-revert (&optional arg noconfirm)
518 "Discard changes in the buffer and update the changes in the disk." 465 "Discard changes in the buffer and update it based on changes on disk.
466Optional arguments are ignored."
519 (wdired-change-to-dired-mode) 467 (wdired-change-to-dired-mode)
520 (revert-buffer) 468 (revert-buffer)
521 (wdired-change-to-wdired-mode)) 469 (wdired-change-to-wdired-mode))
@@ -529,12 +477,12 @@ non-nil means return old filename."
529 477
530(defun wdired-next-line (arg) 478(defun wdired-next-line (arg)
531 "Move down lines then position at filename or the current column. 479 "Move down lines then position at filename or the current column.
532See `wdired-always-move-to-filename-beginning'. Optional prefix ARG 480See `wdired-use-dired-vertical-movement'. Optional prefix ARG
533says how many lines to move; default is one line." 481says how many lines to move; default is one line."
534 (interactive "p") 482 (interactive "p")
535 (next-line arg) 483 (next-line arg)
536 (if (or (eq wdired-always-move-to-filename-beginning t) 484 (if (or (eq wdired-use-dired-vertical-movement t)
537 (and wdired-always-move-to-filename-beginning 485 (and wdired-use-dired-vertical-movement
538 (< (current-column) 486 (< (current-column)
539 (save-excursion (dired-move-to-filename) 487 (save-excursion (dired-move-to-filename)
540 (current-column))))) 488 (current-column)))))
@@ -542,22 +490,17 @@ says how many lines to move; default is one line."
542 490
543(defun wdired-previous-line (arg) 491(defun wdired-previous-line (arg)
544 "Move up lines then position at filename or the current column. 492 "Move up lines then position at filename or the current column.
545See `wdired-always-move-to-filename-beginning'. Optional prefix ARG 493See `wdired-use-dired-vertical-movement'. Optional prefix ARG
546says how many lines to move; default is one line." 494says how many lines to move; default is one line."
547 (interactive "p") 495 (interactive "p")
548 (previous-line arg) 496 (previous-line arg)
549 (if (or (eq wdired-always-move-to-filename-beginning t) 497 (if (or (eq wdired-use-dired-vertical-movement t)
550 (and wdired-always-move-to-filename-beginning 498 (and wdired-use-dired-vertical-movement
551 (< (current-column) 499 (< (current-column)
552 (save-excursion (dired-move-to-filename) 500 (save-excursion (dired-move-to-filename)
553 (current-column))))) 501 (current-column)))))
554 (dired-move-to-filename))) 502 (dired-move-to-filename)))
555 503
556;; dired doesn't works well with newlines, so ...
557(defun wdired-newline ()
558 "Do nothing."
559 (interactive))
560
561;; Put the needed properties to allow the user to change links' targets 504;; Put the needed properties to allow the user to change links' targets
562(defun wdired-preprocess-symlinks () 505(defun wdired-preprocess-symlinks ()
563 (let ((inhibit-read-only t)) 506 (let ((inhibit-read-only t))
@@ -634,19 +577,19 @@ If OLD, return the old target. If MOVE, move point before it."
634 (setq arg 0)))))))) 577 (setq arg 0))))))))
635 578
636(defun wdired-downcase-word (arg) 579(defun wdired-downcase-word (arg)
637 "Wdired version of `downcase-word'. 580 "WDired version of `downcase-word'.
638Like original function but it skips read-only words." 581Like original function but it skips read-only words."
639 (interactive "p") 582 (interactive "p")
640 (wdired-xcase-word 'downcase-word arg)) 583 (wdired-xcase-word 'downcase-word arg))
641 584
642(defun wdired-upcase-word (arg) 585(defun wdired-upcase-word (arg)
643 "Wdired version of `upcase-word'. 586 "WDired version of `upcase-word'.
644Like original function but it skips read-only words." 587Like original function but it skips read-only words."
645 (interactive "p") 588 (interactive "p")
646 (wdired-xcase-word 'upcase-word arg)) 589 (wdired-xcase-word 'upcase-word arg))
647 590
648(defun wdired-capitalize-word (arg) 591(defun wdired-capitalize-word (arg)
649 "Wdired version of `capitalize-word'. 592 "WDired version of `capitalize-word'.
650Like original function but it skips read-only words." 593Like original function but it skips read-only words."
651 (interactive "p") 594 (interactive "p")
652 (wdired-xcase-word 'capitalize-word arg)) 595 (wdired-xcase-word 'capitalize-word arg))