bbdb / utils / bbdb-srv.pl

#!/usr/local/bin/perl

# This script reads a block of message headers on stdin, and converts them
# to an emacs-lisp string (quoting  all dangerous characters) and then 
# uses the `gnudoit' program to cause a running Emacs process to invoke
# the `bbdb-srv' function with that string.
#
# This has the effect of causing the running Emacs to display the BBDB
# record corresponding to these headers.
#
# See the Emacs side of things in bbdb-srv.el for more info.
#
# A trivial application of this is the shell command:
#
#    echo 'From: Jamie Zawinski <jwz@jwz.org>' | bbdb-srv.perl
#
# which will cause the corresponding record to be displayed.
# A more interesting application of this is:
#
#    setenv NS_MSG_DISPLAY_HOOK bbdb-srv.perl
#
# which will hook BBDB up to Mozilla (Unix Netscape Mail and Netscape News
# versions 3.0b2 and later only.)
#
#	-- Jamie Zawinski <jwz@jwz.org>, 25-apr-96

# spawn in the background and return to the caller immediately.
if (fork == 0) { exit 0; }

$str="(bbdb-srv \"";
while(<>)
{
  # quote most shell metacharacters with backslash.
  s/([\\"`$#^!])/\\\1/g;
  # but quote ' as \047
  s/'/\\047/g;
  # and just for kicks, turn newlines into \n
#  s/\n/\\n/g;

  $str = $str.$_;
}
$str=$str."\")";

exec "gnudoit", "-q", $str;
exit 0;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.