1 Return-Path: <Sebastian@SSpaeth.de>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id ABF384196F2
\r
6 for <notmuch@notmuchmail.org>; Wed, 14 Apr 2010 00:38:14 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 7D2HiF6VUi7r for <notmuch@notmuchmail.org>;
\r
16 Wed, 14 Apr 2010 00:38:14 -0700 (PDT)
\r
17 Received: from homiemail-a15.g.dreamhost.com (caiajhbdcbbj.dreamhost.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id ECC4C431FC1
\r
20 for <notmuch@notmuchmail.org>; Wed, 14 Apr 2010 00:38:13 -0700 (PDT)
\r
21 Received: from localhost.localdomain (unknown [195.190.188.219])
\r
22 by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 39D0176C062;
\r
23 Wed, 14 Apr 2010 00:38:12 -0700 (PDT)
\r
24 From: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
25 To: Notmuch developer list <notmuch@notmuchmail.org>
\r
26 Subject: [PATCH 13/13] notmuch.el: Add a function to insert a notmuch
\r
28 Date: Wed, 14 Apr 2010 09:38:05 +0200
\r
29 Message-Id: <1271230685-8478-1-git-send-email-Sebastian@SSpaeth.de>
\r
30 X-Mailer: git-send-email 1.6.3.3
\r
31 In-Reply-To: <87bpdnl02k.fsf@yoom.home.cworth.org>
\r
32 References: <87bpdnl02k.fsf@yoom.home.cworth.org>
\r
33 X-BeenThere: notmuch@notmuchmail.org
\r
34 X-Mailman-Version: 2.1.13
\r
36 List-Id: "Use and development of the notmuch mail system."
\r
37 <notmuch.notmuchmail.org>
\r
38 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
39 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
41 List-Post: <mailto:notmuch@notmuchmail.org>
\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
43 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
44 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
45 X-List-Received-Date: Wed, 14 Apr 2010 07:38:14 -0000
\r
47 This adds a function (and a hook) to have notmuch insert a User-Agent header
\r
48 into composed mails (even if invoked from not-notmuch ways, such as with
\r
49 ctrl-x m. This is invariably added for now without the possibility to
\r
50 turn it off, a task left as a homework for others.
\r
52 Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
\r
54 emacs/notmuch.el | 24 ++++++++++++++++++++++++
\r
55 1 files changed, 24 insertions(+), 0 deletions(-)
\r
57 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
58 index 517c53a..8a7df15 100644
\r
59 --- a/emacs/notmuch.el
\r
60 +++ b/emacs/notmuch.el
\r
62 (require 'notmuch-lib)
\r
63 (require 'notmuch-show)
\r
65 +(defun notmuch-set-user-agent-header ()
\r
66 + "Sets variables so that message mode inserts a notmuch User-Agent
\r
67 + header into send mails"
\r
68 + ;; check if User-Agent is a 'required' mail header and set it if not
\r
69 + (if (not (memq 'User-Agent message-required-mail-headers))
\r
70 + (setq message-required-mail-headers
\r
71 + (append message-required-mail-headers '(User-Agent))))
\r
72 + ;; hide the User-Agent header when composing a mail
\r
73 + (if (not (memq '"^User-Agent:" message-hidden-headers))
\r
74 + (setq message-hidden-headers
\r
75 + (append message-hidden-headers '("^User-Agent:"))))
\r
76 + ;; create the notmuch user agent string
\r
77 + (let ((notmuch-user-agent (concat
\r
78 + (substring (shell-command-to-string
\r
79 + (concat notmuch-command
\r
80 + " --version")) 0 -1)
\r
81 + " (Emacs " emacs-version "/"
\r
82 + system-configuration ")")))
\r
83 + (setq message-newsreader notmuch-user-agent)))
\r
85 +;; set the User-Agent string whenever we invoke message mode
\r
86 +;; TODO: use a variable that allows disabling.
\r
87 +(add-hook 'message-mode-hook 'notmuch-set-user-agent-header)
\r
89 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
91 (with-output-to-string
\r