The default behavior in emacs-25 for the following code is for message citation lines to display the time in UTC, even if (current-time-zone) returns a local time zone such as (-18000 "EST"), and even though (current-time-string) correctly returns a result in local time, and even though my "TZ" environment variable and /etc/localtime are properly set to my local time zone ...

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

If I want the citation line to show the time in local time instead of UTC, I have to wrap message-insert-formatted-citation-line as follows ...

(defun my-message-insert-formatted-citation-line ()
  (message-insert-formatted-citation-line nil nil (car (current-time-zone))))
(setq message-citation-line-function 'my-message-insert-formatted-citation-line)

However, even with this hack, the citation line shows the time zone as a number (e.g., "-0500") for both the %Z and %z format characters.

I'd like the citation line to show the time zone using the actual timezone ID from (cdr (current-time-zone)) instead of a number. In my case, that would be "EST".

In other words, I'd like the citation lines to look something like this:

On Thu 04-Jul-1776 at 12:34:56 EST, Thomas Jefferson <tommy@colonies.uk.gov> wrote:

Note the "EST", which now can only appear as "-0500".

If I pass (cdr (current-time-zone)) as the final argument to message-insert-formatted-citation-line, it is ignored, and the time is once again displayed in UTC.

Does anyone know of an already-existing alternative function for creating citation lines, which doesn't default to UTC, and which properly shows the local time with the actual name of the time zone?

I know I could copy the message-insert-formatted-citation-line function from gnus/message.el to a new function called my-message-insert-formatted-citation-line and change how it handles its "tz" parameter. However, that is a long, complicated function, and I'd rather make use of something that has already been written, if such a function exists anywhere, than to hack this existing function.

Does anyone know of a pre-existing alternative to message-insert-formatted-citation-line that works the way I'd like?

Thank you very much, in advance.

  • The function message-insert-formatted-citation-line accepts an optional argument for the timezone. So trace the usage of message-citation-line-function and see if it is using such an argument -- if not, then fix it. :) You may wish to first play with message-insert-formatted-citation-line in a *scratch* buffer using the optional argument to see if you can get it to do what you want: (message-insert-formatted-citation-line &optional FROM DATE TZ) I see only five (5) usages of message-citation-line-function in message.el and none of them have timezone as an argument. – lawlist Dec 17 '16 at 17:00
  • I already explained in my post how message-insert-formatted-citation-line handles the tz parameter. I also explained that I already read the code in gnus/messge.el, and I even posted a workaround. But the existing code only displays the timezone as a number such as "-0500" instead of by name, such as "EST" ... which I also explained in my post. And I even said that I'm willing to rewrite message-insert-formatted-citation-line, if necessary, but that the reason for my question here is that I'm wondering if this has already been done. I'd rather use something pre-existing, if possble. – HippoMan Dec 17 '16 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.