unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Chong Yidong <cyd@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: M-= in Dired
Date: Sat, 15 Sep 2012 02:45:10 +0300	[thread overview]
Message-ID: <87d31o2mw9.fsf@mail.jurta.org> (raw)
In-Reply-To: <87mx0ydelq.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 10 Sep 2012 01:20:57 +0300")

> I think it's possible to do this in dired-diff without throwing away
> useful functionality of using as default a marked file or a file in
> adjacent windows (dwim-target).  The top default value could be
> a backup file but remaining defaults could remain the same as before.

This patch keeps the new functionality of using the latest existing
backup file, and restores the original functionality of using the default
file with the mark on it and adding more defaults for dwim directories:

=== modified file 'lisp/dired-aux.el'
--- lisp/dired-aux.el	2012-09-13 23:42:39 +0000
+++ lisp/dired-aux.el	2012-09-14 23:45:05 +0000
@@ -62,17 +62,31 @@ (defun dired-diff (file &optional switch
 which is the string of command switches for `diff'."
   (interactive
    (let* ((current (dired-get-filename t))
-	  (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)
+	  ;; 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))
+					    (dired-get-filename t t))))
+	  (default-file (or file-at-mark
+			    (and oldf (file-name-nondirectory oldf))))
+	  ;; Use it as default if it's not the same as the current file.
+	  (default (if (not (equal default-file current))
+		       default-file))
+	  (defaults
+	    (if (not (equal (dired-dwim-target-directory)
+			    (dired-current-directory)))
+		(dired-dwim-target-defaults (list current)
+					    (dired-dwim-target-directory)))))
+     (list
+      (read-file-name
+       (format "Diff %s with%s: " current
+	       (if default (format " (default %s)" default) ""))
+       (if default
+	   (dired-current-directory)
+	 (dired-dwim-target-directory))
+       (delq nil (append (list default) defaults))
+       t)
 	   (if current-prefix-arg
 	       (read-string "Options for diff: "
 			    (if (stringp diff-switches)





  reply	other threads:[~2012-09-14 23:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 14:57 M-= in Dired Chong Yidong
2012-09-07 15:01 ` Lars Ingebrigtsen
2012-09-07 15:29   ` up & down keys in Dired [was: M-= in Dired] Drew Adams
2012-09-07 17:05   ` M-= in Dired Philipp Haselwarter
2012-09-07 17:14     ` up & down keys in Dired [was: M-= in Dired] Drew Adams
2012-09-07 19:21       ` Philipp Haselwarter
2012-09-07 20:42         ` Drew Adams
2012-09-08  7:11         ` Eli Zaretskii
2012-09-09  5:16           ` Stephen J. Turnbull
2012-09-08 18:01         ` Richard Stallman
2012-09-07 15:19 ` M-= in Dired Drew Adams
2012-09-07 16:40   ` chad
2012-09-07 16:51     ` Drew Adams
2012-09-08 22:04   ` Juri Linkov
2012-09-08 22:52     ` Drew Adams
2012-09-09 13:02     ` Jambunathan K
2012-09-09 22:20 ` Juri Linkov
2012-09-14 23:45   ` Juri Linkov [this message]
2012-09-19  3:15     ` Chong Yidong
2012-09-19 20:10       ` Juri Linkov
2012-09-20  4:28         ` Chong Yidong
2012-09-20 12:30           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d31o2mw9.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=cyd@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).