Function: org--copied-files-yank-media-handler

org--copied-files-yank-media-handler is a byte-compiled function defined in org.el.gz.

Signature

(org--copied-files-yank-media-handler MIMETYPE DATA)

Documentation

Handle copied or cut files from file manager.

They are handled as per org-yank-dnd-method. DATA is a string where the first line is the operation to perform: copy or cut. Rest of the lines are file: links to the concerned files.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org.el.gz
;; I cannot find a spec for this but
;; https://indigo.re/posts/2021-12-21-clipboard-data.html and pcmanfm
;; suggests that this is the format.
(defun org--copied-files-yank-media-handler (_mimetype data)
  "Handle copied or cut files from file manager.
They are handled as per `org-yank-dnd-method'.
DATA is a string where the first line is the operation to
perform: copy or cut.  Rest of the lines are file: links to the
concerned files."
  ;; pcmanfm adds a null byte at the end for some reason.
  (let* ((data (split-string data "[\0\n\r]" t))
         (files (cdr data))
         (action (if (equal (car data) "cut")
                     'copy
                   'move))
         (sep (if (= (length files) 1) "" " ")))
    (dolist (f files)
      (if (file-readable-p f)
          (org--dnd-local-file-handler f action sep)
        (message "File `%s' is not readable, skipping" f)))))