aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorChong Yidong2011-08-08 11:53:35 -0400
committerChong Yidong2011-08-08 11:53:35 -0400
commit37e11a631937986f03f6216655ea1c964f7286aa (patch)
tree0ea4917e2a3f3d1a71a9a77ec4d45fccf92a6754 /lisp
parentd56176114c8c9226a43db4bf68df562486e454ed (diff)
downloademacs-37e11a631937986f03f6216655ea1c964f7286aa.tar.gz
emacs-37e11a631937986f03f6216655ea1c964f7286aa.zip
Lisp code shouldn't use set-time-zone-rule except through setenv.
* time.el (display-time-world-list, display-time-world-display): * time-stamp.el (time-stamp-string): * vc/add-log.el (add-change-log-entry): Use setenv instead of set-time-zone-rule. * src/editfns.c (Fset_time_zone_rule): Document relationship with the setenv function. Fixes: debbugs:7337
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/time-stamp.el4
-rw-r--r--lisp/time.el61
-rw-r--r--lisp/vc/add-log.el4
4 files changed, 43 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d2ea294d2d0..bd344dad35a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12011-08-08 Chong Yidong <cyd@stupidchicken.com>
2
3 * time.el (display-time-world-list, display-time-world-display):
4 * time-stamp.el (time-stamp-string):
5 * vc/add-log.el (add-change-log-entry): Use setenv instead of
6 set-time-zone-rule (Bug#7337).
7
12011-08-08 Daiki Ueno <ueno@unixuser.org> 82011-08-08 Daiki Ueno <ueno@unixuser.org>
2 9
3 * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): Fix typo. 10 * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): Fix typo.
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 59340583997..fda8cd1438d 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -424,10 +424,10 @@ format the string."
424 (let ((ts-real-time-zone (getenv "TZ"))) 424 (let ((ts-real-time-zone (getenv "TZ")))
425 (unwind-protect 425 (unwind-protect
426 (progn 426 (progn
427 (set-time-zone-rule time-stamp-time-zone) 427 (setenv "TZ" time-stamp-time-zone)
428 (format-time-string 428 (format-time-string
429 (time-stamp-string-preprocess ts-format))) 429 (time-stamp-string-preprocess ts-format)))
430 (set-time-zone-rule ts-real-time-zone))) 430 (setenv "TZ" ts-real-time-zone)))
431 (format-time-string 431 (format-time-string
432 (time-stamp-string-preprocess ts-format))) 432 (time-stamp-string-preprocess ts-format)))
433 ;; handle version 1 compatibility 433 ;; handle version 1 compatibility
diff --git a/lisp/time.el b/lisp/time.el
index b158ef64691..f8fea0c64a2 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -156,21 +156,24 @@ LABEL is a string to display as the label of that TIMEZONE's time."
156(defcustom display-time-world-list 156(defcustom display-time-world-list
157 ;; Determine if zoneinfo style timezones are supported by testing that 157 ;; Determine if zoneinfo style timezones are supported by testing that
158 ;; America/New York and Europe/London return different timezones. 158 ;; America/New York and Europe/London return different timezones.
159 (let (gmt nyt) 159 (let ((old-tz (getenv "TZ"))
160 (set-time-zone-rule "America/New_York") 160 gmt nyt)
161 (setq nyt (format-time-string "%z")) 161 (unwind-protect
162 (set-time-zone-rule "Europe/London") 162 (progn
163 (setq gmt (format-time-string "%z")) 163 (setenv "TZ" "America/New_York")
164 (set-time-zone-rule nil) 164 (setq nyt (format-time-string "%z"))
165 (setenv "TZ" "Europe/London")
166 (setq gmt (format-time-string "%z")))
167 (setenv "TZ" old-tz))
165 (if (string-equal nyt gmt) 168 (if (string-equal nyt gmt)
166 legacy-style-world-list 169 legacy-style-world-list
167 zoneinfo-style-world-list)) 170 zoneinfo-style-world-list))
168 "Alist of time zones and places for `display-time-world' to display. 171 "Alist of time zones and places for `display-time-world' to display.
169Each element has the form (TIMEZONE LABEL). 172Each element has the form (TIMEZONE LABEL).
170TIMEZONE should be in the format supported by `set-time-zone-rule' on 173TIMEZONE should be in a format supported by your system. See the
171your system. See the documentation of `zoneinfo-style-world-list' and 174documentation of `zoneinfo-style-world-list' and
172\`legacy-style-world-list' for two widely used formats. 175\`legacy-style-world-list' for two widely used formats. LABEL is
173LABEL is a string to display as the label of that TIMEZONE's time." 176a string to display as the label of that TIMEZONE's time."
174 :group 'display-time 177 :group 'display-time
175 :type '(repeat (list string string)) 178 :type '(repeat (list string string))
176 :version "23.1") 179 :version "23.1")
@@ -521,26 +524,26 @@ See `display-time-world'."
521(defun display-time-world-display (alist) 524(defun display-time-world-display (alist)
522 "Replace current buffer text with times in various zones, based on ALIST." 525 "Replace current buffer text with times in various zones, based on ALIST."
523 (let ((inhibit-read-only t) 526 (let ((inhibit-read-only t)
524 (buffer-undo-list t)) 527 (buffer-undo-list t)
528 (old-tz (getenv "TZ"))
529 (max-width 0)
530 result fmt)
525 (erase-buffer) 531 (erase-buffer)
526 (let ((max-width 0) 532 (unwind-protect
527 (result ()) 533 (dolist (zone alist)
528 fmt) 534 (let* ((label (cadr zone))
529 (unwind-protect 535 (width (string-width label)))
530 (dolist (zone alist) 536 (setenv "TZ" (car zone))
531 (let* ((label (cadr zone)) 537 (push (cons label
532 (width (string-width label))) 538 (format-time-string display-time-world-time-format))
533 (set-time-zone-rule (car zone)) 539 result)
534 (push (cons label 540 (when (> width max-width)
535 (format-time-string display-time-world-time-format)) 541 (setq max-width width))))
536 result) 542 (setenv "TZ" old-tz))
537 (when (> width max-width) 543 (setq fmt (concat "%-" (int-to-string max-width) "s %s\n"))
538 (setq max-width width)))) 544 (dolist (timedata (nreverse result))
539 (set-time-zone-rule nil)) 545 (insert (format fmt (car timedata) (cdr timedata)))))
540 (setq fmt (concat "%-" (int-to-string max-width) "s %s\n")) 546 (delete-char -1))
541 (dolist (timedata (nreverse result))
542 (insert (format fmt (car timedata) (cdr timedata)))))
543 (delete-char -1)))
544 547
545;;;###autoload 548;;;###autoload
546(defun display-time-world () 549(defun display-time-world ()
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index e5aead2309f..9170d7b9424 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -853,9 +853,9 @@ non-nil, otherwise in local time."
853 (let ((tz (getenv "TZ"))) 853 (let ((tz (getenv "TZ")))
854 (unwind-protect 854 (unwind-protect
855 (progn 855 (progn
856 (set-time-zone-rule add-log-time-zone-rule) 856 (setenv "TZ" add-log-time-zone-rule)
857 (funcall add-log-time-format)) 857 (funcall add-log-time-format))
858 (set-time-zone-rule tz))) 858 (setenv "TZ" tz)))
859 (funcall add-log-time-format)) 859 (funcall add-log-time-format))
860 " " full-name 860 " " full-name
861 " <" addr ">")) 861 " <" addr ">"))