emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] org-attach: Allow attaching file from visited buffer


From: Nicolas Goaziou
Subject: Re: [O] [PATCH] org-attach: Allow attaching file from visited buffer
Date: Fri, 02 Nov 2018 10:24:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

Eric Danan <address@hidden> 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 <b> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]