From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0Bo7B8y9DmUVTgEAG6o9tA:P1 (envelope-from ) for ; Sat, 23 Sep 2023 12:28:28 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 0Bo7B8y9DmUVTgEAG6o9tA (envelope-from ) for ; Sat, 23 Sep 2023 12:28:28 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DCDA147C28 for ; Sat, 23 Sep 2023 12:28:27 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict), No valid DKIM" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1695464907; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=bLeqEtDQ+vwR17pjglwfbIAT3PzSyBpgL1Xv9q/Wu7E=; b=pDXczHvqmvyiYnwCgiBhuptmvJaajZgjn/TnV1Icij9Ux2NpX0+vrKU5UplxMOUugsYDKF cFRmwvk1Cv9u5IK7MY6VV3H9KfRSpLNFuhc7Jt3nyraUH7R0nhvEeDfp+1SKY3ONJwhgwb KSYYMc3Elvf8qEJpFSwe87a8LPxtnA8jIp1yGvqNpgeuu0l8zvvNPqlXHN5DD09pCqSFI5 uhg3vPTeI+o1BxK6g6gKYtX6TFTjw4QiuoxBRNaLkZcCH3ExrOk0/VPovMFlYkNvnGP6dI d3tKDhMpef8chqYZJ4odGoMfXhthOywMd6Bd2xlAyD66vOxnxsRKJokUKm5nCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1695464907; a=rsa-sha256; cv=none; b=iaHphelbMUJlcsG2Ow/wVaCsHpr49Ku9A0ieyJrKZtU9L8kSMsfS5XIcR9DwwUqwsEZgfp SBJGDZeFdjJ5sntwcVwCGWP1S+7fhMZdUGx6cU7Ti0xgTwzu0Ms8jl8N7nlnsUAjOqo+WV uyDy7UZTYsMc7xpUF+wdirMn+0Zh4YEnXmo8qBWIKwNuW+dA1PTjxLN9rTdbPslHcAuwAN UXq6bKE0SMAyFYntLkOkmILA7MCFuTdb0ps0E2S2SUm2Hp/d/2brOQOIXyYP0JG206vDA6 cKmGic3GNfdYG6M5Db6lL+8RO8KVN78dicSroUA6Y596+cd5QbhmdciH6/9/ew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (strict), No valid DKIM" header.from=posteo.net (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjzra-00012g-LW; Sat, 23 Sep 2023 06:27:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjzrY-00012V-TO for emacs-orgmode@gnu.org; Sat, 23 Sep 2023 06:27:48 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qjzrW-0001mq-Ni for emacs-orgmode@gnu.org; Sat, 23 Sep 2023 06:27:48 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C9950240101 for ; Sat, 23 Sep 2023 12:27:44 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Rt51X19FLz9rxS; Sat, 23 Sep 2023 12:27:43 +0200 (CEST) From: Ihor Radchenko To: Visuwesh Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] [PATCH] Add yank-media and DND handler [9.6.7 (9.6.7-g6eb773 @ /home/viz/lib/emacs/straight/build/org/)] In-Reply-To: <87jzsintv0.fsf@gmail.com> References: <87jzsintv0.fsf@gmail.com> Date: Sat, 23 Sep 2023 10:28:52 +0000 Message-ID: <87lecx2nff.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: -5.24 X-Spam-Score: -5.24 X-Migadu-Queue-Id: DCDA147C28 X-TUID: J34yQHmGFN3c Visuwesh 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 . Support Org development at , or support my work at