* gnus-alias integration bug
@ 2014-04-08 0:36 Ian Kelling
2014-04-08 1:10 ` Michael Hudson-Doyle
2014-04-08 9:19 ` David Mazieres
0 siblings, 2 replies; 4+ messages in thread
From: Ian Kelling @ 2014-04-08 0:36 UTC (permalink / raw)
To: notmuch
gnus-alias allows you to set your identity based on the headers in the
message you are replying. This is an essential feature in a mail client
for me, I want to automatically reply as the person an email was sent to
for certain addresses. This does not work in notmuch. gnus sets the
variable message-reply-buffer when it sets up a message, which
gnus-alias uses to go grab headers. It creates a buffer named
*gnus article copy* which contains all the headers and the message body. It seems notmuch does not set this
variable when it sets up a reply.
Here is an example of a rule needed to do this.
(setq gnus-alias-identity-rules
(quote
(("work"
("to" "work@example.com" previous)
"workidentity"))))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gnus-alias integration bug
2014-04-08 0:36 gnus-alias integration bug Ian Kelling
@ 2014-04-08 1:10 ` Michael Hudson-Doyle
2014-04-08 1:48 ` Ian Kelling, notmuch
2014-04-08 9:19 ` David Mazieres
1 sibling, 1 reply; 4+ messages in thread
From: Michael Hudson-Doyle @ 2014-04-08 1:10 UTC (permalink / raw)
To: Ian Kelling, notmuch
Ian Kelling <ian@iankelling.org> writes:
> gnus-alias allows you to set your identity based on the headers in the
> message you are replying. This is an essential feature in a mail client
> for me, I want to automatically reply as the person an email was sent to
> for certain addresses. This does not work in notmuch.
Which version of notmuch are you using? gnus-alias is working fine for
me with notmuch 0.17 and emacs-version "GNU Emacs 24.4.50.2
(x86_64-pc-linux-gnu, GTK+ Version 3.8.6) of 2014-04-04 on wani04"
Cheers,
mwh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gnus-alias integration bug
2014-04-08 1:10 ` Michael Hudson-Doyle
@ 2014-04-08 1:48 ` Ian Kelling, notmuch
0 siblings, 0 replies; 4+ messages in thread
From: Ian Kelling, notmuch @ 2014-04-08 1:48 UTC (permalink / raw)
To: Michael Hudson-Doyle; +Cc: notmuch
Michael Hudson-Doyle <michael.hudson@canonical.com> writes:
> Which version of notmuch are you using?
notmuch git version from 4/6/2014 bc10f63f9c2390dddfc3d6397889dab375107aa5
GNU Emacs 24.4.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.4.2) of 2014-04-07
How is it that I compiled my emacs from today's sources and you have a
higher version number than me? lol
gnu aliases works, but not that part.
- Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: gnus-alias integration bug
2014-04-08 0:36 gnus-alias integration bug Ian Kelling
2014-04-08 1:10 ` Michael Hudson-Doyle
@ 2014-04-08 9:19 ` David Mazieres
1 sibling, 0 replies; 4+ messages in thread
From: David Mazieres @ 2014-04-08 9:19 UTC (permalink / raw)
To: Ian Kelling, notmuch
Ian Kelling <ian@iankelling.org> writes:
> gnus-alias allows you to set your identity based on the headers in the
> message you are replying. This is an essential feature in a mail client
> for me, I want to automatically reply as the person an email was sent to
> for certain addresses. This does not work in notmuch.
I need this feature, too. There is some support for the same
functionality built into notmuch. The big problem for me is that
.notmuch-config does not support wildcards (e.g., *@mydomain.com or
user-*@mydomain.com). Compounding this issue is that, other than
notmuch reply's internals, notmuch pretty much suppresses the
Delivered-To header, which is crucial for knowing in a non-heuristic way
where an email was actually delivered to. I want to compute my From:
header based on the Delivered-To, so I created a
mail-delivered-to-reply-from alist that maps one to the other.
It's pretty horrifying what I had to do to get this to work, but it
looks something like the following. (Apologies for any mistakes, I had
to strip out additional complexity I have for other things in there, so
it's not verbatim the code that I'm using, but it's pretty close.)
If someone knows a better way of doing this with stock notmuch, please
let me know. I know it's simpler to fix notmuch-reply, but I really
don't want to start depending on a custom-forked version on the notmuch
binary, as I read my mail from multiple operating systems and I'm sure
I'd forget to update one of them.
David
;;; Regular expression matching all of my own email addresses. Note
;;; this is also used by mail-dont-reply-to (which ships with emacs).
(setq mail-dont-reply-to-names
(concat "REXEXP MATCHING ALL YOUR EMAIL ALIASES"))
;;; Alist mapping Delivered-To addresses to the address that should be
;;; in the From header of replies.
(setq mail-delivered-to-reply-from
'(("delivered-to-\\(.*\\)@address.com"
. "Name <send-from-\\1@address.com>")
;; ...
))
(defun compute-from (email)
(let ((case-fold-search t)
(subst (assoc-default email mail-delivered-to-reply-from
#'string-match)))
(and subst
(concat (notmuch-user-name) " <"
(replace-match subst t nil email) ">"))))
(defun get-delivered-to-from-path (path)
(with-temp-buffer
; It's weird to use sed, but there's also no reason to read a huge
; file into a buffer right here when we reply to messags with
; attachments. (notmuch show doesn't support --body=false in
; --format=raw mode, and the other modes all get rid of Delivered-To.)
(call-process "sed" nil t t "-ne"
"/^Delivered-To: */{s///p;q;}; /^$/q" path)
(goto-char (point-max))
(or (bobp) (delete-char -1))
(and (not (bobp)) (buffer-string))))
(defun get-msg-pathnames (query)
(notmuch-call-notmuch-sexp
"search" "--format=sexp" "--format-version=1"
"--output=files" "--" query))
(defun compute-reply-from (pl)
(let* ((orig (plist-get pl :original))
(path (plist-get orig :filename))
(orig-from (plist-get (plist-get orig :headers) :From))
(addr
(cond
((get-delivered-to-from-path path))
;; in case of maildir.synchronize_flags=true, the pathname
;; might already be incorrect, so try getting it again
((and (setq path (car (get-msg-pathnames query-string)))
(get-delivered-to-from-path path)))
((string-match mail-dont-reply-to-names
(setq orig-from (car (rfc822-addresses orig-from))))
orig-from)
)))
(and addr (compute-from addr))))
;;; Somehow no plist-del function in emacs
(defun my-plist-del (plist0 prop)
(if (eq prop (car plist0))
(cddr plist0)
(let ((p (cdr plist0)))
(while (and p (not (eq prop (cadr p))))
(setq p (cddr p)))
(if p (setcdr p (cdddr p)))
plist0)))
(defun fix-reply-sexp (pl)
(let* ((rh (plist-get pl :reply-headers))
(from (compute-reply-from pl))
h)
(if from (setq rh (plist-put rh :From from)))
(and (setq h (plist-get rh :To))
(setq h (mail-dont-reply-to h))
(not (equal h ""))
(setq rh (plist-put rh :To h)))
(and (setq h (plist-get rh :Cc))
(setq h (mail-dont-reply-to h))
(if (equal h "")
(setq rh (my-plist-del rh :Cc))
(setq rh (plist-put rh :Cc h))))
(plist-put pl :reply-headers rh)))
(defadvice notmuch-call-notmuch-sexp (after fix-reply activate)
"Fix From/To/CC headers in reply"
(if (equal (ad-get-arg 0) "reply")
(setq ad-return-value (fix-reply-sexp ad-return-value))))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-08 9:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08 0:36 gnus-alias integration bug Ian Kelling
2014-04-08 1:10 ` Michael Hudson-Doyle
2014-04-08 1:48 ` Ian Kelling, notmuch
2014-04-08 9:19 ` David Mazieres
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).