all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Ryde <user42@zip.com.au>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: 7337@debbugs.gnu.org
Subject: bug#7337: 23.2; (require 'time) changes timezone
Date: Fri, 15 Jul 2011 10:40:50 +1000	[thread overview]
Message-ID: <87k4bkjrzh.fsf@blah.blah> (raw)
In-Reply-To: <m3ei1s2a8m.fsf@quimbies.gnus.org> (Lars Magne Ingebrigtsen's message of "Thu, 14 Jul 2011 16:43:53 +0200")

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
> Hm.  Would that be returning the tzname variable (as described in the
> tzet manual page)?

Probably not, perhaps the TZ entry the C-level environ[], if that's
essentially what set-time-zone-rule writes to.

I later changed the macro I posted to the bit below, doing a `setenv' on
restoring as well as `set-time-zone-rule'.  I suspect set-time-zone-rule
might update the lisp process-environment as well as the C environ[]
... but I'm not certain if that's right, or enough, for combinations of
save/restore and to influence the current process and/or spawned
subprocesses, etc etc.






(defmacro xtide-with-TZ (tz &rest body)
  ;; checkdoc-params: (tz body)
  "Run BODY with `set-time-zone-rule' temporarily to TZ.
The current timezone (per `getenv' \"TZ\") is restored by an
`unwind-protect'.

This doesn't work properly if a `set-time-zone-rule' has been
applied but (setenv \"TZ\") not updated accordingly.  A `setenv'
is done here so that `xtide-with-TZ' will nest successfully at
least."

  ;; This getenv and restore is similar to what add-log.el
  ;; `add-change-log-entry' and time-stamp.el `time-stamp-string' do.  In
  ;; Emacs 23.2 the initializer in `display-time-world-list' always sets
  ;; back to nil, but a restore seems a much better idea.
  ;;
  ;; (setenv "TZ") makes the new TZ visible to a nested `xtide-with-TZ' or
  ;; to `add-change-log-entry'.  As of Emacs 23.2 `set-time-zone-rule'
  ;; changes TZ in the C-level environ[], but not in the lisp level
  ;; `process-environment'.
  ;;
  ;; setenv in emacs22 up returns the value set, but in emacs21 and xemacs21
  ;; it's the whole new `process-environment', or some such, so don't depend
  ;; on the value.
  ;;
  ;; setenv in emacs22 up also calls `set-time-zone-rule' itself, but for
  ;; emacs21 and xemacs21 must do so explicitly
  ;;
  (declare (indent 1)) ;; from 'cl
  `(let ((xtide-with-TZ--old (getenv "TZ"))
         (xtide-with-TZ--new ,tz)) ;; evaluate `tz' expression only once
     (setenv "TZ" xtide-with-TZ--new)
     (set-time-zone-rule xtide-with-TZ--new)
     (unwind-protect
         (progn ,@body)
       (setenv "TZ" xtide-with-TZ--old)
       (set-time-zone-rule xtide-with-TZ--old))))





      reply	other threads:[~2011-07-15  0:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-05 21:46 bug#7337: 23.2; (require 'time) changes timezone Kevin Ryde
2010-11-08 18:01 ` Stefan Monnier
2010-11-09  0:36   ` Kevin Ryde
2010-11-18  0:16     ` Kevin Ryde
2011-08-08 15:55     ` Chong Yidong
2011-07-14 14:43   ` Lars Magne Ingebrigtsen
2011-07-15  0:40     ` Kevin Ryde [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k4bkjrzh.fsf@blah.blah \
    --to=user42@zip.com.au \
    --cc=7337@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.