Include date and time of original message in quoted reply using emacs and gnus
Asked Answered
B

2

9

When I use one of the *-with-original functions to reply to a message using gnus (message) in emacs, I get a quotation similar to this:

"Doe, John" <[email protected]> writes:

> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
> Consectetuer adipiscing elit. Lorem ipsum dolor sit
> amet, consectetuer adipiscing elit.

I would like gnus to behave like other MUAs that include the date and time of the original message, something like:

On Thu 11 October 2012 09:20:12 "Doe, John" <[email protected]> wrote:

> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
> Consectetuer adipiscing elit. Lorem ipsum dolor sit
> amet, consectetuer adipiscing elit.

Is there any way to change the style of quotation to accomplish this?


Update 2: I'm now using an even simpler solution, from kindahero's answer:

(setq message-citation-line-function 'message-insert-formatted-citation-line)
(setq message-citation-line-format "On %a, %b %d %Y at %r, %f wrote:")

Update 1: I ended up with the following solution, based on perh's answer:

(defun my-citation-line ()
  "Inserts name, email, and date"
  (when message-reply-headers
    (insert "On "
        (format-time-string "%a, %b %e, %Y at %r"
                (date-to-time (mail-header-date message-reply-headers)))
        ", "
        (or (gnus-extract-address-component-name (mail-header-from message-reply-headers))
        "Somebody")
        (format " <%s>"
            (or (gnus-extract-address-component-email (mail-header-from message-reply-headers))
            "[email protected]"))
        " wrote:\n")))

(setq message-citation-line-function 'my-citation-line)

The end result looks like this:

On Fri, Oct 12, 2012 at 03:11:48 PM, John Doe <[email protected]> wrote:
Bedeck answered 12/10, 2012 at 20:4 Comment(0)
K
9

actually gnus provides formatted function for you.

(setq message-citation-line-function 'message-insert-formatted-citation-line)
(setq message-citation-line-format "On %a, %b %d %Y, %f wrote:\n")

change the varible according to your taste.. `format-time-string' has options list

Less lines in .emacs :)

Keitloa answered 14/10, 2012 at 10:19 Comment(1)
simpler wins. this is perfect.Bedeck
M
2

You can set the message-citation-line-function to a suitable function inserting the header:

(setq message-citation-line-function 'my-citation-line)

As an example, this function gives the name and an unnormalized date:

(defun my-citation-line ()
   "Inserts name and date"
   (when message-reply-headers
     (insert 
        (or (gnus-extract-address-component-name
         (mail-header-from message-reply-headers))
            "Somebody")
       ", "
       (mail-header-date message-reply-headers)))
       "\n")))
Mcinerney answered 12/10, 2012 at 20:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.