3 # mutt-fetchbug, extensively based off of
4 # mutt-notmuch - notmuch (of a) helper for Mutt
6 # Copyright: © 2011 Stefano Zacchiroli <zack@upsilon.cc>
7 # License: GNU General Public License (GPL), version 3 or above
9 # Differences between mutt-notmuch and mutt-fetchbug are
10 # Copyright: © 2012 Ryan Kavanagh <rak@debian.org>
11 # License: GNU General Public License (GPL), version 3 or above
13 # See the bottom of this file for more documentation.
14 # A manpage can be obtained by running "pod2man mutt-fetchbug > mutt-fetchbug.1"
23 # search($btsmbox, $query)
24 # Fetch bugs matching $query with bts; store results in $btsmbox
26 my ($btsmbox, $query) = @_;
28 system("bts --cache-mode=mbox cache $query"
29 . " && ln -fs ~/.devscripts_cache/bts/$query.mbox $btsmbox");
32 sub search_action($$@) {
33 my ($interactive, $btsmbox, @params) = @_;
36 fetch($btsmbox, join(' ', @params));
41 print "bug number ('?' for man): ";
42 chomp($query = <STDIN>);
45 } elsif ($query eq "") {
46 $done = 1; # quit doing nothing
48 search($btsmbox, $query);
56 my %podflags = ( "verbose" => 1,
62 my $btsmbox = "$ENV{HOME}/.cache/mutt_btsresults";
66 my $getopt = GetOptions(
67 "h|help" => \$help_needed,
68 "o|output-mbox=s" => \$btsmbox,
69 "p|prompt" => \$interactive);
70 if (! $getopt || $#ARGV < 0) { die_usage() };
71 my ($action, @params) = ($ARGV[0], @ARGV[1..$#ARGV]);
75 } elsif ($action eq "search" && $#ARGV == 0 && ! $interactive) {
76 print STDERR "Error: no search term provided\n\n";
78 } elsif ($action eq "search") {
79 search_action($interactive, $btsmbox, @params);
91 mutt-fetchbug - 'bts show' frontend for Mutt
97 =item B<mutt-fetchbug> [I<OPTION>]... search [I<SEARCH-TERM>]...
103 mutt-fetchbug is a frontend to the 'bts show' command (Debian package:
104 devscripts) designed to fetch bugs and place them in a predefined mbox. The
105 search term should typically be a bug number.
113 =item --output-mbox DIR
115 Store search results as (symlink) mbox MBOX. Beware: MBOX will be overwritten.
116 (Default: F<~/.cache/mutt_btsresults/>)
122 Instead of using command line search terms, prompt the user for them (only for
129 Show usage information and exit.
133 =head1 INTEGRATION WITH MUTT
135 mutt-fetchbug can be used to integrate 'bts show' with the Mutt mail user agent
136 (unsurprisingly, given the name). To that end, you should define the following
137 macros in your F<~/.muttrc> (replacing F<~/bin/mutt-fetchbug> for the actual
138 location of mutt-fetchbug on your system):
141 "<enter-command>unset wait_key<enter><shell-escape>~/bin/mutt-fetchbug --prompt search<enter><change-folder-readonly>~/.cache/mutt_btsresults<enter><enter-command>set wait_key<enter>" \
142 "fetch bug(s) (using bts show)"
144 The macro (activated by <F7>) will prompt the user for a bug number and then
145 jump to a temporary mbox showing the fetched bug.
153 mutt-fetchbug is extensively based off of 'mutt-notmuch', which is
154 Copyright: (C) 2011 Stefano Zacchiroli <zack@upsilon.cc>.
156 All differences between mutt-fetchbug and mutt-notmuch are
157 Copyright (C) 2012 Ryan Kavanagh <rak@debian.org>
159 License: GNU General Public License (GPL), version 3 or higher