I would like to drag and drop an image file into an emacs buffer and make the filename appear instead of the image. Is this possible?

1 Answer 1

(setq dnd-protocol-alist '(("^file:" . dnd-insert-filename)))

(defun dnd-insert-filename (uri _action)
  (insert (dnd-get-local-file-name uri)))

I learnt the dnd-protocol-alist user option from Elisp manual: (elisp) Drag and Drop and read its docstring to know how to customize its value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.