From: Sebastian Spaeth <Sebastian@SSpaeth.de>
To: Notmuch developer list <notmuch@notmuchmail.org>
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 [thread overview]
Message-ID: <1271230685-8478-1-git-send-email-Sebastian@SSpaeth.de> (raw)
In-Reply-To: <87bpdnl02k.fsf@yoom.home.cworth.org>
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@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
next prev parent reply other threads:[~2010-04-14 7:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-08 8:26 RFC: User-Agent header Sebastian Spaeth
2010-04-08 15:12 ` Dirk Hohndel
2010-04-10 2:55 ` Carl Worth
2010-04-10 4:43 ` Dirk Hohndel
2010-04-10 13:16 ` Jameson Rollins
2010-04-10 14:00 ` Sebastian Spaeth
2010-04-10 14:45 ` Dirk Hohndel
2010-04-10 14:02 ` Xavier Maillard
2010-04-11 22:12 ` Sebastian Spaeth
2010-04-12 5:45 ` David Edmondson
2010-04-12 8:30 ` [PATCH] " Sebastian Spaeth
2010-04-13 17:44 ` Carl Worth
2010-04-13 22:55 ` Xavier Maillard
2010-04-14 7:38 ` Sebastian Spaeth [this message]
2010-04-14 7:44 ` [PATCH 13/13] notmuch.el: Add a function to insert a notmuch user-agent header David Edmondson
2010-04-14 9:52 ` Sebastian Spaeth
2010-04-14 7:44 ` [PATCH] RFC: User-Agent header Sebastian Spaeth
2010-04-15 19:52 ` Carl Worth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1271230685-8478-1-git-send-email-Sebastian@SSpaeth.de \
--to=sebastian@sspaeth.de \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).