1
1
;;; wdired.el --- Rename files editing their names in dired buffers
3
;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
3
;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
4
;; Free Software Foundation, Inc.
5
6
;; Filename: wdired.el
6
7
;; Author: Juan Le�n Lahoz Garc�a <juanleon1@gmail.com>
370
371
(wdired-change-to-dired-mode)
371
372
(let ((changes nil)
375
file-ori file-new tmp-value)
376
some-file-names-unchanged
377
file-old file-new tmp-value)
377
379
(when (and wdired-allow-to-redirect-links
378
380
(fboundp 'make-symbolic-link))
386
388
(setq changes (or changes (car tmp-value))))
387
389
(goto-char (point-max))
388
390
(while (not (bobp))
389
(setq file-ori (wdired-get-filename nil t))
391
(setq file-old (wdired-get-filename nil t))
391
393
(setq file-new (wdired-get-filename))
392
(unless (equal file-new file-ori)
394
(if (equal file-new file-old)
395
(setq some-file-names-unchanged t)
394
397
(if (not file-new) ;empty filename!
395
(push file-ori files-deleted)
396
(push (cons file-ori (substitute-in-file-name file-new))
398
(push file-old files-deleted)
399
(push (cons file-old (substitute-in-file-name file-new))
398
401
(forward-line -1)))
400
(setq errors (+ errors (wdired-do-renames file-renames))))
403
(setq errors (+ errors (wdired-do-renames files-renamed))))
402
(revert-buffer) ;The "revert" is necessary to re-sort the buffer
406
;; If we are displaying a single file (rather than the
407
;; contents of a directory), change dired-directory if that
408
;; file was renamed. (This ought to be generalized to
409
;; handle the multiple files case, but that's less trivial).
410
(when (and (stringp dired-directory)
411
(not (file-directory-p dired-directory))
412
(null some-file-names-unchanged)
413
(= (length files-renamed) 1))
414
(setq dired-directory (cdr (car files-renamed))))
415
;; Re-sort the buffer.
403
417
(let ((inhibit-read-only t))
404
418
(remove-text-properties (point-min) (point-max)
405
419
'(old-name nil end-name nil old-link nil
728
742
(defun wdired-set-bit ()
729
743
"Set a permission bit character."
731
(if (wdired-perm-allowed-in-pos last-command-char
745
(if (wdired-perm-allowed-in-pos last-command-event
732
746
(- (current-column) wdired-col-perm))
733
(let ((new-bit (char-to-string last-command-char))
747
(let ((new-bit (char-to-string last-command-event))
734
748
(inhibit-read-only t)
735
749
(pos-prop (- (point) (- (current-column) wdired-col-perm))))
736
750
(put-text-property 0 1 'keymap wdired-perm-mode-map new-bit)