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

StackOverflow https://stackoverflow.com/questions/12866308

  •  07-07-2021
  •  | 
  •  

Domanda

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" <johndoe@example.com> 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" <johndoe@example.com> 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))
            "somebody@example.com"))
        " 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 <johndoe@example.com> wrote:
È stato utile?

Soluzione

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 :)

Altri suggerimenti

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")))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top