diff options
| author | Chong Yidong | 2008-11-30 05:42:35 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-11-30 05:42:35 +0000 |
| commit | 393e7e90897453c6fe4920ada27bdbdf7e313d05 (patch) | |
| tree | 6d55c52cc1bc141833dc748f956b507229a6c70e | |
| parent | a124190e811d57e6701339a475452542216dc9a4 (diff) | |
| download | emacs-393e7e90897453c6fe4920ada27bdbdf7e313d05.tar.gz emacs-393e7e90897453c6fe4920ada27bdbdf7e313d05.zip | |
(wdired-finish-edit): If displaying a single file, change
dired-directory if that file was renamed.
| -rw-r--r-- | lisp/wdired.el | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/lisp/wdired.el b/lisp/wdired.el index e2d6a4b85b8..2ad186410ca 100644 --- a/lisp/wdired.el +++ b/lisp/wdired.el | |||
| @@ -369,10 +369,11 @@ non-nil means return old filename." | |||
| 369 | (interactive) | 369 | (interactive) |
| 370 | (wdired-change-to-dired-mode) | 370 | (wdired-change-to-dired-mode) |
| 371 | (let ((changes nil) | 371 | (let ((changes nil) |
| 372 | (files-deleted nil) | ||
| 373 | (file-renames ()) | ||
| 374 | (errors 0) | 372 | (errors 0) |
| 375 | file-ori file-new tmp-value) | 373 | files-deleted |
| 374 | files-renamed | ||
| 375 | some-file-names-unchanged | ||
| 376 | file-old file-new tmp-value) | ||
| 376 | (save-excursion | 377 | (save-excursion |
| 377 | (when (and wdired-allow-to-redirect-links | 378 | (when (and wdired-allow-to-redirect-links |
| 378 | (fboundp 'make-symbolic-link)) | 379 | (fboundp 'make-symbolic-link)) |
| @@ -386,20 +387,32 @@ non-nil means return old filename." | |||
| 386 | (setq changes (or changes (car tmp-value)))) | 387 | (setq changes (or changes (car tmp-value)))) |
| 387 | (goto-char (point-max)) | 388 | (goto-char (point-max)) |
| 388 | (while (not (bobp)) | 389 | (while (not (bobp)) |
| 389 | (setq file-ori (wdired-get-filename nil t)) | 390 | (setq file-old (wdired-get-filename nil t)) |
| 390 | (when file-ori | 391 | (when file-old |
| 391 | (setq file-new (wdired-get-filename)) | 392 | (setq file-new (wdired-get-filename)) |
| 392 | (unless (equal file-new file-ori) | 393 | (if (equal file-new file-old) |
| 394 | (setq some-file-names-unchanged t) | ||
| 393 | (setq changes t) | 395 | (setq changes t) |
| 394 | (if (not file-new) ;empty filename! | 396 | (if (not file-new) ;empty filename! |
| 395 | (push file-ori files-deleted) | 397 | (push file-old files-deleted) |
| 396 | (push (cons file-ori (substitute-in-file-name file-new)) | 398 | (push (cons file-old (substitute-in-file-name file-new)) |
| 397 | file-renames)))) | 399 | files-renamed)))) |
| 398 | (forward-line -1))) | 400 | (forward-line -1))) |
| 399 | (when file-renames | 401 | (when files-renamed |
| 400 | (setq errors (+ errors (wdired-do-renames file-renames)))) | 402 | (setq errors (+ errors (wdired-do-renames files-renamed)))) |
| 401 | (if changes | 403 | (if changes |
| 402 | (revert-buffer) ;The "revert" is necessary to re-sort the buffer | 404 | (progn |
| 405 | ;; If we are displaying a single file (rather than the | ||
| 406 | ;; contents of a directory), change dired-directory if that | ||
| 407 | ;; file was renamed. (This ought to be generalized to | ||
| 408 | ;; handle the multiple files case, but that's less trivial). | ||
| 409 | (when (and (stringp dired-directory) | ||
| 410 | (not (file-directory-p dired-directory)) | ||
| 411 | (null some-file-names-unchanged) | ||
| 412 | (= (length files-renamed) 1)) | ||
| 413 | (setq dired-directory (cdr (car files-renamed)))) | ||
| 414 | ;; Re-sort the buffer. | ||
| 415 | (revert-buffer)) | ||
| 403 | (let ((inhibit-read-only t)) | 416 | (let ((inhibit-read-only t)) |
| 404 | (remove-text-properties (point-min) (point-max) | 417 | (remove-text-properties (point-min) (point-max) |
| 405 | '(old-name nil end-name nil old-link nil | 418 | '(old-name nil end-name nil old-link nil |