Function: x-dnd-handle-direct-save

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

Signature

(x-dnd-handle-direct-save SELECTION TYPE VALUE)

Documentation

Handle a selection request for XdndDirectSave.

Source Code

;; Defined in /usr/src/emacs/lisp/x-dnd.el.gz
(defun x-dnd-handle-direct-save (_selection _type _value)
  "Handle a selection request for `XdndDirectSave'."
  (setq x-dnd-xds-performed t)
  (let* ((uri (x-window-property "XdndDirectSave0"
                                 x-dnd-xds-source-frame
                                 "AnyPropertyType" nil t))
         (local-file-uri (if (and (string-match "^file://\\([^/]*\\)" uri)
                                  (not (equal (match-string 1 uri) "")))
                             (dnd-get-local-file-uri uri)
                           uri))
         (local-name (and local-file-uri
                          (dnd-get-local-file-name local-file-uri))))
    (if (not local-name)
        '(STRING . "F")
      ;; We want errors to be signaled immediately during ERT
      ;; testing, instead of being silently handled.  (bug#56712)
      (if x-dnd-xds-testing
          (prog1 '(STRING . "S")
            (copy-file x-dnd-xds-current-file
                       local-name t)
            (when (equal x-dnd-xds-current-file
                         dnd-last-dragged-remote-file)
              (dnd-remove-last-dragged-remote-file)))
        (condition-case nil
            (progn
              (copy-file x-dnd-xds-current-file
                         local-name t)
              (when (equal x-dnd-xds-current-file
                           dnd-last-dragged-remote-file)
                (dnd-remove-last-dragged-remote-file)))
          (:success '(STRING . "S"))
          (error '(STRING . "E")))))))