diff options
| author | Paul Eggert | 2014-10-28 18:42:51 -0700 |
|---|---|---|
| committer | Paul Eggert | 2014-10-28 18:42:51 -0700 |
| commit | 123ddec7f807f4bd7400bbbe08219afb02269c00 (patch) | |
| tree | cac1153049785a70e015b32748521098956de5d8 /lisp | |
| parent | 14e5809d3cc1fd89e50f88d5783219091596a271 (diff) | |
| download | emacs-123ddec7f807f4bd7400bbbe08219afb02269c00.tar.gz emacs-123ddec7f807f4bd7400bbbe08219afb02269c00.zip | |
Simplify use of current-time and friends.
* doc/misc/org.texi (Dynamic blocks):
* lisp/allout-widgets.el (allout-widgets-hook-error-handler):
* lisp/calendar/appt.el (appt-display-message):
* lisp/calendar/icalendar.el (icalendar--convert-float-to-ical):
* lisp/calendar/timeclock.el (timeclock-in, timeclock-when-to-leave)
(timeclock-last-period, timeclock-day-base):
* lisp/eshell/em-ls.el (eshell-ls-file):
* lisp/eshell/esh-util.el (eshell-parse-ange-ls):
* lisp/generic-x.el (named-database-print-serial):
* lisp/net/newst-backend.el (newsticker--get-news-by-url-callback)
(newsticker-get-news, newsticker--sentinel-work)
(newsticker--image-get, newsticker--image-sentinel):
* lisp/net/tramp-sh.el (tramp-get-remote-touch):
* lisp/progmodes/opascal.el (opascal-debug-log):
* lisp/textmodes/remember.el (remember-mail-date)
(remember-store-in-files):
* lisp/vc/vc-annotate.el (vc-annotate-display-autoscale)
(vc-default-annotate-current-time):
* lisp/vc/vc-bzr.el (vc-bzr-shelve-snapshot):
* lisp/vc/vc-cvs.el (vc-cvs-annotate-current-time):
* lisp/vc/vc-rcs.el (vc-rcs-annotate-current-time):
* lisp/url/url-util.el (url-get-normalized-date):
* lisp/erc/erc-backend.el (TOPIC):
* lisp/gnus/gnus-delay.el (gnus-delay-article):
* lisp/gnus/gnus-sum.el (gnus-summary-read-document):
* lisp/gnus/gnus-util.el (gnus-seconds-today, gnus-seconds-month):
* lisp/gnus/message.el (message-make-expires-date):
* lisp/org/org-archive.el (org-archive-subtree)
(org-archive-to-archive-sibling):
* lisp/org/org-clock.el (org-resolve-clocks, org-clock-get-sum-start)
(org-clock-special-range):
* lisp/org/org-timer.el (org-timer-seconds):
* lisp/org/org.el (org-read-date-analyze, org-get-cursor-date):
* lisp/org/ox-html.el (org-html-format-spec):
* lisp/org/ox-icalendar.el (org-icalendar--vtodo):
Omit unnecessary call to current-time.
* lisp/calendar/time-date.el (time-to-seconds) [!float-time]:
* lisp/calendar/timeclock.el (timeclock-time-to-date):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Use current time if arg is nil, to be compatible with float-time.
(time-date--day-in-year): New function, with most of the guts of
the old time-to-day-in-year.
(time-to-day-in-year): Use it.
(time-to-days): Use it, to avoid decoding the same time stamp twice.
* lisp/calendar/timeclock.el (timeclock-update-mode-line):
* lisp/cedet/srecode/args.el (srecode-semantic-handle-:time):
* lisp/gnus/gnus-util.el (gnus-seconds-year):
* lisp/org/org.el (org-get-cursor-date):
Don't call current-time twice to get the current time stamp,
as this can lead to inconsistent results.
* lisp/completion.el (cmpl-hours-since-origin):
* lisp/erc/erc.el (erc-emacs-time-to-erc-time):
* lisp/ido.el (ido-time-stamp):
* lisp/vc/vc-annotate.el (vc-annotate-convert-time):
Simplify by using float-time.
* lisp/completion.el (save-completions-to-file):
* lisp/url/url-cache.el (url-cache-prune-cache):
Rename local var to avoid confusion.
* lisp/gnus/gnus-util.el (gnus-float-time):
* lisp/net/rcirc.el (rcirc-float-time):
* lisp/org/org-compat.el (org-float-time):
Simplify to an alias because time-to-seconds now behaves like float-time
with respect to nil arg.
* lisp/subr.el (progress-reporter-do-update):
Don't call float-time unless needed.
* lisp/erc/erc.el (erc-current-time): Simplify by using erc-emacs-time-to-erc-time.
* lisp/org/org-clock.el (org-clock-get-table-data): Omit unnecessary, lossy
conversion from floating point to Emacs time and back.
(org-resolve-clocks): Prefer two-argument floor.
Diffstat (limited to 'lisp')
42 files changed, 239 insertions, 155 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 89d887b0f0b..1ddef8293b7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,50 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * allout-widgets.el (allout-widgets-hook-error-handler): | ||
| 5 | * calendar/appt.el (appt-display-message): | ||
| 6 | * calendar/icalendar.el (icalendar--convert-float-to-ical): | ||
| 7 | * calendar/timeclock.el (timeclock-in, timeclock-when-to-leave) | ||
| 8 | (timeclock-last-period, timeclock-day-base): | ||
| 9 | * eshell/em-ls.el (eshell-ls-file): | ||
| 10 | * eshell/esh-util.el (eshell-parse-ange-ls): | ||
| 11 | * generic-x.el (named-database-print-serial): | ||
| 12 | * net/newst-backend.el (newsticker--get-news-by-url-callback) | ||
| 13 | (newsticker-get-news, newsticker--sentinel-work) | ||
| 14 | (newsticker--image-get, newsticker--image-sentinel): | ||
| 15 | * net/tramp-sh.el (tramp-get-remote-touch): | ||
| 16 | * progmodes/opascal.el (opascal-debug-log): | ||
| 17 | * textmodes/remember.el (remember-mail-date) | ||
| 18 | (remember-store-in-files): | ||
| 19 | * vc/vc-annotate.el (vc-annotate-display-autoscale) | ||
| 20 | (vc-default-annotate-current-time): | ||
| 21 | * vc/vc-bzr.el (vc-bzr-shelve-snapshot): | ||
| 22 | * vc/vc-cvs.el (vc-cvs-annotate-current-time): | ||
| 23 | * vc/vc-rcs.el (vc-rcs-annotate-current-time): | ||
| 24 | Omit unnecessary call to current-time. | ||
| 25 | * calendar/time-date.el (time-to-seconds) [!float-time]: | ||
| 26 | * vc/vc-annotate.el (vc-annotate-convert-time): | ||
| 27 | Use current time if arg is nil, to be compatible with float-time. | ||
| 28 | (time-date--day-in-year): New function, with most of the guts of | ||
| 29 | the old time-to-day-in-year. | ||
| 30 | (time-to-day-in-year): Use it. | ||
| 31 | (time-to-days): Use it, to avoid decoding the same time stamp twice. | ||
| 32 | * calendar/timeclock.el (timeclock-time-to-date): | ||
| 33 | Arg is now optional, like current-time-string. | ||
| 34 | (timeclock-update-mode-line): | ||
| 35 | Don't call current-time twice to get the current time stamp, | ||
| 36 | as this can lead to inconsistent results. | ||
| 37 | * completion.el (cmpl-hours-since-origin): | ||
| 38 | * ido.el (ido-time-stamp): | ||
| 39 | * vc/vc-annotate.el (vc-annotate-convert-time): | ||
| 40 | Simplify by using float-time. | ||
| 41 | * completion.el (save-completions-to-file): | ||
| 42 | Rename local var to avoid confusion. | ||
| 43 | * net/rcirc.el (rcirc-float-time): Simplify to an alias because | ||
| 44 | time-to-seconds now behaves like float-time with respect to nil arg. | ||
| 45 | * subr.el (progress-reporter-do-update): | ||
| 46 | Don't call float-time unless needed. | ||
| 47 | |||
| 1 | 2014-10-29 Leo Liu <sdl.web@gmail.com> | 48 | 2014-10-29 Leo Liu <sdl.web@gmail.com> |
| 2 | 49 | ||
| 3 | * net/rcirc.el (rcirc-fill-column): Use function. | 50 | * net/rcirc.el (rcirc-fill-column): Use function. |
diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el index 66ec0c333a7..f2dcdb40425 100644 --- a/lisp/allout-widgets.el +++ b/lisp/allout-widgets.el | |||
| @@ -902,7 +902,7 @@ encompassing condition-case." | |||
| 902 | (header | 902 | (header |
| 903 | (format "allout-widgets-last-hook-error stored, %s/%s %s %s" | 903 | (format "allout-widgets-last-hook-error stored, %s/%s %s %s" |
| 904 | this mode args | 904 | this mode args |
| 905 | (format-time-string "%e-%b-%Y %r" (current-time))))) | 905 | (format-time-string "%e-%b-%Y %r")))) |
| 906 | ;; post to *Messages* then immediately replace with more compact notice: | 906 | ;; post to *Messages* then immediately replace with more compact notice: |
| 907 | (message "%s" (setq allout-widgets-last-hook-error | 907 | (message "%s" (setq allout-widgets-last-hook-error |
| 908 | (format "%s:\n%s" header bt))) | 908 | (format "%s:\n%s" header bt))) |
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el index c90a20d92ca..7e32d890e15 100644 --- a/lisp/calendar/appt.el +++ b/lisp/calendar/appt.el | |||
| @@ -228,7 +228,7 @@ also calls `beep' for an audible reminder." | |||
| 228 | string (car string))) | 228 | string (car string))) |
| 229 | (cond ((eq appt-display-format 'window) | 229 | (cond ((eq appt-display-format 'window) |
| 230 | ;; TODO use calendar-month-abbrev-array rather than %b? | 230 | ;; TODO use calendar-month-abbrev-array rather than %b? |
| 231 | (let ((time (format-time-string "%a %b %e " (current-time))) | 231 | (let ((time (format-time-string "%a %b %e ")) |
| 232 | err) | 232 | err) |
| 233 | (condition-case err | 233 | (condition-case err |
| 234 | (funcall appt-disp-window-function | 234 | (funcall appt-disp-window-function |
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el index 43610036861..5f89318e139 100644 --- a/lisp/calendar/icalendar.el +++ b/lisp/calendar/icalendar.el | |||
| @@ -1682,7 +1682,7 @@ entries. ENTRY-MAIN is the first line of the diary entry." | |||
| 1682 | (cons (concat | 1682 | (cons (concat |
| 1683 | ;;Start today (yes this is an arbitrary choice): | 1683 | ;;Start today (yes this is an arbitrary choice): |
| 1684 | "\nDTSTART;VALUE=DATE:" | 1684 | "\nDTSTART;VALUE=DATE:" |
| 1685 | (format-time-string "%Y%m%d" (current-time)) | 1685 | (format-time-string "%Y%m%d") |
| 1686 | ;;BUT remove today if `diary-float' | 1686 | ;;BUT remove today if `diary-float' |
| 1687 | ;;expression does not hold true for today: | 1687 | ;;expression does not hold true for today: |
| 1688 | (when | 1688 | (when |
| @@ -1691,7 +1691,7 @@ entries. ENTRY-MAIN is the first line of the diary entry." | |||
| 1691 | (diary-float month dayname n))) | 1691 | (diary-float month dayname n))) |
| 1692 | (concat | 1692 | (concat |
| 1693 | "\nEXDATE;VALUE=DATE:" | 1693 | "\nEXDATE;VALUE=DATE:" |
| 1694 | (format-time-string "%Y%m%d" (current-time)))) | 1694 | (format-time-string "%Y%m%d"))) |
| 1695 | "\nRRULE:" | 1695 | "\nRRULE:" |
| 1696 | (if (or (numberp month) (listp month)) | 1696 | (if (or (numberp month) (listp month)) |
| 1697 | "FREQ=YEARLY;BYMONTH=" | 1697 | "FREQ=YEARLY;BYMONTH=" |
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el index 48fe2294354..82bc05f299f 100644 --- a/lisp/calendar/time-date.el +++ b/lisp/calendar/time-date.el | |||
| @@ -44,7 +44,7 @@ The value of the last form in BODY is returned. | |||
| 44 | 44 | ||
| 45 | Each element of the list VARLIST is a list of the form | 45 | Each element of the list VARLIST is a list of the form |
| 46 | \(HIGH-SYMBOL LOW-SYMBOL MICRO-SYMBOL [PICO-SYMBOL [TYPE-SYMBOL]] TIME-VALUE). | 46 | \(HIGH-SYMBOL LOW-SYMBOL MICRO-SYMBOL [PICO-SYMBOL [TYPE-SYMBOL]] TIME-VALUE). |
| 47 | The time value TIME-VALUE is decoded and the result it bound to | 47 | The time value TIME-VALUE is decoded and the result is bound to |
| 48 | the symbols HIGH-SYMBOL, LOW-SYMBOL and MICRO-SYMBOL. | 48 | the symbols HIGH-SYMBOL, LOW-SYMBOL and MICRO-SYMBOL. |
| 49 | The optional PICO-SYMBOL is bound to the picoseconds part. | 49 | The optional PICO-SYMBOL is bound to the picoseconds part. |
| 50 | 50 | ||
| @@ -147,10 +147,12 @@ If DATE lacks timezone information, GMT is assumed." | |||
| 147 | (or (featurep 'emacs) | 147 | (or (featurep 'emacs) |
| 148 | (and (fboundp 'float-time) | 148 | (and (fboundp 'float-time) |
| 149 | (subrp (symbol-function 'float-time))) | 149 | (subrp (symbol-function 'float-time))) |
| 150 | (defun time-to-seconds (time) | 150 | (defun time-to-seconds (&optional time) |
| 151 | "Convert time value TIME to a floating point number." | 151 | "Convert optional value TIME to a floating point number. |
| 152 | (with-decoded-time-value ((high low micro pico type time)) | 152 | TIME defaults to the current time." |
| 153 | (+ (* 1.0 high 65536) | 153 | (with-decoded-time-value ((high low micro pico type |
| 154 | (or time (current-time)))) | ||
| 155 | (+ (* high 65536.0) | ||
| 154 | low | 156 | low |
| 155 | (/ (+ (* micro 1e6) pico) 1e12)))))) | 157 | (/ (+ (* micro 1e6) pico) 1e12)))))) |
| 156 | 158 | ||
| @@ -272,11 +274,9 @@ DATE1 and DATE2 should be date-time strings." | |||
| 272 | (not (zerop (% year 100)))) | 274 | (not (zerop (% year 100)))) |
| 273 | (zerop (% year 400)))) | 275 | (zerop (% year 400)))) |
| 274 | 276 | ||
| 275 | ;;;###autoload | 277 | (defun time-date--day-in-year (tim) |
| 276 | (defun time-to-day-in-year (time) | 278 | "Return the day number within the year corresponding to the decoded time TIM." |
| 277 | "Return the day number within the year corresponding to TIME." | 279 | (let* ((month (nth 4 tim)) |
| 278 | (let* ((tim (decode-time time)) | ||
| 279 | (month (nth 4 tim)) | ||
| 280 | (day (nth 3 tim)) | 280 | (day (nth 3 tim)) |
| 281 | (year (nth 5 tim)) | 281 | (year (nth 5 tim)) |
| 282 | (day-of-year (+ day (* 31 (1- month))))) | 282 | (day-of-year (+ day (* 31 (1- month))))) |
| @@ -287,13 +287,18 @@ DATE1 and DATE2 should be date-time strings." | |||
| 287 | day-of-year)) | 287 | day-of-year)) |
| 288 | 288 | ||
| 289 | ;;;###autoload | 289 | ;;;###autoload |
| 290 | (defun time-to-day-in-year (time) | ||
| 291 | "Return the day number within the year corresponding to TIME." | ||
| 292 | (time-date--day-in-year (decode-time time))) | ||
| 293 | |||
| 294 | ;;;###autoload | ||
| 290 | (defun time-to-days (time) | 295 | (defun time-to-days (time) |
| 291 | "The number of days between the Gregorian date 0001-12-31bce and TIME. | 296 | "The number of days between the Gregorian date 0001-12-31bce and TIME. |
| 292 | TIME should be a time value. | 297 | TIME should be a time value. |
| 293 | The Gregorian date Sunday, December 31, 1bce is imaginary." | 298 | The Gregorian date Sunday, December 31, 1bce is imaginary." |
| 294 | (let* ((tim (decode-time time)) | 299 | (let* ((tim (decode-time time)) |
| 295 | (year (nth 5 tim))) | 300 | (year (nth 5 tim))) |
| 296 | (+ (time-to-day-in-year time) ; Days this year | 301 | (+ (time-date--day-in-year tim) ; Days this year |
| 297 | (* 365 (1- year)) ; + Days in prior years | 302 | (* 365 (1- year)) ; + Days in prior years |
| 298 | (/ (1- year) 4) ; + Julian leap years | 303 | (/ (1- year) 4) ; + Julian leap years |
| 299 | (- (/ (1- year) 100)) ; - century years | 304 | (- (/ (1- year) 100)) ; - century years |
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el index 2b4db9a7820..fb69357b1b4 100644 --- a/lisp/calendar/timeclock.el +++ b/lisp/calendar/timeclock.el | |||
| @@ -320,7 +320,7 @@ display (non-nil means on)." | |||
| 320 | (cancel-timer timeclock-update-timer) | 320 | (cancel-timer timeclock-update-timer) |
| 321 | (setq timeclock-update-timer nil)))) | 321 | (setq timeclock-update-timer nil)))) |
| 322 | 322 | ||
| 323 | (defsubst timeclock-time-to-date (time) | 323 | (defsubst timeclock-time-to-date (&optional time) |
| 324 | "Convert the TIME value to a textual date string." | 324 | "Convert the TIME value to a textual date string." |
| 325 | (format-time-string "%Y/%m/%d" time)) | 325 | (format-time-string "%Y/%m/%d" time)) |
| 326 | 326 | ||
| @@ -351,7 +351,7 @@ discover the name of the project." | |||
| 351 | (unless (and timeclock-last-event | 351 | (unless (and timeclock-last-event |
| 352 | (equal (timeclock-time-to-date | 352 | (equal (timeclock-time-to-date |
| 353 | (cadr timeclock-last-event)) | 353 | (cadr timeclock-last-event)) |
| 354 | (timeclock-time-to-date (current-time)))) | 354 | (timeclock-time-to-date))) |
| 355 | (let ((workday (or (and (numberp arg) arg) | 355 | (let ((workday (or (and (numberp arg) arg) |
| 356 | (and arg 0) | 356 | (and arg 0) |
| 357 | (and timeclock-get-workday-function | 357 | (and timeclock-get-workday-function |
| @@ -543,7 +543,7 @@ non-nil, the amount returned will be relative to past time worked." | |||
| 543 | If TODAY-ONLY is non-nil, the value returned will be relative only to | 543 | If TODAY-ONLY is non-nil, the value returned will be relative only to |
| 544 | the time worked today, and not to past time." | 544 | the time worked today, and not to past time." |
| 545 | (timeclock-seconds-to-time | 545 | (timeclock-seconds-to-time |
| 546 | (- (timeclock-time-to-seconds (current-time)) | 546 | (- (timeclock-time-to-seconds) |
| 547 | (let ((discrep (timeclock-find-discrep))) | 547 | (let ((discrep (timeclock-find-discrep))) |
| 548 | (if discrep | 548 | (if discrep |
| 549 | (if today-only | 549 | (if today-only |
| @@ -647,14 +647,12 @@ that variable's documentation." | |||
| 647 | (if timeclock-use-elapsed | 647 | (if timeclock-use-elapsed |
| 648 | (timeclock-workday-elapsed) | 648 | (timeclock-workday-elapsed) |
| 649 | (timeclock-workday-remaining (not timeclock-relative)))) | 649 | (timeclock-workday-remaining (not timeclock-relative)))) |
| 650 | (last-in (equal (car timeclock-last-event) "i"))) | 650 | (last-in (equal (car timeclock-last-event) "i")) |
| 651 | (todays-date (timeclock-time-to-date))) | ||
| 651 | (when (and (< remainder 0) | 652 | (when (and (< remainder 0) |
| 652 | (not (and timeclock-day-over | 653 | (not (and timeclock-day-over |
| 653 | (equal timeclock-day-over | 654 | (equal timeclock-day-over todays-date)))) |
| 654 | (timeclock-time-to-date | 655 | (setq timeclock-day-over todays-date) |
| 655 | (current-time)))))) | ||
| 656 | (setq timeclock-day-over | ||
| 657 | (timeclock-time-to-date (current-time))) | ||
| 658 | (run-hooks 'timeclock-day-over-hook)) | 656 | (run-hooks 'timeclock-day-over-hook)) |
| 659 | (setq timeclock-mode-string | 657 | (setq timeclock-mode-string |
| 660 | (propertize | 658 | (propertize |
| @@ -725,9 +723,8 @@ recorded to disk. If MOMENT is non-nil, use that as the current time. | |||
| 725 | This is only provided for coherency when used by | 723 | This is only provided for coherency when used by |
| 726 | `timeclock-discrepancy'." | 724 | `timeclock-discrepancy'." |
| 727 | (if (equal (car timeclock-last-event) "i") | 725 | (if (equal (car timeclock-last-event) "i") |
| 728 | (- (timeclock-time-to-seconds (or moment (current-time))) | 726 | (- (timeclock-time-to-seconds moment) |
| 729 | (timeclock-time-to-seconds | 727 | (timeclock-time-to-seconds (cadr timeclock-last-event))) |
| 730 | (cadr timeclock-last-event))) | ||
| 731 | timeclock-last-period)) | 728 | timeclock-last-period)) |
| 732 | 729 | ||
| 733 | (defsubst timeclock-entry-length (entry) | 730 | (defsubst timeclock-entry-length (entry) |
| @@ -1156,7 +1153,7 @@ discrepancy, today's discrepancy, and the time worked today." | |||
| 1156 | (+ timeclock-last-period timeclock-elapsed))))) | 1153 | (+ timeclock-last-period timeclock-elapsed))))) |
| 1157 | (setq timeclock-last-event event | 1154 | (setq timeclock-last-event event |
| 1158 | timeclock-last-event-workday | 1155 | timeclock-last-event-workday |
| 1159 | (if (equal (timeclock-time-to-date now) last-date-limited) | 1156 | (if (equal todays-date last-date-limited) |
| 1160 | last-date-seconds | 1157 | last-date-seconds |
| 1161 | timeclock-workday)) | 1158 | timeclock-workday)) |
| 1162 | (forward-line)) | 1159 | (forward-line)) |
| @@ -1182,7 +1179,7 @@ discrepancy, today's discrepancy, and the time worked today." | |||
| 1182 | (defun timeclock-day-base (&optional time) | 1179 | (defun timeclock-day-base (&optional time) |
| 1183 | "Given a time within a day, return 0:0:0 within that day. | 1180 | "Given a time within a day, return 0:0:0 within that day. |
| 1184 | If optional argument TIME is non-nil, use that instead of the current time." | 1181 | If optional argument TIME is non-nil, use that instead of the current time." |
| 1185 | (let ((decoded (decode-time (or time (current-time))))) | 1182 | (let ((decoded (decode-time time))) |
| 1186 | (setcar (nthcdr 0 decoded) 0) | 1183 | (setcar (nthcdr 0 decoded) 0) |
| 1187 | (setcar (nthcdr 1 decoded) 0) | 1184 | (setcar (nthcdr 1 decoded) 0) |
| 1188 | (setcar (nthcdr 2 decoded) 0) | 1185 | (setcar (nthcdr 2 decoded) 0) |
diff --git a/lisp/cedet/ChangeLog b/lisp/cedet/ChangeLog index d19bae5be30..8e911cfe6d6 100644 --- a/lisp/cedet/ChangeLog +++ b/lisp/cedet/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * srecode/args.el (srecode-semantic-handle-:time): | ||
| 5 | Don't call current-time twice to get the current time stamp, | ||
| 6 | as this can lead to inconsistent results. | ||
| 7 | |||
| 1 | 2014-10-24 Stefan Monnier <monnier@iro.umontreal.ca> | 8 | 2014-10-24 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 9 | ||
| 3 | * semantic/complete.el: Require semantic/db-find. | 10 | * semantic/complete.el: Require semantic/db-find. |
diff --git a/lisp/cedet/srecode/args.el b/lisp/cedet/srecode/args.el index b4977f0882e..8c03e17d7b3 100644 --- a/lisp/cedet/srecode/args.el +++ b/lisp/cedet/srecode/args.el | |||
| @@ -101,35 +101,35 @@ do not contain any text from preceding or following text." | |||
| 101 | (defun srecode-semantic-handle-:time (dict) | 101 | (defun srecode-semantic-handle-:time (dict) |
| 102 | "Add macros into the dictionary DICT based on the current :time." | 102 | "Add macros into the dictionary DICT based on the current :time." |
| 103 | ;; DATE Values | 103 | ;; DATE Values |
| 104 | (srecode-dictionary-set-value | 104 | (let ((now (current-time))) |
| 105 | dict "YEAR" (format-time-string "%Y" (current-time))) | 105 | (srecode-dictionary-set-value |
| 106 | (srecode-dictionary-set-value | 106 | dict "YEAR" (format-time-string "%Y" now)) |
| 107 | dict "MONTHNAME" (format-time-string "%B" (current-time))) | 107 | (srecode-dictionary-set-value |
| 108 | (srecode-dictionary-set-value | 108 | dict "MONTHNAME" (format-time-string "%B" now)) |
| 109 | dict "MONTH" (format-time-string "%m" (current-time))) | 109 | (srecode-dictionary-set-value |
| 110 | (srecode-dictionary-set-value | 110 | dict "MONTH" (format-time-string "%m" now)) |
| 111 | dict "DAY" (format-time-string "%d" (current-time))) | 111 | (srecode-dictionary-set-value |
| 112 | (srecode-dictionary-set-value | 112 | dict "DAY" (format-time-string "%d" now)) |
| 113 | dict "WEEKDAY" (format-time-string "%a" (current-time))) | 113 | (srecode-dictionary-set-value |
| 114 | ;; Time Values | 114 | dict "WEEKDAY" (format-time-string "%a" now)) |
| 115 | (srecode-dictionary-set-value | 115 | ;; Time Values |
| 116 | dict "HOUR" (format-time-string "%H" (current-time))) | 116 | (srecode-dictionary-set-value |
| 117 | (srecode-dictionary-set-value | 117 | dict "HOUR" (format-time-string "%H" now)) |
| 118 | dict "HOUR12" (format-time-string "%l" (current-time))) | 118 | (srecode-dictionary-set-value |
| 119 | (srecode-dictionary-set-value | 119 | dict "HOUR12" (format-time-string "%l" now)) |
| 120 | dict "AMPM" (format-time-string "%p" (current-time))) | 120 | (srecode-dictionary-set-value |
| 121 | (srecode-dictionary-set-value | 121 | dict "AMPM" (format-time-string "%p" now)) |
| 122 | dict "MINUTE" (format-time-string "%M" (current-time))) | 122 | (srecode-dictionary-set-value |
| 123 | (srecode-dictionary-set-value | 123 | dict "MINUTE" (format-time-string "%M" now)) |
| 124 | dict "SECOND" (format-time-string "%S" (current-time))) | 124 | (srecode-dictionary-set-value |
| 125 | (srecode-dictionary-set-value | 125 | dict "SECOND" (format-time-string "%S" now)) |
| 126 | dict "TIMEZONE" (format-time-string "%Z" (current-time))) | 126 | (srecode-dictionary-set-value |
| 127 | ;; Convenience pre-packed date/time | 127 | dict "TIMEZONE" (format-time-string "%Z" now)) |
| 128 | (srecode-dictionary-set-value | 128 | ;; Convenience pre-packed date/time |
| 129 | dict "DATE" (format-time-string "%D" (current-time))) | 129 | (srecode-dictionary-set-value |
| 130 | (srecode-dictionary-set-value | 130 | dict "DATE" (format-time-string "%D" now)) |
| 131 | dict "TIME" (format-time-string "%X" (current-time))) | 131 | (srecode-dictionary-set-value |
| 132 | ) | 132 | dict "TIME" (format-time-string "%X" now)))) |
| 133 | 133 | ||
| 134 | ;;; :file ARGUMENT HANDLING | 134 | ;;; :file ARGUMENT HANDLING |
| 135 | ;; | 135 | ;; |
diff --git a/lisp/completion.el b/lisp/completion.el index 7e5c2143870..d2d94e778d5 100644 --- a/lisp/completion.el +++ b/lisp/completion.el | |||
| @@ -435,8 +435,7 @@ Used to decide whether to save completions.") | |||
| 435 | 435 | ||
| 436 | 436 | ||
| 437 | (defun cmpl-hours-since-origin () | 437 | (defun cmpl-hours-since-origin () |
| 438 | (let ((time (current-time))) | 438 | (floor (float-time) 3600)) |
| 439 | (floor (+ (* 65536.0 (nth 0 time)) (nth 1 time)) 3600))) | ||
| 440 | 439 | ||
| 441 | ;;--------------------------------------------------------------------------- | 440 | ;;--------------------------------------------------------------------------- |
| 442 | ;; "Symbol" parsing functions | 441 | ;; "Symbol" parsing functions |
| @@ -1950,7 +1949,7 @@ If file name is not specified, use `save-completions-file-name'." | |||
| 1950 | (kept-old-versions 0) | 1949 | (kept-old-versions 0) |
| 1951 | (kept-new-versions completions-file-versions-kept) | 1950 | (kept-new-versions completions-file-versions-kept) |
| 1952 | last-use-time | 1951 | last-use-time |
| 1953 | (current-time (cmpl-hours-since-origin)) | 1952 | (this-use-time (cmpl-hours-since-origin)) |
| 1954 | (total-in-db 0) | 1953 | (total-in-db 0) |
| 1955 | (total-perm 0) | 1954 | (total-perm 0) |
| 1956 | (total-saved 0) | 1955 | (total-saved 0) |
| @@ -1982,13 +1981,13 @@ If file name is not specified, use `save-completions-file-name'." | |||
| 1982 | ;; or if | 1981 | ;; or if |
| 1983 | (if (> (completion-num-uses completion) 0) | 1982 | (if (> (completion-num-uses completion) 0) |
| 1984 | ;; it's been used | 1983 | ;; it's been used |
| 1985 | (setq last-use-time current-time) | 1984 | (setq last-use-time this-use-time) |
| 1986 | ;; or it was saved before and | 1985 | ;; or it was saved before and |
| 1987 | (and last-use-time | 1986 | (and last-use-time |
| 1988 | ;; save-completions-retention-time is nil | 1987 | ;; save-completions-retention-time is nil |
| 1989 | (or (not save-completions-retention-time) | 1988 | (or (not save-completions-retention-time) |
| 1990 | ;; or time since last use is < ...retention-time* | 1989 | ;; or time since last use is < ...retention-time* |
| 1991 | (< (- current-time last-use-time) | 1990 | (< (- this-use-time last-use-time) |
| 1992 | save-completions-retention-time))))) | 1991 | save-completions-retention-time))))) |
| 1993 | ;; write to file | 1992 | ;; write to file |
| 1994 | (setq total-saved (1+ total-saved)) | 1993 | (setq total-saved (1+ total-saved)) |
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index efa3219db07..75a01581fcd 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * erc-backend.el (TOPIC): Omit unnecessary call to current-time. | ||
| 5 | * erc.el (erc-emacs-time-to-erc-time): Simplify by using float-time. | ||
| 6 | (erc-current-time): Simplify by using erc-emacs-time-to-erc-time. | ||
| 7 | |||
| 1 | 2014-10-20 Glenn Morris <rgm@gnu.org> | 8 | 2014-10-20 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * Merge in all changes up to 24.4 release. | 10 | * Merge in all changes up to 24.4 release. |
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 8751a194e3b..fb22f58822d 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el | |||
| @@ -1465,8 +1465,7 @@ add things to `%s' instead." | |||
| 1465 | "The channel topic has changed." nil | 1465 | "The channel topic has changed." nil |
| 1466 | (let* ((ch (car (erc-response.command-args parsed))) | 1466 | (let* ((ch (car (erc-response.command-args parsed))) |
| 1467 | (topic (erc-trim-string (erc-response.contents parsed))) | 1467 | (topic (erc-trim-string (erc-response.contents parsed))) |
| 1468 | (time (format-time-string erc-server-timestamp-format | 1468 | (time (format-time-string erc-server-timestamp-format))) |
| 1469 | (current-time)))) | ||
| 1470 | (pcase-let ((`(,nick ,login ,host) | 1469 | (pcase-let ((`(,nick ,login ,host) |
| 1471 | (erc-parse-user (erc-response.sender parsed)))) | 1470 | (erc-parse-user (erc-response.sender parsed)))) |
| 1472 | (erc-update-channel-member ch nick nick nil nil nil nil nil nil host login) | 1471 | (erc-update-channel-member ch nick nick nil nil nil nil nil nil host login) |
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index c70dfb94d7e..9363d4a8262 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el | |||
| @@ -5956,17 +5956,15 @@ Returns a list of the form (HIGH LOW), compatible with Emacs time format." | |||
| 5956 | (list (truncate (/ n 65536)) | 5956 | (list (truncate (/ n 65536)) |
| 5957 | (truncate (mod n 65536))))) | 5957 | (truncate (mod n 65536))))) |
| 5958 | 5958 | ||
| 5959 | (defun erc-emacs-time-to-erc-time (time) | 5959 | (defalias 'erc-emacs-time-to-erc-time |
| 5960 | "Convert Emacs TIME to a number of seconds since the epoch." | 5960 | (if (featurep 'xemacs) 'time-to-seconds 'float-time) |
| 5961 | (when time | 5961 | "Convert time value TIME to a floating point number. |
| 5962 | (+ (* (nth 0 time) 65536.0) (nth 1 time)))) | 5962 | TIME defaults to the current time.") |
| 5963 | ; (round (+ (* (nth 0 tm) 65536.0) (nth 1 tm)))) | ||
| 5964 | 5963 | ||
| 5965 | (defun erc-current-time () | 5964 | (defalias 'erc-current-time 'erc-emacs-time-to-erc-time |
| 5966 | "Return the `current-time' as a number of seconds since the epoch. | 5965 | "Return the `current-time' as a number of seconds since the epoch. |
| 5967 | 5966 | ||
| 5968 | See also `erc-emacs-time-to-erc-time'." | 5967 | See also `erc-emacs-time-to-erc-time'.") |
| 5969 | (erc-emacs-time-to-erc-time (current-time))) | ||
| 5970 | 5968 | ||
| 5971 | (defun erc-time-diff (t1 t2) | 5969 | (defun erc-time-diff (t1 t2) |
| 5972 | "Return the time difference in seconds between T1 and T2." | 5970 | "Return the time difference in seconds between T1 and T2." |
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el index faba9088ecd..4ddf8862618 100644 --- a/lisp/eshell/em-ls.el +++ b/lisp/eshell/em-ls.el | |||
| @@ -490,7 +490,7 @@ whose cdr is the list of file attributes." | |||
| 490 | " " (format-time-string | 490 | " " (format-time-string |
| 491 | (concat | 491 | (concat |
| 492 | eshell-ls-date-format " " | 492 | eshell-ls-date-format " " |
| 493 | (if (= (nth 5 (decode-time (current-time))) | 493 | (if (= (nth 5 (decode-time)) |
| 494 | (nth 5 (decode-time | 494 | (nth 5 (decode-time |
| 495 | (nth (cond | 495 | (nth (cond |
| 496 | ((eq sort-method 'by-atime) 4) | 496 | ((eq sort-method 'by-atime) 4) |
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el index cd73c0afa75..53f642510f2 100644 --- a/lisp/eshell/esh-util.el +++ b/lisp/eshell/esh-util.el | |||
| @@ -653,7 +653,7 @@ If NOSORT is non-nil, the list is not sorted--its order is unpredictable. | |||
| 653 | (match-string 6)))) | 653 | (match-string 6)))) |
| 654 | (if (nth 0 moment) | 654 | (if (nth 0 moment) |
| 655 | (setcar (nthcdr 5 moment) | 655 | (setcar (nthcdr 5 moment) |
| 656 | (nth 5 (decode-time (current-time)))) | 656 | (nth 5 (decode-time))) |
| 657 | (setcar (nthcdr 0 moment) 0) | 657 | (setcar (nthcdr 0 moment) 0) |
| 658 | (setcar (nthcdr 1 moment) 0) | 658 | (setcar (nthcdr 1 moment) 0) |
| 659 | (setcar (nthcdr 2 moment) 0)) | 659 | (setcar (nthcdr 2 moment) 0)) |
diff --git a/lisp/generic-x.el b/lisp/generic-x.el index 21b429781f9..c14700b9a1e 100644 --- a/lisp/generic-x.el +++ b/lisp/generic-x.el | |||
| @@ -1650,7 +1650,7 @@ like an INI file. You can add this hook to `find-file-hook'." | |||
| 1650 | (defun named-database-print-serial () | 1650 | (defun named-database-print-serial () |
| 1651 | "Print a serial number based on the current date." | 1651 | "Print a serial number based on the current date." |
| 1652 | (interactive) | 1652 | (interactive) |
| 1653 | (insert (format-time-string named-database-time-string (current-time))))) | 1653 | (insert (format-time-string named-database-time-string)))) |
| 1654 | 1654 | ||
| 1655 | (when (memq 'resolve-conf-generic-mode generic-extras-enable-list) | 1655 | (when (memq 'resolve-conf-generic-mode generic-extras-enable-list) |
| 1656 | 1656 | ||
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 04253780783..cc38aabeec7 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * gnus-delay.el (gnus-delay-article): | ||
| 5 | * gnus-sum.el (gnus-summary-read-document): | ||
| 6 | * gnus-util.el (gnus-seconds-today, gnus-seconds-month): | ||
| 7 | * message.el (message-make-expires-date): | ||
| 8 | Omit unnecessary call to current-time. | ||
| 9 | * gnus-util.el (gnus-float-time): Simplify to an alias because | ||
| 10 | time-to-seconds now behaves like float-time with respect to nil arg. | ||
| 11 | (gnus-seconds-year): Don't call current-time twice to get the current | ||
| 12 | time stamp, as this can lead to inconsistent results. | ||
| 13 | |||
| 1 | 2014-10-27 Katsumi Yamaoka <yamaoka@jpl.org> | 14 | 2014-10-27 Katsumi Yamaoka <yamaoka@jpl.org> |
| 2 | 15 | ||
| 3 | * gnus.el (gnus-mode-line-buffer-identification): | 16 | * gnus.el (gnus-mode-line-buffer-identification): |
diff --git a/lisp/gnus/gnus-delay.el b/lisp/gnus/gnus-delay.el index 75b967e2d48..2a286dabcbc 100644 --- a/lisp/gnus/gnus-delay.el +++ b/lisp/gnus/gnus-delay.el | |||
| @@ -98,7 +98,7 @@ DELAY is a string, giving the length of the time. Possible values are: | |||
| 98 | (setq hour (string-to-number (match-string 1 delay)) | 98 | (setq hour (string-to-number (match-string 1 delay)) |
| 99 | minute (string-to-number (match-string 2 delay))) | 99 | minute (string-to-number (match-string 2 delay))) |
| 100 | ;; Use current time, except... | 100 | ;; Use current time, except... |
| 101 | (setq deadline (apply 'vector (decode-time (current-time)))) | 101 | (setq deadline (apply 'vector (decode-time))) |
| 102 | ;; ... for minute and hour. | 102 | ;; ... for minute and hour. |
| 103 | (aset deadline 1 minute) | 103 | (aset deadline 1 minute) |
| 104 | (aset deadline 2 hour) | 104 | (aset deadline 2 hour) |
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index db0242ef42b..55a263d0d79 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el | |||
| @@ -9333,7 +9333,7 @@ Obeys the standard process/prefix convention." | |||
| 9333 | ((gnus-group-read-ephemeral-group | 9333 | ((gnus-group-read-ephemeral-group |
| 9334 | (setq vgroup (format | 9334 | (setq vgroup (format |
| 9335 | "nnvirtual:%s-%s" gnus-newsgroup-name | 9335 | "nnvirtual:%s-%s" gnus-newsgroup-name |
| 9336 | (format-time-string "%Y%m%dT%H%M%S" (current-time)))) | 9336 | (format-time-string "%Y%m%dT%H%M%S"))) |
| 9337 | `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) | 9337 | `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups)) |
| 9338 | t | 9338 | t |
| 9339 | (cons (current-buffer) 'summary))) | 9339 | (cons (current-buffer) 'summary))) |
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index fe4d707be2e..15f3aede889 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el | |||
| @@ -313,14 +313,12 @@ Symbols are also allowed; their print names are used instead." | |||
| 313 | 313 | ||
| 314 | ;; Every version of Emacs Gnus supports has built-in float-time. | 314 | ;; Every version of Emacs Gnus supports has built-in float-time. |
| 315 | ;; The featurep test silences an irritating compiler warning. | 315 | ;; The featurep test silences an irritating compiler warning. |
| 316 | (eval-and-compile | 316 | (defalias 'gnus-float-time |
| 317 | (if (or (featurep 'emacs) | 317 | (if (or (featurep 'emacs) |
| 318 | (fboundp 'float-time)) | 318 | (fboundp 'float-time)) |
| 319 | (defalias 'gnus-float-time 'float-time) | 319 | 'float-time 'time-to-seconds) |
| 320 | (defun gnus-float-time (&optional time) | 320 | "Convert time value TIME to a floating point number. |
| 321 | "Convert time value TIME to a floating point number. | 321 | TIME defaults to the current time.") |
| 322 | TIME defaults to the current time." | ||
| 323 | (time-to-seconds (or time (current-time)))))) | ||
| 324 | 322 | ||
| 325 | ;;; Keymap macros. | 323 | ;;; Keymap macros. |
| 326 | 324 | ||
| @@ -389,19 +387,20 @@ TIME defaults to the current time." | |||
| 389 | 387 | ||
| 390 | (defun gnus-seconds-today () | 388 | (defun gnus-seconds-today () |
| 391 | "Return the number of seconds passed today." | 389 | "Return the number of seconds passed today." |
| 392 | (let ((now (decode-time (current-time)))) | 390 | (let ((now (decode-time))) |
| 393 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)))) | 391 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)))) |
| 394 | 392 | ||
| 395 | (defun gnus-seconds-month () | 393 | (defun gnus-seconds-month () |
| 396 | "Return the number of seconds passed this month." | 394 | "Return the number of seconds passed this month." |
| 397 | (let ((now (decode-time (current-time)))) | 395 | (let ((now (decode-time))) |
| 398 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) | 396 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) |
| 399 | (* (- (car (nthcdr 3 now)) 1) 3600 24)))) | 397 | (* (- (car (nthcdr 3 now)) 1) 3600 24)))) |
| 400 | 398 | ||
| 401 | (defun gnus-seconds-year () | 399 | (defun gnus-seconds-year () |
| 402 | "Return the number of seconds passed this year." | 400 | "Return the number of seconds passed this year." |
| 403 | (let ((now (decode-time (current-time))) | 401 | (let* ((current (current-time)) |
| 404 | (days (format-time-string "%j" (current-time)))) | 402 | (now (decode-time current)) |
| 403 | (days (format-time-string "%j" current))) | ||
| 405 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) | 404 | (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600) |
| 406 | (* (- (string-to-number days) 1) 3600 24)))) | 405 | (* (- (string-to-number days) 1) 3600 24)))) |
| 407 | 406 | ||
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 1cec37e15dc..3cd9e93366c 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -5550,7 +5550,7 @@ If NOW, use that time instead." | |||
| 5550 | "Make date string for the Expires header. Expiry in DAYS days. | 5550 | "Make date string for the Expires header. Expiry in DAYS days. |
| 5551 | 5551 | ||
| 5552 | In posting styles use `(\"Expires\" (make-expires-date 30))'." | 5552 | In posting styles use `(\"Expires\" (make-expires-date 30))'." |
| 5553 | (let* ((cur (decode-time (current-time))) | 5553 | (let* ((cur (decode-time)) |
| 5554 | (nday (+ days (nth 3 cur)))) | 5554 | (nday (+ days (nth 3 cur)))) |
| 5555 | (setf (nth 3 cur) nday) | 5555 | (setf (nth 3 cur) nday) |
| 5556 | (message-make-date (apply 'encode-time cur)))) | 5556 | (message-make-date (apply 'encode-time cur)))) |
diff --git a/lisp/ido.el b/lisp/ido.el index b16ab1f91a6..bda2525b629 100644 --- a/lisp/ido.el +++ b/lisp/ido.el | |||
| @@ -1306,8 +1306,7 @@ Only used if `ido-use-virtual-buffers' is non-nil.") | |||
| 1306 | 1306 | ||
| 1307 | (defun ido-time-stamp (&optional time) | 1307 | (defun ido-time-stamp (&optional time) |
| 1308 | ;; Time is a floating point number (fractions of 1 hour) | 1308 | ;; Time is a floating point number (fractions of 1 hour) |
| 1309 | (setq time (or time (current-time))) | 1309 | (/ (float-time time) 3600)) |
| 1310 | (/ (+ (* (car time) 65536.0) (car (cdr time))) 3600.0)) | ||
| 1311 | 1310 | ||
| 1312 | (defun ido-cache-ftp-valid (&optional time) | 1311 | (defun ido-cache-ftp-valid (&optional time) |
| 1313 | (and (numberp ido-cache-ftp-work-directory-time) | 1312 | (and (numberp ido-cache-ftp-work-directory-time) |
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el index 00d595c977f..ba100534085 100644 --- a/lisp/net/newst-backend.el +++ b/lisp/net/newst-backend.el | |||
| @@ -757,7 +757,7 @@ from." | |||
| 757 | ) | 757 | ) |
| 758 | ((eq status-type :error) | 758 | ((eq status-type :error) |
| 759 | (message "%s: Error while retrieving news from %s: %s: \"%s\"" | 759 | (message "%s: Error while retrieving news from %s: %s: \"%s\"" |
| 760 | (format-time-string "%A, %H:%M" (current-time)) | 760 | (format-time-string "%A, %H:%M") |
| 761 | feed-name | 761 | feed-name |
| 762 | (car status-details) (cdr status-details)))))))) | 762 | (car status-details) (cdr status-details)))))))) |
| 763 | 763 | ||
| @@ -787,7 +787,7 @@ See `newsticker-get-news'." | |||
| 787 | FEED-NAME must be a string which occurs as the label (i.e. the first element) | 787 | FEED-NAME must be a string which occurs as the label (i.e. the first element) |
| 788 | in an element of `newsticker-url-list' or `newsticker-url-list-defaults'." | 788 | in an element of `newsticker-url-list' or `newsticker-url-list-defaults'." |
| 789 | (newsticker--debug-msg "%s: Getting news for %s" | 789 | (newsticker--debug-msg "%s: Getting news for %s" |
| 790 | (format-time-string "%A, %H:%M" (current-time)) | 790 | (format-time-string "%A, %H:%M") |
| 791 | feed-name) | 791 | feed-name) |
| 792 | (let* ((item (or (assoc feed-name newsticker-url-list) | 792 | (let* ((item (or (assoc feed-name newsticker-url-list) |
| 793 | (assoc feed-name newsticker-url-list-defaults) | 793 | (assoc feed-name newsticker-url-list-defaults) |
| @@ -845,14 +845,14 @@ Argument BUFFER is the buffer of the retrieval process." | |||
| 845 | (concat "%s: Newsticker could not retrieve news from %s.\n" | 845 | (concat "%s: Newsticker could not retrieve news from %s.\n" |
| 846 | "Return status: `%s'\n" | 846 | "Return status: `%s'\n" |
| 847 | "Command was `%s'") | 847 | "Command was `%s'") |
| 848 | (format-time-string "%A, %H:%M" (current-time)) | 848 | (format-time-string "%A, %H:%M") |
| 849 | feed-name event command) | 849 | feed-name event command) |
| 850 | "" | 850 | "" |
| 851 | (current-time) | 851 | (current-time) |
| 852 | 'new | 852 | 'new |
| 853 | 0 nil)) | 853 | 0 nil)) |
| 854 | (message "%s: Error while retrieving news from %s" | 854 | (message "%s: Error while retrieving news from %s" |
| 855 | (format-time-string "%A, %H:%M" (current-time)) | 855 | (format-time-string "%A, %H:%M") |
| 856 | feed-name) | 856 | feed-name) |
| 857 | (throw 'oops nil)) | 857 | (throw 'oops nil)) |
| 858 | (let* ((coding-system 'utf-8) | 858 | (let* ((coding-system 'utf-8) |
| @@ -1020,7 +1020,7 @@ Argument BUFFER is the buffer of the retrieval process." | |||
| 1020 | 1020 | ||
| 1021 | (defun newsticker--do-xml-workarounds () | 1021 | (defun newsticker--do-xml-workarounds () |
| 1022 | "Fix all issues which `xml-parse-region' could be choking on." | 1022 | "Fix all issues which `xml-parse-region' could be choking on." |
| 1023 | 1023 | ||
| 1024 | ;; a very very dirty workaround to overcome the | 1024 | ;; a very very dirty workaround to overcome the |
| 1025 | ;; problems with the newest (20030621) xml.el: | 1025 | ;; problems with the newest (20030621) xml.el: |
| 1026 | ;; remove all unnecessary whitespace | 1026 | ;; remove all unnecessary whitespace |
| @@ -1808,11 +1808,11 @@ download it from URL first." | |||
| 1808 | (time-add (nth 5 (file-attributes image-name)) | 1808 | (time-add (nth 5 (file-attributes image-name)) |
| 1809 | (seconds-to-time 86400)))) | 1809 | (seconds-to-time 86400)))) |
| 1810 | (newsticker--debug-msg "%s: Getting image for %s skipped" | 1810 | (newsticker--debug-msg "%s: Getting image for %s skipped" |
| 1811 | (format-time-string "%A, %H:%M" (current-time)) | 1811 | (format-time-string "%A, %H:%M") |
| 1812 | feed-name) | 1812 | feed-name) |
| 1813 | ;; download | 1813 | ;; download |
| 1814 | (newsticker--debug-msg "%s: Getting image for %s" | 1814 | (newsticker--debug-msg "%s: Getting image for %s" |
| 1815 | (format-time-string "%A, %H:%M" (current-time)) | 1815 | (format-time-string "%A, %H:%M") |
| 1816 | feed-name) | 1816 | feed-name) |
| 1817 | (if (eq newsticker-retrieval-method 'intern) | 1817 | (if (eq newsticker-retrieval-method 'intern) |
| 1818 | (newsticker--image-download-by-url feed-name filename directory url) | 1818 | (newsticker--image-download-by-url feed-name filename directory url) |
| @@ -1859,7 +1859,7 @@ Save image as FILENAME in DIRECTORY, download it from URL." | |||
| 1859 | (unless (and (eq p-status 'exit) | 1859 | (unless (and (eq p-status 'exit) |
| 1860 | (= exit-status 0)) | 1860 | (= exit-status 0)) |
| 1861 | (message "%s: Error while retrieving image from %s" | 1861 | (message "%s: Error while retrieving image from %s" |
| 1862 | (format-time-string "%A, %H:%M" (current-time)) | 1862 | (format-time-string "%A, %H:%M") |
| 1863 | feed-name) | 1863 | feed-name) |
| 1864 | (newsticker--image-remove directory feed-name) | 1864 | (newsticker--image-remove directory feed-name) |
| 1865 | (throw 'oops nil)) | 1865 | (throw 'oops nil)) |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 388c2b2879c..858fad4c060 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -599,10 +599,10 @@ If ARG is non-nil, instead prompt for connection parameters." | |||
| 599 | `(with-current-buffer rcirc-server-buffer | 599 | `(with-current-buffer rcirc-server-buffer |
| 600 | ,@body)) | 600 | ,@body)) |
| 601 | 601 | ||
| 602 | (defun rcirc-float-time () | 602 | (defalias 'rcirc-float-time |
| 603 | (if (featurep 'xemacs) | 603 | (if (featurep 'xemacs) |
| 604 | (time-to-seconds (current-time)) | 604 | 'time-to-seconds |
| 605 | (float-time))) | 605 | 'float-time)) |
| 606 | 606 | ||
| 607 | (defun rcirc-prompt-for-encryption (server-plist) | 607 | (defun rcirc-prompt-for-encryption (server-plist) |
| 608 | "Prompt the user for the encryption method to use. | 608 | "Prompt the user for the encryption method to use. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ce5e2faff50..1976e0e7f66 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -5213,7 +5213,7 @@ Return ATTR." | |||
| 5213 | (format | 5213 | (format |
| 5214 | "%s -t %s %s" | 5214 | "%s -t %s %s" |
| 5215 | result | 5215 | result |
| 5216 | (format-time-string "%Y%m%d%H%M.%S" (current-time)) | 5216 | (format-time-string "%Y%m%d%H%M.%S") |
| 5217 | (tramp-file-name-handler 'file-remote-p tmpfile 'localname)))) | 5217 | (tramp-file-name-handler 'file-remote-p tmpfile 'localname)))) |
| 5218 | (delete-file tmpfile)) | 5218 | (delete-file tmpfile)) |
| 5219 | result))) | 5219 | result))) |
diff --git a/lisp/org/ChangeLog b/lisp/org/ChangeLog index 0f28ef0df92..0f50e574171 100644 --- a/lisp/org/ChangeLog +++ b/lisp/org/ChangeLog | |||
| @@ -1,3 +1,24 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * org-archive.el (org-archive-subtree) | ||
| 5 | (org-archive-to-archive-sibling): | ||
| 6 | * org-clock.el (org-resolve-clocks, org-clock-get-sum-start) | ||
| 7 | (org-clock-special-range): | ||
| 8 | * org-timer.el (org-timer-seconds): | ||
| 9 | * org.el (org-read-date-analyze, org-get-cursor-date): | ||
| 10 | * ox-html.el (org-html-format-spec): | ||
| 11 | * ox-icalendar.el (org-icalendar--vtodo): | ||
| 12 | Omit unnecessary call to current-time. | ||
| 13 | * org-clock.el (org-clock-get-table-data): Omit unnecessary, lossy | ||
| 14 | conversion from floating point to Emacs time and back. | ||
| 15 | (org-resolve-clocks): Prefer two-argument floor. | ||
| 16 | * org-compat.el (org-float-time): Simplify to an alias because | ||
| 17 | time-to-seconds now behaves like float-time with respect to nil arg. | ||
| 18 | * org.el (org-get-cursor-date): | ||
| 19 | Don't call current-time twice to get the current time stamp, | ||
| 20 | as this can lead to inconsistent results. | ||
| 21 | |||
| 1 | 2014-10-20 Glenn Morris <rgm@gnu.org> | 22 | 2014-10-20 Glenn Morris <rgm@gnu.org> |
| 2 | 23 | ||
| 3 | * Merge in all changes up to 24.4 release. | 24 | * Merge in all changes up to 24.4 release. |
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el index 6deac47ba8e..87471a9cea9 100644 --- a/lisp/org/org-archive.el +++ b/lisp/org/org-archive.el | |||
| @@ -231,8 +231,7 @@ this heading." | |||
| 231 | (error "No file associated to buffer")))) | 231 | (error "No file associated to buffer")))) |
| 232 | (olpath (mapconcat 'identity (org-get-outline-path) "/")) | 232 | (olpath (mapconcat 'identity (org-get-outline-path) "/")) |
| 233 | (time (format-time-string | 233 | (time (format-time-string |
| 234 | (substring (cdr org-time-stamp-formats) 1 -1) | 234 | (substring (cdr org-time-stamp-formats) 1 -1))) |
| 235 | (current-time))) | ||
| 236 | category todo priority ltags itags atags | 235 | category todo priority ltags itags atags |
| 237 | ;; end of variables that will be used for saving context | 236 | ;; end of variables that will be used for saving context |
| 238 | location afile heading buffer level newfile-p infile-p visiting | 237 | location afile heading buffer level newfile-p infile-p visiting |
| @@ -441,8 +440,7 @@ sibling does not exist, it will be created at the end of the subtree." | |||
| 441 | (org-set-property | 440 | (org-set-property |
| 442 | "ARCHIVE_TIME" | 441 | "ARCHIVE_TIME" |
| 443 | (format-time-string | 442 | (format-time-string |
| 444 | (substring (cdr org-time-stamp-formats) 1 -1) | 443 | (substring (cdr org-time-stamp-formats) 1 -1))) |
| 445 | (current-time))) | ||
| 446 | (outline-up-heading 1 t) | 444 | (outline-up-heading 1 t) |
| 447 | (hide-subtree) | 445 | (hide-subtree) |
| 448 | (org-cycle-show-empty-lines 'folded) | 446 | (org-cycle-show-empty-lines 'folded) |
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el index 1bbe8506531..51c87892a9c 100644 --- a/lisp/org/org-clock.el +++ b/lisp/org/org-clock.el | |||
| @@ -1046,9 +1046,9 @@ If `only-dangling-p' is non-nil, only ask to resolve dangling | |||
| 1046 | (lambda (clock) | 1046 | (lambda (clock) |
| 1047 | (format | 1047 | (format |
| 1048 | "Dangling clock started %d mins ago" | 1048 | "Dangling clock started %d mins ago" |
| 1049 | (floor | 1049 | (floor (- (org-float-time) |
| 1050 | (/ (- (org-float-time (current-time)) | 1050 | (org-float-time (cdr clock))) |
| 1051 | (org-float-time (cdr clock))) 60)))))) | 1051 | 60))))) |
| 1052 | (or last-valid | 1052 | (or last-valid |
| 1053 | (cdr clock))))))))))) | 1053 | (cdr clock))))))))))) |
| 1054 | 1054 | ||
| @@ -1368,7 +1368,7 @@ decides which time to use." | |||
| 1368 | (current-time)) | 1368 | (current-time)) |
| 1369 | ((equal cmt "today") | 1369 | ((equal cmt "today") |
| 1370 | (setq org--msg-extra "showing today's task time.") | 1370 | (setq org--msg-extra "showing today's task time.") |
| 1371 | (let* ((dt (decode-time (current-time)))) | 1371 | (let* ((dt (decode-time))) |
| 1372 | (setq dt (append (list 0 0 0) (nthcdr 3 dt))) | 1372 | (setq dt (append (list 0 0 0) (nthcdr 3 dt))) |
| 1373 | (if org-extend-today-until | 1373 | (if org-extend-today-until |
| 1374 | (setf (nth 2 dt) org-extend-today-until)) | 1374 | (setf (nth 2 dt) org-extend-today-until)) |
| @@ -2029,7 +2029,7 @@ If MSTART is non-nil, use this number to specify the starting day of a | |||
| 2029 | month (1 is the first day of the month). | 2029 | month (1 is the first day of the month). |
| 2030 | If you can combine both, the month starting day will have priority." | 2030 | If you can combine both, the month starting day will have priority." |
| 2031 | (if (integerp key) (setq key (intern (number-to-string key)))) | 2031 | (if (integerp key) (setq key (intern (number-to-string key)))) |
| 2032 | (let* ((tm (decode-time (or time (current-time)))) | 2032 | (let* ((tm (decode-time time)) |
| 2033 | (s 0) (m (nth 1 tm)) (h (nth 2 tm)) | 2033 | (s 0) (m (nth 1 tm)) (h (nth 2 tm)) |
| 2034 | (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm)) | 2034 | (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm)) |
| 2035 | (dow (nth 6 tm)) | 2035 | (dow (nth 6 tm)) |
| @@ -2670,10 +2670,8 @@ TIME: The sum of all time spend in this tree, in minutes. This time | |||
| 2670 | (when (and te (listp te)) | 2670 | (when (and te (listp te)) |
| 2671 | (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te)))) | 2671 | (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te)))) |
| 2672 | ;; Now the times are strings we can parse. | 2672 | ;; Now the times are strings we can parse. |
| 2673 | (if ts (setq ts (org-float-time | 2673 | (if ts (setq ts (org-matcher-time ts))) |
| 2674 | (seconds-to-time (org-matcher-time ts))))) | 2674 | (if te (setq te (org-matcher-time te))) |
| 2675 | (if te (setq te (org-float-time | ||
| 2676 | (seconds-to-time (org-matcher-time te))))) | ||
| 2677 | (save-excursion | 2675 | (save-excursion |
| 2678 | (org-clock-sum ts te | 2676 | (org-clock-sum ts te |
| 2679 | (unless (null matcher) | 2677 | (unless (null matcher) |
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el index 4466b0be80d..122658970f5 100644 --- a/lisp/org/org-compat.el +++ b/lisp/org/org-compat.el | |||
| @@ -411,12 +411,10 @@ Pass BUFFER to the XEmacs version of `move-to-column'." | |||
| 411 | (when focus-follows-mouse | 411 | (when focus-follows-mouse |
| 412 | (set-mouse-position frame (1- (frame-width frame)) 0))))) | 412 | (set-mouse-position frame (1- (frame-width frame)) 0))))) |
| 413 | 413 | ||
| 414 | (defun org-float-time (&optional time) | 414 | (defalias 'org-float-time |
| 415 | (if (featurep 'xemacs) 'time-to-seconds 'float-time) | ||
| 415 | "Convert time value TIME to a floating point number. | 416 | "Convert time value TIME to a floating point number. |
| 416 | TIME defaults to the current time." | 417 | TIME defaults to the current time.") |
| 417 | (if (featurep 'xemacs) | ||
| 418 | (time-to-seconds (or time (current-time))) | ||
| 419 | (float-time time))) | ||
| 420 | 418 | ||
| 421 | ;; `user-error' is only available from 24.2.50 on | 419 | ;; `user-error' is only available from 24.2.50 on |
| 422 | (unless (fboundp 'user-error) | 420 | (unless (fboundp 'user-error) |
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el index 8161699f316..b22db7bc6fa 100644 --- a/lisp/org/org-timer.el +++ b/lisp/org/org-timer.el | |||
| @@ -195,8 +195,8 @@ it in the buffer." | |||
| 195 | (defun org-timer-seconds () | 195 | (defun org-timer-seconds () |
| 196 | (if org-timer-timer-is-countdown | 196 | (if org-timer-timer-is-countdown |
| 197 | (- (org-float-time org-timer-start-time) | 197 | (- (org-float-time org-timer-start-time) |
| 198 | (org-float-time (current-time))) | 198 | (org-float-time)) |
| 199 | (- (org-float-time (or org-timer-pause-time (current-time))) | 199 | (- (org-float-time org-timer-pause-time) |
| 200 | (org-float-time org-timer-start-time)))) | 200 | (org-float-time org-timer-start-time)))) |
| 201 | 201 | ||
| 202 | ;;;###autoload | 202 | ;;;###autoload |
diff --git a/lisp/org/org.el b/lisp/org/org.el index 1604241f6b3..30bb98d98ed 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el | |||
| @@ -16490,7 +16490,7 @@ user." | |||
| 16490 | (defun org-read-date-analyze (ans org-def org-defdecode) | 16490 | (defun org-read-date-analyze (ans org-def org-defdecode) |
| 16491 | "Analyze the combined answer of the date prompt." | 16491 | "Analyze the combined answer of the date prompt." |
| 16492 | ;; FIXME: cleanup and comment | 16492 | ;; FIXME: cleanup and comment |
| 16493 | (let ((nowdecode (decode-time (current-time))) | 16493 | (let ((nowdecode (decode-time)) |
| 16494 | delta deltan deltaw deltadef year month day | 16494 | delta deltan deltaw deltadef year month day |
| 16495 | hour minute second wday pm h2 m2 tl wday1 | 16495 | hour minute second wday pm h2 m2 tl wday1 |
| 16496 | iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) | 16496 | iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) |
| @@ -16648,7 +16648,7 @@ user." | |||
| 16648 | (deltan | 16648 | (deltan |
| 16649 | (setq futurep nil) | 16649 | (setq futurep nil) |
| 16650 | (unless deltadef | 16650 | (unless deltadef |
| 16651 | (let ((now (decode-time (current-time)))) | 16651 | (let ((now (decode-time))) |
| 16652 | (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) | 16652 | (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) |
| 16653 | (cond ((member deltaw '("d" "")) (setq day (+ day deltan))) | 16653 | (cond ((member deltaw '("d" "")) (setq day (+ day deltan))) |
| 16654 | ((equal deltaw "w") (setq day (+ day (* 7 deltan)))) | 16654 | ((equal deltaw "w") (setq day (+ day (* 7 deltan)))) |
| @@ -22062,8 +22062,9 @@ the agenda) or the current time of the day." | |||
| 22062 | (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp)) | 22062 | (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp)) |
| 22063 | (setq hod (string-to-number (match-string 1 tp)) | 22063 | (setq hod (string-to-number (match-string 1 tp)) |
| 22064 | mod (string-to-number (match-string 2 tp)))) | 22064 | mod (string-to-number (match-string 2 tp)))) |
| 22065 | (or tp (setq hod (nth 2 (decode-time (current-time))) | 22065 | (or tp (let ((now (decode-time))) |
| 22066 | mod (nth 1 (decode-time (current-time)))))) | 22066 | (setq hod (nth 2 now) |
| 22067 | mod (nth 1 now))))) | ||
| 22067 | (cond | 22068 | (cond |
| 22068 | ((eq major-mode 'calendar-mode) | 22069 | ((eq major-mode 'calendar-mode) |
| 22069 | (setq date (calendar-cursor-to-date) | 22070 | (setq date (calendar-cursor-to-date) |
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el index 21f34810f15..a3f0b501da6 100644 --- a/lisp/org/ox-html.el +++ b/lisp/org/ox-html.el | |||
| @@ -1630,8 +1630,7 @@ used in the preamble or postamble." | |||
| 1630 | (?c . ,(plist-get info :creator)) | 1630 | (?c . ,(plist-get info :creator)) |
| 1631 | (?C . ,(let ((file (plist-get info :input-file))) | 1631 | (?C . ,(let ((file (plist-get info :input-file))) |
| 1632 | (format-time-string org-html-metadata-timestamp-format | 1632 | (format-time-string org-html-metadata-timestamp-format |
| 1633 | (if file (nth 5 (file-attributes file)) | 1633 | (if file (nth 5 (file-attributes file)))))) |
| 1634 | (current-time))))) | ||
| 1635 | (?v . ,(or org-html-validation-link "")))) | 1634 | (?v . ,(or org-html-validation-link "")))) |
| 1636 | 1635 | ||
| 1637 | (defun org-html--build-pre/postamble (type info) | 1636 | (defun org-html--build-pre/postamble (type info) |
diff --git a/lisp/org/ox-icalendar.el b/lisp/org/ox-icalendar.el index cd48bbf9aef..38bdcf95dd2 100644 --- a/lisp/org/ox-icalendar.el +++ b/lisp/org/ox-icalendar.el | |||
| @@ -678,7 +678,7 @@ Return VTODO component as a string." | |||
| 678 | (org-element-property :scheduled entry)) | 678 | (org-element-property :scheduled entry)) |
| 679 | ;; If we can't use a scheduled time for some | 679 | ;; If we can't use a scheduled time for some |
| 680 | ;; reason, start task now. | 680 | ;; reason, start task now. |
| 681 | (let ((now (decode-time (current-time)))) | 681 | (let ((now (decode-time))) |
| 682 | (list 'timestamp | 682 | (list 'timestamp |
| 683 | (list :type 'active | 683 | (list :type 'active |
| 684 | :minute-start (nth 1 now) | 684 | :minute-start (nth 1 now) |
diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el index fd8e249bbb9..2f3704be6fa 100644 --- a/lisp/progmodes/opascal.el +++ b/lisp/progmodes/opascal.el | |||
| @@ -1397,7 +1397,7 @@ If before the indent, the point is moved to the indent." | |||
| 1397 | (when opascal-debug | 1397 | (when opascal-debug |
| 1398 | (opascal-ensure-buffer opascal-debug-buffer "*OPascal Debug Log*") | 1398 | (opascal-ensure-buffer opascal-debug-buffer "*OPascal Debug Log*") |
| 1399 | (opascal-log-msg opascal-debug-buffer | 1399 | (opascal-log-msg opascal-debug-buffer |
| 1400 | (concat (format-time-string "%H:%M:%S " (current-time)) | 1400 | (concat (format-time-string "%H:%M:%S ") |
| 1401 | (apply #'format (cons format-string args)) | 1401 | (apply #'format (cons format-string args)) |
| 1402 | "\n")))) | 1402 | "\n")))) |
| 1403 | 1403 | ||
diff --git a/lisp/subr.el b/lisp/subr.el index edf59b88941..55ff739fec5 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -4507,11 +4507,10 @@ NEW-MESSAGE, if non-nil, sets a new message for the reporter." | |||
| 4507 | (min-value (aref parameters 1)) | 4507 | (min-value (aref parameters 1)) |
| 4508 | (max-value (aref parameters 2)) | 4508 | (max-value (aref parameters 2)) |
| 4509 | (text (aref parameters 3)) | 4509 | (text (aref parameters 3)) |
| 4510 | (current-time (float-time)) | ||
| 4511 | (enough-time-passed | 4510 | (enough-time-passed |
| 4512 | ;; See if enough time has passed since the last update. | 4511 | ;; See if enough time has passed since the last update. |
| 4513 | (or (not update-time) | 4512 | (or (not update-time) |
| 4514 | (when (>= current-time update-time) | 4513 | (when (>= (float-time) update-time) |
| 4515 | ;; Calculate time for the next update | 4514 | ;; Calculate time for the next update |
| 4516 | (aset parameters 0 (+ update-time (aref parameters 5))))))) | 4515 | (aset parameters 0 (+ update-time (aref parameters 5))))))) |
| 4517 | (cond ((and min-value max-value) | 4516 | (cond ((and min-value max-value) |
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el index 95b947481b5..260e7abfff3 100644 --- a/lisp/textmodes/remember.el +++ b/lisp/textmodes/remember.el | |||
| @@ -319,9 +319,7 @@ With a prefix or a visible region, use the region as INITIAL." | |||
| 319 | 319 | ||
| 320 | (defsubst remember-mail-date (&optional rfc822-p) | 320 | (defsubst remember-mail-date (&optional rfc822-p) |
| 321 | "Return a simple date. Nothing fancy." | 321 | "Return a simple date. Nothing fancy." |
| 322 | (if rfc822-p | 322 | (format-time-string (if rfc822-p "%a, %e %b %Y %T %z" "%a %b %e %T %Y"))) |
| 323 | (format-time-string "%a, %e %b %Y %T %z" (current-time)) | ||
| 324 | (format-time-string "%a %b %e %T %Y" (current-time)))) | ||
| 325 | 323 | ||
| 326 | (defun remember-buffer-desc () | 324 | (defun remember-buffer-desc () |
| 327 | "Using the first line of the current buffer, create a short description." | 325 | "Using the first line of the current buffer, create a short description." |
| @@ -461,8 +459,7 @@ Used by `remember-store-in-files'." | |||
| 461 | "Store remember data in a file in `remember-data-directory'. | 459 | "Store remember data in a file in `remember-data-directory'. |
| 462 | The file is named by calling `format-time-string' using | 460 | The file is named by calling `format-time-string' using |
| 463 | `remember-directory-file-name-format' as the format string." | 461 | `remember-directory-file-name-format' as the format string." |
| 464 | (let ((name (format-time-string | 462 | (let ((name (format-time-string remember-directory-file-name-format)) |
| 465 | remember-directory-file-name-format (current-time))) | ||
| 466 | (text (buffer-string))) | 463 | (text (buffer-string))) |
| 467 | (with-temp-buffer | 464 | (with-temp-buffer |
| 468 | (insert text) | 465 | (insert text) |
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 26e1dd1756d..12972ea04ab 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2014-10-29 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Simplify use of current-time and friends. | ||
| 4 | * url-cache.el (url-cache-prune-cache): | ||
| 5 | Rename local var to avoid confusion. | ||
| 6 | * url-util.el (url-get-normalized-date): | ||
| 7 | Omit unnecessary call to current-time. | ||
| 8 | |||
| 1 | 2014-10-20 Glenn Morris <rgm@gnu.org> | 9 | 2014-10-20 Glenn Morris <rgm@gnu.org> |
| 2 | 10 | ||
| 3 | * Merge in all changes up to 24.4 release. | 11 | * Merge in all changes up to 24.4 release. |
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el index 50ce38f064b..9b634bd4b0c 100644 --- a/lisp/url/url-cache.el +++ b/lisp/url/url-cache.el | |||
| @@ -212,7 +212,7 @@ If `url-standalone-mode' is non-nil, cached items never expire." | |||
| 212 | "Remove all expired files from the cache. | 212 | "Remove all expired files from the cache. |
| 213 | `url-cache-expire-time' says how old a file has to be to be | 213 | `url-cache-expire-time' says how old a file has to be to be |
| 214 | considered \"expired\"." | 214 | considered \"expired\"." |
| 215 | (let ((current-time (current-time)) | 215 | (let ((now (current-time)) |
| 216 | (total-files 0) | 216 | (total-files 0) |
| 217 | (deleted-files 0)) | 217 | (deleted-files 0)) |
| 218 | (setq directory (or directory url-cache-directory)) | 218 | (setq directory (or directory url-cache-directory)) |
| @@ -228,7 +228,7 @@ considered \"expired\"." | |||
| 228 | (time-add | 228 | (time-add |
| 229 | (nth 5 (file-attributes file)) | 229 | (nth 5 (file-attributes file)) |
| 230 | (seconds-to-time url-cache-expire-time)) | 230 | (seconds-to-time url-cache-expire-time)) |
| 231 | current-time) | 231 | now) |
| 232 | (delete-file file) | 232 | (delete-file file) |
| 233 | (setq deleted-files (1+ deleted-files)))))) | 233 | (setq deleted-files (1+ deleted-files)))))) |
| 234 | (if (< deleted-files total-files) | 234 | (if (< deleted-files total-files) |
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index b796e769c60..f7d2d4410d9 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el | |||
| @@ -189,8 +189,7 @@ Will not do anything if `url-show-status' is nil." | |||
| 189 | (defun url-get-normalized-date (&optional specified-time) | 189 | (defun url-get-normalized-date (&optional specified-time) |
| 190 | "Return a 'real' date string that most HTTP servers can understand." | 190 | "Return a 'real' date string that most HTTP servers can understand." |
| 191 | (let ((system-time-locale "C")) | 191 | (let ((system-time-locale "C")) |
| 192 | (format-time-string "%a, %d %b %Y %T GMT" | 192 | (format-time-string "%a, %d %b %Y %T GMT" specified-time t))) |
| 193 | (or specified-time (current-time)) t))) | ||
| 194 | 193 | ||
| 195 | ;;;###autoload | 194 | ;;;###autoload |
| 196 | (defun url-eat-trailing-space (x) | 195 | (defun url-eat-trailing-space (x) |
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el index 580e7727a06..e270ec401ba 100644 --- a/lisp/vc/vc-annotate.el +++ b/lisp/vc/vc-annotate.el | |||
| @@ -253,7 +253,7 @@ cover the range from the oldest annotation to the newest." | |||
| 253 | (interactive "P") | 253 | (interactive "P") |
| 254 | (let ((newest 0.0) | 254 | (let ((newest 0.0) |
| 255 | (oldest 999999.) ;Any CVS users at the founding of Rome? | 255 | (oldest 999999.) ;Any CVS users at the founding of Rome? |
| 256 | (current (vc-annotate-convert-time (current-time))) | 256 | (current (vc-annotate-convert-time)) |
| 257 | date) | 257 | date) |
| 258 | (message "Redisplaying annotation...") | 258 | (message "Redisplaying annotation...") |
| 259 | ;; Run through this file and find the oldest and newest dates annotated. | 259 | ;; Run through this file and find the oldest and newest dates annotated. |
| @@ -664,11 +664,10 @@ nil if no such cell exists." | |||
| 664 | (setq i (+ i 1))) | 664 | (setq i (+ i 1))) |
| 665 | tmp-cons)) ; Return the appropriate value | 665 | tmp-cons)) ; Return the appropriate value |
| 666 | 666 | ||
| 667 | (defun vc-annotate-convert-time (time) | 667 | (defun vc-annotate-convert-time (&optional time) |
| 668 | "Convert a time value to a floating-point number of days. | 668 | "Convert optional value TIME to a floating-point number of days. |
| 669 | The argument TIME is a list as returned by `current-time' or | 669 | TIME defaults to the current time." |
| 670 | `encode-time', only the first two elements of that list are considered." | 670 | (/ (float-time time) 86400)) |
| 671 | (/ (+ (* (float (car time)) (lsh 1 16)) (cadr time)) 24 3600)) | ||
| 672 | 671 | ||
| 673 | (defun vc-annotate-difference (&optional offset) | 672 | (defun vc-annotate-difference (&optional offset) |
| 674 | "Return the time span in days to the next annotation. | 673 | "Return the time span in days to the next annotation. |
| @@ -683,7 +682,7 @@ or OFFSET if present." | |||
| 683 | 682 | ||
| 684 | (defun vc-default-annotate-current-time (_backend) | 683 | (defun vc-default-annotate-current-time (_backend) |
| 685 | "Return the current time, encoded as fractional days." | 684 | "Return the current time, encoded as fractional days." |
| 686 | (vc-annotate-convert-time (current-time))) | 685 | (vc-annotate-convert-time)) |
| 687 | 686 | ||
| 688 | (defvar vc-annotate-offset nil) | 687 | (defvar vc-annotate-offset nil) |
| 689 | 688 | ||
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 4693998dfaf..a093bcb6b92 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -1167,10 +1167,7 @@ stream. Standard error output is discarded." | |||
| 1167 | "Create a stash with the current tree state." | 1167 | "Create a stash with the current tree state." |
| 1168 | (interactive) | 1168 | (interactive) |
| 1169 | (vc-bzr-command "shelve" nil 0 nil "--all" "-m" | 1169 | (vc-bzr-command "shelve" nil 0 nil "--all" "-m" |
| 1170 | (let ((ct (current-time))) | 1170 | (format-time-string "Snapshot on %Y-%m-%d at %H:%M")) |
| 1171 | (concat | ||
| 1172 | (format-time-string "Snapshot on %Y-%m-%d" ct) | ||
| 1173 | (format-time-string " at %H:%M" ct)))) | ||
| 1174 | (vc-bzr-command "unshelve" nil 0 nil "--apply" "--keep") | 1171 | (vc-bzr-command "unshelve" nil 0 nil "--apply" "--keep") |
| 1175 | (vc-resynch-buffer (vc-bzr-root default-directory) t t)) | 1172 | (vc-resynch-buffer (vc-bzr-root default-directory) t t)) |
| 1176 | 1173 | ||
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index f7684a3b82c..ad5559bb699 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el | |||
| @@ -605,7 +605,7 @@ Optional arg REVISION is a revision to annotate from." | |||
| 605 | "Return the current time, based at midnight of the current day, and | 605 | "Return the current time, based at midnight of the current day, and |
| 606 | encoded as fractional days." | 606 | encoded as fractional days." |
| 607 | (vc-annotate-convert-time | 607 | (vc-annotate-convert-time |
| 608 | (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time)))))) | 608 | (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time))))) |
| 609 | 609 | ||
| 610 | (defun vc-cvs-annotate-time () | 610 | (defun vc-cvs-annotate-time () |
| 611 | "Return the time of the next annotation (as fraction of days) | 611 | "Return the time of the next annotation (as fraction of days) |
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el index 6b064260f95..57515d04dc7 100644 --- a/lisp/vc/vc-rcs.el +++ b/lisp/vc/vc-rcs.el | |||
| @@ -811,7 +811,7 @@ Optional arg REVISION is a revision to annotate from." | |||
| 811 | "Return the current time, based at midnight of the current day, and | 811 | "Return the current time, based at midnight of the current day, and |
| 812 | encoded as fractional days." | 812 | encoded as fractional days." |
| 813 | (vc-annotate-convert-time | 813 | (vc-annotate-convert-time |
| 814 | (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time)))))) | 814 | (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time))))) |
| 815 | 815 | ||
| 816 | (defun vc-rcs-annotate-time () | 816 | (defun vc-rcs-annotate-time () |
| 817 | "Return the time of the next annotation (as fraction of days) | 817 | "Return the time of the next annotation (as fraction of days) |