You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more a feature request than an issue, although my wish to be able to customise the reply/forward citation lines arose from an issue I had with the citation line created by org-msg (which down the track comes from gnus-article-browse-html-article I believe).
The issue I had was that From: would mention several authors when I reply to an email thread, somewhat inconsistently, as the email thread had at least 3 authors, but only two would be mentioned in the From: line. I would only expect a single author to be mentioned in From:! Also the same author would be found twice on the Cc: line, despite the email being replied to only having that author in Cc once. Finally, the citation line when responding in html was different from the one when responding in plain text.
Copying the Outlook look-and-feel is great (since this is also my corporate environment), but I still feel it would be nice to offer the possibility of customising the citation line. I managed to achieve this by dirty hacks to org-msg.el (I'd feel awkward to PR these, and I don't know how easily the below transfers to other muas than mu4e). I can now have a failsafe, consistent citation line when replying/forwarding in html and in text formats. Here are the basic steps:
In my .emacs, I edit message-citation-line-format by extracting information from the original message rather than format specifiers (see its docstring). These format specifiers (%f, %a, %Z etc) are not substituted properly when I use this variable for an html reply/forward in org-msg. The variable message-citation-line-format can be set up in any way you like. Mine below is based on how a forward looks like in alpine. (This is a simplified version. In my actual customisation, I edit the message-citation-line-format variable differently for a forward than for a reply in my .emacs.)
(setq
;; ;; Use time zone of the original author (at least for plain-text reply/forward):
;; message-citation-line-function 'message-insert-formatted-citation-line
;; Use optional arguments of message-insert-formatted-citation-line so time zone is local rather than that of the original author
message-citation-line-function '(lambda()
(let* ((from (mail-header-from message-reply-headers))
(date (mail-header-date message-reply-headers)))
(message-insert-formatted-citation-line from date (current-time-zone))))
(add-hook 'mu4e-compose-pre-hook 'lambda()
(let ((msg mu4e-compose-parent-message)) ;; msg is nil if new (not reply, forward, or edit)
(when msg
(let* ((date (mu4e-message-field msg :date))
(from (car (mu4e-message-field msg :from)))
(fromname (plist-get from :name))
(fromemail (plist-get from :email))
(to_list (mu4e-message-field msg :to))
(cc_list (mu4e-message-field msg :cc))
(subject (mu4e-message-field msg :subject))
(to_string (substring (loop for (keyemail email keyname name) in to_list concat (format "%s <%s>,\n\t" name email)) 0 -3));; remove terminal comma
(cc_string (if cc_list (substring (loop for (keyemail email keyname name) in cc_list concat (format "%s <%s>,\n\t" name email)) 0 -3) "")));; remove terminal comma
(setq message-citation-line-format (concat
(format "Date: %s\n" (format-time-string "%a %d %b %Y %R %Z" date))
(format "From: %s <%s>\n" fromname fromemail)
(format "To: %s\n" to_string)
(when cc_list (format "Cc: %s\n" cc_string))
(format "Subject: %s\n\n" subject)))))))
In org-msg.el, I shadow the argument header of org-msg-save-article-for-reply-gnus (called by org-msg-save-article-for-reply-mu4e) by adding a local variable header set to the message-citation-line-format variable prepared above:
[...]
(let* ((browse-url-browser-function #'ignore)
(save (cl-copy-list gnus-article-browse-html-temp-list))
(header message-citation-line-format)) ;; added to shadow the function's argument
[...]
I do some more dirty things in org-msg-improve-reply-header so it looks nicer to me: I don't delete line breaks, and I explicitly boldface only "\nDate", "\nFrom", "\nTo", "\nCc", "\nSubject" when prefix equals these strings (needed for my format because Cc is a list of contacts, one per line). Here is the relevant code for this part:
I also don't replace name/emails by mailto links, because I like being able to select the list for copy/pasting into a new email from time to time.
Note the above also automatically removes the issue of the 'attachment' line being sometimes added by gnus. (I am sure it must be possible to grab that info from mu4e-compose-parent-message and mu4e-message-field but I am not interested in it either.)
This gives me a citation line looking like this:
Date: Fri 07 Jul 2023 15:55 AEST From: prbuen <my@email> To: Re Cipient <re@cipient> Cc: Carbon Copy1 <carbon@copy1>,
___ Carbon Copy2 <carbon@copy2>,
___ Carbon Copy3 <carbon@copy3> Subject: Customising reply/format citation line in org-msg
Hello,
This is an amazing package, thanks so much for writing it! It is the reason I can keep emailing in Emacs in my professional environment :). The only hitch above is a lack of alignment of the different lines in Cc (fine with fixed width fonts only; some better text-to-html translation would be needed).
Thanks,
P
The text was updated successfully, but these errors were encountered:
This is more a feature request than an issue, although my wish to be able to customise the reply/forward citation lines arose from an issue I had with the citation line created by org-msg (which down the track comes from
gnus-article-browse-html-article
I believe).The issue I had was that From: would mention several authors when I reply to an email thread, somewhat inconsistently, as the email thread had at least 3 authors, but only two would be mentioned in the From: line. I would only expect a single author to be mentioned in From:! Also the same author would be found twice on the Cc: line, despite the email being replied to only having that author in Cc once. Finally, the citation line when responding in html was different from the one when responding in plain text.
Copying the Outlook look-and-feel is great (since this is also my corporate environment), but I still feel it would be nice to offer the possibility of customising the citation line. I managed to achieve this by dirty hacks to org-msg.el (I'd feel awkward to PR these, and I don't know how easily the below transfers to other muas than
mu4e
). I can now have a failsafe, consistent citation line when replying/forwarding in html and in text formats. Here are the basic steps:.emacs
, I editmessage-citation-line-format
by extracting information from the original message rather than format specifiers (see its docstring). These format specifiers (%f, %a, %Z etc) are not substituted properly when I use this variable for an html reply/forward inorg-msg
. The variablemessage-citation-line-format
can be set up in any way you like. Mine below is based on how a forward looks like inalpine
. (This is a simplified version. In my actual customisation, I edit themessage-citation-line-format
variable differently for a forward than for a reply in my.emacs
.)org-msg.el
, I shadow the argumentheader
oforg-msg-save-article-for-reply-gnus
(called byorg-msg-save-article-for-reply-mu4e
) by adding a local variableheader
set to themessage-citation-line-format
variable prepared above:org-msg-improve-reply-header
so it looks nicer to me: I don't delete line breaks, and I explicitly boldface only "\nDate", "\nFrom", "\nTo", "\nCc", "\nSubject" when prefix equals these strings (needed for my format because Cc is a list of contacts, one per line). Here is the relevant code for this part:I also don't replace name/emails by mailto links, because I like being able to select the list for copy/pasting into a new email from time to time.
Note the above also automatically removes the issue of the 'attachment' line being sometimes added by gnus. (I am sure it must be possible to grab that info from
mu4e-compose-parent-message
andmu4e-message-field
but I am not interested in it either.)This gives me a citation line looking like this:
The text was updated successfully, but these errors were encountered: