diff options
| author | Paul Eggert | 2019-02-10 23:46:24 -0800 |
|---|---|---|
| committer | Paul Eggert | 2019-02-10 23:54:35 -0800 |
| commit | 93241242537ad18b08486d4abd00e16c225a6a30 (patch) | |
| tree | 762c5c8c203c4b1f93a5b9f2fafbf86fbd894ce7 | |
| parent | 988e37fa0f922b852715671d59a0e3f682373411 (diff) | |
| download | emacs-93241242537ad18b08486d4abd00e16c225a6a30.tar.gz emacs-93241242537ad18b08486d4abd00e16c225a6a30.zip | |
Don’t assume CURRENT_TIME_LIST
Use timestamp accessors instead of delving into a timestamp
format that is planned to change in a future version.
* lisp/find-lisp.el (find-lisp-format-time):
* lisp/gnus/gnus-group.el (gnus-group-set-timestamp):
* lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda):
Use encode-time instead of delving into timestamp format.
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
Use float-time instead of delving into timestamp format.
* lisp/gnus/nnmaildir.el (nnmaildir-request-accept-article):
Use format-time-string instead of delving into timestamp format.
* lisp/gnus/nnmaildir.el (nnmaildir-request-expire-articles):
Use time-less-p instead of delving into timestamp format.
* lisp/ido.el (ido-wash-history, ido-file-name-all-completions):
Use time-equal-p instead of delving into timestamp format.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use format-time-string to generate POSIX ‘test -t’ format instead
of timestamp-format-dependent code along with shell arithmetic
that can’t possibly do the right thing on a POSIX platform.
| -rw-r--r-- | lisp/find-lisp.el | 11 | ||||
| -rw-r--r-- | lisp/gnus/gnus-group.el | 11 | ||||
| -rw-r--r-- | lisp/gnus/gnus-icalendar.el | 5 | ||||
| -rw-r--r-- | lisp/gnus/nnmaildir.el | 15 | ||||
| -rw-r--r-- | lisp/ido.el | 31 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 5 | ||||
| -rw-r--r-- | lisp/woman.el | 6 |
7 files changed, 32 insertions, 52 deletions
diff --git a/lisp/find-lisp.el b/lisp/find-lisp.el index c5febee6f5c..073e2bc573f 100644 --- a/lisp/find-lisp.el +++ b/lisp/find-lisp.el | |||
| @@ -342,16 +342,11 @@ list of ls option letters of which c and u are recognized). Use | |||
| 342 | the same method as \"ls\" to decide whether to show time-of-day or | 342 | the same method as \"ls\" to decide whether to show time-of-day or |
| 343 | year, depending on distance between file date and NOW." | 343 | year, depending on distance between file date and NOW." |
| 344 | (let* ((time (nth (find-lisp-time-index switches) file-attr)) | 344 | (let* ((time (nth (find-lisp-time-index switches) file-attr)) |
| 345 | (diff16 (- (car time) (car now))) | 345 | (diff (encode-time (time-subtract time now) 'integer)) |
| 346 | (diff (+ (ash diff16 16) (- (car (cdr time)) (car (cdr now))))) | 346 | (past-cutoff -15778476) ; 1/2 of a Gregorian year |
| 347 | (past-cutoff (- (* 6 30 24 60 60))) ; 6 30-day months | ||
| 348 | (future-cutoff (* 60 60))) ; 1 hour | 347 | (future-cutoff (* 60 60))) ; 1 hour |
| 349 | (format-time-string | 348 | (format-time-string |
| 350 | (if (and | 349 | (if (<= past-cutoff diff future-cutoff) |
| 351 | (<= past-cutoff diff) (<= diff future-cutoff) | ||
| 352 | ;; Sanity check in case `diff' computation overflowed. | ||
| 353 | (<= (1- (ash past-cutoff -16)) diff16) | ||
| 354 | (<= diff16 (1+ (ash future-cutoff -16)))) | ||
| 355 | "%b %e %H:%M" | 350 | "%b %e %H:%M" |
| 356 | "%b %e %Y") | 351 | "%b %e %Y") |
| 357 | time))) | 352 | time))) |
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el index 510bd7415d9..cf8423b2db1 100644 --- a/lisp/gnus/gnus-group.el +++ b/lisp/gnus/gnus-group.el | |||
| @@ -4578,8 +4578,7 @@ and the second element is the address." | |||
| 4578 | This function can be used in hooks like `gnus-select-group-hook' | 4578 | This function can be used in hooks like `gnus-select-group-hook' |
| 4579 | or `gnus-group-catchup-group-hook'." | 4579 | or `gnus-group-catchup-group-hook'." |
| 4580 | (when gnus-newsgroup-name | 4580 | (when gnus-newsgroup-name |
| 4581 | (let ((time (current-time))) | 4581 | (let ((time (encode-time nil 'integer))) |
| 4582 | (setcdr (cdr time) nil) | ||
| 4583 | (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))) | 4582 | (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time)))) |
| 4584 | 4583 | ||
| 4585 | (defsubst gnus-group-timestamp (group) | 4584 | (defsubst gnus-group-timestamp (group) |
| @@ -4588,11 +4587,11 @@ or `gnus-group-catchup-group-hook'." | |||
| 4588 | 4587 | ||
| 4589 | (defun gnus-group-timestamp-delta (group) | 4588 | (defun gnus-group-timestamp-delta (group) |
| 4590 | "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number." | 4589 | "Return the offset in seconds from the timestamp for GROUP to the current time, as a floating point number." |
| 4591 | (let* ((time (or (gnus-group-timestamp group) | 4590 | ;; FIXME: This should return a Lisp integer, not a Lisp float, |
| 4592 | (list 0 0))) | 4591 | ;; since it is always an integer. |
| 4592 | (let* ((time (or (gnus-group-timestamp group) 0)) | ||
| 4593 | (delta (time-subtract nil time))) | 4593 | (delta (time-subtract nil time))) |
| 4594 | (+ (* (nth 0 delta) 65536.0) | 4594 | (float-time delta))) |
| 4595 | (nth 1 delta)))) | ||
| 4596 | 4595 | ||
| 4597 | (defun gnus-group-timestamp-string (group) | 4596 | (defun gnus-group-timestamp-string (group) |
| 4598 | "Return a string of the timestamp for GROUP." | 4597 | "Return a string of the timestamp for GROUP." |
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el index 06f09271647..a9d15f92262 100644 --- a/lisp/gnus/gnus-icalendar.el +++ b/lisp/gnus/gnus-icalendar.el | |||
| @@ -655,10 +655,7 @@ is searched." | |||
| 655 | (defun gnus-icalendar-show-org-agenda (event) | 655 | (defun gnus-icalendar-show-org-agenda (event) |
| 656 | (let* ((time-delta (time-subtract (gnus-icalendar-event:end-time event) | 656 | (let* ((time-delta (time-subtract (gnus-icalendar-event:end-time event) |
| 657 | (gnus-icalendar-event:start-time event))) | 657 | (gnus-icalendar-event:start-time event))) |
| 658 | (duration-days (1+ (/ (+ (* (car time-delta) (expt 2 16)) | 658 | (duration-days (1+ (floor (encode-time time-delta 'integer) 86400)))) |
| 659 | (cadr time-delta)) | ||
| 660 | 86400)))) | ||
| 661 | |||
| 662 | (org-agenda-list nil (gnus-icalendar-event:start event) duration-days))) | 659 | (org-agenda-list nil (gnus-icalendar-event:start event) duration-days))) |
| 663 | 660 | ||
| 664 | (cl-defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status) | 661 | (cl-defmethod gnus-icalendar-event:sync-to-org ((event gnus-icalendar-event-request) reply-status) |
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el index afaf3dcfcff..9df2292e783 100644 --- a/lisp/gnus/nnmaildir.el +++ b/lisp/gnus/nnmaildir.el | |||
| @@ -1467,7 +1467,7 @@ This variable is set by `nnmaildir-request-article'.") | |||
| 1467 | (unless (string-equal nnmaildir--delivery-time file) | 1467 | (unless (string-equal nnmaildir--delivery-time file) |
| 1468 | (setq nnmaildir--delivery-time file | 1468 | (setq nnmaildir--delivery-time file |
| 1469 | nnmaildir--delivery-count 0)) | 1469 | nnmaildir--delivery-count 0)) |
| 1470 | (setq file (concat file "M" (number-to-string (caddr time)))) | 1470 | (setq file (concat file (format-time-string "M%6N" time))) |
| 1471 | (setq file (concat file nnmaildir--delivery-pid) | 1471 | (setq file (concat file nnmaildir--delivery-pid) |
| 1472 | file (concat file "Q" (number-to-string nnmaildir--delivery-count)) | 1472 | file (concat file "Q" (number-to-string nnmaildir--delivery-count)) |
| 1473 | file (concat file "." (nnmaildir--system-name)) | 1473 | file (concat file "." (nnmaildir--system-name)) |
| @@ -1553,7 +1553,7 @@ This variable is set by `nnmaildir-request-article'.") | |||
| 1553 | (defun nnmaildir-request-expire-articles (ranges &optional gname server force) | 1553 | (defun nnmaildir-request-expire-articles (ranges &optional gname server force) |
| 1554 | (let ((no-force (not force)) | 1554 | (let ((no-force (not force)) |
| 1555 | (group (nnmaildir--prepare server gname)) | 1555 | (group (nnmaildir--prepare server gname)) |
| 1556 | pgname time boundary bound-iter high low target dir nlist | 1556 | pgname time boundary high low target dir nlist |
| 1557 | didnt nnmaildir--file nnmaildir-article-file-name | 1557 | didnt nnmaildir--file nnmaildir-article-file-name |
| 1558 | deactivate-mark) | 1558 | deactivate-mark) |
| 1559 | (catch 'return | 1559 | (catch 'return |
| @@ -1602,15 +1602,8 @@ This variable is set by `nnmaildir-request-article'.") | |||
| 1602 | ((null time) | 1602 | ((null time) |
| 1603 | (nnmaildir--expired-article group article)) | 1603 | (nnmaildir--expired-article group article)) |
| 1604 | ((and no-force | 1604 | ((and no-force |
| 1605 | (progn | 1605 | (time-less-p boundary |
| 1606 | (setq time (file-attribute-modification-time time) | 1606 | (file-attribute-modification-time time))) |
| 1607 | bound-iter boundary) | ||
| 1608 | (while (and bound-iter time | ||
| 1609 | (= (car bound-iter) (car time))) | ||
| 1610 | (setq bound-iter (cdr bound-iter) | ||
| 1611 | time (cdr time))) | ||
| 1612 | (and bound-iter time | ||
| 1613 | (car-less-than-car bound-iter time)))) | ||
| 1614 | (setq didnt (cons (nnmaildir--art-num article) didnt))) | 1607 | (setq didnt (cons (nnmaildir--art-num article) didnt))) |
| 1615 | (t | 1608 | (t |
| 1616 | (setq nnmaildir-article-file-name nnmaildir--file | 1609 | (setq nnmaildir-article-file-name nnmaildir--file |
diff --git a/lisp/ido.el b/lisp/ido.el index b32cacce750..8078d184db7 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -1515,20 +1515,20 @@ Removes badly formatted data and ignored directories." | |||
| 1515 | (files (cdr (cdr (car l))))) | 1515 | (files (cdr (cdr (car l))))) |
| 1516 | (and | 1516 | (and |
| 1517 | (stringp dir) | 1517 | (stringp dir) |
| 1518 | (consp time) | 1518 | (if (condition-case nil |
| 1519 | (cond | 1519 | (not (time-equal-p time 0)) |
| 1520 | ((integerp (car time)) | 1520 | (error)) |
| 1521 | (and (not (zerop (float-time time))) | 1521 | (ido-may-cache-directory dir) |
| 1522 | (ido-may-cache-directory dir))) | 1522 | (and |
| 1523 | ((eq (car time) 'ftp) | 1523 | (consp time) |
| 1524 | (and (numberp (cdr time)) | 1524 | (numberp (cdr time)) |
| 1525 | (ido-is-ftp-directory dir) | 1525 | (cond |
| 1526 | (ido-cache-ftp-valid (cdr time)))) | 1526 | ((eq (car time) 'ftp) |
| 1527 | ((eq (car time) 'unc) | 1527 | (and (ido-is-ftp-directory dir) |
| 1528 | (and (numberp (cdr time)) | 1528 | (ido-cache-ftp-valid (cdr time)))) |
| 1529 | (ido-is-unc-host dir) | 1529 | ((eq (car time) 'unc) |
| 1530 | (ido-cache-unc-valid (cdr time)))) | 1530 | (and (ido-is-unc-host dir) |
| 1531 | (t nil)) | 1531 | (ido-cache-unc-valid (cdr time))))))) |
| 1532 | (let ((s files) (ok t)) | 1532 | (let ((s files) (ok t)) |
| 1533 | (while s | 1533 | (while s |
| 1534 | (if (stringp (car s)) | 1534 | (if (stringp (car s)) |
| @@ -3621,8 +3621,7 @@ Uses and updates `ido-dir-file-cache'." | |||
| 3621 | (ido-cache-unc-valid (cdr ctime))))) | 3621 | (ido-cache-unc-valid (cdr ctime))))) |
| 3622 | (t | 3622 | (t |
| 3623 | (if attr | 3623 | (if attr |
| 3624 | (setq valid (and (= (car ctime) (car mtime)) | 3624 | (setq valid (time-equal-p ctime mtime))))) |
| 3625 | (= (car (cdr ctime)) (car (cdr mtime)))))))) | ||
| 3626 | (unless valid | 3625 | (unless valid |
| 3627 | (setq ido-dir-file-cache (delq cached ido-dir-file-cache) | 3626 | (setq ido-dir-file-cache (delq cached ido-dir-file-cache) |
| 3628 | cached nil))) | 3627 | cached nil))) |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 34faf4ce280..f8b0505b41b 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -679,9 +679,8 @@ But handle the case, if the \"test\" command is not available." | |||
| 679 | (current-time) | 679 | (current-time) |
| 680 | time))) | 680 | time))) |
| 681 | (tramp-adb-send-command-and-check | 681 | (tramp-adb-send-command-and-check |
| 682 | ;; Use shell arithmetic because of Emacs integer size limit. | 682 | v (format "touch -t %s %s" |
| 683 | v (format "touch -t $(( %d * 65536 + %d )) %s" | 683 | (format-time-string "%Y%m%d%H%M.%S" time) |
| 684 | (car time) (cadr time) | ||
| 685 | (tramp-shell-quote-argument localname)))))) | 684 | (tramp-shell-quote-argument localname)))))) |
| 686 | 685 | ||
| 687 | (defun tramp-adb-handle-copy-file | 686 | (defun tramp-adb-handle-copy-file |
diff --git a/lisp/woman.el b/lisp/woman.el index 9548fdc6b3a..110069335c8 100644 --- a/lisp/woman.el +++ b/lisp/woman.el | |||
| @@ -2010,10 +2010,8 @@ Optional argument REDRAW, if non-nil, forces mode line to be updated." | |||
| 2010 | ;; (after Man-bgproc-sentinel-advice activate) | 2010 | ;; (after Man-bgproc-sentinel-advice activate) |
| 2011 | ;; ;; Terminates man processing | 2011 | ;; ;; Terminates man processing |
| 2012 | ;; "Report formatting time." | 2012 | ;; "Report formatting time." |
| 2013 | ;; (let* ((time (current-time)) | 2013 | ;; (message "Man formatting done in %s seconds" |
| 2014 | ;; (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536) | 2014 | ;; (float-time (time-subtract nil WoMan-Man-start-time)))) |
| 2015 | ;; (- (cadr time) (cadr WoMan-Man-start-time))))) | ||
| 2016 | ;; (message "Man formatting done in %d seconds" time))) | ||
| 2017 | 2015 | ||
| 2018 | 2016 | ||
| 2019 | ;;; Buffer handling: | 2017 | ;;; Buffer handling: |