emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Karl Maihofer <ignoramus@gmx.de>
To: emacs-orgmode@gnu.org
Subject: Re: How to export property values of agenda selection?
Date: Mon, 8 Apr 2013 09:00:58 +0000 (UTC)	[thread overview]
Message-ID: <loom.20130408T105137-188@post.gmane.org> (raw)
In-Reply-To: m2obdq95w4.fsf@christianmoe.com

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

      reply	other threads:[~2013-04-08 16:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 17:51 How to export property values of agenda selection? Karl Maihofer
2013-03-26 22:53 ` Christian Moe
2013-03-27 18:08   ` Karl Maihofer
2013-04-06 12:48   ` Karl Maihofer
2013-04-07  7:06     ` Christian Moe
2013-04-08  9:00       ` Karl Maihofer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20130408T105137-188@post.gmane.org \
    --to=ignoramus@gmx.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).