From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: dired-dwim-target-directory (was: find-file-read-args) Date: Tue, 17 Nov 2009 19:43:54 +0200 Organization: JURTA Message-ID: <87d43h84n9.fsf_-_@mail.jurta.org> References: <3b31caf90911051613w80af4cu61352a29ce5dcd77@mail.gmail.com> <87vdhoe73d.fsf@mail.jurta.org> <87y6mkb6qr.fsf@mail.jurta.org> <87bpjfiark.fsf@mail.jurta.org> <871vk8uo0q.fsf@mail.jurta.org> <87ocn8ayrw.fsf@mail.jurta.org> <4AFBE741.1040506@gmx.at> <87tyx05849.fsf@mail.jurta.org> <871vjz27lw.fsf@mail.jurta.org> <4B003A50.30601@gmx.at> <4B025430.1010204@gmx.at> <87my2ljxun.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258480815 22796 80.91.229.12 (17 Nov 2009 18:00:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2009 18:00:15 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 17 19:00:07 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NASLW-0001Dy-At for ged-emacs-devel@m.gmane.org; Tue, 17 Nov 2009 19:00:06 +0100 Original-Received: from localhost ([127.0.0.1]:33207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NASLV-0003eu-P5 for ged-emacs-devel@m.gmane.org; Tue, 17 Nov 2009 13:00:05 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NASKd-00035G-Bt for emacs-devel@gnu.org; Tue, 17 Nov 2009 12:59:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NASKY-000324-So for emacs-devel@gnu.org; Tue, 17 Nov 2009 12:59:11 -0500 Original-Received: from [199.232.76.173] (port=53329 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NASKY-00031t-MH for emacs-devel@gnu.org; Tue, 17 Nov 2009 12:59:06 -0500 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:38768 helo=mx1.starman.ee) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NASKY-0007Jn-0n for emacs-devel@gnu.org; Tue, 17 Nov 2009 12:59:06 -0500 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.30.92.cable.starman.ee [82.131.30.92]) by mx1.starman.ee (Postfix) with ESMTP id B59803F4152 for ; Tue, 17 Nov 2009 19:58:59 +0200 (EET) In-Reply-To: <87my2ljxun.fsf@mail.jurta.org> (Juri Linkov's message of "Tue, 17 Nov 2009 11:59:36 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117111 Archived-At: There are some other minibuffer prompts that suffer from the lack of the directory names of other Dired windows in the default values. Trying to compare files in Dired with a directory in another Dired window on the same frame using `ediff-files', `dired-diff', `dired-compare-directories' was troublesome until now. The following patch adds directories from other Dired windows to the default values. Index: lisp/dired-aux.el =================================================================== RCS file: /sources/emacs/emacs/lisp/dired-aux.el,v retrieving revision 1.197 diff -c -r1.197 dired-aux.el *** lisp/dired-aux.el 13 Nov 2009 22:19:50 -0000 1.197 --- lisp/dired-aux.el 17 Nov 2009 17:43:00 -0000 *************** *** 59,88 **** With prefix arg, prompt for second argument SWITCHES, which is options for `diff'." (interactive ! (let ((current (dired-get-filename t)) ! (default (if (mark t) ! (save-excursion (goto-char (mark t)) ! (dired-get-filename t t))))) ! (if (or (equal default current) ! (and (not (equal (dired-dwim-target-directory) ! (dired-current-directory))) ! (not mark-active))) ! (setq default nil)) (require 'diff) ! (list (read-file-name (format "Diff %s with%s: " ! current ! (if default ! (concat " (default " default ")") ! "")) ! (if default ! (dired-current-directory) ! (dired-dwim-target-directory)) ! default t) ! (if current-prefix-arg ! (read-string "Options for diff: " ! (if (stringp diff-switches) ! diff-switches ! (mapconcat 'identity diff-switches " "))))))) (diff file (dired-get-filename t) switches)) ;;;###autoload --- 59,85 ---- With prefix arg, prompt for second argument SWITCHES, which is options for `diff'." (interactive ! (let* ((current (dired-get-filename t)) ! (target-dir (dired-dwim-target-directory)) ! (marked (and (mark t) (save-excursion ! (goto-char (mark t)) ! (dired-get-filename nil t)))) ! (defaults ! (append (dired-do-create-files-defaults nil target-dir) ! ;; Additional file with the mark. ! (and marked (list marked))))) (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: " current) target-dir nil t)) ! (if current-prefix-arg ! (read-string "Options for diff: " ! (if (stringp diff-switches) ! diff-switches ! (mapconcat 'identity diff-switches " "))))))) (diff file (dired-get-filename t) switches)) ;;;###autoload *************** *** 128,138 **** (not (and (= (nth 2 fa1) (nth 2 fa2)) - mark files with different UID (= (nth 3 fa1) (nth 3 fa2)))) and GID." (interactive ! (list (read-directory-name (format "Compare %s with: " ! (dired-current-directory)) ! (dired-dwim-target-directory) ! (dired-dwim-target-directory)) ! (read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil"))) (let* ((dir1 (dired-current-directory)) (file-alist1 (dired-files-attributes dir1)) (file-alist2 (dired-files-attributes dir2)) --- 125,141 ---- (not (and (= (nth 2 fa1) (nth 2 fa2)) - mark files with different UID (= (nth 3 fa1) (nth 3 fa2)))) and GID." (interactive ! (list ! (let* ((target-dir (dired-dwim-target-directory)) ! (defaults (dired-do-create-files-defaults nil target-dir))) ! (minibuffer-with-setup-hook ! (lambda () ! (set (make-local-variable 'minibuffer-default-add-function) nil) ! (setq minibuffer-default defaults)) ! (read-directory-name (format "Compare %s with: " ! (dired-current-directory)) ! target-dir target-dir t))) ! (read-from-minibuffer "Mark if (lisp expr or RET): " nil nil t nil "nil"))) (let* ((dir1 (dired-current-directory)) (file-alist1 (dired-files-attributes dir1)) (file-alist2 (dired-files-attributes dir2)) Index: lisp/ediff-util.el =================================================================== RCS file: /sources/emacs/emacs/lisp/ediff-util.el,v retrieving revision 1.99 diff -c -r1.99 ediff-util.el *** lisp/ediff-util.el 13 Nov 2009 22:19:50 -0000 1.99 --- lisp/ediff-util.el 17 Nov 2009 17:43:23 -0000 *************** *** 3113,3133 **** (if (string= default-file "") (setq default-file nil)) ! (let (f) ! (setq f (expand-file-name ! (read-file-name ! (format "%s%s " ! prompt ! (cond (default-file ! (concat " (default " default-file "):")) ! (t (concat " (default " default-dir "):")))) ! default-dir ! (or default-file default-dir) ! t ; must match, no-confirm ! (if default-file (file-name-directory default-file)) ! ) ! default-dir ! )) ;; If user entered a directory name, expand the default file in that ;; directory. This allows the user to enter a directory name for the ;; B-file and diff against the default-file in that directory instead --- 3113,3134 ---- (if (string= default-file "") (setq default-file nil)) ! (let ((defaults (dired-do-create-files-defaults ! nil (dired-dwim-target-directory))) ! f) ! (setq f (minibuffer-with-setup-hook ! (lambda () (setq minibuffer-default defaults)) ! (read-file-name ! (format "%s%s " ! prompt ! (cond (default-file ! (concat " (default " default-file "):")) ! (t (concat " (default " default-dir "):")))) ! default-dir ! (or default-file default-dir) ! t ; must match, no-confirm ! (if default-file (file-name-directory default-file))))) ! (setq f (expand-file-name f default-dir)) ;; If user entered a directory name, expand the default file in that ;; directory. This allows the user to enter a directory name for the ;; B-file and diff against the default-file in that directory instead -- Juri Linkov http://www.jurta.org/emacs/