emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Karl Maihofer
Subject: Re: [O] How to export property values of agenda selection?
Date: Mon, 8 Apr 2013 09:00:58 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

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(/address@hidden/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




reply via email to

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