Function: dnd-direct-save

dnd-direct-save is a byte-compiled function defined in dnd.el.gz.

Signature

(dnd-direct-save FILE NAME &optional FRAME ALLOW-SAME-FRAME)

Documentation

Drag FILE from FRAME, but do not treat it as an actual file.

Instead, ask the target window to insert the file with NAME. File managers will create a file in the displayed directory with the contents of FILE and the name NAME, while text editors will insert the contents of FILE in a new document named NAME.

ALLOW-SAME-FRAME means the same as in dnd-begin-file-drag. Return copy if the drop was successful, else nil.

View in manual

Probably introduced at or before Emacs version 29.1.

Source Code

;; Defined in /usr/src/emacs/lisp/dnd.el.gz
(defun dnd-direct-save (file name &optional frame allow-same-frame)
  "Drag FILE from FRAME, but do not treat it as an actual file.
Instead, ask the target window to insert the file with NAME.
File managers will create a file in the displayed directory with
the contents of FILE and the name NAME, while text editors will
insert the contents of FILE in a new document named
NAME.

ALLOW-SAME-FRAME means the same as in `dnd-begin-file-drag'.
Return `copy' if the drop was successful, else nil."
  (setq file (expand-file-name file))
  (cond ((eq window-system 'x)
         (when (x-dnd-do-direct-save file name frame
                                     allow-same-frame)
           'copy))
        ;; Avoid infinite recursion.
        (t (let ((dnd-direct-save-remote-files nil))
             (dnd-begin-file-drag file frame nil allow-same-frame)))))