Visuwesh <visuwe...@gmail.com> writes: > The patch compiles cleanly without warnings but I haven't tested _this_ > patch yet, I have these functions in my init.el and have tested those.
Thanks for the patch! See my comments below. > +*** Images and files in clipboard can be attached > + > +Org can now attach images in clipboard and files copied/cut to the > +clipboard from file managers using the ~yank-media~ command which also > +inserts a link to the attached file. > + > +Images can be saved to a separate directory instead of being attached, > +customize ~org-media-image-save-type~. This requires Emacs 29, which should be documented. > ;; Update `customize-package-emacs-version-alist' > (add-to-list 'customize-package-emacs-version-alist > @@ -15125,20 +15128,20 @@ INCREMENT-STEP divisor." > (setq hour (mod hour 24)) > (setq pos-match-group 1 > new (format "-%02d:%02d" hour minute))) > - > + These whitespace changes are not relevant. > +;;; Yank media handler and DND > +(defun org-setup-yank-dnd-handlers () > + "Setup the `yank-media' and DND handlers for buffer." > + (setq-local dnd-protocol-alist > + (cons '("^file:///" . org--dnd-local-file-handler) > + dnd-protocol-alist)) > + (yank-media-handler "image/.*" #'org--image-yank-media-handler) This function is not yet available in Emacs <29. Need to protect with `fboundp'. > +(defcustom org-media-image-save-type 'attach Maybe org-yank-image-save-type? > +(defun org--image-yank-media-handler (mimetype data) > + "Save image DATA of mime-type MIMETYPE and insert link at point. > +It is saved as per `org-media-image-save-type'. The name for the > +image is prompted and the extension is automatically added to the > +end." > + (let* ((ext (symbol-name (mailcap-mime-type-to-extension mimetype))) > + (iname (read-string "Insert filename for image: ")) It would be nice if we auto-generate the file name here by default. It is what I would expect from yanking an image at least. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>