* Querying Org-contacts with lbdb (e.g. for mutt)
@ 2011-10-25 13:31 Karl Voit
0 siblings, 0 replies; only message in thread
From: Karl Voit @ 2011-10-25 13:31 UTC (permalink / raw)
To: emacs-orgmode
Hi!
I want to share a solution that allows lbdb[1] queries return
Org-contacts[2] email addresses. The solution is done by Russell
Adams who encouraged me to post it here because he did only mention
it in [3] but did not post the results yet. I took Russells solution
and modified it to be of more general use and added a few comments
in the Perl script.
If you are interested in my personal approach for managing contact
information with Org-contacts, please refer to [4].
The set up requires three things:
1. configuration file .lbdbrc (usually in ~ or ~/.lbdb/)
- add «m_orgcontact» to the variable «METHODS»
- add «$HOME/.lbdb/modules» to the variable «MODULES_PATH»
,----[ example lines ]
| METHODS="m_orgcontact m_muttalias m_inmail"
| MODULES_PATH="/usr/lib/lbdb $HOME/.lbdb/modules"
`----
2. ~/.lbdb/modules/m_orgcontact (just a small interface to connect
lbdb to the script)
,----[ m_orgcontact ]
| #!/bin/sh
|
| m_orgcontact_query()
| {
| ${HOME}/.lbdb/modules/orgcontact.pl $1
| }
| #end
`----
3. ~/.lbdb/modules/orgcontact.pl (the actual script that queries)
See below footnotes for the whole script.
1. http://www.spinnaker.de/lbdb/
2. http://julien.danjou.info/org-contacts.html
3. http://lists.gnu.org/archive/html/emacs-orgmode/2011-02/msg00459.html
4. http://article.gmane.org/gmane.emacs.orgmode/47478/
---- ~/.lbdb/modules/orgcontact.pl --------------------------
#!/usr/bin/env perl
use strict;
use warnings;
## FIXXME: error handling when no argument is given (though unlikely)
$/="\n*"; ## split between Org-mode headings (i.e. newline followed by asterisk)
## the path to your Org-contacts file:
my $orgmodefile=$ENV{"HOME"} . "/share/all/org-mode/contacts.org";
open(MYFILE,$orgmodefile);
my @rawcontacts = <MYFILE>; ## read in whole contact file, heading by heading
close(MYFILE);
$/="\n"; ## reset split string to newlines (only)
foreach (@rawcontacts) {
if ( $_ =~ m/$ARGV[0]/i ){ ## ARGV[0] is the query string
my $name;
foreach (split("\n",$_)) { ## go through it line by line
# The first line consists of the contact name (followed by tag(s))
unless (defined $name) {
$name = $_;
$name =~ s/^\*+\s(.*)\s+:\S+:.*$/$1/g; ## extract string between asterisks and tags
}
# if (m/^\s+:.*EMAIL.*:/i) {
if (m/^:EMAIL:/i) { ## for each property «:EMAIL:» print out result
my $email = $_;
$email =~ s/^:\S+:\s+(\S+)/$1/g;
$email =~ s/\s*$//;
printf("%s\t%s\t(Org)\n", $email, $name);
}
}
}
}
-------------------------------------------------------------
--
Karl Voit
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-25 13:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-25 13:31 Querying Org-contacts with lbdb (e.g. for mutt) Karl Voit
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).