From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.bugs Subject: bug#7337: 23.2; (require 'time) changes timezone Date: Fri, 15 Jul 2011 10:40:50 +1000 Message-ID: <87k4bkjrzh.fsf@blah.blah> References: <87fwvftpdp.fsf@blah.blah> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1310690671 5060 80.91.229.12 (15 Jul 2011 00:44:31 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Jul 2011 00:44:31 +0000 (UTC) Cc: 7337@debbugs.gnu.org To: Lars Magne Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 15 02:44:27 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QhWW0-000143-R1 for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Jul 2011 02:44:24 +0200 Original-Received: from localhost ([::1]:53711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhWVz-0002yu-T7 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2011 20:44:23 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:39551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhWVj-0002yg-0H for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 20:44:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhWVe-0002ij-W6 for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 20:44:06 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhWVe-0002id-S2 for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2011 20:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QhWVe-0007ci-2o; Thu, 14 Jul 2011 20:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kevin Ryde Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Jul 2011 00:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7337 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7337-submit@debbugs.gnu.org id=B7337.131069058829239 (code B ref 7337); Fri, 15 Jul 2011 00:44:01 +0000 Original-Received: (at 7337) by debbugs.gnu.org; 15 Jul 2011 00:43:08 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhWUm-0007bX-74 for submit@debbugs.gnu.org; Thu, 14 Jul 2011 20:43:08 -0400 Original-Received: from mailout2-6.pacific.net.au ([61.8.2.229] helo=mailout2.pacific.net.au) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QhWUi-0007az-9N for 7337@debbugs.gnu.org; Thu, 14 Jul 2011 20:43:06 -0400 Original-Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout2.pacific.net.au (Postfix) with ESMTP id A5DFE2BBA36; Fri, 15 Jul 2011 10:42:56 +1000 (EST) Original-Received: from blah.blah (unknown [203.26.175.98]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 96DBB27424; Fri, 15 Jul 2011 10:42:49 +1000 (EST) Original-Received: from gg by blah.blah with local (Exim 4.72) (envelope-from ) id 1QhWSY-00064y-Kd; Fri, 15 Jul 2011 10:40:50 +1000 In-Reply-To: (Lars Magne Ingebrigtsen's message of "Thu, 14 Jul 2011 16:43:53 +0200") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 14 Jul 2011 20:44:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:49103 Archived-At: Lars Magne Ingebrigtsen 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))))