Instead of using a static citation line for the first line of the
reply message, use the customizable one defined by message-mode.
This makes it easy for users to customize the reply style, and
retains consistency for users with existing message-mode
customizations.

The test has been updated to reflect how the message will be
formatted with the default value of message-citation-line-format.

---
 emacs/notmuch-mua.el |   19 ++++++++++++++++---
 test/emacs           |    2 +-
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 64e160a..b58f919 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -135,9 +135,22 @@ list."
          (forward-line -1)
        (goto-char (point-max)))

-      (insert (format "On %s, %s wrote:\n"
-                     (cdr (assq 'date original-headers))
-                     (cdr (assq 'from original-headers))))
+      (let* ((quoth message-citation-line-format)
+            (case-fold-search nil)
+            (full-from (cdr (assq 'from original-headers)))
+            (from-addr (car (mail-header-parse-address full-from)))
+            (from-name (cdr (mail-header-parse-address full-from)))
+            (first-name (car (split-string from-name)))
+            (last-name (append (cdr (split-string from-name))))
+            (time (date-to-time (cdr (assq 'date original-headers)))))
+
+       (setq quoth (replace-regexp-in-string "%f" full-from quoth t t))
+       (setq quoth (replace-regexp-in-string "%n" from-addr quoth t t))
+       (setq quoth (replace-regexp-in-string "%N" from-name quoth t t))
+       (setq quoth (replace-regexp-in-string "%F" first-name quoth t t))
+       (setq quoth (replace-regexp-in-string "%L" last-name quoth t t))
+       (setq quoth (format-time-string quoth time))
+       (insert quoth))

       (if plain-parts
          (mapc (lambda (part) (notmuch-mua-insert-part-quoted part)) 
plain-parts)
diff --git a/test/emacs b/test/emacs
index ac47b16..3f59b23 100755
--- a/test/emacs
+++ b/test/emacs
@@ -268,7 +268,7 @@ Subject: Re: Testing message sent via SMTP
 In-Reply-To: <XXX>
 Fcc: $(pwd)/mail/sent
 --text follows this line--
-On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite at 
notmuchmail.org> wrote:
+On Sat, Jan 01 2000, Notmuch Test Suite wrote:
 > This is a test that messages are sent via SMTP
 EOF
 test_expect_equal_file OUTPUT EXPECTED
-- 
1.7.5.4

Reply via email to