bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13772: 24.3.50; dired-diff does not replace dired-backup-diff


From: Juri Linkov
Subject: bug#13772: 24.3.50; dired-diff does not replace dired-backup-diff
Date: Thu, 28 Feb 2013 01:57:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (x86_64-pc-linux-gnu)

> The M-= binding for dired-backup-diff was deleted,
> supposedly because dired-diff now replaces it.
> However, it does not.  If you type it on a backup file,
> it does not present the current file as the default argument.
> The default argument gives an error.
>
> And if you specify the current file as the argument, you get a diff
> between the right two files, but it is in reverse order.

The following patch copies the relevant logic from `diff-backup'
to `dired-diff', so that typing it on a backup file should present
its original as the default argument and run a diff in correct order.

=== modified file 'lisp/dired-aux.el'
*** lisp/dired-aux.el   2013-01-01 09:11:05 +0000
--- lisp/dired-aux.el   2013-02-27 23:56:03 +0000
*************** (defconst dired-quark-subst-regexp "\\(^
*** 55,61 ****
  (defun dired-diff (file &optional switches)
    "Compare file at point with file FILE using `diff'.
  If called interactively, prompt for FILE.  If the file at point
! has a backup file, use that as the default.  If the mark is active
  in Transient Mark mode, use the file at the mark as the default.
  \(That's the mark set by \\[set-mark-command], not by Dired's
  \\[dired-mark] command.)
--- 55,62 ----
  (defun dired-diff (file &optional switches)
    "Compare file at point with file FILE using `diff'.
  If called interactively, prompt for FILE.  If the file at point
! has a backup file, use that as the default.  If the file at point
! is a backup file, use its original.  If the mark is active
  in Transient Mark mode, use the file at the mark as the default.
  \(That's the mark set by \\[set-mark-command], not by Dired's
  \\[dired-mark] command.)
*************** (defun dired-diff (file &optional switch
*** 67,74 ****
  the string of command switches for the third argument of `diff'."
    (interactive
     (let* ((current (dired-get-filename t))
!         ;; Get the latest existing backup file.
!         (oldf (diff-latest-backup-file current))
          ;; Get the file at the mark.
          (file-at-mark (if (and transient-mark-mode mark-active)
                            (save-excursion (goto-char (mark t))
--- 68,77 ----
  the string of command switches for the third argument of `diff'."
    (interactive
     (let* ((current (dired-get-filename t))
!         ;; Get the latest existing backup file or its original.
!         (oldf (if (backup-file-name-p current)
!                   (file-name-sans-versions current)
!                 (diff-latest-backup-file current)))
          ;; Get the file at the mark.
          (file-at-mark (if (and transient-mark-mode mark-active)
                            (save-excursion (goto-char (mark t))
*************** (defun dired-diff (file &optional switch
*** 107,113 ****
                   (equal (expand-file-name current file)
                          (expand-file-name current))))
        (error "Attempt to compare the file to itself"))
!     (diff file current switches)))
  
  ;;;###autoload
  (defun dired-backup-diff (&optional switches)
--- 110,119 ----
                   (equal (expand-file-name current file)
                          (expand-file-name current))))
        (error "Attempt to compare the file to itself"))
!     (if (and (backup-file-name-p current)
!            (not (backup-file-name-p file)))
!       (diff current file switches)
!       (diff file current switches))))
  
  ;;;###autoload
  (defun dired-backup-diff (&optional switches)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]