~ubuntu-branches/ubuntu/karmic/emacs-snapshot/karmic

« back to all changes in this revision

Viewing changes to lisp/wdired.el

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-04-05 09:14:30 UTC
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: james.westby@ubuntu.com-20090405091430-nw07lynn2arotjbe
Tags: upstream-20090320
Import upstream version 20090320

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
;;; wdired.el --- Rename files editing their names in dired buffers
2
2
 
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.
4
5
 
5
6
;; Filename: wdired.el
6
7
;; Author: Juan Le�n Lahoz Garc�a <juanleon1@gmail.com>
369
370
  (interactive)
370
371
  (wdired-change-to-dired-mode)
371
372
  (let ((changes nil)
372
 
        (files-deleted nil)
373
 
        (file-renames ())
374
373
        (errors 0)
375
 
        file-ori file-new tmp-value)
 
374
        files-deleted
 
375
        files-renamed
 
376
        some-file-names-unchanged
 
377
        file-old file-new tmp-value)
376
378
    (save-excursion
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))
390
 
        (when file-ori
 
391
        (setq file-old (wdired-get-filename nil t))
 
392
        (when file-old
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)
393
396
            (setq changes 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))
397
 
                    file-renames))))
 
398
                (push file-old files-deleted)
 
399
              (push (cons file-old (substitute-in-file-name file-new))
 
400
                    files-renamed))))
398
401
        (forward-line -1)))
399
 
    (when file-renames
400
 
      (setq errors (+ errors (wdired-do-renames file-renames))))
 
402
    (when files-renamed
 
403
      (setq errors (+ errors (wdired-do-renames files-renamed))))
401
404
    (if changes
402
 
        (revert-buffer) ;The "revert" is necessary to re-sort the buffer
 
405
        (progn
 
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.
 
416
          (revert-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."
730
744
  (interactive)
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)