OK, final post from me on this issue. This is what I am using in my
.emacs now. It does not clutter up the message compose window with a
User-Agent header as it is hidden by message mode. It is also not shown
by default in the notmuch-show modes but viewing the full headers
confirms that it is indeed being send. It works for "c-x m" and "m" in
notmuch-show mode, AND it also work for "r"eplies in notmuch-show mode.

I put this in the message mode hook because we will then not call the
notmuch binary each time we start up emacs, but it will be dynamically
be created when message mode is invoked. Not sure if others have a
cleverer solution here.

;; set the User-Agent string whenever we invoke message mode
(add-hook 'message-mode-hook '(lambda()
    ;; check if User-Agent is a required 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 if not already hidden
    (if (not (memq '"^User-Agent:" message-hidden-headers))
        (setq message-hidden-headers 
              (append message-hidden-headers '("^User-Agent:"))))
    ;; create 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))
))

Sebastian
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to