From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.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 cNVWHcEYD2XiQQEA9RJhRA:P1 (envelope-from ) for ; Sat, 23 Sep 2023 18:56:33 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cNVWHcEYD2XiQQEA9RJhRA (envelope-from ) for ; Sat, 23 Sep 2023 18:56:33 +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 30CF540AC7 for ; Sat, 23 Sep 2023 18:56:33 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KhoF2FU9; 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=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1695488193; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=crtB9hotMP163u7oWS74lngu+JQMVeTKOxkPPrJe53g=; b=RmL+f9tEH2zFIDD8rZaQojlrjQOqhwLwupRCNLUPvbxXGgNwJJyZRofZbN4eTwgW59PiF1 Pwvhkq3FTwxyc1rA4BZGAzOKK297UpWTAWO069A5ZZwJphmr/BLAa5MtyMN7XpxxjizJhT 5G4br6+298S77lAwsVYz3sD8Ede5bYNlVrT1S+acOLmXs3W3IWYmRV4KPx9kh+DLFC7Bv9 vOlj0tOaGfS0No3FGA7oIFQilpcRnZR/LUoqH8jdB8pJ0cN3vXNYtFI+yP+59pDF0hh7h9 0W3aGKmLoAy6kNpLCXUBsRCHkBEBFePIGiydSCKJwpgW7dyQCznay53ZeQvyQA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1695488193; a=rsa-sha256; cv=none; b=Na4MNzqf409T8fzm6tLkEf2BOUn9YrBV6YzZ7IB0tSOHqCQRVDmVZFX3ssEU2W0tv2XJoF ERsLmYEVQWSM/RIj8IVrXANJ6tEMV4fw2Xy3GyrS1LerGLkBKL0OxeWFMPO00RHNsvQtco YFuZo/Ena4jwv3Kj8CWOsaq8c9scjMDdOdQQYMEHHnALozo1kAt2z0CgW7WUZtm2KGVNFc gy+AVBuHhq11TNlOXG4/QPYb99AUaTMXrf/e+GpfJ3m/TrSGq34nDriWpRDbHwergfmhB3 CJwtcB6hBmORRX4AFI+9UaP9X2+5eKFdq9SfGjMxOcU/othMS8tZ1H/ob+7ilg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KhoF2FU9; 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=pass (policy=none) header.from=gmail.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qk5uw-0002uI-6g; Sat, 23 Sep 2023 12:55:42 -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 1qk5uu-0002u5-Cy for emacs-orgmode@gnu.org; Sat, 23 Sep 2023 12:55:40 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qk5us-0002it-P8 for emacs-orgmode@gnu.org; Sat, 23 Sep 2023 12:55:40 -0400 Received: by mail-pj1-x1042.google.com with SMTP id 98e67ed59e1d1-2768239d2f3so2911127a91.1 for ; Sat, 23 Sep 2023 09:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695488137; x=1696092937; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=crtB9hotMP163u7oWS74lngu+JQMVeTKOxkPPrJe53g=; b=KhoF2FU9dJ4lyJHCLZWe0K5o20L2cQwK9NkTfVeiYwu8UWHk0uQpjaU+ESdMmpTqTz pm/kn4QNXEj9RuMbnu6yd8gEY5xOk5LCKfv5dfw08dzvMAPjC5PDOUqo7Lecq4r9voIm BR5H8Og+e82VA9iIoNHzU7QUZXbB/0y37hpEjnZcDGd0B9rEbO6SwdmLKsr+u+nNSCbn mVYkANMRPSvlq4cz26iCaAflp5VFMHs+TjGWHK/gxXpL7R/jDfR+dJi75MLpdngYOQEu eF9pk/4DBe3w2xZss0SVTwj+6I2kF76+jRau07m5Bw1EboGaoi/73x8AM/28+4To1564 SMug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695488137; x=1696092937; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=crtB9hotMP163u7oWS74lngu+JQMVeTKOxkPPrJe53g=; b=nfQW/NMeAQANHzoFuovc8k8vZ6MqMvR9gCApen5UzRjAl8hCJYlkCGtVpYyRLn47aK 3Wp0hrJGvZa7zY1etMtAAIJiiEVDQQAsU30BoCh1spi76ik+UkHsySpvwTtvYY16FTm/ hUlWjF7tEzl9JfL0A+aXQxWbXu6tnznTai8StVbETa5Ik0BEK5lSX7kBwQR2DZ4XMsxw noabBsXxuhhHev6gjyS8reD+TUdkLe0MBPXyy53MlQUu3epdFmrk9b7uGN4Pr9V6BNKO OisWk46lpcHnGD+GOnzNPXcJtr+Yf8VPs5e9DWqv8wjTfS5itBY0Y5AVUVgEYnX0bswS OX3A== X-Gm-Message-State: AOJu0YxIdAaQ892R0AXGKk7F3u+DFakOq31lgPE/J7MMs+5sfVWVUu6r wRomuU16ccNukb7x3xIGZ8w= X-Google-Smtp-Source: AGHT+IEUsMYgmAFSPBgzZB8Ls1iCsaLt7gIh9/hofy82zItL3Vs6/MgtSWAjCnFaoGyznao8358IUQ== X-Received: by 2002:a17:90a:77cb:b0:268:2164:dc93 with SMTP id e11-20020a17090a77cb00b002682164dc93mr2475786pjs.13.1695488136800; Sat, 23 Sep 2023 09:55:36 -0700 (PDT) Received: from localhost ([118.185.152.162]) by smtp.gmail.com with ESMTPSA id t11-20020a17090a024b00b0026b70d2a8a2sm654814pje.29.2023.09.23.09.55.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:55:36 -0700 (PDT) From: Visuwesh To: Ihor Radchenko 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: <87lecx2nff.fsf@localhost> (Ihor Radchenko's message of "Sat, 23 Sep 2023 10:28:52 +0000") References: <87jzsintv0.fsf@gmail.com> <87lecx2nff.fsf@localhost> Date: Sat, 23 Sep 2023 22:25:33 +0530 Message-ID: <87bkdsomm2.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::1042; envelope-from=visuweshm@gmail.com; helo=mail-pj1-x1042.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: -6.64 X-Spam-Score: -6.64 X-Migadu-Queue-Id: 30CF540AC7 X-TUID: bcp5MaimlgX/ [=E0=AE=9A=E0=AE=A9=E0=AE=BF =E0=AE=9A=E0=AF=86=E0=AE=AA=E0=AF=8D=E0=AE=9F= =E0=AE=AE=E0=AF=8D=E0=AE=AA=E0=AE=B0=E0=AF=8D 23, 2023] Ihor Radchenko wrot= e: >> +*** 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. Yes, will do. >> ;; 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))) >> -=20=20=20=20=20=20=20 >> + > > These whitespace changes are not relevant. Sorry, I missed these sneaky changes when I made the commit. >> +;;; 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 `fb= oundp'. Of course. >> +(defcustom org-media-image-save-type 'attach > > Maybe org-yank-image-save-type? That is a better name but still doesn't inform the user that it is respected by DND too. >> +(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. Hmm, I think I prefer having a descriptive name for the file. It would aid in searching for the attachment later (in the org document, and using find & friends). We can add a user option but how should the name be auto-generated? Timestamp? I have no ideas in this regard.