]> git.cworth.org Git - notmuch-wiki/blob - emacstips.mdwn
emacstips: Fix the presentation of the code examples.
[notmuch-wiki] / emacstips.mdwn
1 [[!img notmuch-logo.png alt="Notmuch logo" class="left"]]
2 #Tips and Tricks for using notmuch with Emacs
3
4 * How to do FCC/BCC...
5
6   Any notmuch reply will automatically include your primary email
7   address in a BCC so that any messages you send will (eventually) end
8   up in your mail store as well.
9
10   But this doesn't do anything for messages that you compose that are
11   not replies. So we need to get sane message-mode FCC figured
12   out. Some investigation is still needed here.
13
14 * How to customize notmuch-folders
15
16   There's a "notmuch-folder" command available in the emacs client
17   that displays a list of "folders" and the number of messages in
18   each. Each folder is simply a named search specification. To
19   configure this mode, edit your ${HOME}/.emacs file and include text
20   something like the following:
21
22                 (setq notmuch-folders '(("inbox" . "tag:inbox")
23                                         ("unread" . "tag:inbox AND tag:unread")
24                                         ("notmuch" . "tag:inbox AND to:notmuchmail.org")))
25
26   Of course, you can have any number of folders, each configured
27   with any supported search terms (see "notmuch help search-terms").
28
29 * Viewing HTML messages with an external viewer
30
31   The emacs client can often display an HTML message inline, but it
32   sometimes fails for one reason or another, (or is perhaps inadequate
33   if you really need to see the graphical presentation of the HTML
34   message).
35
36   In this case, it can be useful to display the message in an external
37   viewer, such as a web browser. Here's a little script that Keith
38   Packard wrote, which he calls view-html:
39
40                 #!/bin/sh
41                 dir=3D`mktemp -d`
42                 trap "rm -r $dir" 0
43                 cat "$@" > "$dir"/msg
44                 if munpack -C "$dir" -t < "$dir"/msg 2>&1 | grep 'Did not find'; then
45                     sed -n '/[Hh][Tt][Mm][Ll]/,$p' "$dir"/msg > $dir/part1.html
46                     rm "$dir"/msg
47                 fi
48                 for i in "$dir"/part*; do
49                     if grep -q -i -e '<html>' -e 'text/html' "$i"; then
50                         iceweasel "$i" &
51                         sleep 3
52                         exit 0
53                     fi
54                 done
55
56   Save that script somewhere in your ${PATH}, make it executable, and
57   change the invocation of iceweasel to any other HTML viewer if
58   necessary. Then within the emacs client, press "|" to pipe the
59   current message, then type "view-html".
60
61   Keith mentions the following caveat, "Note that if iceweasel isn't
62   already running, it seems to shut down when the script exits. I
63   don't know why."