org-download icon indicating copy to clipboard operation
org-download copied to clipboard

Integration with emacs 29 and native drag and drop support

Open vonpupp opened this issue 1 year ago • 3 comments
trafficstars

Hello,

I used this for a while flawlessly integrated with org-roam (I am not sure where I got the config snippet). The idea is: my org-roam home is in ~/org/exobrain. That directory is managed by git and text files only. I have another folder for the attachments: ~/org-media.

When I dragged anything into an org roam buffer titled for example "Books to read", then a folder under ~/org-media would be created with the buffer filename as the name of the folder, for instance ~/org-media/20200822194657-books_to_read/ and the file would be copied there.

That is the exact behavior that I would want to continue with but now with the native drag and drop support added to emacs 29, org-download doesn't seem to work anymore.

Here is my actual config that used to work:

(use-package! org-download
  :after org
  :commands
  org-download-dnd
  org-download-yank
  org-download-screenshot
  org-download-dnd-base64
  :init
  (map! :map org-mode-map
        "s-<print>" #'org-download-screenshot
        "s-y" #'org-download-yank)
  (pushnew! dnd-protocol-alist
            '("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd)
            '("^data:" . org-download-dnd-base64))
  (advice-add #'org-download-enable :override #'ignore)

  (after! org
    ;; A shorter link to attachments
    (+org-define-basic-link "download" (lambda () (or org-download-image-dir org-attach-id-dir "."))
      :image-data-fun #'+org-image-file-data-fn
      :requires 'org-download)
    (org-add-link-type "xdg" (lambda (path) (browse-url-xdg-open path))))
  :config
  (defun +org/org-download-method (link)
    (let* ((filename
            (file-name-nondirectory
             (car (url-path-and-query
                   (url-generic-parse-url link)))))
           ;; Create folder name with current buffer name, and place in root dir
           (dirname (concat "~/org-media/"
                            (replace-regexp-in-string " " "_"
                                                      (downcase (file-name-base buffer-file-name))))))
      (make-directory dirname t)
      (expand-file-name filename dirname)))
  (setq org-download-screenshot-method
        (cond (IS-MAC "screencapture -i %s")
              (IS-LINUX
               ;(cond ((executable-find "maim")  "maim -u -s %s")
               (cond ;((executable-find "flameshot")  "flameshot gui --raw > %s")
                     ((executable-find "scrot") "scrot -s %s")))))
  (setq org-download-method '+org/org-download-method)
  )

Any ideas/help please? Thank you.

vonpupp avatar Jan 14 '24 15:01 vonpupp

same question...

sovereignyy99 avatar Jan 26 '24 14:01 sovereignyy99

To make org-download work, add the code in init.el:

(add-hook 'org-mode-hook
	  (lambda ()
	    (kill-local-variable 'dnd-protocol-alist)))

cuprum avatar Jun 13 '24 09:06 cuprum