Mercurial > emacs
annotate lisp/wdired.el @ 68100:e5611feba7f7
* gtkutil.c (xg_toggle_notify_cb): New function.
(xg_toggle_visibility_cb): Move setting of x_gtk_show_hidden_files to
xg_toggle_notify_cb.
(xg_get_file_with_chooser): Add callback to xg_toggle_notify_cb when
parameter value changes so the toggle button gets updated.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Mon, 09 Jan 2006 19:03:20 +0000 |
parents | 827930ad591b |
children | 3a7458f9152d |
rev | line source |
---|---|
55098 | 1 ;;; wdired.el --- Rename files editing their names in dired buffers |
2 | |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
55098 | 4 |
5 ;; Filename: wdired.el | |
61350
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
6 ;; Author: Juan León Lahoz García <juanleon1@gmail.com> |
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
7 ;; Version: 2.0 |
55098 | 8 ;; Keywords: dired, environment, files, renaming |
9 | |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or | |
13 ;; modify it under the terms of the GNU General Public License as | |
14 ;; published by the Free Software Foundation; either version 2, or (at | |
15 ;; your option) any later version. | |
16 | |
17 ;; This program is distributed in the hope that it will be useful, but | |
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 ;; General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
55098 | 26 |
27 ;;; Commentary: | |
28 | |
29 ;; wdired.el (the "w" is for writable) provides an alternative way of | |
30 ;; renaming files. | |
31 ;; | |
32 ;; Have you ever wished to use C-x r t (string-rectangle), M-% | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
33 ;; (query-replace), M-c (capitalize-word), etc. to change the name of |
61473 | 34 ;; the files in a "dired" buffer? Now you can do this. All the power |
35 ;; of Emacs commands are available to renaming files! | |
55098 | 36 ;; |
37 ;; This package provides a function that makes the filenames of a a | |
38 ;; dired buffer editable, by changing the buffer mode (which inhibits | |
39 ;; all of the commands of dired mode). Here you can edit the names of | |
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. | |
42 ;; | |
61473 | 43 ;; Another things you can do with WDired: |
55098 | 44 ;; |
45 ;; - To move files to another directory (by typing their path, | |
46 ;; absolute or relative, as a part of the new filename). | |
47 ;; | |
48 ;; - To change the target of symbolic links. | |
49 ;; | |
50 ;; - To change the permission bits of the filenames (in systems with a | |
51 ;; working unix-alike `dired-chmod-program'). See and customize the | |
61473 | 52 ;; variable `wdired-allow-to-change-permissions'. To change a single |
55098 | 53 ;; char (toggling between its two more usual values) you can press |
61473 | 54 ;; the space bar over it or left-click the mouse. To set any char to |
55098 | 55 ;; an specific value (this includes the SUID, SGID and STI bits) you |
61473 | 56 ;; can use the key labeled as the letter you want. Please note that |
55098 | 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 | |
59 ;; WYSIWYG :-). | |
60 ;; | |
61 ;; - To mark files for deletion, by deleting their whole filename. | |
62 | |
63 ;;; Installation: | |
64 | |
65 ;; Add this file (byte-compiling it is recommended) to your load-path. | |
66 ;; Then add one of these set of lines (or similar ones) to your config: | |
67 ;; | |
68 ;; This is the easy way: | |
69 ;; | |
70 ;; (require 'wdired) | |
71 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) | |
72 ;; | |
61473 | 73 ;; This is the recommended way for faster Emacs startup time and lower |
74 ;; memory consumption: | |
55098 | 75 ;; |
76 ;; (autoload 'wdired-change-to-wdired-mode "wdired") | |
61473 | 77 ;; (eval-after-load "dired" |
55098 | 78 ;; '(lambda () |
79 ;; (define-key dired-mode-map "r" 'wdired-change-to-wdired-mode) | |
80 ;; (define-key dired-mode-map | |
81 ;; [menu-bar immediate wdired-change-to-wdired-mode] | |
82 ;; '("Edit File Names" . wdired-change-to-wdired-mode)))) | |
83 ;; | |
61473 | 84 ;; Type "M-x customize-group RET wdired" if you want to make changes |
85 ;; to the default behavior. | |
55098 | 86 |
87 ;;; Usage: | |
88 | |
89 ;; Then, you can start editing the names of the files by typing "r" | |
90 ;; (or whatever key you choose, or M-x wdired-change-to-wdired-mode). | |
91 ;; Use C-c C-c when finished or C-c C-k to abort. You can use also the | |
92 ;; menu options: in dired mode, "Edit File Names" under "Immediate". | |
93 ;; While editing the names, a new submenu "WDired" is available at top | |
94 ;; level. You can customize the behavior of this package from this | |
95 ;; menu. | |
96 | |
97 ;;; Change Log: | |
98 | |
61473 | 99 ;; Google is your friend (previous versions with complete changelogs |
100 ;; were posted to gnu.emacs.sources) | |
55098 | 101 |
102 ;;; Code: | |
103 | |
61473 | 104 (defvar dired-backup-overwrite) ; Only in Emacs 20.x this is a custom var |
55098 | 105 (eval-when-compile |
106 (set (make-local-variable 'byte-compile-dynamic) t)) | |
107 | |
108 (eval-and-compile | |
109 (require 'dired) | |
110 (autoload 'dired-do-create-files-regexp "dired-aux") | |
111 (autoload 'dired-call-process "dired-aux")) | |
112 | |
113 (defgroup wdired nil | |
114 "Mode to rename files by editing their names in dired buffers." | |
115 :group 'dired) | |
116 | |
117 (defcustom wdired-use-interactive-rename nil | |
61473 | 118 "*If non-nil, WDired requires confirmation before actually renaming files. |
119 If nil, WDired doesn't require confirmation to change the file names, | |
120 and the variable `wdired-confirm-overwrite' controls whether it is ok | |
121 to overwrite files without asking." | |
55098 | 122 :type 'boolean |
123 :group 'wdired) | |
124 | |
61473 | 125 (defcustom wdired-confirm-overwrite t |
126 "*If nil the renames can overwrite files without asking. | |
127 This variable has no effect at all if `wdired-use-interactive-rename' | |
128 is not nil." | |
55098 | 129 :type 'boolean |
130 :group 'wdired) | |
131 | |
61473 | 132 (defcustom wdired-use-dired-vertical-movement nil |
133 "*If t, the \"up\" and \"down\" movement works as in Dired mode. | |
55098 | 134 That is, always move the point to the beginning of the filename at line. |
135 | |
136 If `sometimes, only move to the beginning of filename if the point is | |
137 before it, and `track-eol' is honored. This behavior is very handy | |
138 when editing several filenames. | |
139 | |
140 If nil, \"up\" and \"down\" movement is done as in any other buffer." | |
141 :type '(choice (const :tag "As in any other mode" nil) | |
142 (const :tag "Smart cursor placement" sometimes) | |
143 (other :tag "As in dired mode" t)) | |
144 :group 'wdired) | |
145 | |
146 (defcustom wdired-allow-to-redirect-links t | |
61473 | 147 "*If non-nil, the target of the symbolic links are editable. |
55098 | 148 In systems without symbolic links support, this variable has no effect |
149 at all." | |
150 :type 'boolean | |
151 :group 'wdired) | |
152 | |
153 (defcustom wdired-allow-to-change-permissions nil | |
61473 | 154 "*If non-nil, the permissions bits of the files are editable. |
55098 | 155 |
156 If t, to change a single bit, put the cursor over it and press the | |
157 space bar, or left click over it. You can also hit the letter you want | |
158 to set: if this value is allowed, the character in the buffer will be | |
159 changed. Anyway, the point is advanced one position, so, for example, | |
61473 | 160 you can keep the <x> key pressed to give execution permissions to |
55098 | 161 everybody to that file. |
162 | |
163 If `advanced, the bits are freely editable. You can use | |
164 `string-rectangle', `query-replace', etc. You can put any value (even | |
165 newlines), but if you want your changes to be useful, you better put a | |
166 intelligible value. | |
167 | |
61473 | 168 Anyway, the real change of the permissions is done by the external |
55098 | 169 program `dired-chmod-program', which must exist." |
170 :type '(choice (const :tag "Not allowed" nil) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
171 (const :tag "Toggle/set bits" t) |
55098 | 172 (other :tag "Bits freely editable" advanced)) |
173 :group 'wdired) | |
174 | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
175 (defvar wdired-mode-map |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
176 (let ((map (make-sparse-keymap))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
177 (define-key map "\C-x\C-s" 'wdired-finish-edit) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
178 (define-key map "\C-c\C-c" 'wdired-finish-edit) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
179 (define-key map "\C-c\C-k" 'wdired-abort-changes) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
180 (define-key map "\C-c\C-[" 'wdired-abort-changes) |
61473 | 181 (define-key map "\C-m" 'ignore) |
182 (define-key map "\C-j" 'ignore) | |
183 (define-key map "\C-o" 'ignore) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
184 (define-key map [up] 'wdired-previous-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
185 (define-key map "\C-p" 'wdired-previous-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
186 (define-key map [down] 'wdired-next-line) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
187 (define-key map "\C-n" 'wdired-next-line) |
55098 | 188 |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
189 (define-key map [menu-bar wdired] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
190 (cons "WDired" (make-sparse-keymap "WDired"))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
191 (define-key map [menu-bar wdired wdired-customize] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
192 '("Options" . wdired-customize)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
193 (define-key map [menu-bar wdired dashes] |
55098 | 194 '("--")) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
195 (define-key map [menu-bar wdired wdired-abort-changes] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
196 '("Abort Changes" . wdired-abort-changes)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
197 (define-key map [menu-bar wdired wdired-finish-edit] |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
198 '("Commit Changes" . wdired-finish-edit)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
199 ;; FIXME: Use the new remap trick. |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
200 (substitute-key-definition 'upcase-word 'wdired-upcase-word |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
201 map global-map) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
202 (substitute-key-definition 'capitalize-word 'wdired-capitalize-word |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
203 map global-map) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
204 (substitute-key-definition 'downcase-word 'wdired-downcase-word |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
205 map global-map) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
206 map)) |
55098 | 207 |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
208 (defvar wdired-mode-hook nil |
61473 | 209 "Hooks run when changing to WDired mode.") |
55098 | 210 |
211 ;; Local variables (put here to avoid compilation gripes) | |
212 (defvar wdired-col-perm) ;; Column where the permission bits start | |
213 (defvar wdired-old-content) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
214 (defvar wdired-old-point) |
55098 | 215 |
216 | |
217 (defun wdired-mode () | |
218 "\\<wdired-mode-map>File Names Editing mode. | |
219 | |
61473 | 220 Press \\[wdired-finish-edit] to make the changes to take effect |
221 and exit. To abort the edit, use \\[wdired-abort-changes]. | |
55098 | 222 |
61473 | 223 In this mode you can edit the names of the files, the target of |
224 the links and the permission bits of the files. You can use | |
225 \\[customize-group] RET wdired to customize WDired behavior. | |
55098 | 226 |
61473 | 227 The only editable texts in a WDired buffer are filenames, |
228 symbolic link targets, and filenames permission." | |
55098 | 229 (interactive) |
230 (error "This mode can be enabled only by `wdired-change-to-wdired-mode'")) | |
231 (put 'wdired-mode 'mode-class 'special) | |
232 | |
233 | |
234 ;;;###autoload | |
235 (defun wdired-change-to-wdired-mode () | |
236 "Put a dired buffer in a mode in which filenames are editable. | |
61473 | 237 \\<wdired-mode-map> |
238 This mode allows the user to change the names of the files, and after | |
239 typing \\[wdired-finish-edit] Emacs renames the files and directories | |
240 in disk. | |
55098 | 241 |
242 See `wdired-mode'." | |
243 (interactive) | |
244 (set (make-local-variable 'wdired-old-content) | |
245 (buffer-substring (point-min) (point-max))) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
246 (set (make-local-variable 'wdired-old-point) (point)) |
61350
796b7fe4bfd8
(wdired-advise-functions, wdired-add-skip-in-replace)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61030
diff
changeset
|
247 (set (make-local-variable 'query-replace-skip-read-only) t) |
55098 | 248 (use-local-map wdired-mode-map) |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
249 (force-mode-line-update) |
55098 | 250 (setq buffer-read-only nil) |
251 (dired-unadvertise default-directory) | |
252 (add-hook 'kill-buffer-hook 'wdired-check-kill-buffer nil t) | |
253 (setq major-mode 'wdired-mode) | |
61473 | 254 (setq mode-name "Editable Dired") |
55098 | 255 (setq revert-buffer-function 'wdired-revert) |
256 ;; I temp disable undo for performance: since I'm going to clear the | |
257 ;; undo list, it can save more than a 9% of time with big | |
258 ;; directories because setting properties modify the undo-list. | |
259 (buffer-disable-undo) | |
260 (wdired-preprocess-files) | |
261 (if wdired-allow-to-change-permissions | |
262 (wdired-preprocess-perms)) | |
263 (if (and wdired-allow-to-redirect-links (fboundp 'make-symbolic-link)) | |
264 (wdired-preprocess-symlinks)) | |
265 (buffer-enable-undo) ; Performance hack. See above. | |
266 (set-buffer-modified-p nil) | |
267 (setq buffer-undo-list nil) | |
62746
0fe5c8d2cd65
(wdired-change-to-wdired-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
61473
diff
changeset
|
268 (run-mode-hooks 'wdired-mode-hook) |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
269 (message "%s" (substitute-command-keys |
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
270 "Press \\[wdired-finish-edit] when finished \ |
61030
6b0506554db8
(wdired-change-to-wdired-mode):
Juri Linkov <juri@jurta.org>
parents:
60141
diff
changeset
|
271 or \\[wdired-abort-changes] to abort changes"))) |
55098 | 272 |
273 | |
274 ;; Protect the buffer so only the filenames can be changed, and put | |
275 ;; properties so filenames (old and new) can be easily found. | |
276 (defun wdired-preprocess-files () | |
277 (put-text-property 1 2 'front-sticky t) | |
278 (save-excursion | |
279 (goto-char (point-min)) | |
280 (let ((b-protection (point)) | |
281 filename) | |
282 (while (not (eobp)) | |
283 (setq filename (dired-get-filename nil t)) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
284 (when (and filename |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
285 (not (member (file-name-nondirectory filename) '("." "..")))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
286 (dired-move-to-filename) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
287 (put-text-property (- (point) 2) (1- (point)) 'old-name filename) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
288 (put-text-property b-protection (1- (point)) 'read-only t) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
289 (setq b-protection (dired-move-to-end-of-filename t))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
290 (put-text-property (point) (1+ (point)) 'end-name t) |
55098 | 291 (forward-line)) |
292 (put-text-property b-protection (point-max) 'read-only t)))) | |
293 | |
294 ;; This code is a copy of some dired-get-filename lines. | |
295 (defsubst wdired-normalize-filename (file) | |
296 (setq file | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
297 ;; FIXME: shouldn't we check for a `b' argument or somesuch before |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
298 ;; doing such unquoting? --Stef |
55098 | 299 (read (concat |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
300 "\"" (replace-regexp-in-string |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
301 "\\([^\\]\\|\\`\\)\"" "\\1\\\\\"" file) |
55098 | 302 "\""))) |
303 (and file buffer-file-coding-system | |
304 (not file-name-coding-system) | |
305 (not default-file-name-coding-system) | |
306 (setq file (encode-coding-string file buffer-file-coding-system))) | |
307 file) | |
308 | |
309 (defun wdired-get-filename (&optional no-dir old) | |
310 "Return the filename at line. | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
311 Similar to `dired-get-filename' but it doesn't rely on regexps. It |
61473 | 312 relies on WDired buffer's properties. Optional arg NO-DIR with value |
55098 | 313 non-nil means don't include directory. Optional arg OLD with value |
314 non-nil means return old filename." | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
315 ;; FIXME: Use dired-get-filename's new properties. |
55098 | 316 (let (beg end file) |
317 (save-excursion | |
318 (setq end (progn (end-of-line) (point))) | |
319 (beginning-of-line) | |
320 (setq beg (next-single-property-change (point) 'old-name nil end)) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
321 (unless (eq beg end) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
322 (if old |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
323 (setq file (get-text-property beg 'old-name)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
324 (setq end (next-single-property-change (1+ beg) 'end-name)) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
325 (setq file (buffer-substring-no-properties (+ 2 beg) end))) |
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
326 (and file (setq file (wdired-normalize-filename file)))) |
55098 | 327 (if (or no-dir old) |
328 file | |
329 (and file (> (length file) 0) | |
330 (concat (dired-current-directory) file)))))) | |
331 | |
332 | |
333 (defun wdired-change-to-dired-mode () | |
334 "Change the mode back to dired." | |
335 (let ((inhibit-read-only t)) | |
336 (remove-text-properties (point-min) (point-max) | |
337 '(read-only nil local-map nil))) | |
338 (put-text-property 1 2 'front-sticky nil) | |
339 (use-local-map dired-mode-map) | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
340 (force-mode-line-update) |
55098 | 341 (setq buffer-read-only t) |
342 (setq major-mode 'dired-mode) | |
343 (setq mode-name "Dired") | |
344 (dired-advertise) | |
345 (remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t) | |
346 (setq revert-buffer-function 'dired-revert)) | |
347 | |
348 | |
349 (defun wdired-abort-changes () | |
350 "Abort changes and return to dired mode." | |
351 (interactive) | |
352 (let ((inhibit-read-only t)) | |
353 (erase-buffer) | |
67561
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
354 (insert wdired-old-content) |
827930ad591b
(wdired-old-point): New internal variable.
Juri Linkov <juri@jurta.org>
parents:
65582
diff
changeset
|
355 (goto-char wdired-old-point)) |
55098 | 356 (wdired-change-to-dired-mode) |
357 (set-buffer-modified-p nil) | |
55371
a96e9558b1ea
(wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents:
55109
diff
changeset
|
358 (setq buffer-undo-list nil) |
a96e9558b1ea
(wdired-change-to-wdired-mode): Quote wdired-mode-hook in run-hooks.
Lars Hansen <larsh@soem.dk>
parents:
55109
diff
changeset
|
359 (message "Changes aborted")) |
55098 | 360 |
361 (defun wdired-finish-edit () | |
362 "Actually rename files based on your editing in the Dired buffer." | |
363 (interactive) | |
364 (wdired-change-to-dired-mode) | |
61473 | 365 (let ((overwrite (or (not wdired-confirm-overwrite) 1)) |
55098 | 366 (changes nil) |
367 (files-deleted nil) | |
368 (errors 0) | |
369 file-ori file-new tmp-value) | |
370 (save-excursion | |
371 (if (and wdired-allow-to-redirect-links | |
372 (fboundp 'make-symbolic-link)) | |
373 (progn | |
374 (setq tmp-value (wdired-do-symlink-changes)) | |
375 (setq errors (cdr tmp-value)) | |
376 (setq changes (car tmp-value)))) | |
377 (if (and wdired-allow-to-change-permissions | |
378 (boundp 'wdired-col-perm)) ; could have been changed | |
379 (progn | |
380 (setq tmp-value (wdired-do-perm-changes)) | |
381 (setq errors (+ errors (cdr tmp-value))) | |
382 (setq changes (or changes (car tmp-value))))) | |
383 (goto-char (point-max)) | |
384 (while (not (bobp)) | |
385 (setq file-ori (wdired-get-filename nil t)) | |
386 (if file-ori | |
387 (setq file-new (wdired-get-filename))) | |
388 (if (and file-ori (not (equal file-new file-ori))) | |
389 (progn | |
390 (setq changes t) | |
391 (if (not file-new) ;empty filename! | |
392 (setq files-deleted (cons file-ori files-deleted)) | |
393 (progn | |
394 (setq file-new (substitute-in-file-name file-new)) | |
395 (if wdired-use-interactive-rename | |
396 (wdired-search-and-rename file-ori file-new) | |
56545
c3fa830eb56c
(wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents:
55371
diff
changeset
|
397 ;; If dired-rename-file autoloads dired-aux while |
c3fa830eb56c
(wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents:
55371
diff
changeset
|
398 ;; dired-backup-overwrite is locally bound, |
c3fa830eb56c
(wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents:
55371
diff
changeset
|
399 ;; dired-backup-overwrite won't be initialized. |
c3fa830eb56c
(wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents:
55371
diff
changeset
|
400 ;; So we must ensure dired-aux is loaded. |
c3fa830eb56c
(wdired-finish-edit): Require dired-aux before locally binding dired-backup-overwrite.
Lars Hansen <larsh@soem.dk>
parents:
55371
diff
changeset
|
401 (require 'dired-aux) |
55098 | 402 (condition-case err |
403 (let ((dired-backup-overwrite nil)) | |
404 (dired-rename-file file-ori file-new | |
405 overwrite)) | |
406 (error | |
407 (setq errors (1+ errors)) | |
408 (dired-log (concat "Rename `" file-ori "' to `" | |
409 file-new "' failed:\n%s\n") | |
410 err)))))))) | |
411 (forward-line -1))) | |
412 (if changes | |
413 (revert-buffer) ;The "revert" is necessary to re-sort the buffer | |
414 (let ((buffer-read-only nil)) | |
415 (remove-text-properties (point-min) (point-max) | |
416 '(old-name nil end-name nil old-link nil | |
417 end-link nil end-perm nil | |
418 old-perm nil perm-changed nil)) | |
419 (message "(No changes to be performed)"))) | |
420 (if files-deleted | |
421 (wdired-flag-for-deletion files-deleted)) | |
422 (if (> errors 0) | |
423 (dired-log-summary (format "%d rename actions failed" errors) nil))) | |
424 (set-buffer-modified-p nil) | |
425 (setq buffer-undo-list nil)) | |
426 | |
427 ;; Renames a file, searching it in a modified dired buffer, in order | |
428 ;; to be able to use `dired-do-create-files-regexp' and get its | |
429 ;; "benefits" | |
430 (defun wdired-search-and-rename (filename-ori filename-new) | |
431 (save-excursion | |
432 (goto-char (point-max)) | |
433 (forward-line -1) | |
434 (let ((exit-while nil) | |
435 curr-filename) | |
436 (while (not exit-while) | |
437 (setq curr-filename (wdired-get-filename)) | |
438 (if (and curr-filename | |
439 (equal (substitute-in-file-name curr-filename) filename-new)) | |
440 (progn | |
441 (setq exit-while t) | |
442 (let ((inhibit-read-only t)) | |
443 (dired-move-to-filename) | |
444 (search-forward (wdired-get-filename t) nil t) | |
445 (replace-match (file-name-nondirectory filename-ori) t t)) | |
446 (dired-do-create-files-regexp | |
447 (function dired-rename-file) | |
448 "Move" 1 ".*" filename-new nil t)) | |
449 (progn | |
450 (forward-line -1) | |
451 (beginning-of-line) | |
452 (setq exit-while (= 1 (point))))))))) | |
453 | |
454 ;; marks a list of files for deletion | |
455 (defun wdired-flag-for-deletion (filenames-ori) | |
456 (save-excursion | |
457 (goto-char (point-min)) | |
458 (while (not (eobp)) | |
459 (if (member (dired-get-filename nil t) filenames-ori) | |
460 (dired-flag-file-deletion 1) | |
461 (forward-line))))) | |
462 | |
463 (defun wdired-customize () | |
61473 | 464 "Customize WDired options." |
55098 | 465 (interactive) |
466 (customize-apropos "wdired" 'groups)) | |
467 | |
468 (defun wdired-revert (&optional arg noconfirm) | |
61473 | 469 "Discard changes in the buffer and update it based on changes on disk. |
470 Optional arguments are ignored." | |
55098 | 471 (wdired-change-to-dired-mode) |
472 (revert-buffer) | |
473 (wdired-change-to-wdired-mode)) | |
474 | |
475 (defun wdired-check-kill-buffer () | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
476 ;; FIXME: Can't we use the normal mechanism for that? --Stef |
55098 | 477 (if (and |
478 (buffer-modified-p) | |
479 (not (y-or-n-p "Buffer changed. Discard changes and kill buffer? "))) | |
480 (error nil))) | |
481 | |
482 (defun wdired-next-line (arg) | |
483 "Move down lines then position at filename or the current column. | |
61473 | 484 See `wdired-use-dired-vertical-movement'. Optional prefix ARG |
55098 | 485 says how many lines to move; default is one line." |
486 (interactive "p") | |
487 (next-line arg) | |
61473 | 488 (if (or (eq wdired-use-dired-vertical-movement t) |
489 (and wdired-use-dired-vertical-movement | |
55098 | 490 (< (current-column) |
491 (save-excursion (dired-move-to-filename) | |
492 (current-column))))) | |
493 (dired-move-to-filename))) | |
494 | |
495 (defun wdired-previous-line (arg) | |
496 "Move up lines then position at filename or the current column. | |
61473 | 497 See `wdired-use-dired-vertical-movement'. Optional prefix ARG |
55098 | 498 says how many lines to move; default is one line." |
499 (interactive "p") | |
500 (previous-line arg) | |
61473 | 501 (if (or (eq wdired-use-dired-vertical-movement t) |
502 (and wdired-use-dired-vertical-movement | |
55098 | 503 (< (current-column) |
504 (save-excursion (dired-move-to-filename) | |
505 (current-column))))) | |
506 (dired-move-to-filename))) | |
507 | |
508 ;; Put the needed properties to allow the user to change links' targets | |
509 (defun wdired-preprocess-symlinks () | |
510 (let ((inhibit-read-only t)) | |
511 (save-excursion | |
512 (goto-char (point-min)) | |
513 (while (not (eobp)) | |
514 (if (looking-at dired-re-sym) | |
515 (progn | |
516 (re-search-forward " -> \\(.*\\)$") | |
517 (put-text-property (- (match-beginning 1) 2) | |
518 (1- (match-beginning 1)) 'old-link | |
519 (match-string-no-properties 1)) | |
520 (put-text-property (match-end 1) (1+ (match-end 1)) 'end-link t) | |
521 (put-text-property (1- (match-beginning 1)) | |
522 (match-end 1) 'read-only nil))) | |
523 (forward-line) | |
524 (beginning-of-line))))) | |
525 | |
526 | |
527 (defun wdired-get-previous-link (&optional old move) | |
528 "Return the next symlink target. | |
529 If OLD, return the old target. If MOVE, move point before it." | |
530 (let (beg end target) | |
531 (setq beg (previous-single-property-change (point) 'old-link nil)) | |
532 (if beg | |
533 (progn | |
534 (if old | |
535 (setq target (get-text-property (1- beg) 'old-link)) | |
536 (setq end (next-single-property-change beg 'end-link)) | |
537 (setq target (buffer-substring-no-properties (1+ beg) end))) | |
538 (if move (goto-char (1- beg))))) | |
539 (and target (wdired-normalize-filename target)))) | |
540 | |
541 | |
542 | |
543 ;; Perform the changes in the target of the changed links. | |
544 (defun wdired-do-symlink-changes() | |
545 (let ((changes nil) | |
546 (errors 0) | |
547 link-to-ori link-to-new link-from) | |
548 (goto-char (point-max)) | |
549 (while (setq link-to-new (wdired-get-previous-link)) | |
550 (setq link-to-ori (wdired-get-previous-link t t)) | |
551 (setq link-from (wdired-get-filename nil t)) | |
552 (if (not (equal link-to-new link-to-ori)) | |
553 (progn | |
554 (setq changes t) | |
555 (if (equal link-to-new "") ;empty filename! | |
556 (setq link-to-new "/dev/null")) | |
557 (condition-case err | |
558 (progn | |
559 (delete-file link-from) | |
560 (make-symbolic-link | |
561 (substitute-in-file-name link-to-new) link-from)) | |
562 (error | |
563 (setq errors (1+ errors)) | |
564 (dired-log (concat "Link `" link-from "' to `" | |
565 link-to-new "' failed:\n%s\n") | |
566 err)))))) | |
567 (cons changes errors))) | |
568 | |
569 ;; Perform a "case command" skipping read-only words. | |
570 (defun wdired-xcase-word (command arg) | |
571 (if (< arg 0) | |
572 (funcall command arg) | |
573 (progn | |
574 (while (> arg 0) | |
575 (condition-case err | |
576 (progn | |
577 (funcall command 1) | |
578 (setq arg (1- arg))) | |
579 (error | |
580 (if (not (forward-word 1)) | |
581 (setq arg 0)))))))) | |
582 | |
583 (defun wdired-downcase-word (arg) | |
61473 | 584 "WDired version of `downcase-word'. |
55098 | 585 Like original function but it skips read-only words." |
586 (interactive "p") | |
587 (wdired-xcase-word 'downcase-word arg)) | |
588 | |
589 (defun wdired-upcase-word (arg) | |
61473 | 590 "WDired version of `upcase-word'. |
55098 | 591 Like original function but it skips read-only words." |
592 (interactive "p") | |
593 (wdired-xcase-word 'upcase-word arg)) | |
594 | |
595 (defun wdired-capitalize-word (arg) | |
61473 | 596 "WDired version of `capitalize-word'. |
55098 | 597 Like original function but it skips read-only words." |
598 (interactive "p") | |
599 (wdired-xcase-word 'capitalize-word arg)) | |
600 | |
601 | |
602 ;; The following code deals with changing the access bits (or | |
603 ;; permissions) of the files. | |
604 | |
605 (defvar wdired-perm-mode-map nil) | |
606 (unless wdired-perm-mode-map | |
607 (setq wdired-perm-mode-map (copy-keymap wdired-mode-map)) | |
608 (define-key wdired-perm-mode-map " " 'wdired-toggle-bit) | |
609 (define-key wdired-perm-mode-map "r" 'wdired-set-bit) | |
610 (define-key wdired-perm-mode-map "w" 'wdired-set-bit) | |
611 (define-key wdired-perm-mode-map "x" 'wdired-set-bit) | |
612 (define-key wdired-perm-mode-map "-" 'wdired-set-bit) | |
613 (define-key wdired-perm-mode-map "S" 'wdired-set-bit) | |
614 (define-key wdired-perm-mode-map "s" 'wdired-set-bit) | |
615 (define-key wdired-perm-mode-map "T" 'wdired-set-bit) | |
616 (define-key wdired-perm-mode-map "t" 'wdired-set-bit) | |
617 (define-key wdired-perm-mode-map "s" 'wdired-set-bit) | |
618 (define-key wdired-perm-mode-map "l" 'wdired-set-bit) | |
619 (define-key wdired-perm-mode-map [down-mouse-1] 'wdired-mouse-toggle-bit)) | |
620 | |
621 ;; Put a local-map to the permission bits of the files, and store the | |
622 ;; original name and permissions as a property | |
623 (defun wdired-preprocess-perms() | |
624 (let ((inhibit-read-only t) | |
625 filename) | |
626 (set (make-local-variable 'wdired-col-perm) nil) | |
627 (save-excursion | |
628 (goto-char (point-min)) | |
629 (while (not (eobp)) | |
630 (if (and (not (looking-at dired-re-sym)) | |
631 (setq filename (wdired-get-filename))) | |
632 (progn | |
633 (re-search-forward dired-re-perms) | |
634 (or wdired-col-perm | |
635 (setq wdired-col-perm (- (current-column) 9))) | |
636 (if (eq wdired-allow-to-change-permissions 'advanced) | |
637 (put-text-property (match-beginning 0) (match-end 0) | |
638 'read-only nil) | |
639 (put-text-property (1+ (match-beginning 0)) (match-end 0) | |
640 'local-map wdired-perm-mode-map)) | |
641 (put-text-property (match-end 0) (1+ (match-end 0)) 'end-perm t) | |
642 (put-text-property (match-beginning 0) (1+ (match-beginning 0)) | |
643 'old-perm (match-string-no-properties 0)))) | |
644 (forward-line) | |
645 (beginning-of-line))))) | |
646 | |
647 (defun wdired-perm-allowed-in-pos (char pos) | |
648 (cond | |
649 ((= char ?-) t) | |
650 ((= char ?r) (= (% pos 3) 0)) | |
651 ((= char ?w) (= (% pos 3) 1)) | |
652 ((= char ?x) (= (% pos 3) 2)) | |
653 ((memq char '(?s ?S)) (memq pos '(2 5))) | |
654 ((memq char '(?t ?T)) (= pos 8)) | |
655 ((= char ?l) (= pos 5)))) | |
656 | |
657 (defun wdired-set-bit () | |
658 "Set a permission bit character." | |
659 (interactive) | |
660 (if (wdired-perm-allowed-in-pos last-command-char | |
661 (- (current-column) wdired-col-perm)) | |
662 (let ((new-bit (char-to-string last-command-char)) | |
663 (inhibit-read-only t) | |
664 (pos-prop (- (point) (- (current-column) wdired-col-perm)))) | |
665 (put-text-property 0 1 'local-map wdired-perm-mode-map new-bit) | |
666 (put-text-property 0 1 'read-only t new-bit) | |
667 (insert new-bit) | |
668 (delete-char 1) | |
669 (put-text-property pos-prop (1- pos-prop) 'perm-changed t)) | |
670 (forward-char 1))) | |
671 | |
672 (defun wdired-toggle-bit() | |
673 "Toggle the permission bit at point." | |
674 (interactive) | |
675 (let ((inhibit-read-only t) | |
676 (new-bit "-") | |
677 (pos-prop (- (point) (- (current-column) wdired-col-perm)))) | |
678 (if (eq (char-after (point)) ?-) | |
679 (setq new-bit | |
680 (if (= (% (- (current-column) wdired-col-perm) 3) 0) "r" | |
681 (if (= (% (- (current-column) wdired-col-perm) 3) 1) "w" | |
682 "x")))) | |
683 (put-text-property 0 1 'local-map wdired-perm-mode-map new-bit) | |
684 (put-text-property 0 1 'read-only t new-bit) | |
685 (insert new-bit) | |
686 (delete-char 1) | |
687 (put-text-property pos-prop (1- pos-prop) 'perm-changed t))) | |
688 | |
689 (defun wdired-mouse-toggle-bit (event) | |
690 "Toggle the permission bit that was left clicked." | |
691 (interactive "e") | |
692 (mouse-set-point event) | |
693 (wdired-toggle-bit)) | |
694 | |
695 ;; Allowed chars for 4000 bit are Ss in position 3 | |
696 ;; Allowed chars for 2000 bit are Ssl in position 6 | |
697 ;; Allowed chars for 1000 bit are Tt in position 9 | |
698 (defun wdired-perms-to-number (perms) | |
699 (let ((nperm 0777)) | |
700 (if (= (elt perms 1) ?-) (setq nperm (- nperm 400))) | |
701 (if (= (elt perms 2) ?-) (setq nperm (- nperm 200))) | |
702 (let ((p-bit (elt perms 3))) | |
703 (if (memq p-bit '(?- ?S)) (setq nperm (- nperm 100))) | |
704 (if (memq p-bit '(?s ?S)) (setq nperm (+ nperm 4000)))) | |
705 (if (= (elt perms 4) ?-) (setq nperm (- nperm 40))) | |
706 (if (= (elt perms 5) ?-) (setq nperm (- nperm 20))) | |
707 (let ((p-bit (elt perms 6))) | |
708 (if (memq p-bit '(?- ?S ?l)) (setq nperm (- nperm 10))) | |
709 (if (memq p-bit '(?s ?S ?l)) (setq nperm (+ nperm 2000)))) | |
710 (if (= (elt perms 7) ?-) (setq nperm (- nperm 4))) | |
711 (if (= (elt perms 8) ?-) (setq nperm (- nperm 2))) | |
712 (let ((p-bit (elt perms 9))) | |
713 (if (memq p-bit '(?- ?T)) (setq nperm (- nperm 1))) | |
714 (if (memq p-bit '(?t ?T)) (setq nperm (+ nperm 1000)))) | |
715 nperm)) | |
716 | |
717 ;; Perform the changes in the permissions of the files that have | |
718 ;; changed. | |
719 (defun wdired-do-perm-changes () | |
720 (let ((changes nil) | |
721 (errors 0) | |
722 (prop-wanted (if (eq wdired-allow-to-change-permissions 'advanced) | |
723 'old-perm 'perm-changed)) | |
724 filename perms-ori perms-new perm-tmp) | |
725 (goto-char (next-single-property-change (point-min) prop-wanted | |
726 nil (point-max))) | |
727 (while (not (eobp)) | |
728 (setq perms-ori (get-text-property (point) 'old-perm)) | |
729 (setq perms-new (buffer-substring-no-properties | |
730 (point) (next-single-property-change (point) 'end-perm))) | |
731 (if (not (equal perms-ori perms-new)) | |
732 (progn | |
733 (setq changes t) | |
734 (setq filename (wdired-get-filename nil t)) | |
735 (if (= (length perms-new) 10) | |
736 (progn | |
737 (setq perm-tmp | |
738 (int-to-string (wdired-perms-to-number perms-new))) | |
739 (if (not (equal 0 (dired-call-process dired-chmod-program | |
740 t perm-tmp filename))) | |
741 (progn | |
742 (setq errors (1+ errors)) | |
743 (dired-log (concat dired-chmod-program " " perm-tmp | |
744 " `" filename "' failed\n\n"))))) | |
745 (setq errors (1+ errors)) | |
746 (dired-log (concat "Cannot parse permission `" perms-new | |
747 "' for file `" filename "'\n\n"))))) | |
748 (goto-char (next-single-property-change (1+ (point)) prop-wanted | |
749 nil (point-max)))) | |
750 (cons changes errors))) | |
751 | |
752 (provide 'wdired) | |
753 | |
55109
043dd9a4d1b4
(wdired-mode-map): Move init into declaration. Fix `return' binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55107
diff
changeset
|
754 ;; arch-tag: bc00902e-526f-4305-bc7f-8862a559184f |
55098 | 755 ;;; wdired.el ends here |