diff options
author | Juri Linkov <juri@jurta.org> | 2009-11-25 17:11:29 +0000 |
---|---|---|
committer | Juri Linkov <juri@jurta.org> | 2009-11-25 17:11:29 +0000 |
commit | 7d371eac644665cdc4afcac57e7a09560e010a31 (patch) | |
tree | 668947c7530c04603a2a5372cc13156c4f96ad0e /lisp/dired.el | |
parent | 04ae543a28153fda0c084a5d56f59e2f7b12510d (diff) | |
download | emacs-7d371eac644665cdc4afcac57e7a09560e010a31.tar.gz |
Provide additional default values (file name at point or at the
current Dired line) via M-n for file reading minibuffers. (Bug#5010)
* minibuffer.el (read-file-name-defaults): New function.
(read-file-name): Reset `minibuffer-default' to nil when
it duplicates initial input `insdef'.
Bind `minibuffer-default-add-function' to lambda that
calls `read-file-name-defaults' in `minibuffer-selected-window'.
(minibuffer-insert-file-name-at-point): New command.
* files.el (file-name-at-point-functions): New defcustom.
(find-file-default): Remove defvar.
(find-file-read-args): Don't use `find-file-default'.
Move `minibuffer-with-setup-hook' that sets `minibuffer-default'
to `read-file-name'.
(find-file-literally): Use `read-file-name' with
`confirm-nonexistent-file-or-buffer'.
* ffap.el (ffap-guess-file-name-at-point): New autoloaded function.
* dired.el (dired-read-dir-and-switches):
Move `minibuffer-with-setup-hook' that sets `minibuffer-default'
to `read-file-name'.
(dired-file-name-at-point): New function.
(dired-mode): Add hook `dired-file-name-at-point' to
`file-name-at-point-functions'.
Diffstat (limited to 'lisp/dired.el')
-rw-r--r-- | lisp/dired.el | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 788c5be3289..17bb3449da9 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -599,12 +599,8 @@ Don't use that together with FILTER." (if (next-read-file-uses-dialog-p) (read-directory-name (format "Dired %s(directory): " str) nil default-directory nil) - (let ((default (and buffer-file-name - (abbreviate-file-name buffer-file-name)))) - (minibuffer-with-setup-hook - (lambda () (setq minibuffer-default default)) - (read-file-name (format "Dired %s(directory): " str) - nil default-directory nil))))))) + (read-file-name (format "Dired %s(directory): " str) + nil default-directory nil))))) ;; We want to switch to a more sophisticated version of ;; dired-read-dir-and-switches like the following, if there is a way @@ -659,6 +655,15 @@ Don't use that together with FILTER." ;; (read-file-name (format "Dired %s(directory): " str) ;; nil default-directory nil)))))))) +(defun dired-file-name-at-point () + "Try to get a file name at point in the current dired buffer. +This hook is inteneded to be put in `file-name-at-point-functions'." + (let ((filename (dired-get-filename nil t))) + (when filename + (if (file-directory-p filename) + (file-name-as-directory (abbreviate-file-name filename)) + (abbreviate-file-name filename))))) + ;;;###autoload (define-key ctl-x-map "d" 'dired) ;;;###autoload (defun dired (dirname &optional switches) @@ -1772,6 +1777,7 @@ Keybindings: (when (featurep 'dnd) (set (make-local-variable 'dnd-protocol-alist) (append dired-dnd-protocol-alist dnd-protocol-alist))) + (add-hook 'file-name-at-point-functions 'dired-file-name-at-point nil t) (add-hook 'isearch-mode-hook 'dired-isearch-filenames-setup nil t) (run-mode-hooks 'dired-mode-hook)) |