Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

gnus

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:
like image 498
mgalgs Avatar asked Oct 12 '12 20:10

mgalgs


2 Answers

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

like image 107
kindahero Avatar answered Nov 03 '22 17:11

kindahero


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")))
like image 2
perh Avatar answered Nov 03 '22 16:11

perh