[PATCH 13/13] notmuch.el: Add a function to insert a notmuch user-agent header
Sebastian Spaeth
Sebastian at SSpaeth.de
Wed Apr 14 00:38:05 PDT 2010
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 <Sebastian at SSpaeth.de>
---
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
More information about the notmuch
mailing list