[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dired-dwim-target-directory (was: find-file-read-args)
From: |
Juri Linkov |
Subject: |
dired-dwim-target-directory (was: find-file-read-args) |
Date: |
Tue, 17 Nov 2009 19:43:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu) |
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/
- Re: find-file-read-args, (continued)
- Re: find-file-read-args, Juri Linkov, 2009/11/09
- Re: find-file-read-args, Juri Linkov, 2009/11/12
- Re: find-file-read-args, martin rudalics, 2009/11/12
- Re: find-file-read-args, Juri Linkov, 2009/11/12
- Re: find-file-read-args, Juri Linkov, 2009/11/15
- Re: find-file-read-args, martin rudalics, 2009/11/15
- Re: find-file-read-args, Stefan Monnier, 2009/11/15
- Re: find-file-read-args, martin rudalics, 2009/11/17
- Re: find-file-read-args, Juri Linkov, 2009/11/17
- dired-dwim-target-directory (was: find-file-read-args), Juri Linkov, 2009/11/17
- dired-dwim-target-directory (was: find-file-read-args),
Juri Linkov <=
- Re: find-file-read-args, Stefan Monnier, 2009/11/22
- Re: find-file-read-args, Juri Linkov, 2009/11/23
- Re: find-file-read-args, Stefan Monnier, 2009/11/23
- Re: find-file-read-args, Juri Linkov, 2009/11/23
- Re: find-file-read-args, Stefan Monnier, 2009/11/23
- Re: find-file-read-args, Juri Linkov, 2009/11/24
- Re: find-file-read-args, Stefan Monnier, 2009/11/24
- find-file-literally (was: find-file-read-args), Juri Linkov, 2009/11/23
- Re: find-file-literally, Stefan Monnier, 2009/11/24
- M-! M-n should fetch filename (Re: FFAP), Juri Linkov, 2009/11/09