Function: x-dnd-save-direct
x-dnd-save-direct is a byte-compiled function defined in x-dnd.el.gz.
Signature
(x-dnd-save-direct NEED-NAME FILENAME)
Documentation
Handle dropping a file FILENAME that should be saved first, asking the user.
NEED-NAME non-nil means the caller requests the full absolute file name of FILENAME under which to save it; FILENAME is just the base name in that case. The function then prompts the user for where to save to file and returns the result to the caller.
NEED-NAME nil means the file was saved as FILENAME (which should be the full absolute file name in that case). The function then refreshes the Dired display, if the current buffer is in Dired mode, or visits the file otherwise.
This function is intended to be the value of x-dnd-direct-save-function,
which see.
Source Code
;; Defined in /usr/src/emacs/lisp/x-dnd.el.gz
(defun x-dnd-save-direct (need-name filename)
"Handle dropping a file FILENAME that should be saved first, asking the user.
NEED-NAME non-nil means the caller requests the full absolute
file name of FILENAME under which to save it; FILENAME is just
the base name in that case. The function then prompts the user
for where to save to file and returns the result to the caller.
NEED-NAME nil means the file was saved as FILENAME (which should
be the full absolute file name in that case). The function then
refreshes the Dired display, if the current buffer is in Dired
mode, or visits the file otherwise.
This function is intended to be the value of `x-dnd-direct-save-function',
which see."
(if need-name
(let ((file-name (read-file-name "Write file: "
default-directory
nil nil filename)))
(when (file-exists-p file-name)
(unless (y-or-n-p (format-message
"File `%s' exists; overwrite? " file-name))
(setq file-name nil)))
file-name)
;; TODO: move this to dired.el once a platform-agonistic
;; interface can be found.
(if (derived-mode-p 'dired-mode)
(revert-buffer)
(find-file filename))))