From 35d98877f0c972d08e476ac72336ef4107a76356 Mon Sep 17 00:00:00 2001 From: Chong Yidong Date: Sat, 8 Sep 2012 22:48:26 +0800 Subject: [PATCH] Don't bind M-= in Dired. * lisp/dired.el (dired-mode-map): Don't bind M-=. * lisp/dired-aux.el (dired-diff): Use backup file as default. --- etc/NEWS | 7 +++++++ lisp/ChangeLog | 6 ++++++ lisp/dired-aux.el | 53 ++++++++++++++++++----------------------------- lisp/dired.el | 10 ++++----- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7a9c9a21c9..5beb47b7b0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -423,6 +423,13 @@ channel keys found, if any. if the command ends in `;' (when operating on multiple files). Otherwise, it executes the command on each file in parallel. +*** The minibuffer default for `=' (`dired-diff) has changed. +It is now the backup file for the file at point, if one exists, rather +than the file at the mark. + +*** `M-=' is no longer bound to `dired-backup-diff' in Dired buffers. +The global binding for `M-=', `count-words-region' is in effect. + ** Shell *** New option `async-shell-command-buffer' specifies what buffer to use diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b45d2fd823..f9a0d45700 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-09-08 Chong Yidong + + * dired.el (dired-mode-map): Don't bind M-=. + + * dired-aux.el (dired-diff): Use backup file as default. + 2012-09-08 Drew Adams * subr.el (add-to-history): Fix delete usage (Bug#12314). diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 6186f762e0..1f8e8068de 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -54,43 +54,30 @@ into this list; they also should call `dired-log' to log the errors.") ;;;###autoload (defun dired-diff (file &optional switches) "Compare file at point with file FILE using `diff'. -FILE defaults to the file at the mark. (That's the mark set by -\\[set-mark-command], not by Dired's \\[dired-mark] command.) -The prompted-for FILE is the first file given to `diff'. +If called interactively, prompt for FILE; if the file at point +has a backup file, use that as the default. + +FILE is the first file given to `diff'. With prefix arg, prompt for second argument SWITCHES, which is the string of command switches for `diff'." (interactive (let* ((current (dired-get-filename t)) - ;; Get the file at the mark. - (file-at-mark (if (mark t) - (save-excursion (goto-char (mark t)) - (dired-get-filename t t)))) - ;; Use it as default if it's not the same as the current file, - ;; and the target dir is the current dir or the mark is active. - (default (if (and (not (equal file-at-mark current)) - (or (equal (dired-dwim-target-directory) - (dired-current-directory)) - mark-active)) - file-at-mark)) - (target-dir (if default - (dired-current-directory) - (dired-dwim-target-directory))) - (defaults (dired-dwim-target-defaults (list current) target-dir))) - (require 'diff) - (list - (minibuffer-with-setup-hook - (lambda () - (set (make-local-variable 'minibuffer-default-add-function) nil) - (setq minibuffer-default defaults)) - (read-file-name - (format "Diff %s with%s: " current - (if default (format " (default %s)" default) "")) - target-dir default t)) - (if current-prefix-arg - (read-string "Options for diff: " - (if (stringp diff-switches) - diff-switches - (mapconcat 'identity diff-switches " "))))))) + (oldf (file-newest-backup current)) + (dir (if oldf (file-name-directory oldf)))) + (list (read-file-name + (format "Diff %s with%s: " + (file-name-nondirectory current) + (if oldf + (concat " (default " + (file-name-nondirectory oldf) + ")") + "")) + dir oldf t) + (if current-prefix-arg + (read-string "Options for diff: " + (if (stringp diff-switches) + diff-switches + (mapconcat 'identity diff-switches " "))))))) (let ((current (dired-get-filename t))) (when (or (equal (expand-file-name file) (expand-file-name current)) diff --git a/lisp/dired.el b/lisp/dired.el index cd27b6b640..f4ae027181 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1410,7 +1410,6 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (define-key map "&" 'dired-do-async-shell-command) ;; Comparison commands (define-key map "=" 'dired-diff) - (define-key map "\M-=" 'dired-backup-diff) ;; Tree Dired commands (define-key map "\M-\C-?" 'dired-unmark-all-files) (define-key map "\M-\C-d" 'dired-tree-down) @@ -3745,14 +3744,15 @@ Ask means pop up a menu for the user to select one of copy, move or link." ;;;;;; dired-run-shell-command dired-do-shell-command dired-do-async-shell-command ;;;;;; dired-clean-directory dired-do-print dired-do-touch dired-do-chown ;;;;;; dired-do-chgrp dired-do-chmod dired-compare-directories dired-backup-diff -;;;;;; dired-diff) "dired-aux" "dired-aux.el" "9499f79f5853da0aa93d26465c7bf3a1") +;;;;;; dired-diff) "dired-aux" "dired-aux.el" "4b260eda371d319a6c8e8e5ec917e287") ;;; Generated autoloads from dired-aux.el (autoload 'dired-diff "dired-aux" "\ Compare file at point with file FILE using `diff'. -FILE defaults to the file at the mark. (That's the mark set by -\\[set-mark-command], not by Dired's \\[dired-mark] command.) -The prompted-for FILE is the first file given to `diff'. +If called interactively, prompt for FILE; if the file at point +has a backup file, use that as the default. + +FILE is the first file given to `diff'. With prefix arg, prompt for second argument SWITCHES, which is the string of command switches for `diff'. -- 2.20.1