emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Feature Request: attach link type
@ 2011-02-16 20:39 Darlan Cavalcante Moreira
  2011-03-03 10:18 ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-02-16 20:39 UTC (permalink / raw)
  To: Orgmode Mailing List


Hello List,

One org-mode feature that I find extremely useful is org-attach. I use it
frequently as an easy way to store files associated with a task (in fact,
any sub-tree) without worrying too much about where the files are located
(for some specific sub-trees I like to set the attach directory).

However, sometimes I need to put a link to an attached file in the text in
its sub-tree. Up to now I just used the path to the file, but that required
me to locate where the file is located in order to insert the link. This is
not a lot of work, but destroys the beauty of attached files, IMHO, and I
think some "attach link type" would be a better solution.

Using the functions already provided by org-attach I could get
#+LINK: attach elisp:(org-open-file (org-attach-expand "%s"))
However, I always have to confirm the execution of the elisp code. It would
be better if this link type was already provided in org (possible when
org-attach is loaded). Besides, org inline images should work with this
link type.


Other useful things (just random thoughts) could be:
 - Perform some operation when a file is attached, such as replacing
   white-spaces in the file-name by underscores
 - When a file is attached a link to it could be stored in the kill ring,
   in case the user want to insert it in the current text. Alternatively,
   an interactive function to insert a link to an attached file (using the
   same completions we already get for opening attached files) would also
   be very handy.

--
Darlan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: attach link type
  2011-02-16 20:39 Feature Request: attach link type Darlan Cavalcante Moreira
@ 2011-03-03 10:18 ` Bastien
  2011-03-04 18:10   ` Darlan Cavalcante Moreira
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-03-03 10:18 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: Orgmode Mailing List

Hi Darlan,

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:

> Using the functions already provided by org-attach I could get
> #+LINK: attach elisp:(org-open-file (org-attach-expand "%s"))
> However, I always have to confirm the execution of the elisp code. 

You want to set `org-confirm-elisp-link-function' to nil.

> Other useful things (just random thoughts) could be:
>  - Perform some operation when a file is attached, such as replacing
>    white-spaces in the file-name by underscores

IMHO this goes beyond what org-attach.el should do: attach files.
Besides, that would require even more confirmation steps.

>  - When a file is attached a link to it could be stored in the kill ring,
>    in case the user want to insert it in the current text. Alternatively,
>    an interactive function to insert a link to an attached file (using the
>    same completions we already get for opening attached files) would also
>    be very handy.

Yes, good idea.

From latest git, set `org-attach-store-link-p' to `t' if you want a link
to be stored in `org-stored-links' when attaching a file.

Thanks,

-- 
 Bastien

-- 
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: attach link type
  2011-03-03 10:18 ` Bastien
@ 2011-03-04 18:10   ` Darlan Cavalcante Moreira
  2011-03-04 21:56     ` Sébastien Vauban
  2011-03-05  9:14     ` Bastien
  0 siblings, 2 replies; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-03-04 18:10 UTC (permalink / raw)
  To: Bastien; +Cc: Orgmode Mailing List

At Thu, 03 Mar 2011 11:18:06 +0100,
Bastien <bzg@altern.org> wrote:
> 
> Hi Darlan,
> 
> Darlan Cavalcante Moreira <darcamo@gmail.com> writes:
> 
> > Using the functions already provided by org-attach I could get
> > #+LINK: attach elisp:(org-open-file (org-attach-expand "%s"))
> > However, I always have to confirm the execution of the elisp code. 
> 
> You want to set `org-confirm-elisp-link-function' to nil.

Thanks Bastien.

I knew there was some variable to control this for all elisp links. I would
prefer not to set this to nil, since I like the confirmation for other
elisp links and since links for attached files are common for me I thought
it could be a "built-in link". But that's OK.

> 
> > Other useful things (just random thoughts) could be:
> >  - Perform some operation when a file is attached, such as replacing
> >    white-spaces in the file-name by underscores
> 
> IMHO this goes beyond what org-attach.el should do: attach files.
> Besides, that would require even more confirmation steps.

My common use scenario for org-attach is to store files associated to a
sub-tree. For instance, when I receive a file by E-mail that I need to read
I create a task for it and attach the file. I usually need to change the
file name, since I don't like spaces and If would be practical if I could
attach the file as it is and know that org-attach would store it the way I
like. Is there a hook I could use to do this myself then? (I'm not a lisp
programmer, but think I can google tips about how to do this).

> 
> >  - When a file is attached a link to it could be stored in the kill ring,
> >    in case the user want to insert it in the current text. Alternatively,
> >    an interactive function to insert a link to an attached file (using the
> >    same completions we already get for opening attached files) would also
> >    be very handy.
> 
> Yes, good idea.
> 
> From latest git, set `org-attach-store-link-p' to `t' if you want a link
> to be stored in `org-stored-links' when attaching a file.

This is even better then storing it in the kill ring. I noticed that the
link points to the location of the original file and not to the location
where it was attached (which is what thought it would do). Is this what you
intended?

> 
> Thanks,
> 
> -- 
>  Bastien


--
Darlan

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Feature Request: attach link type
  2011-03-04 18:10   ` Darlan Cavalcante Moreira
@ 2011-03-04 21:56     ` Sébastien Vauban
  2011-03-04 22:10       ` Darlan Cavalcante Moreira
  2011-03-05  9:14     ` Bastien
  1 sibling, 1 reply; 9+ messages in thread
From: Sébastien Vauban @ 2011-03-04 21:56 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Darlan and Bastien,

Darlan Cavalcante Moreira wrote:
>> > Other useful things (just random thoughts) could be:
>> >  - Perform some operation when a file is attached, such as replacing
>> >    white-spaces in the file-name by underscores
>> 
>> IMHO this goes beyond what org-attach.el should do: attach files.
>> Besides, that would require even more confirmation steps.
>
> My common use scenario for org-attach is to store files associated to a
> sub-tree. For instance, when I receive a file by E-mail that I need to read
> I create a task for it and attach the file. I usually need to change the
> file name, since I don't like spaces and If would be practical if I could
> attach the file as it is and know that org-attach would store it the way I
> like. Is there a hook I could use to do this myself then? (I'm not a lisp
> programmer, but think I can google tips about how to do this).

Just to comment on that point: reworking the filename is exactly what Gnus do
with attachment files, once you want to save them. It (optionally) do whatever
is needed to make them better, such as removing spaces, replacing accents,
etc...

Best regards,
  Seb

-- 
Sébastien Vauban

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Feature Request: attach link type
  2011-03-04 21:56     ` Sébastien Vauban
@ 2011-03-04 22:10       ` Darlan Cavalcante Moreira
  0 siblings, 0 replies; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-03-04 22:10 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode


I once tried Gnus, but end up using Wanderlust, which is pretty good. Along
with org-contacts I'm becoming more and more motivated to try Gnus again. I
try to have a look at it. Thanks.


At Fri, 04 Mar 2011 22:56:41 +0100,
Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
> 
> Hi Darlan and Bastien,
> 
> Darlan Cavalcante Moreira wrote:
> >> > Other useful things (just random thoughts) could be:
> >> >  - Perform some operation when a file is attached, such as replacing
> >> >    white-spaces in the file-name by underscores
> >> 
> >> IMHO this goes beyond what org-attach.el should do: attach files.
> >> Besides, that would require even more confirmation steps.
> >
> > My common use scenario for org-attach is to store files associated to a
> > sub-tree. For instance, when I receive a file by E-mail that I need to read
> > I create a task for it and attach the file. I usually need to change the
> > file name, since I don't like spaces and If would be practical if I could
> > attach the file as it is and know that org-attach would store it the way I
> > like. Is there a hook I could use to do this myself then? (I'm not a lisp
> > programmer, but think I can google tips about how to do this).
> 
> Just to comment on that point: reworking the filename is exactly what Gnus do
> with attachment files, once you want to save them. It (optionally) do whatever
> is needed to make them better, such as removing spaces, replacing accents,
> etc...
> 
> Best regards,
>   Seb
> 
> -- 
> Sébastien Vauban
> 
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: attach link type
  2011-03-04 18:10   ` Darlan Cavalcante Moreira
  2011-03-04 21:56     ` Sébastien Vauban
@ 2011-03-05  9:14     ` Bastien
  2011-03-09 18:23       ` Darlan Cavalcante Moreira
  1 sibling, 1 reply; 9+ messages in thread
From: Bastien @ 2011-03-05  9:14 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: Orgmode Mailing List

Hi Darlan,

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:

> I knew there was some variable to control this for all elisp links. I would
> prefer not to set this to nil, since I like the confirmation for other
> elisp links and since links for attached files are common for me I thought
> it could be a "built-in link". But that's OK.

I just introduced `org-confirm-elisp-link-not-regexp' which allows the
user to avoid confirmation step for elisp code matching a regexp.  Hope
that helps in your case.

> My common use scenario for org-attach is to store files associated to a
> sub-tree. For instance, when I receive a file by E-mail that I need to read
> I create a task for it and attach the file. I usually need to change the
> file name, since I don't like spaces and If would be practical if I could
> attach the file as it is and know that org-attach would store it the way I
> like. Is there a hook I could use to do this myself then? (I'm not a lisp
> programmer, but think I can google tips about how to do this).

I've been working a bit on your idea, it's possible to create a function
and to use it to rename a file when the user is attaching it - but there
are problems: for example, if this function changes, then there will be
*several* attachements for the same file...  we don't want that.

So, renaming the file belongs elsewhere IMHO.

>> >  - When a file is attached a link to it could be stored in the kill ring,
>> >    in case the user want to insert it in the current text. Alternatively,
>> >    an interactive function to insert a link to an attached file (using the
>> >    same completions we already get for opening attached files) would also
>> >    be very handy.
>> 
>> Yes, good idea.
>> 
>> From latest git, set `org-attach-store-link-p' to `t' if you want a link
>> to be stored in `org-stored-links' when attaching a file.
>
> This is even better then storing it in the kill ring. I noticed that the
> link points to the location of the original file and not to the location
> where it was attached (which is what thought it would do). Is this what you
> intended?

Yes.  Since the file is now also available as an attachment, a link to
the source file might be useful, while a link to the attached file is a
bit redundant with what org-attach allows you to do (get the file).

Does that make sense?

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Feature Request: attach link type
  2011-03-05  9:14     ` Bastien
@ 2011-03-09 18:23       ` Darlan Cavalcante Moreira
  2011-03-10 10:24         ` Bastien
  0 siblings, 1 reply; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-03-09 18:23 UTC (permalink / raw)
  To: Bastien; +Cc: Orgmode Mailing List

At Sat, 05 Mar 2011 10:14:17 +0100,
Bastien <bzg@altern.org> wrote:

Hello Bastien,

Sorry for the late reply. For some reason (path related) Emacs was loading
an older version of org instead of the one from git and I wasn't seeing your
changes.

>
> Hi Darlan,
> 
> Darlan Cavalcante Moreira <darcamo@gmail.com> writes:
> 
> > I knew there was some variable to control this for all elisp links. I would
> > prefer not to set this to nil, since I like the confirmation for other
> > elisp links and since links for attached files are common for me I thought
> > it could be a "built-in link". But that's OK.
> 
> I just introduced `org-confirm-elisp-link-not-regexp' which allows the
> user to avoid confirmation step for elisp code matching a regexp.  Hope
> that helps in your case.
>

I tested this and it works perfectly. Thanks!

> > My common use scenario for org-attach is to store files associated to a
> > sub-tree. For instance, when I receive a file by E-mail that I need to read
> > I create a task for it and attach the file. I usually need to change the
> > file name, since I don't like spaces and If would be practical if I could
> > attach the file as it is and know that org-attach would store it the way I
> > like. Is there a hook I could use to do this myself then? (I'm not a lisp
> > programmer, but think I can google tips about how to do this).
> 
> I've been working a bit on your idea, it's possible to create a function
> and to use it to rename a file when the user is attaching it - but there
> are problems: for example, if this function changes, then there will be
> *several* attachements for the same file...  we don't want that.
> 
> So, renaming the file belongs elsewhere IMHO.

I understand. I may be using org-attach in a way a little different from
what it was originally intended to.

> 
> >> >  - When a file is attached a link to it could be stored in the kill ring,
> >> >    in case the user want to insert it in the current text. Alternatively,
> >> >    an interactive function to insert a link to an attached file (using the
> >> >    same completions we already get for opening attached files) would also
> >> >    be very handy.
> >> 
> >> Yes, good idea.
> >> 
> >> From latest git, set `org-attach-store-link-p' to `t' if you want a link
> >> to be stored in `org-stored-links' when attaching a file.
> >
> > This is even better then storing it in the kill ring. I noticed that the
> > link points to the location of the original file and not to the location
> > where it was attached (which is what thought it would do). Is this what you
> > intended?
> 
> Yes.  Since the file is now also available as an attachment, a link to
> the source file might be useful, while a link to the attached file is a
> bit redundant with what org-attach allows you to do (get the file).
> 
> Does that make sense?
>
> Thanks,
> 
> -- 
>  Bastien

I think yes and no, depending on what the user wants to do.

I my case I use org-attach as a way to store files related to org that *I
don't need to access outside org-mode*. For files that I access outside
org-mode I don't attach it at all. I just use links to the file when I need
to. Therefore I almost always delete the original file after attaching it
and that's why IMHO the stored link should point to the location where the
file was attached to.

Again, maybe I'm just using org-attach in a way a little different from
what it was originally intended to. That's why for me It makes sense to
create an attach link type.

--
Darlan Cavalcante

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Feature Request: attach link type
  2011-03-09 18:23       ` Darlan Cavalcante Moreira
@ 2011-03-10 10:24         ` Bastien
  2011-03-10 14:52           ` Darlan Cavalcante Moreira
  0 siblings, 1 reply; 9+ messages in thread
From: Bastien @ 2011-03-10 10:24 UTC (permalink / raw)
  To: Darlan Cavalcante Moreira; +Cc: Orgmode Mailing List

Hi Darlan,

Darlan Cavalcante Moreira <darcamo@gmail.com> writes:

> I think yes and no, depending on what the user wants to do.
>
> I my case I use org-attach as a way to store files related to org that *I
> don't need to access outside org-mode*. For files that I access outside
> org-mode I don't attach it at all. I just use links to the file when I need
> to. Therefore I almost always delete the original file after attaching it
> and that's why IMHO the stored link should point to the location where the
> file was attached to.
>
> Again, maybe I'm just using org-attach in a way a little different from
> what it was originally intended to. That's why for me It makes sense to
> create an attach link type.

Thanks for the explanations -- I've now allowed org-attach-store-link-p
to be set to 'attached so that the link points to the attached location
instead of the original location.

Let me know if it does the right thing for you.

Best,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Re: Feature Request: attach link type
  2011-03-10 10:24         ` Bastien
@ 2011-03-10 14:52           ` Darlan Cavalcante Moreira
  0 siblings, 0 replies; 9+ messages in thread
From: Darlan Cavalcante Moreira @ 2011-03-10 14:52 UTC (permalink / raw)
  To: Bastien; +Cc: Orgmode Mailing List


Thank you Bastien.
It works as expected.

--
Darlan

At Thu, 10 Mar 2011 11:24:26 +0100,
Bastien <bzg@altern.org> wrote:
> 
> Hi Darlan,
> 
> Darlan Cavalcante Moreira <darcamo@gmail.com> writes:
> 
> > I think yes and no, depending on what the user wants to do.
> >
> > I my case I use org-attach as a way to store files related to org that *I
> > don't need to access outside org-mode*. For files that I access outside
> > org-mode I don't attach it at all. I just use links to the file when I need
> > to. Therefore I almost always delete the original file after attaching it
> > and that's why IMHO the stored link should point to the location where the
> > file was attached to.
> >
> > Again, maybe I'm just using org-attach in a way a little different from
> > what it was originally intended to. That's why for me It makes sense to
> > create an attach link type.
> 
> Thanks for the explanations -- I've now allowed org-attach-store-link-p
> to be set to 'attached so that the link points to the attached location
> instead of the original location.
> 
> Let me know if it does the right thing for you.
> 
> Best,
> 
> -- 
>  Bastien

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-03-10 14:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 20:39 Feature Request: attach link type Darlan Cavalcante Moreira
2011-03-03 10:18 ` Bastien
2011-03-04 18:10   ` Darlan Cavalcante Moreira
2011-03-04 21:56     ` Sébastien Vauban
2011-03-04 22:10       ` Darlan Cavalcante Moreira
2011-03-05  9:14     ` Bastien
2011-03-09 18:23       ` Darlan Cavalcante Moreira
2011-03-10 10:24         ` Bastien
2011-03-10 14:52           ` Darlan Cavalcante Moreira

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).