Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non image files open new buffer #203

Open
basaran opened this issue Jun 27, 2022 · 0 comments
Open

non image files open new buffer #203

basaran opened this issue Jun 27, 2022 · 0 comments

Comments

@basaran
Copy link

basaran commented Jun 27, 2022

Hello,

I'm using doom emacs with org-download enabled. Everything is fine, except when you drag and drop a non-image file, it inserts the link into the org document but also opens the file in a new buffer.

I'm new to lisp, and after some digging, I found the org-download-dnd-fallback function, which sends the event back to the dnd-protocol-alist after removing itself in a closure or something.

So, I tried to find a way to stop that from happening, and I made a modified dnd handler. But I think it might make it more consistent if you could stop that from happening within the boundaries of org-download as the link gets inserted anyway.

(setq dnd-protocol-alist
      '(
        ("^data:" . org-download-dnd-base64)
        ("^\\(?:https?\\|ftp\\|file\\|nfs\\):" . org-download-dnd)
        ;; stopper
        ("^file:///" . org-download-dnd-stop)
        ("^file:///" . dnd-open-local-file)
        ("^file://" . dnd-open-file)
        ("^file:" . dnd-open-local-file)
        ("^\\(https?\\|ftp\\|file\\|nfs\\)://" . dnd-open-file)))

;; stopper function
(defun org-download-dnd-stop (uri action)
  (cond ((not (eq major-mode 'org-mode))
         (let ((dnd-protocol-alist
                (rassq-delete-all
                 'org-download-dnd-stop
                 (copy-alist dnd-protocol-alist))))
           (dnd-handle-one-url nil action uri)))))

What do you think? Perhaps, I handled this from the wrong angle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant