org-download
org-download copied to clipboard
Integration with emacs 29 and native drag and drop support
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.
same question...
To make org-download work, add the code in init.el:
(add-hook 'org-mode-hook
(lambda ()
(kill-local-variable 'dnd-protocol-alist)))