[O] org-store-link programmatically?

2013-11-01 Thread David Belohrad

Dear all,

i want to write a piece of code as a 'template', which generates TODO
using capture template, and inserts into the todo a LINK TO THE
LOCATION, from which I have called the org-capture.

the main usage for me is basically when I get email message (notmuch),
to generate a journal entry with some comments and at the end of this
entry a link to that email.

I thought like defining a function like this one:

  (defun org-notmuch-copymail ()
(interactive)
(org-store-link)
;; some code to get the link into the yank buffer
(org-capture nil c))
 
where the 'c' template is defined as follows:

(c Global todo entry with clipboard content entry (file+headline (concat 
my-org-files gtd.org) Tasks)
* TODO %?\n:LOGBOOK:\n%c\n:END:\n)

The trouble #1 I have is a call to (org-store-link), which always fails,
because it requires 'an argument' I have a hard time to find which one.

One of the options I was considering was as well to 'construct' the link
myself. That requires some 'generalization' as I would have to detect
(somehow) what type of buffer it is. As filelinks:

[[mylink.png][sometext]]

are different from notmuch links:

[[notmuch:id:75a7a46b727b42dca8c70b1c64db0...@cernfe23.cern.ch][email]]


Any ideas how to solve this?

As a bonus question: I've noticed, that when I store link, and then
paste it, it pastes the files using absolute paths. I would very much
prefer relative paths. Is there any way how to change this behaviour?

many thanks

david



Re: [O] org-store-link programmatically?

2013-11-01 Thread Josiah Schwab
Hi David,

 i want to write a piece of code as a 'template', which generates TODO
 using capture template, and inserts into the todo a LINK TO THE
 LOCATION, from which I have called the org-capture.

Have you looked at 9.1.3 Capture templates in the documentation?
http://orgmode.org/manual/Capture-templates.html

It seems to me that the example TODO entry given (using %a in the
template) will do what you describe:

,
| During expansion of the template, %a has been replaced by a link to
| the location from where you called the capture command. This can be
| extremely useful for deriving tasks from emails, for example.
`

Best,
Josiah



Re: [O] org-store-link programmatically?

2013-11-01 Thread David Belohrad
Josiah Schwab jsch...@gmail.com writes:

 Hi David,

 i want to write a piece of code as a 'template', which generates TODO
 using capture template, and inserts into the todo a LINK TO THE
 LOCATION, from which I have called the org-capture.

 Have you looked at 9.1.3 Capture templates in the documentation?
 http://orgmode.org/manual/Capture-templates.html

 It seems to me that the example TODO entry given (using %a in the
 template) will do what you describe:

 ,
 | During expansion of the template, %a has been replaced by a link to
 | the location from where you called the capture command. This can be
 | extremely useful for deriving tasks from emails, for example.
 `

 Best,
 Josiah

Right! Thanks for hint. I did not see this one. Does exactly what I
wanted to achieve

nice weekend

.d.