Search code examples
emacselispemacs24gnususenet

Per newsgroup timezone in Date: header


How to configure emacs/gnus to use per newsgroup time zone in posted messages?

I would like to use CET time zone in pl.* newsgroups and UCT in general newsgroups.


Solution

  • I would use message-header-setup-hook or message-send-hook with this function:

    (defvar date-rewrite-rules
      '(("pl" . return-time-string-in-CET)
        ("." . return-time-string-in-UTC)))
    (defun rewrite-date-based-on-newsgroup ()
      (save-excursion
        (save-restriction
          (widen)
          (goto-char 0)
          (narrow-to-region 0 (search-forward mail-header-separator))
          (goto-char 0)
          (search-forward-regexp "^Newsgroup: ")
          (let ((date-f nil)
                (tail date-rewrite-rules))
            (while (and (null date-f)
                        tail)
              (let ((rule (pop tail)))
                (when (looking-at (car rule))
                  (setq date-f (cdr rule)))))
            (when date-f
              (goto-char 0)
              (search-forward-regexp "^Date: ")
              (delete-region (point) (line-end-position))
              (insert (funcall date-f)))))))
    

    NB: the code is untested, this is merely a starting point from which you should develop your solution.