diff options
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/dired-aux.el | 66 | ||||
| -rw-r--r-- | lisp/dired.el | 17 |
4 files changed, 64 insertions, 29 deletions
| @@ -468,8 +468,8 @@ file at point. | |||
| 468 | mark/unmark/flag all files in the active region. | 468 | mark/unmark/flag all files in the active region. |
| 469 | 469 | ||
| 470 | *** The minibuffer default for `=' (`dired-diff) has changed. | 470 | *** The minibuffer default for `=' (`dired-diff) has changed. |
| 471 | It is now the backup file for the file at point, if one exists, rather | 471 | It is now the backup file for the file at point, if one exists. |
| 472 | than the file at the mark. | 472 | In Transient Mark mode the default is the file at the active mark. |
| 473 | 473 | ||
| 474 | *** `M-=' is no longer bound to `dired-backup-diff' in Dired buffers. | 474 | *** `M-=' is no longer bound to `dired-backup-diff' in Dired buffers. |
| 475 | The global binding for `M-=', `count-words-region' is in effect. | 475 | The global binding for `M-=', `count-words-region' is in effect. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 66927960d25..8036e819d4d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2012-09-18 Juri Linkov <juri@jurta.org> | 1 | 2012-09-18 Juri Linkov <juri@jurta.org> |
| 2 | 2 | ||
| 3 | * dired-aux.el (dired-diff): Restore original functionality of | ||
| 4 | getting the default value, but keep new feature of using the | ||
| 5 | latest existing backup file (`diff-latest-backup-file'). | ||
| 6 | |||
| 7 | 2012-09-18 Juri Linkov <juri@jurta.org> | ||
| 8 | |||
| 3 | * dired.el (dired-mark): If the region is active in Transient Mark | 9 | * dired.el (dired-mark): If the region is active in Transient Mark |
| 4 | mode, mark all files in the active region. Doc fix. | 10 | mode, mark all files in the active region. Doc fix. |
| 5 | (dired-unmark, dired-flag-file-deletion, dired-unmark-backward): | 11 | (dired-unmark, dired-flag-file-deletion, dired-unmark-backward): |
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 54f9f03a69c..7ba67050337 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el | |||
| @@ -51,33 +51,57 @@ into this list; they also should call `dired-log' to log the errors.") | |||
| 51 | (defconst dired-star-subst-regexp "\\(^\\|[ \t]\\)\\*\\([ \t]\\|$\\)") | 51 | (defconst dired-star-subst-regexp "\\(^\\|[ \t]\\)\\*\\([ \t]\\|$\\)") |
| 52 | (defconst dired-quark-subst-regexp "\\(^\\|[ \t]\\)\\?\\([ \t]\\|$\\)") | 52 | (defconst dired-quark-subst-regexp "\\(^\\|[ \t]\\)\\?\\([ \t]\\|$\\)") |
| 53 | 53 | ||
| 54 | (declare-function diff-latest-backup-file "diff" (fn)) ; actually belongs into files.el | ||
| 55 | |||
| 54 | ;;;###autoload | 56 | ;;;###autoload |
| 55 | (defun dired-diff (file &optional switches) | 57 | (defun dired-diff (file &optional switches) |
| 56 | "Compare file at point with file FILE using `diff'. | 58 | "Compare file at point with file FILE using `diff'. |
| 57 | If called interactively, prompt for FILE; if the file at point | 59 | If called interactively, prompt for FILE. If the file at point |
| 58 | has a backup file, use that as the default. | 60 | has a backup file, use that as the default. If the mark is active |
| 61 | in Transient Mark mode, use the file at the mark as the default. | ||
| 62 | \(That's the mark set by \\[set-mark-command], not by Dired's | ||
| 63 | \\[dired-mark] command.) | ||
| 64 | |||
| 65 | FILE is the first file given to `diff'. The file at point | ||
| 66 | is the second file given to `diff'. | ||
| 59 | 67 | ||
| 60 | FILE is the first file given to `diff'. | 68 | With prefix arg, prompt for second argument SWITCHES, which is |
| 61 | With prefix arg, prompt for second argument SWITCHES, | 69 | the string of command switches for the third argument of `diff'." |
| 62 | which is the string of command switches for `diff'." | ||
| 63 | (interactive | 70 | (interactive |
| 64 | (let* ((current (dired-get-filename t)) | 71 | (let* ((current (dired-get-filename t)) |
| 65 | (oldf (file-newest-backup current)) | 72 | ;; Get the latest existing backup file. |
| 66 | (dir (if oldf (file-name-directory oldf)))) | 73 | (oldf (diff-latest-backup-file current)) |
| 67 | (list (read-file-name | 74 | ;; Get the file at the mark. |
| 68 | (format "Diff %s with%s: " | 75 | (file-at-mark (if (and transient-mark-mode mark-active) |
| 69 | (file-name-nondirectory current) | 76 | (save-excursion (goto-char (mark t)) |
| 70 | (if oldf | 77 | (dired-get-filename t t)))) |
| 71 | (concat " (default " | 78 | (default-file (or file-at-mark |
| 72 | (file-name-nondirectory oldf) | 79 | (and oldf (file-name-nondirectory oldf)))) |
| 73 | ")") | 80 | ;; Use it as default if it's not the same as the current file, |
| 74 | "")) | 81 | ;; and the target dir is current or there is a default file. |
| 75 | dir oldf t) | 82 | (default (if (and (not (equal default-file current)) |
| 76 | (if current-prefix-arg | 83 | (or (equal (dired-dwim-target-directory) |
| 77 | (read-string "Options for diff: " | 84 | (dired-current-directory)) |
| 78 | (if (stringp diff-switches) | 85 | default-file)) |
| 79 | diff-switches | 86 | default-file)) |
| 80 | (mapconcat 'identity diff-switches " "))))))) | 87 | (target-dir (if default |
| 88 | (dired-current-directory) | ||
| 89 | (dired-dwim-target-directory))) | ||
| 90 | (defaults (dired-dwim-target-defaults (list current) target-dir))) | ||
| 91 | (list | ||
| 92 | (minibuffer-with-setup-hook | ||
| 93 | (lambda () | ||
| 94 | (set (make-local-variable 'minibuffer-default-add-function) nil) | ||
| 95 | (setq minibuffer-default defaults)) | ||
| 96 | (read-file-name | ||
| 97 | (format "Diff %s with%s: " current | ||
| 98 | (if default (format " (default %s)" default) "")) | ||
| 99 | target-dir default t)) | ||
| 100 | (if current-prefix-arg | ||
| 101 | (read-string "Options for diff: " | ||
| 102 | (if (stringp diff-switches) | ||
| 103 | diff-switches | ||
| 104 | (mapconcat 'identity diff-switches " "))))))) | ||
| 81 | (let ((current (dired-get-filename t))) | 105 | (let ((current (dired-get-filename t))) |
| 82 | (when (or (equal (expand-file-name file) | 106 | (when (or (equal (expand-file-name file) |
| 83 | (expand-file-name current)) | 107 | (expand-file-name current)) |
diff --git a/lisp/dired.el b/lisp/dired.el index abbd5acaf4f..0f453fe8f5d 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -3763,17 +3763,22 @@ Ask means pop up a menu for the user to select one of copy, move or link." | |||
| 3763 | ;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command | 3763 | ;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command |
| 3764 | ;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown | 3764 | ;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown |
| 3765 | ;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff | 3765 | ;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff |
| 3766 | ;;;;;; dired-diff) "dired-aux" "dired-aux.el" "3650b53533253c50b10e2aa8c9005ebf") | 3766 | ;;;;;; dired-diff) "dired-aux" "dired-aux.el" "2a883f0d481a8d0292eb90c09ae36a8e") |
| 3767 | ;;; Generated autoloads from dired-aux.el | 3767 | ;;; Generated autoloads from dired-aux.el |
| 3768 | 3768 | ||
| 3769 | (autoload 'dired-diff "dired-aux" "\ | 3769 | (autoload 'dired-diff "dired-aux" "\ |
| 3770 | Compare file at point with file FILE using `diff'. | 3770 | Compare file at point with file FILE using `diff'. |
| 3771 | If called interactively, prompt for FILE; if the file at point | 3771 | If called interactively, prompt for FILE. If the file at point |
| 3772 | has a backup file, use that as the default. | 3772 | has a backup file, use that as the default. If the mark is active |
| 3773 | in Transient Mark mode, use the file at the mark as the default. | ||
| 3774 | \(That's the mark set by \\[set-mark-command], not by Dired's | ||
| 3775 | \\[dired-mark] command.) | ||
| 3773 | 3776 | ||
| 3774 | FILE is the first file given to `diff'. | 3777 | FILE is the first file given to `diff'. The file at point |
| 3775 | With prefix arg, prompt for second argument SWITCHES, | 3778 | is the second file given to `diff'. |
| 3776 | which is the string of command switches for `diff'. | 3779 | |
| 3780 | With prefix arg, prompt for second argument SWITCHES, which is | ||
| 3781 | the string of command switches for the third argument of `diff'. | ||
| 3777 | 3782 | ||
| 3778 | \(fn FILE &optional SWITCHES)" t nil) | 3783 | \(fn FILE &optional SWITCHES)" t nil) |
| 3779 | 3784 | ||