diff options
| author | Chong Yidong | 2011-08-08 11:53:35 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-08-08 11:53:35 -0400 |
| commit | 37e11a631937986f03f6216655ea1c964f7286aa (patch) | |
| tree | 0ea4917e2a3f3d1a71a9a77ec4d45fccf92a6754 | |
| parent | d56176114c8c9226a43db4bf68df562486e454ed (diff) | |
| download | emacs-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
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/time-stamp.el | 4 | ||||
| -rw-r--r-- | lisp/time.el | 61 | ||||
| -rw-r--r-- | lisp/vc/add-log.el | 4 | ||||
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/editfns.c | 7 |
6 files changed, 52 insertions, 34 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d2ea294d2d0..bd344dad35a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2011-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 | |||
| 1 | 2011-08-08 Daiki Ueno <ueno@unixuser.org> | 8 | 2011-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. |
| 169 | Each element has the form (TIMEZONE LABEL). | 172 | Each element has the form (TIMEZONE LABEL). |
| 170 | TIMEZONE should be in the format supported by `set-time-zone-rule' on | 173 | TIMEZONE should be in a format supported by your system. See the |
| 171 | your system. See the documentation of `zoneinfo-style-world-list' and | 174 | documentation 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 |
| 173 | LABEL is a string to display as the label of that TIMEZONE's time." | 176 | a 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 ">")) |
diff --git a/src/ChangeLog b/src/ChangeLog index 4df4455e862..cbe2d8659b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | 2011-08-08 Chong Yidong <cyd@stupidchicken.com> | 1 | 2011-08-08 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 2 | ||
| 3 | * editfns.c (Fset_time_zone_rule): Document relationship with the | ||
| 4 | setenv function. | ||
| 5 | |||
| 3 | * ftfont.c (ftfont_pattern_entity): Copy the extras argument to | 6 | * ftfont.c (ftfont_pattern_entity): Copy the extras argument to |
| 4 | the font entity extracted from the cache (Bug#8109). | 7 | the font entity extracted from the cache (Bug#8109). |
| 5 | 8 | ||
diff --git a/src/editfns.c b/src/editfns.c index 5eed386afb7..297f7b6d7e4 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2053,7 +2053,12 @@ static char *initial_tz; | |||
| 2053 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, | 2053 | DEFUN ("set-time-zone-rule", Fset_time_zone_rule, Sset_time_zone_rule, 1, 1, 0, |
| 2054 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. | 2054 | doc: /* Set the local time zone using TZ, a string specifying a time zone rule. |
| 2055 | If TZ is nil, use implementation-defined default time zone information. | 2055 | If TZ is nil, use implementation-defined default time zone information. |
| 2056 | If TZ is t, use Universal Time. */) | 2056 | If TZ is t, use Universal Time. |
| 2057 | |||
| 2058 | Instead of calling this function, you typically want (setenv "TZ" TZ). | ||
| 2059 | That changes both the environment of the Emacs process and the | ||
| 2060 | variable `process-environment', whereas `set-time-zone-rule' affects | ||
| 2061 | only the former. */) | ||
| 2057 | (Lisp_Object tz) | 2062 | (Lisp_Object tz) |
| 2058 | { | 2063 | { |
| 2059 | const char *tzstring; | 2064 | const char *tzstring; |