File: metamutt

package info (click to toggle)
tin 981002-2
  • links: PTS
  • area: non-free
  • in suites: slink
  • size: 3,088 kB
  • ctags: 4,969
  • sloc: ansic: 46,800; sh: 1,655; makefile: 1,144; yacc: 699; perl: 103
file content (112 lines) | stat: -rwxr-xr-x 3,278 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#! /bin/sh
#
# $Id: metamutt,v 1.11 1998/10/01 21:40:08 roland Exp $
#
# This should become a replacement of metamail, using the mail reader
# mutt. The options of metamail are not yet implemented, but it should
# work as a filter without any problems.
# 
# This script was written to use it in combination with the tin news
# reader, where you have to set the envionment variable
# METAMAIL=metamutt, but it should work with other programs, too.
#
# You need formail (from the procmail package) to use this script. If
# you don't want to install formail, you will find an alternative
# solution (commented out) below.
#
# Pressing "g" allows you to post a Followup to a newsgroup.
#
# Options:
#  -D allows splits a digest into seperate mails by using formail
#     (Feature added by Martin Ramsch <m.ramsch@computer.org>)
#
# Most recent version can be found at http://www.rhein.de/~roland/mutt/metamutt
#
##########################################################################
#
#   Copyright (C) 1997-1998  Roland Rosenfeld <roland@spinnaker.rhein.de>
#
#   This program is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License as
#   published by the Free Software Foundation; either version 2 of
#   the License, or (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

TMP=/tmp/metamutt.$$
trap "rm -f $TMP*; exit" 0 1 2 15

# formail options:
fmopt=''

# do we read a digest?
digest='no'

# handle options (ignore most of them at the moment):
for parameter 
do
    case $1 in 
        -- ) shift; break;;
        -e|-p ) shift;;
        -m ) shift 2;;
	-D ) fmopt='-ds cat'
	     digest='yes'
	     shift;;
        * )  break;;
    esac
done

# create mbox message using formail (from procmail package):
cat "$@" | formail $fmopt > $TMP-mbox

# If you don't have formail installed, try this:
#echo "From PIPE `env LC_ALL=C date`" > $TMP-mbox
#cat $* - | sed 's/^From />From /' >> $TMP-mbox

# create special muttrc for metamutt:
if [ -f ~/.mutt/muttrc ]
then
    echo 'source ~/.mutt/muttrc' > $TMP-rc
else
    echo 'source ~/.muttrc' > $TMP-rc
fi

cat >> $TMP-rc <<EOF
macro pager g ":set sendmail=$TMP-inews dsn_notify='' dsn_return=''<return>:my_hdr `formail -X Newsgroups < $TMP-mbox`<return>r"
EOF

# some additions, if we read exactly one article.
if [ "$digest" = "no" ]
then

cat >> $TMP-rc <<EOF
set pager_index_lines=0
set quit=yes
bind pager \t next-page
bind pager i quit
bind pager q quit
bind pager x quit
bind index q quit
push "<return>"
EOF

fi

# create special inews which removes mail only headers:
cat > $TMP-inews<<EOF
#! /bin/sh
formail -I To -I Cc -I Bcc -I Fcc -I From\  -I In-Reply-To \
    -R X-Mailer User-Agent | inews -h
EOF
chmod 700 $TMP-inews

# run mutt on mbox message with special muttrc:
mutt -F $TMP-rc -R -f $TMP-mbox </dev/tty >/dev/tty