File: bbdb-srv.pl

package info (click to toggle)
xemacs21-packages 2009.02.17.dfsg.2-4
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 116,276 kB
  • ctags: 89,333
  • sloc: lisp: 1,232,060; ansic: 16,570; java: 13,514; xml: 6,477; sh: 4,617; makefile: 4,022; asm: 3,007; perl: 840; cpp: 500; ruby: 257; csh: 96; haskell: 93; awk: 49; python: 47
file content (45 lines) | stat: -rwxr-xr-x 1,270 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/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;