Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id ABF384196F2 for ; Wed, 14 Apr 2010 00:38:14 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7D2HiF6VUi7r for ; Wed, 14 Apr 2010 00:38:14 -0700 (PDT) Received: from homiemail-a15.g.dreamhost.com (caiajhbdcbbj.dreamhost.com [208.97.132.119]) by olra.theworths.org (Postfix) with ESMTP id ECC4C431FC1 for ; Wed, 14 Apr 2010 00:38:13 -0700 (PDT) Received: from localhost.localdomain (unknown [195.190.188.219]) by homiemail-a15.g.dreamhost.com (Postfix) with ESMTPA id 39D0176C062; Wed, 14 Apr 2010 00:38:12 -0700 (PDT) From: Sebastian Spaeth To: Notmuch developer list Subject: [PATCH 13/13] notmuch.el: Add a function to insert a notmuch user-agent header Date: Wed, 14 Apr 2010 09:38:05 +0200 Message-Id: <1271230685-8478-1-git-send-email-Sebastian@SSpaeth.de> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <87bpdnl02k.fsf@yoom.home.cworth.org> References: <87bpdnl02k.fsf@yoom.home.cworth.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Apr 2010 07:38:14 -0000 This adds a function (and a hook) to have notmuch insert a User-Agent header into composed mails (even if invoked from not-notmuch ways, such as with ctrl-x m. This is invariably added for now without the possibility to turn it off, a task left as a homework for others. Signed-off-by: Sebastian Spaeth --- emacs/notmuch.el | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 517c53a..8a7df15 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -54,6 +54,30 @@ (require 'notmuch-lib) (require 'notmuch-show) +(defun notmuch-set-user-agent-header () + "Sets variables so that message mode inserts a notmuch User-Agent + header into send mails" + ;; check if User-Agent is a 'required' mail header and set it if not + (if (not (memq 'User-Agent message-required-mail-headers)) + (setq message-required-mail-headers + (append message-required-mail-headers '(User-Agent)))) + ;; hide the User-Agent header when composing a mail + (if (not (memq '"^User-Agent:" message-hidden-headers)) + (setq message-hidden-headers + (append message-hidden-headers '("^User-Agent:")))) + ;; create the notmuch user agent string + (let ((notmuch-user-agent (concat + (substring (shell-command-to-string + (concat notmuch-command + " --version")) 0 -1) + " (Emacs " emacs-version "/" + system-configuration ")"))) + (setq message-newsreader notmuch-user-agent))) + +;; set the User-Agent string whenever we invoke message mode +;; TODO: use a variable that allows disabling. +(add-hook 'message-mode-hook 'notmuch-set-user-agent-header) + (defun notmuch-select-tag-with-completion (prompt &rest search-terms) (let ((tag-list (with-output-to-string -- 1.6.3.3