-<h2 id="advanced_tips">Advanced tips and tweaks</h2>
-* <span id="fcc">**How to do FCC/BCC...**</span>
-
- Any notmuch reply will automatically include your primary email
- address in a BCC so that any messages you send will (eventually) end
- up in your mail store as well. But this doesn't do anything for
- messages that you compose that are not replies.
-
- Another method is described in [this
- mail](http://mid.gmane.org/878wbj4nfq.fsf@servo.finestructure.net)
- (id:878wbj4nfq.fsf@servo.finestructure.net). It involves a trivial
- python script (which should be rewritten in lisp and integrated into
- the notmuch frontend, really, but is not difficult to setup.
-
- This is the code, I needed in my .emacs file to make it work with
- the python wrapper that I called mddeliver.py:
-
- ;; fcc handler
- (defun maildir-deliver-region(destdir)
- (shell-command-on-region
- (point-min) (point-max)
- (concat "/usr/local/bin/mddeliver.py -c -s -d " destdir)))
- (setq message-fcc-handler-function 'maildir-deliver-region)
- (defun my-message-header-setup ()
- (message-add-header "Fcc: ~/mail/INBOX.Sent"))
- (add-hook 'message-send-hook 'my-message-header-setup)
-
-* <span id="customize_notmuch_folder">How to customize notmuch-folders</span>
-
- There's a "notmuch-folder" command available in the emacs client
- that displays a list of "folders" and the number of messages in
- each. Each folder is simply a named search specification. To
- configure this mode, edit your ${HOME}/.emacs file and include text
- something like the following:
-
- (setq notmuch-folders '(("inbox" . "tag:inbox")
- ("unread" . "tag:inbox AND tag:unread")
- ("notmuch" . "tag:inbox AND to:notmuchmail.org")))
-
- Of course, you can have any number of folders, each configured
- with any supported search terms (see "notmuch help search-terms").
-
- Personally, I find it fairly useful to add "not tag:delete" to those
- views as I use that tag to mark messages as deleted and it
- automatically removes them from my standard views. Use whatever
- seems most useful to you.
-
-* Viewing HTML messages with an external viewer
-
- The emacs client can often display an HTML message inline, but it
- sometimes fails for one reason or another, (or is perhaps inadequate
- if you really need to see the graphical presentation of the HTML
- message).
-
- In this case, it can be useful to display the message in an external
- viewer, such as a web browser. Here's a little script that Keith
- Packard wrote, which he calls view-html:
+# Advanced tips and tweaks
+
+## Add a key binding to add/remove/toggle a tag
+
+The `notmuch-{search,show}-{add,remove}-tag` functions are very useful
+for making quick tag key bindings. For instance, here's an example
+of how to make a key binding to add the "spam" tag and remove the
+"inbox" tag in notmuch-show-mode:
+
+ (define-key notmuch-show-mode-map "S"
+ (lambda ()
+ "mark message as spam"
+ (interactive)
+ (notmuch-show-add-tag "spam")
+ (notmuch-show-remove-tag "inbox")))
+
+You can do the same for threads in `notmuch-search-mode` by just
+replacing "show" with "search" in the called functions.
+
+The definition above makes use of a lambda function, but you could
+also define a separate function first:
+
+ (defun notmuch-show-tag-spam()
+ "mark message as spam"
+ (interactive)
+ (notmuch-show-add-tag "spam")
+ (notmuch-show-remove-tag "inbox")))
+ (define-key notmuch-show-mode-map "S" 'notmuch-show-tag-spam)
+
+Here's a more complicated example of how to add a toggle "deleted"
+key:
+
+ (define-key notmuch-show-mode-map "d"
+ (lambda ()
+ "toggle deleted tag for message"
+ (interactive)
+ (if (member "deleted" (notmuch-show-get-tags))
+ (notmuch-show-remove-tag "deleted")
+ (notmuch-show-add-tag "deleted"))))
+
+## How to do FCC/BCC...
+
+The Emacs interface to notmuch will automatically add an `Fcc`
+header to your outgoing mail so that any messages you send will also
+be saved in your mail store. You can control where this copy of the
+message is saved by setting the variables `message-directory` (which
+defines a base directory) and `notmuch-fcc-dirs` which defines the
+subdirectory relative to `message-directory` in which to save the
+mail. Enter a directory (without the maildir `/cur` ending which
+will be appended automatically). To customize both variables at the
+same time, use the fancy command:
+
+ M-x customize-apropos<RET>\(notmuch-fcc-dirs\)\|\(message-directory\)
+
+This mechanism also allows you to select different folders to be
+used for the outgoing mail depending on your selected `From`
+address. Please see the documentation for the variable
+`notmuch-fcc-dirs` in the customization window for how to arrange
+this.
+
+## How to customize `notmuch-saved-searches`
+
+When starting notmuch, a list of saved searches and message counts is
+displayed, replacing the older `notmuch-folders` command. The set of
+saved searches displayed can be modified directly from the notmuch
+interface (using the `[save]` button next to a previous search) or by
+customising the variable `notmuch-saved-searches`.
+
+An example setting might be:
+
+ (setq notmuch-saved-searches '(("inbox" . "tag:inbox")
+ ("unread" . "tag:inbox AND tag:unread")
+ ("notmuch" . "tag:inbox AND to:notmuchmail.org")))
+
+Of course, you can have any number of saved searches, each configured
+with any supported search terms (see "notmuch help search-terms").
+
+Some users find it useful to add `and not tag:delete` to those
+searches, as they use the `delete` tag to mark messages as
+deleted. This causes messages that are marked as deleted to be removed
+from the commonly used views of messages. Use whatever seems most
+useful to you.
+
+## Viewing HTML messages with an external viewer
+
+The emacs client can display an HTML message inline using either the
+`html2text` library or some text browser, like w3m or lynx. This is
+controlled by the `mm-text-html-renderer` variable.
+
+The first option is theorically better, because it can generate
+strings formatted for emacs and do whatever you want, e.g., substitute
+text inside <b> tags for bold text in the buffer. The library, however
+is still in a very early development phase and cannot yet process
+properly many elements, like tables and <style> directives, and even
+the generated text is often poorly formatted.
+
+Among the available browsers, w3m seems to do a better job converting
+the html, and if you have the w3m emacs package, you can use it,
+instead of the w3m-standalone, and thus preserve the text formatting.
+
+But if the rendering fails for one reason or another, or if you really
+need to see the graphical presentation of the HTML message, it can be
+useful to display the message in an external viewer, such as a web
+browser. Here's a little script that Keith Packard wrote, which he
+calls `view-html`: