Re: [O] How to export property values of agenda selection?

2013-04-08 Thread Karl Maihofer
Hi Christian,

Christian Moe mail at christianmoe.com writes:
 I'm not quite clear on your use case / desired result now. Why do you
 want results through batch mode on the command line in order to embed
 them in a webpage? Embed how? Is this something you could perhaps do
 simply by exporting from Org to HTML? 

Thanks for your mail. I found a (not so quick but very dirty) way to do what
I want. Just to explain:

The first step was the management of distribution lists withhin emacs.  In
the second step I wanted to make the distribution lists also available via
Web.  What I did now is to use a combination of php, emacs batch mode and
agenda views, shellscript and perl:

In my index.php I call a shell script:
=

!-- ;-separated list of email addresses --
pre?php echo shell_exec(emacs-export-distribution-list.sh); ?/pre

emacs-export-distribution-list.sh
==

# Export Agenda View and write to file
emacs -batch -l ~/.emacs -eval '(org-batch-agenda 1)' | sed '1d' | sed
'1d'  distribution_list.txt

# Extract email adresses
perl -wne 'while(/[\w\.]+@[\w\.]+\w+/g){print $; }' distribution_list.txt

Emacs configuration


(setq org-agenda-custom-commands
  (quote ((1 Distribution List tags tag1+tag2
 ((org-agenda-prefix-format
  '((tags  . %-40:(km/get-properties) ; )))
  (org-use-tag-inheritance nil))

And the function:

(defun km/get-properties ()
  (concat
(org-entry-get (point) EMAIL)))


In emacs I could not find a way to extract only the email addresses in an
agenda view. So it was a good idea to use the following in the buffer as you
suggested:

#+NAME: list2csv
#+BEGIN_SRC emacs-lisp :var match=tag1+tag2
  (mapconcat 'identity 
 (org-map-entries 
  '(org-entry-get (point) EMAIL) 
  match nil)
 ,)
#+END_SRC

But for the webpage I could use Perl to further process an agenda view.  And
since I knew how to get an agenda view exported using emacs batch mode, this
was the hack I was looking for.

Perhaps not very professional, but it works. ;-)

Thanks again for your help!

Karl




Re: [O] How to export property values of agenda selection?

2013-04-07 Thread Christian Moe

Hi,

If I recall, you have a bunch of tagged headings with EMAIL properties,
and you want to extract a comma-separated list of email addresses based
on tag matching. I posted an example of one approach, using a Babel block
to put results inline.

I'm not quite clear on your use case / desired result now. Why do you
want results through batch mode on the command line in order to embed
them in a webpage? Embed how? Is this something you could perhaps do
simply by exporting from Org to HTML? 

Yours,
Christian

 Does anybody know how to get the results via Emacs batch mode on the command
 line? I'd like to embed the results in a webpage.

 The following is my starting point and of course terribly wrong and it
 doesn't work. It's hard for me to find documentation (that I understand).

 $ emacs -batch -l ~/.emacs -eval (progn 
(find-file \~/test.org\)
(org-babel-execute-src-block 'list2csv)
(kill-buffer))

 Thanks,
 Karl




Re: [O] How to export property values of agenda selection?

2013-04-06 Thread Karl Maihofer
Christian Moe mail at christianmoe.com writes:
 I don't know how to do it from the agenda selection, but here's a pretty
 simple way to do it in the document buffer using Babel:
 
 #+NAME: list2csv
 #+BEGIN_SRC emacs-lisp :var match=topic2
   (mapconcat 'identity 
  (org-map-entries 
   '(org-entry-get (point) EMAIL) 
   match nil)
  ,)
 #+END_SRC
 
 Now you can use a CALL line with a tags match as a parameter, like
 
 #+CALL: list2csv(match=topic2)
 
 to get
 
 #+RESULTS: list2csv(match=topic2)
 : peter at mayer.com,karl at august.com

Does anybody know how to get the results via Emacs batch mode on the command
line? I'd like to embed the results in a webpage.

The following is my starting point and of course terribly wrong and it
doesn't work. It's hard for me to find documentation (that I understand).

$ emacs -batch -l ~/.emacs -eval (progn 
   (find-file \~/test.org\)
   (org-babel-execute-src-block 'list2csv)
   (kill-buffer))

Thanks,
Karl




Re: [O] How to export property values of agenda selection?

2013-03-27 Thread Karl Maihofer
Christian Moe mail at christianmoe.com writes:
 I don't know how to do it from the agenda selection, but here's a pretty
 simple way to do it in the document buffer using Babel:

Christian, thanks a lot! That does the job.

Kind regards,
Karl






Re: [O] How to export property values of agenda selection?

2013-03-26 Thread Christian Moe

Karl Maihofer writes:
 * Peter Mayer   :topic1:topic2:
 :PROPERTIES:
 :EMAIL:pe...@mayer.com
 :END:
 * Karl August:topic1:topic2:topic4:
 :PROPERTIES:
 :EMAIL: k...@august.com
 :END:
 * Peter Müller 
 :topic1:
 :PROPERTIES:
 :EMAIL:pe...@mueller.com
 :END:
[...]
 What I'd like to do now is to export a comma-separated list of the email
 addresses of the entries in the agenda selection:
 pe...@mayer.com,k...@august.com in the case above.

I don't know how to do it from the agenda selection, but here's a pretty
simple way to do it in the document buffer using Babel:

#+NAME: list2csv
#+BEGIN_SRC emacs-lisp :var match=topic2
  (mapconcat 'identity 
 (org-map-entries 
  '(org-entry-get (point) EMAIL) 
  match nil)
 ,)
#+END_SRC

Now you can use a CALL line with a tags match as a parameter, like

#+CALL: list2csv(match=topic2)

to get

#+RESULTS: list2csv(match=topic2)
: pe...@mayer.com,k...@august.com

Yours,
Christian