lisp/org-attach.el (org-attach-attach): Add dired-dwim-target-directory

Use case: have two windows open side-by-side. One has an Org-mode
file, the other - a Dired buffer with a file we want to attach.

With this change, and user's `dired-dwim-target' setting, the prompt
for file to attach will start in the Dired buffer's directory.
This commit is contained in:
Oleh Krehel 2017-05-09 17:30:18 +02:00
parent c801ef0328
commit e23b806bd8
1 changed files with 18 additions and 10 deletions

View File

@ -375,7 +375,15 @@ Only do this when `org-attach-store-link-p' is non-nil."
If VISIT-DIR is non-nil, visit the directory with dired.
METHOD may be `cp', `mv', `ln', `lns' or `url' default taken from
`org-attach-method'."
(interactive "fFile to keep as an attachment: \nP")
(interactive
(list
(read-file-name "File to keep as an attachment:"
(or (progn
(require 'dired-aux)
(dired-dwim-target-directory))
default-directory))
current-prefix-arg
nil))
(setq method (or method org-attach-method))
(let ((basename (file-name-nondirectory file)))
(when (and org-attach-file-list-property (not org-attach-inherited))