From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: wdired Date: Fri, 24 Feb 2006 17:43:50 +0100 Message-ID: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1140851236 776 80.91.229.2 (25 Feb 2006 07:07:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 25 Feb 2006 07:07:16 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Feb 25 08:07:13 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FCtW7-0002Eo-ML for ged-emacs-devel@m.gmane.org; Sat, 25 Feb 2006 08:07:00 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FCtW8-0007X2-Ob for ged-emacs-devel@m.gmane.org; Sat, 25 Feb 2006 02:07:00 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FCkHV-0005wP-Dg for emacs-devel@gnu.org; Fri, 24 Feb 2006 16:15:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FCj0n-0002Ay-Ob for emacs-devel@gnu.org; Fri, 24 Feb 2006 14:54:00 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FChLX-0002A2-1n for emacs-devel@gnu.org; Fri, 24 Feb 2006 13:07:15 -0500 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1FCg0D-0002Ni-78 for emacs-devel@gnu.org; Fri, 24 Feb 2006 11:41:09 -0500 Original-Received: (qmail invoked by alias); 24 Feb 2006 16:40:52 -0000 Original-Received: from N706P001.adsl.highway.telekom.at (EHLO V357900157) [62.47.32.33] by mail.gmx.net (mp011) with SMTP; 24 Feb 2006 17:40:52 +0100 X-Authenticated: #14592706 Original-To: emacs-devel@gnu.org X-Y-GMX-Trusted: 0 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:50937 Archived-At: Create a Dired buffer and do M-x wdired-change-to-wdired-mode RET: 1. Move point before the space preceding a filename and type C-d. If you now delete the remaining characters of the filename you can't use self-insertion any more to change the name of the file. If you delete all characters but the first and hit C-c C-c, the file will be marked for deletion. In any other case, `wdired-finish-edit' will try to rename the file with the first character omitted. Similar scenarios apply for removing spaces preceding symlinks and permission bits with `wdired-allow-to-change-permissions' set to `advanced'. 2. With `wdired-allow-to-change-permissions' t typing SPC to toggle the rightmost permission bit allows to overtype all following characters in the buffer. A similar effect can be obtained by typing "-" over the rightmost permission bit. The patch below attempts to correct this behavior and simplify the code. * wdired.el (wdired-change-to-wdired-mode, wdired-finish-edit, wdired-search-and-rename, wdired-do-symlink-changes, wdired-do-perm-changes): Simplify code. (wdired-preprocess-files, wdired-preprocess-symlinks, wdired-preprocess-perms): Make read-only property of preceding character rear-nonsticky to avoid that it can be modified. Put old-name and old-link properties on character preceding name and replace put-text-property by add-text-properties. (wdired-get-filename, wdired-get-previous-link): Get old-name and old-link properties from character preceding name and simplify code. (wdired-preprocess-perms, wdired-set-bit, wdired-toggle-bit): Make local-map property rear-nonsticky to avoid that text following permissions may be modified. Use add-text-properties instead of put-text-property when changing a permission bit. (wdired-change-to-dired-mode): Remove stickiness properties. ================================================================================ *** wdired.el Wed Feb 1 10:17:44 2006 --- wdired.el Fri Feb 24 17:15:30 2006 *************** *** 265,271 **** (wdired-preprocess-symlinks)) (buffer-enable-undo) ; Performance hack. See above. (set-buffer-modified-p nil) - (setq buffer-undo-list nil) (run-mode-hooks 'wdired-mode-hook) (message "%s" (substitute-command-keys "Press \\[wdired-finish-edit] when finished \ --- 265,270 ---- *************** *** 285,294 **** (when (and filename (not (member (file-name-nondirectory filename) '("." "..")))) (dired-move-to-filename) ! (put-text-property (- (point) 2) (1- (point)) 'old-name filename) ! (put-text-property b-protection (1- (point)) 'read-only t) ! (setq b-protection (dired-move-to-end-of-filename t))) ! (put-text-property (point) (1+ (point)) 'end-name t) (forward-line)) (put-text-property b-protection (point-max) 'read-only t)))) --- 284,297 ---- (when (and filename (not (member (file-name-nondirectory filename) '("." "..")))) (dired-move-to-filename) ! ;; Put rear-nonsticky property to avoid that text preceding the ! ;; filename can be modified. ! (add-text-properties ! (1- (point)) (point) `(old-name ,filename rear-nonsticky (read-only))) ! (put-text-property b-protection (point) 'read-only t) ! (setq b-protection (dired-move-to-end-of-filename t)) ! ;; Put end-name property iff filename is non-nil. ! (put-text-property (point) (1+ (point)) 'end-name t)) (forward-line)) (put-text-property b-protection (point-max) 'read-only t)))) *************** *** 312,342 **** Similar to `dired-get-filename' but it doesn't rely on regexps. It relies on WDired buffer's properties. Optional arg NO-DIR with value non-nil means don't include directory. Optional arg OLD with value ! non-nil means return old filename." ;; FIXME: Use dired-get-filename's new properties. ! (let (beg end file) ! (save-excursion ! (setq end (progn (end-of-line) (point))) ! (beginning-of-line) ! (setq beg (next-single-property-change (point) 'old-name nil end)) ! (unless (eq beg end) ! (if old ! (setq file (get-text-property beg 'old-name)) ! (setq end (next-single-property-change (1+ beg) 'end-name)) ! (setq file (buffer-substring-no-properties (+ 2 beg) end))) ! (and file (setq file (wdired-normalize-filename file)))) ! (if (or no-dir old) ! file ! (and file (> (length file) 0) ! (concat (dired-current-directory) file)))))) ! (defun wdired-change-to-dired-mode () "Change the mode back to dired." (let ((inhibit-read-only t)) ! (remove-text-properties (point-min) (point-max) ! '(read-only nil local-map nil))) ! (put-text-property 1 2 'front-sticky nil) (use-local-map dired-mode-map) (force-mode-line-update) (setq buffer-read-only t) --- 315,343 ---- Similar to `dired-get-filename' but it doesn't rely on regexps. It relies on WDired buffer's properties. Optional arg NO-DIR with value non-nil means don't include directory. Optional arg OLD with value ! non-nil means return old filename without directory." ;; FIXME: Use dired-get-filename's new properties. ! (let* ((end (line-end-position)) ! (beg (next-single-property-change ! (line-beginning-position) 'old-name nil end)) ! file) ! (when beg ! (cond ! (old (setq file (get-text-property beg 'old-name))) ! ((setq end (next-single-property-change beg 'end-name nil end)) ! (setq file (buffer-substring-no-properties (1+ beg) end)) ! (when file (setq file (wdired-normalize-filename file))))) ! (cond ! ((or no-dir old) file) ! ((and file (> (length file) 0)) ! (concat (dired-current-directory) file)))))) (defun wdired-change-to-dired-mode () "Change the mode back to dired." (let ((inhibit-read-only t)) ! (remove-text-properties ! (point-min) (point-max) ! '(front-sticky nil rear-nonsticky nil read-only nil local-map nil))) (use-local-map dired-mode-map) (force-mode-line-update) (setq buffer-read-only t) *************** *** 346,352 **** (remove-hook 'kill-buffer-hook 'wdired-check-kill-buffer t) (setq revert-buffer-function 'dired-revert)) - (defun wdired-abort-changes () "Abort changes and return to dired mode." (interactive) --- 347,352 ---- *************** *** 364,427 **** (interactive) (wdired-change-to-dired-mode) (let ((overwrite (or (not wdired-confirm-overwrite) 1)) - (changes nil) - (files-deleted nil) (errors 0) ! file-ori file-new tmp-value) (save-excursion ! (if (and wdired-allow-to-redirect-links ! (fboundp 'make-symbolic-link)) ! (progn ! (setq tmp-value (wdired-do-symlink-changes)) ! (setq errors (cdr tmp-value)) ! (setq changes (car tmp-value)))) ! (if (and wdired-allow-to-change-permissions ! (boundp 'wdired-col-perm)) ; could have been changed ! (progn ! (setq tmp-value (wdired-do-perm-changes)) ! (setq errors (+ errors (cdr tmp-value))) ! (setq changes (or changes (car tmp-value))))) (goto-char (point-max)) (while (not (bobp)) ! (setq file-ori (wdired-get-filename nil t)) ! (if file-ori ! (setq file-new (wdired-get-filename))) ! (if (and file-ori (not (equal file-new file-ori))) ! (progn ! (setq changes t) ! (if (not file-new) ;empty filename! ! (setq files-deleted (cons file-ori files-deleted)) ! (progn ! (setq file-new (substitute-in-file-name file-new)) ! (if wdired-use-interactive-rename ! (wdired-search-and-rename file-ori file-new) ! ;; If dired-rename-file autoloads dired-aux while ! ;; dired-backup-overwrite is locally bound, ! ;; dired-backup-overwrite won't be initialized. ! ;; So we must ensure dired-aux is loaded. ! (require 'dired-aux) ! (condition-case err ! (let ((dired-backup-overwrite nil)) ! (dired-rename-file file-ori file-new ! overwrite)) ! (error ! (setq errors (1+ errors)) ! (dired-log (concat "Rename `" file-ori "' to `" ! file-new "' failed:\n%s\n") ! err)))))))) (forward-line -1))) (if changes ! (revert-buffer) ;The "revert" is necessary to re-sort the buffer ! (let ((buffer-read-only nil)) ! (remove-text-properties (point-min) (point-max) ! '(old-name nil end-name nil old-link nil ! end-link nil end-perm nil ! old-perm nil perm-changed nil)) (message "(No changes to be performed)"))) ! (if files-deleted ! (wdired-flag-for-deletion files-deleted)) ! (if (> errors 0) ! (dired-log-summary (format "%d rename actions failed" errors) nil))) (set-buffer-modified-p nil) (setq buffer-undo-list nil)) --- 364,419 ---- (interactive) (wdired-change-to-dired-mode) (let ((overwrite (or (not wdired-confirm-overwrite) 1)) (errors 0) ! changes files-deleted file-ori file-new tmp-value) (save-excursion ! (when (and wdired-allow-to-redirect-links ! (fboundp 'make-symbolic-link)) ! (setq tmp-value (wdired-do-symlink-changes)) ! (setq errors (cdr tmp-value)) ! (setq changes (car tmp-value))) ! (when (and wdired-allow-to-change-permissions ! (boundp 'wdired-col-perm)) ; could have been changed ! (setq tmp-value (wdired-do-perm-changes)) ! (setq errors (+ errors (cdr tmp-value))) ! (setq changes (or changes (car tmp-value)))) (goto-char (point-max)) (while (not (bobp)) ! (when (setq file-ori (wdired-get-filename nil t)) ! (setq file-new (wdired-get-filename)) ! (unless (string-equal file-new file-ori) ! (setq changes t) ! (if (not file-new) ; empty filename! ! (setq files-deleted (cons file-ori files-deleted)) ! (setq file-new (substitute-in-file-name file-new)) ! (if wdired-use-interactive-rename ! (wdired-search-and-rename file-ori file-new) ! ;; If dired-rename-file autoloads dired-aux while ! ;; dired-backup-overwrite is locally bound, ! ;; dired-backup-overwrite won't be initialized. ! ;; So we must ensure dired-aux is loaded. ! (require 'dired-aux) ! (condition-case err ! (let ((dired-backup-overwrite nil)) ! (dired-rename-file file-ori file-new overwrite)) ! (error ! (setq errors (1+ errors)) ! (dired-log (concat "Rename `" file-ori "' to `" ! file-new "' failed:\n%s\n") ! err))))))) (forward-line -1))) (if changes ! (revert-buffer) ;The "revert" is necessary to re-sort the buffer ! (let ((inhibit-read-only t)) ! (remove-text-properties ! (point-min) (point-max) ! '(old-name nil end-name nil old-link nil end-link nil ! end-perm nil old-perm nil perm-changed nil)) (message "(No changes to be performed)"))) ! (when files-deleted ! (wdired-flag-for-deletion files-deleted)) ! (when (> errors 0) ! (dired-log-summary (format "%d rename actions failed" errors) nil))) (set-buffer-modified-p nil) (setq buffer-undo-list nil)) *************** *** 447,456 **** (dired-do-create-files-regexp (function dired-rename-file) "Move" 1 ".*" filename-new nil t)) ! (progn ! (forward-line -1) ! (beginning-of-line) ! (setq exit-while (= 1 (point))))))))) ;; marks a list of files for deletion (defun wdired-flag-for-deletion (filenames-ori) --- 439,446 ---- (dired-do-create-files-regexp (function dired-rename-file) "Move" 1 ".*" filename-new nil t)) ! (forward-line -1) ! (setq exit-while (bobp))))))) ;; marks a list of files for deletion (defun wdired-flag-for-deletion (filenames-ori) *************** *** 512,570 **** (save-excursion (goto-char (point-min)) (while (not (eobp)) ! (if (looking-at dired-re-sym) ! (progn ! (re-search-forward " -> \\(.*\\)$") ! (put-text-property (- (match-beginning 1) 2) ! (1- (match-beginning 1)) 'old-link ! (match-string-no-properties 1)) ! (put-text-property (match-end 1) (1+ (match-end 1)) 'end-link t) ! (put-text-property (1- (match-beginning 1)) ! (match-end 1) 'read-only nil))) ! (forward-line) ! (beginning-of-line))))) ! (defun wdired-get-previous-link (&optional old move) "Return the next symlink target. If OLD, return the old target. If MOVE, move point before it." (let (beg end target) (setq beg (previous-single-property-change (point) 'old-link nil)) ! (if beg ! (progn ! (if old ! (setq target (get-text-property (1- beg) 'old-link)) ! (setq end (next-single-property-change beg 'end-link)) ! (setq target (buffer-substring-no-properties (1+ beg) end))) ! (if move (goto-char (1- beg))))) ! (and target (wdired-normalize-filename target)))) ! ! ;; Perform the changes in the target of the changed links. ! (defun wdired-do-symlink-changes() ! (let ((changes nil) ! (errors 0) ! link-to-ori link-to-new link-from) (goto-char (point-max)) (while (setq link-to-new (wdired-get-previous-link)) (setq link-to-ori (wdired-get-previous-link t t)) (setq link-from (wdired-get-filename nil t)) ! (if (not (equal link-to-new link-to-ori)) ! (progn ! (setq changes t) ! (if (equal link-to-new "") ;empty filename! ! (setq link-to-new "/dev/null")) ! (condition-case err ! (progn ! (delete-file link-from) ! (make-symbolic-link ! (substitute-in-file-name link-to-new) link-from)) ! (error ! (setq errors (1+ errors)) ! (dired-log (concat "Link `" link-from "' to `" ! link-to-new "' failed:\n%s\n") ! err)))))) (cons changes errors))) ;; Perform a "case command" skipping read-only words. --- 502,555 ---- (save-excursion (goto-char (point-min)) (while (not (eobp)) ! (when (looking-at dired-re-sym) ! (re-search-forward " -> \\(.*\\)$") ! ;; Put rear-nonsticky property to avoid that text preceding the target ! ;; can be modified. ! (add-text-properties ! (1- (match-beginning 1)) (match-beginning 1) ! `(old-link ,(match-string-no-properties 1) ! rear-nonsticky (read-only))) ! (put-text-property (match-end 1) (1+ (match-end 1)) 'end-link t) ! (put-text-property ! (match-beginning 1) (match-end 1) 'read-only nil)) ! (forward-line))))) (defun wdired-get-previous-link (&optional old move) "Return the next symlink target. If OLD, return the old target. If MOVE, move point before it." (let (beg end target) (setq beg (previous-single-property-change (point) 'old-link nil)) ! (when beg ! (if old ! (setq target (get-text-property (1- beg) 'old-link)) ! (setq end (next-single-property-change beg 'end-link)) ! (setq target (buffer-substring-no-properties beg end))) ! (when move (goto-char (1- beg))) ! (when target (wdired-normalize-filename target))))) ;; Perform the changes in the target of the changed links. ! (defun wdired-do-symlink-changes () ! (let ((errors 0) ! changes link-to-ori link-to-new link-from) (goto-char (point-max)) (while (setq link-to-new (wdired-get-previous-link)) (setq link-to-ori (wdired-get-previous-link t t)) (setq link-from (wdired-get-filename nil t)) ! (when (not (equal link-to-new link-to-ori)) ! (setq changes t) ! (when (equal link-to-new "") ; empty filename! ! (setq link-to-new null-device)) ! (condition-case err ! (progn ! (delete-file link-from) ! (make-symbolic-link ! (substitute-in-file-name link-to-new) link-from)) ! (error ! (setq errors (1+ errors)) ! (dired-log (concat "Link `" link-from "' to `" ! link-to-new "' failed:\n%s\n") ! err))))) (cons changes errors))) ;; Perform a "case command" skipping read-only words. *************** *** 621,649 **** ;; Put a local-map to the permission bits of the files, and store the ;; original name and permissions as a property ! (defun wdired-preprocess-perms() ! (let ((inhibit-read-only t) ! filename) (set (make-local-variable 'wdired-col-perm) nil) (save-excursion (goto-char (point-min)) (while (not (eobp)) ! (if (and (not (looking-at dired-re-sym)) ! (setq filename (wdired-get-filename))) ! (progn ! (re-search-forward dired-re-perms) ! (or wdired-col-perm ! (setq wdired-col-perm (- (current-column) 9))) ! (if (eq wdired-allow-to-change-permissions 'advanced) ! (put-text-property (match-beginning 0) (match-end 0) ! 'read-only nil) ! (put-text-property (1+ (match-beginning 0)) (match-end 0) ! 'local-map wdired-perm-mode-map)) ! (put-text-property (match-end 0) (1+ (match-end 0)) 'end-perm t) ! (put-text-property (match-beginning 0) (1+ (match-beginning 0)) ! 'old-perm (match-string-no-properties 0)))) ! (forward-line) ! (beginning-of-line))))) (defun wdired-perm-allowed-in-pos (char pos) (cond --- 606,640 ---- ;; Put a local-map to the permission bits of the files, and store the ;; original name and permissions as a property ! (defun wdired-preprocess-perms () ! (let ((inhibit-read-only t)) (set (make-local-variable 'wdired-col-perm) nil) (save-excursion (goto-char (point-min)) (while (not (eobp)) ! (when (and (not (looking-at dired-re-sym)) ! (wdired-get-filename) ! (re-search-forward dired-re-perms (line-end-position) 'eol)) ! (let ((begin (match-beginning 0)) ! (end (match-end 0))) ! (unless wdired-col-perm ! (setq wdired-col-perm (- (current-column) 9))) ! (if (eq wdired-allow-to-change-permissions 'advanced) ! (progn ! (put-text-property begin end 'read-only nil) ! ;; Put rear-nonsticky property to avoid that text preceding ! ;; the permissions can be modified. ! (put-text-property ! (1- begin) begin 'rear-nonsticky '(read-only))) ! ;; Put rear-nonsticky property to avoid that local-map applies to ! ;; text following permissions. ! (add-text-properties ! (1+ begin) end ! `(local-map ,wdired-perm-mode-map rear-nonsticky (local-map)))) ! (put-text-property end (1+ end) 'end-perm t) ! (put-text-property ! begin (1+ begin) 'old-perm (match-string-no-properties 0)))) ! (forward-line))))) (defun wdired-perm-allowed-in-pos (char pos) (cond *************** *** 658,691 **** (defun wdired-set-bit () "Set a permission bit character." (interactive) ! (if (wdired-perm-allowed-in-pos last-command-char ! (- (current-column) wdired-col-perm)) ! (let ((new-bit (char-to-string last-command-char)) ! (inhibit-read-only t) (pos-prop (- (point) (- (current-column) wdired-col-perm)))) ! (put-text-property 0 1 'local-map wdired-perm-mode-map new-bit) ! (put-text-property 0 1 'read-only t new-bit) ! (insert new-bit) (delete-char 1) ! (put-text-property pos-prop (1- pos-prop) 'perm-changed t)) (forward-char 1))) (defun wdired-toggle-bit() "Toggle the permission bit at point." (interactive) ! (let ((inhibit-read-only t) ! (new-bit "-") ! (pos-prop (- (point) (- (current-column) wdired-col-perm)))) ! (if (eq (char-after (point)) ?-) (setq new-bit (if (= (% (- (current-column) wdired-col-perm) 3) 0) "r" (if (= (% (- (current-column) wdired-col-perm) 3) 1) "w" "x")))) ! (put-text-property 0 1 'local-map wdired-perm-mode-map new-bit) ! (put-text-property 0 1 'read-only t new-bit) ! (insert new-bit) ! (delete-char 1) ! (put-text-property pos-prop (1- pos-prop) 'perm-changed t))) (defun wdired-mouse-toggle-bit (event) "Toggle the permission bit that was left clicked." --- 649,687 ---- (defun wdired-set-bit () "Set a permission bit character." (interactive) ! (if (wdired-perm-allowed-in-pos ! last-command-char (- (current-column) wdired-col-perm)) ! (let ((inhibit-read-only t) (pos-prop (- (point) (- (current-column) wdired-col-perm)))) ! (insert (char-to-string last-command-char)) ! ;; Put text properties for inserted character. ! (add-text-properties ! (1- (point)) (point) ! `(local-map ,wdired-perm-mode-map read-only t ! rear-nonsticky (local-map))) (delete-char 1) ! (put-text-property (1- pos-prop) pos-prop 'perm-changed t)) (forward-char 1))) (defun wdired-toggle-bit() "Toggle the permission bit at point." (interactive) ! (let ((inhibit-read-only t) ! (new-bit "-") ! (pos-prop (- (point) (- (current-column) wdired-col-perm)))) ! (when (eq (char-after (point)) ?-) (setq new-bit (if (= (% (- (current-column) wdired-col-perm) 3) 0) "r" (if (= (% (- (current-column) wdired-col-perm) 3) 1) "w" "x")))) ! (insert new-bit) ! ;; Put text properties for inserted character. ! (add-text-properties ! (1- (point)) (point) ! `(local-map ,wdired-perm-mode-map read-only t ! rear-nonsticky (local-map))) ! (delete-char 1) ! (put-text-property (1- pos-prop) pos-prop 'perm-changed t))) (defun wdired-mouse-toggle-bit (event) "Toggle the permission bit that was left clicked." *************** *** 718,753 **** ;; Perform the changes in the permissions of the files that have ;; changed. (defun wdired-do-perm-changes () ! (let ((changes nil) ! (errors 0) (prop-wanted (if (eq wdired-allow-to-change-permissions 'advanced) 'old-perm 'perm-changed)) ! filename perms-ori perms-new perm-tmp) ! (goto-char (next-single-property-change (point-min) prop-wanted ! nil (point-max))) (while (not (eobp)) (setq perms-ori (get-text-property (point) 'old-perm)) (setq perms-new (buffer-substring-no-properties (point) (next-single-property-change (point) 'end-perm))) ! (if (not (equal perms-ori perms-new)) ! (progn ! (setq changes t) ! (setq filename (wdired-get-filename nil t)) ! (if (= (length perms-new) 10) ! (progn ! (setq perm-tmp ! (int-to-string (wdired-perms-to-number perms-new))) ! (if (not (equal 0 (dired-call-process dired-chmod-program ! t perm-tmp filename))) ! (progn ! (setq errors (1+ errors)) ! (dired-log (concat dired-chmod-program " " perm-tmp ! " `" filename "' failed\n\n"))))) ! (setq errors (1+ errors)) ! (dired-log (concat "Cannot parse permission `" perms-new ! "' for file `" filename "'\n\n"))))) ! (goto-char (next-single-property-change (1+ (point)) prop-wanted ! nil (point-max)))) (cons changes errors))) (provide 'wdired) --- 714,746 ---- ;; Perform the changes in the permissions of the files that have ;; changed. (defun wdired-do-perm-changes () ! (let ((errors 0) (prop-wanted (if (eq wdired-allow-to-change-permissions 'advanced) 'old-perm 'perm-changed)) ! changes filename perms-ori perms-new perm-tmp) ! (goto-char (next-single-property-change ! (point-min) prop-wanted nil (point-max))) (while (not (eobp)) (setq perms-ori (get-text-property (point) 'old-perm)) (setq perms-new (buffer-substring-no-properties (point) (next-single-property-change (point) 'end-perm))) ! (when (not (equal perms-ori perms-new)) ! (setq changes t) ! (setq filename (wdired-get-filename nil t)) ! (if (= (length perms-new) 10) ! (progn ! (setq perm-tmp ! (int-to-string (wdired-perms-to-number perms-new))) ! (when (not (equal 0 (dired-call-process dired-chmod-program ! t perm-tmp filename))) ! (setq errors (1+ errors)) ! (dired-log (concat dired-chmod-program " " perm-tmp ! " `" filename "' failed\n\n")))) ! (setq errors (1+ errors)) ! (dired-log (concat "Cannot parse permission `" perms-new ! "' for file `" filename "'\n\n")))) ! (goto-char (next-single-property-change ! (1+ (point)) prop-wanted nil (point-max)))) (cons changes errors))) (provide 'wdired) ================================================================================