muttprofile-1.0.1.orig/0040755000175000001440000000000007757204572014374 5ustar madduckusersmuttprofile-1.0.1.orig/muttprofile.html0100644000175000001440000001510607611125060017613 0ustar madduckusers Muttprofile

Muttprofile

Muttprofile is a utility to choose profiles with the Mutt email client. It is useful at least in the following cases:

Muttprofile was written in Perl. It is distributed under GNU General Public Licence (same as Mutt itself).

Note! (2003-01-11)

It seems that muttprofile is not working correctly in RedHat 8 (with Perl 5.8). Thanks for Marco Fioretti for informing me. The problem seems to be related to 'stty' and the Perl module 'Term::Complete' which is using it for changing terminal characteristics. I'll try to fix it, but at the moment, I don't have too much spare time, nor a working rh8 at my disposal...

Version history

1.0.0 2000-05-10 First public release

Requirements

Muttprofile is a somewhat Unix-oriented tool in its command-line operation. It also makes use of symbolic links. I don't know if it works under other operating systems.

Download

Download muttprofile!

Alternatively, you can go with Rikard Florin's version of muttprofile. He has rewritten muttprofile to include a graphical user interface using the Term::ANSIScreen and Term::ReadKey modules.

Installation

Muttprofile itself requires no special installation but you might want to check the first line of the file (#!/usr/bin/perl -w) and change the path to perl if needed ('which perl' might be useful here :-)

After that you need to tell Mutt how to call muttprofile and load the active profile. Perhaps the easiest way to invoke muttprofile from mutt is to bind a key with mutt macro command. For example, adding this to your muttrc-file


macro	index	<F10>	"!muttprofile\n:source ~/.mutt/profile.active\n" "Call muttprofile and load profile"
binds the function key <F10> to call muttprofile and load the new active profile.

Other examples:


macro	index	<F10>	"!muttprofile\n:source ~/.mutt/profile.active\n^f" "Call muttprofile, load profile and forget PGP passphrase"
binds the function key <F10> to call muttprofile, load the new active profile and tells Mutt to forget the currently active PGP passphrase.


macro	index	<F10>	"!muttprofile\n:source ~/.mutt/profile.active\n^fm" "New message with profile"
binds the function key <F10> to start muttprofile, load the profile, forget the PGP passphrase and start a new message.

In the profile files, you may want to add the following:

# NAME: name for your profile
# DESC: description of you profile, optional

In the interactive mode, muttprofile displays these to help you choose a profile. If they are missing, filename is used instead of the NAME. DESC is optional.

Documentation

Dodumentation is included in POD format. You can read it using perldoc -F muttprofile.

For convenience, you can find the corresponding man page here: Muttprofile man page

Short summary:
muttprofile looks for profile files in your mutt directory, reads NAME and DESC keywords, let's you choose a profile based on those and finally creates a symbolic link that points to that profile file. Thus Mutt only needs to load one profile (the active profile).

Future development

At the moment, muttprofile is what it is and stays that way. If necessary (propably not) I'll try to keep it functional with new versions of Mutt.

It is possible (though very unlikely) that I add some or all of the following features some day:

Acknowledgments

Matti Airas helped me a lot with muttprofile: for example he suggested the idea of using symlinks and to use NAME and DESC keys in the profiles. He also introduced me to Mutt :-)

Rikard Florin for continuing work with muttprofile. He has rewritten muttprofile to include a graphical user interface. His version is available here.

The people in the mutt-users mailing list gave me valuable help with mutt configuration.

See also

Information on (Sender) profiles with Mutt
Martti Rahkila's Mutt Resources


URL: http://www.iki.fi/martti.rahkila/mutt/muttprofile.html
Last update: 2003-01-11
Author: Martti Rahkila
muttprofile-1.0.1.orig/muttprofile.10100644000175000001440000001703207736111157017021 0ustar madduckusers.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MUTTPROFILE 1" .TH MUTTPROFILE 1 "2003-01-15" "perl v5.8.0" "User Contributed Perl Documentation" .SH "NAME" muttprofile \- Choose a Mutt Profile .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBmuttprofile\fR [\-a|\-\-active string] [\-d|\-\-dir directory] [\-h|\-\-help] [\-p|\-\-profile regexp] [\-v|\-\-view] [\-V|\-\-Version] [profile] .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBmuttprofile\fR is a simple utility to choose a profile to be used with Mutt email\-client. It has two operating modes: command-line and interactive. Muttprofile goes to interactive mode if no command-line arguments are present or option \-v|\-\-view is present without profile name. .PP Muttprofile looks for profile files in the Mutt directory, opens them and looks for \&\s-1NAME\s0 and \s-1DESC\s0 definitions. It then creates a symbolic link to the profile chosen by the user. The rest of the work is done with a Mutt macro. .SH "USAGE" .IX Header "USAGE" Interactive mode: .PP Type the name of the profile and the program creates a symlink to load the profile. Press to complete, to see list of choices. .PP Command-line options: .PP \&\fB\-a | \-\-active\fR Set the name for active profile symlink, default is profile.active .PP \&\fB\-d | \-\-dir\fR Set the Mutt directory, default is ~/.mutt .PP \&\fB\-h | \-\-help\fR prints a short help and exits .PP \&\fB\-p | \-\-profile\fR (Perl) Regexp to match profile files in Mutt directory .PP \&\fB\-v | \-\-view\fR Instead of creating a symlink, view profile contents .PP \&\fB\-V | \-\-version\fR prints the version information and exits (use \-\-version for long and \-V for short version) .PP \&\fBprofile\fR if profile exits, create the symlink to load it from Mutt, otherwise exit with error .SH "INSTALL" .IX Header "INSTALL" \&\fBMuttprofile\fR requires no installation, but you might have to check the first line of the file (\f(CW\*(C`#!/usr/bin/perl \-w\*(C'\fR) and change the path to perl if needed (\f(CW'which perl'\fR might be useful here :\-) .SH "SETTING UP PROFILES" .IX Header "SETTING UP PROFILES" \&\fBMuttprofile\fR checks the profile files for the following information: .PP # \s-1NAME:\s0 name for your profile .PP # \s-1DESC:\s0 description of your profile .PP This information is used for choosing and displaying available profiles. \&\s-1DESC\s0 is optional, but if \s-1NAME\s0 is missing, filename is used instead. .SH "USING MUTTPROFILE FROM MUTT" .IX Header "USING MUTTPROFILE FROM MUTT" Perhaps the easiest way to invoke \fBmuttprofile\fR from \fBmutt\fR is to bind a key with mutt macro command. For example, adding this to your \fImuttrc\fR\-file .PP macro index \*(L"!muttprofile\en:source ~/.mutt/profile.active\enm\*(R" \*(L"New message with profile\*(R" .PP binds the function key to start muttprofile, load the profile and start a new message .SH "EXIT CODES" .IX Header "EXIT CODES" The default exit codes for muttprofile are: .PP .Vb 3 \& 0 OK \& 1 PROFILE ALREADY ACTIVE \& 2 ERROR .Ve .PP These codes can be used in shell scripts etc. .SH "FURTHER INFORMATION" .IX Header "FURTHER INFORMATION" Discussion of profiles with Mutt: http://www.iki.fi/martti.rahkila/mutt/ .PP Mutt home page: http://www.mutt.org .SH "MODULES" .IX Header "MODULES" \&\fBmuttprofile\fR uses the perl modules \f(CW\*(C`Term::Complete\*(C'\fR and \f(CW\*(C`Getopt::Long\*(C'\fR that both come with the Perl distribution. .SH "LICENCE" .IX Header "LICENCE" \&\fBmuttprofile\fR is distibuted under \s-1GNU\s0 General Public Licence (\s-1GPL\s0), same as Mutt. For details, see http://www.gnu.org/copyleft/gpl.html .SH "BUGS" .IX Header "BUGS" None known so far. Inevitably to appear sooner or later. .SH "VERSION" .IX Header "VERSION" .RE .IP "1.0.0 (current)" .IX Item "1.0.0 (current)" First public release. .PP 2000\-05\-10 Martti Rahkila .SH "AUTHOR" .IX Header "AUTHOR" .Vb 3 \& Martti Rahkila \& martti.rahkila@iki.fi \& http://www.iki.fi/martti.rahkila/mutt .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fImutt\fR\|(1), \fIperl\fR\|(1) muttprofile-1.0.1.orig/muttprofile0100600000175000001440000003447307757201773016671 0ustar madduckusers#!/usr/bin/perl -w # muttprofile - choose mutt profile interactively # Copyright (C) 2000-2003 Martti Rahkila # http://www.iki.fi/martti.rahkila/mutt/ # # 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. # (http://www.gnu.org/copyleft/gpl.html) # # 2000-05-10 v1.0.0 # 2003-11-20 v1.0.1 three bugfixes ### defaults my $mutt_path = "~/.mutt"; # directory for mutt files, change with option -d my $active_profile = "profile.active"; # symlink to the real profile, change with option -a my $profile_regexp = "/^profile.*[^\~]\$/"; # default is "profilesomething, change with option -p ### initialize use strict; use Getopt::Long; # for command line options use Term::Complete; # for interactive mode # declarations sub read_link; # returns name of the real active profile, otherwise false sub create_link; # the actual beef here, make a symlink and remove old one if needed sub expand_tilde; # if home directory was given with tilde, expands it to absolute path my %profiles; my %descriptions; # versions my $version = "1.0.1"; # major.minor.patchlevel my $license = "This program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n(http://www.gnu.org/copyleft/gpl.html)"; my $version_string = "muttprofile $version, (c) 2000-2003 Martti Rahkila\n\n$license\n"; # set return values my $ok = 0; my $already_active = 1; my $error = 2; ### main ## command line first my ($set_active_profile,$view_config,$set_mutt_directory,$help,$set_profiles,$view_source,$version_number,$version_long); Getopt::Long::Configure(qw/no_ignore_case/); # command line options unless (GetOptions( "a=s" => \$set_active_profile, "active=s" => \$set_active_profile, "d=s" => \$set_mutt_directory, "dir=s" => \$set_mutt_directory, "h" => \$help, "help" => \$help, "p=s" => \$set_profiles, "profile=s" => \$set_profiles, "v" => \$view_source, "view" => \$view_source, "V" => \$version_number, "Version" => \$version_long, "version" => \$version_long ) ) { print STDERR "Invalid command line options. Exiting($error)\n"; exit($error); } my $input; my $found = 0; my $str =""; my $real_active_profile; if ($help) { print STDOUT <) { if (/\#\s*NAME:\s*(.*)\s*$/i) { $name = $1; next; } if (/\#\s*DESC:\s*(.*)\s*$/i) { $desc = $1; next; } } close(FILE); $name = $f if ($name eq ""); $profiles{$name} = $f; $descriptions{$name} = $desc; } # do we want view_mode my $view_mode = 0; if ($view_source) { $view_mode = 1; } # find active profile $real_active_profile = read_link($real_mutt_path,$active_profile); # do we have a profile name on the command line? if (@ARGV) { $str = shift; if (defined($profiles{$str})) { $found = 1; # we want to wiew source if ($view_mode == 1) { open(FILE,"<$real_mutt_path/$profiles{$str}") || print STDERR "Cannot open profile $str.\n",exit($error); while () { print STDOUT $_; } close(FILE); exit($ok); } if ($real_active_profile) { # symlink exists if ("$profiles{$str}" eq $real_active_profile) { print STDOUT "Chosen profile ($profiles{$str}) is already active.\n"; exit($already_active); } } # create the link, remove old if needed if (create_link($real_mutt_path,$active_profile,$profiles{$str})) { print STDOUT "New active profile: $profiles{$str}\n"; exit($ok); } else { # something wrong here print STDERR "Error creating symlink. Exiting($error).\n"; exit($error); } } else { print STDERR "Unknown profile ($str). Exiting($error).\n"; exit($error); } } ## command line clear, going for interactive mode my $prompt = "Profile name (tab to complete, * = active profile): "; my @list; my $plength = 0; my $dlength = 0; my $i = 0; my $k; foreach $k (keys %profiles) { push(@list,$k); $plength = length($k) if (length($k) > $plength); $dlength = length($descriptions{$k}) if (length($descriptions{$k}) > $dlength); $i++; } # cutpoint for descriptions my $max = length($prompt) + $plength; if ($max < 80) { $max = 80; } # output format my $mark; my $format = "format STDOUT = \n" . '^ ' . '^' . '<' x ($plength - 1) . " ^" . '<' x ($max - $plength - 5) . '~~' . "\n" . '$mark,$name,$desc' . "\n" . '.' . "\n"; eval($format); print STDOUT "Available profiles ($i):\n"; #foreach $k (keys %profiles) { #http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=218960 foreach $k (sort keys %profiles) { $mark = ""; $name = ""; $desc = ""; if ($real_active_profile eq $profiles{$k}) { $mark = "*"; } $name = $k; $desc = $descriptions{$k} if ($descriptions{$k} ne ''); write STDOUT; } $found = 0; $str =""; # get the profile name $str = Complete($prompt,@list); # verify given profile name if ($str eq '') { print STDERR "No profile chosen. Exiting($error).\n"; exit($error); } unless (defined($profiles{$str})) { print STDERR "Unknown profile ($str). Exiting($error).\n"; exit($error); } else { # we have a valid profile name # we want to wiew source if ($view_mode == 1) { open(FILE,"<$real_mutt_path/$profiles{$str}") || print STDERR "Cannot open profile $str. Exiting($error).\n",exit($error); while () { print STDOUT $_; } close(FILE); exit($ok); } if ($real_active_profile) { # symlink exists if ("$profiles{$str}" eq $real_active_profile) { print STDOUT "Chosen profile ($profiles{$str}) is already active.\n"; exit($already_active); } } # create the link, remove old if needed if (create_link($real_mutt_path,$active_profile,$profiles{$str})) { print STDOUT "New active profile: $profiles{$str}\n"; exit($ok); } else { # something wrong here print STDERR "Error creating symlink. Exiting($error).\n"; exit($error); } } exit($ok); ### subs sub read_link { my $real_mutt_path = shift; my $active_profile = shift; my $real_active_profile; if (-l "$real_mutt_path/$active_profile") { # symlink exists $real_active_profile = readlink("$real_mutt_path/$active_profile"); } else { # no symlink yet $real_active_profile = 0; } return $real_active_profile; } sub create_link { # the beef... my $real_mutt_path = shift; my $active_profile = shift; my $profile = shift; my $link; chdir($real_mutt_path); $link = read_link($real_mutt_path,$active_profile); unlink($active_profile) if ($link); if (symlink("$profile","$active_profile")) { return 1; } else { return 0; } } sub expand_tilde { my $dir = shift; # tilde expansion if ($dir =~ /~/) { $dir =~ s{ ^ ~( [^/]* ) } { $1 ? (getpwnam($1))[7] : ($ENV{'HOME'} || $ENV{'LOGDIR'} || (getpwuid($>))[7]) }ex; } return($dir); } ### documentation __END__ =head1 NAME muttprofile - Choose a Mutt Profile =head1 SYNOPSIS B [-a|--active string] [-d|--dir directory] [-h|--help] [-p|--profile regexp] [-v|--view] [-V|--Version] [profile] =head1 DESCRIPTION B is a simple utility to choose a profile to be used with Mutt email-client. It has two operating modes: command-line and interactive. Muttprofile goes to interactive mode if no command-line arguments are present or option -v|--view is present without profile name. Muttprofile looks for profile files in the Mutt directory, opens them and looks for NAME and DESC definitions. It then creates a symbolic link to the profile chosen by the user. The rest of the work is done with a Mutt macro. =head1 USAGE Interactive mode: Type the name of the profile and the program creates a symlink to load the profile. Press to complete, to see list of choices. Command-line options: B<-a | --active> Set the name for active profile symlink, default is profile.active B<-d | --dir> Set the Mutt directory, default is ~/.mutt B<-h | --help> prints a short help and exits B<-p | --profile> (Perl) Regexp to match profile files in Mutt directory B<-v | --view> Instead of creating a symlink, view profile contents B<-V | --version> prints the version information and exits (use --version for long and -V for short version) B if profile exits, create the symlink to load it from Mutt, otherwise exit with error =head1 INSTALL B requires no installation, but you might have to check the first line of the file (C<#!/usr/bin/perl -w>) and change the path to perl if needed (C<'which perl'> might be useful here :-) =head1 SETTING UP PROFILES B checks the profile files for the following information: # NAME: name for your profile # DESC: description of your profile This information is used for choosing and displaying available profiles. DESC is optional, but if NAME is missing, filename is used instead. =head1 USING MUTTPROFILE FROM MUTT Perhaps the easiest way to invoke B from B is to bind a key with mutt macro command. For example, adding this to your F-file macro index "!muttprofile\n:source ~/.mutt/profile.active\nm" "New message with profile" binds the function key to start muttprofile, load the profile and start a new message =head1 EXIT CODES The default exit codes for muttprofile are: 0 OK 1 PROFILE ALREADY ACTIVE 2 ERROR These codes can be used in shell scripts etc. =head1 FURTHER INFORMATION Discussion of profiles with Mutt: http://www.iki.fi/martti.rahkila/mutt/ Mutt home page: http://www.mutt.org =head1 REQUIREMENTS B requires B (obviously :-) and B version 5 or later. The required perl modules are C and C that both come with the Perl distribution. Please note that the C module in Perl 5.8.0 may produce an error. This has been fixed in Perl 5.8.1. =head1 LICENCE B is distibuted under GNU General Public Licence (GPL), same as Mutt. For details, see http://www.gnu.org/copyleft/gpl.html =head1 BUGS No known bugs at the moment. Inevitably to appear sooner or later. =head1 VERSION HISTORY =item 1.0.1 (current) Two bugfixes, details can be found from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=218957 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=218960 Additional bugfix regarding a case when active profile exist but is a file instead of symlink. 2003-11-20 Martti Rahkila =item 1.0.0 First public release. 2000-05-10 Martti Rahkila =head1 AUTHOR Martti Rahkila martti.rahkila@iki.fi http://www.iki.fi/martti.rahkila/mutt =head1 SEE ALSO L, L =cut