]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: Have email reply positions respect relevant message.el options
authorKristoffer Balintona <krisbalintona@gmail.com>
Tue, 5 Nov 2024 03:22:39 +0000 (21:22 -0600)
committerDavid Bremner <david@tethera.net>
Sat, 24 Jan 2026 23:29:27 +0000 (08:29 +0900)
Previously, when composing email replies with `notmuch-mua-new-mail',
the email signature would always be placed below the email citation.
However, there are two message.el user options that affect the
position of the signature and email body:
`message-cite-reply-position` and `message-cite-style-gmail'.
Previously, neither of these user options were respected.

Respect these user options. If `message-cite-reply-position' is
'traditional or 'below, place the email signature below the citation
(the previous behavior is retained). If `message-cite-reply-position'
is 'above, place the email signature above the citation (like in
Gmail-style email replies).

`message-cite-style-gmail' may specify a value for
`message-cite-reply-position'. If it does, that value takes precedence
over `message-cite-reply-position'.

emacs/notmuch-mua.el

index 74c62aafd28d69eb5de5135ee4f9f53c481d72e4..74bb559a6abc7efe8f5e9062c9350a2682040ff3 100644 (file)
@@ -318,6 +318,29 @@ Typically this is added to `notmuch-mua-send-hook'."
            (when message-signature-insert-empty-line
              (forward-line -1))
          (goto-char (point-max))))
+      ;; If `message-cite-reply-position' is the symbol 'above, then
+      ;; before inserting the citation, put the point after the
+      ;; signature and insert a newline for spacing.  This emulates
+      ;; the Gmail-style of email replies, where the signature and
+      ;; email reply body are above the email citation.  If
+      ;; `message-cite-style'is non-nil and specifies a value for
+      ;; `message-cite-reply-position', then use that value instead.
+      ;;
+      ;; Regarding the use of `cadadr' instead of `cdr' on the result
+      ;; of `assoc' below: the value stored in `message-cite-style' is
+      ;; itself a quoted form, e.g., (quote above).  Using `cdr' once
+      ;; returns that entire quoted form.  Using `cadadr' skips the
+      ;; `quote' symbol and returns the underlying symbol
+      ;; (e.g. `above').  (We do this to avoid a call to `eval'
+      ;; because of security concerns.)
+      (when (eq (or (cadadr (assoc 'message-cite-reply-position
+                                  (if (symbolp message-cite-style)
+                                      (symbol-value message-cite-style)
+                                    message-cite-style)))
+                   message-cite-reply-position)
+               'above)
+       (goto-char (point-max))
+       (insert "\n"))
       (let ((from (plist-get original-headers :From))
            (date (plist-get original-headers :Date))
            (start (point)))