From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] org-attach: Allow attaching file from visited buffer Date: Fri, 02 Nov 2018 10:24:40 +0100 Message-ID: <87bm77al2f.fsf@nicolasgoaziou.fr> References: <87y3f8cfal.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIVh9-00065p-QA for emacs-orgmode@gnu.org; Fri, 02 Nov 2018 05:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIVh6-0000BH-ET for emacs-orgmode@gnu.org; Fri, 02 Nov 2018 05:24:47 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:54741) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gIVh6-0000Ae-3y for emacs-orgmode@gnu.org; Fri, 02 Nov 2018 05:24:44 -0400 In-Reply-To: (Eric Danan's message of "Mon, 25 Jun 2018 15:04:11 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Eric Danan Cc: emacs-orgmode@gnu.org Hello, Eric Danan writes: > Sorry for the slow reply. Sorry for the even slower reply. > I tried something similar to your second proposal (mimicking > `org-attach-dired-to-subtree'), but more convenient in my opinion and > not losing the method choice. It mimicks the mechanism to store links: > there is a new command `org-store-attachment' (to which one could give > a global keybinding such as `C-c a`) that stores an attachment to the > current buffer in a new variable `org-stored-attachments', and > `org-attach-attach', when called interactively, prompts to select an > attachment from this variable if it is non nil (the attachment is then > removed from the variable). See attached patch (yes I've signed the > FSF papers). > > "Storing an attachment" simply means storing the buffer file name or, > if there is none, the buffer name, to the variable (there may be a > better terminology for that). Then `org-attach-attach' detects if the > "file" is actually the name of a non-file-visiting buffer and uses > `write-file' rather than the specified or default method in that case. > So we keep the method choice and don't need to add a specific command > for buffers to the dispatcher. If you think it's not worth introducing > complications for allowing to attach non-file-visiting buffers, we > could simply prevent this in `org-store-attachment'. I also made it so > that if `org-store-attachment' is called from a dired buffer, then the > file at point is stored rather than the dired buffer itself. This sounds interesting, but I have the feeling that would be a bit complicated in practice. I assume that when you want to attach a document to a node, you're already at the node. Ideally, it should be possible to attach something in one step from here. With your proposal, you need to first mark a buffer as an attachment, then go back to the node and attach it properly. Moreover, when you marked something as an attachment, changed your mind, and now want to attach something else, `org-store-attachment' prevents from doing this. The variable shadows other options when it is non-nil. There are also issues, e.g., what happens if the buffer marked as an attachment has been killed? > This can certainly be improved, but I hope it is sufficient for you to > judge whether you think it is a good idea or not. I eventually added, in "next" branch (Org 9.3), something much simpler. Pressing from the attach dispatcher offers to choose a buffer from the list of active buffers, and save its contents to a file in the attachment directory. Does it suit your needs? > - We could add a mechanism for making `org-attach-attach' > unconditionally read a file name, ignoring `org-stored-attachments' > (i.e. a prefix argument, distinct from the one to visit the attachment > directory). We could also add a command to clear > `org-stored-attachments' from the dispatcher. That would solve second problem, but not the others. > I understand that other users may not like this mechanism and prefer > different solutions (or leaving things as they are). There was a > recent suggestion to make the list of commands in the attachment > dispatcher customizable: > > http://lists.gnu.org/archive/html/emacs-orgmode/2018-06/msg00139.html > > Do you think it would make sense to do so? It could make sense to allow customizing attachment actions, if anyone wants try implementing it. Thank you for your work and for the ideas! Regards, -- Nicolas Goaziou