aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/org
diff options
context:
space:
mode:
authorPaul Eggert2014-10-28 18:42:51 -0700
committerPaul Eggert2014-10-28 18:42:51 -0700
commit123ddec7f807f4bd7400bbbe08219afb02269c00 (patch)
treecac1153049785a70e015b32748521098956de5d8 /lisp/org
parent14e5809d3cc1fd89e50f88d5783219091596a271 (diff)
downloademacs-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/org')
-rw-r--r--lisp/org/ChangeLog21
-rw-r--r--lisp/org/org-archive.el6
-rw-r--r--lisp/org/org-clock.el16
-rw-r--r--lisp/org/org-compat.el8
-rw-r--r--lisp/org/org-timer.el4
-rw-r--r--lisp/org/org.el9
-rw-r--r--lisp/org/ox-html.el3
-rw-r--r--lisp/org/ox-icalendar.el2
8 files changed, 42 insertions, 27 deletions
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 @@
12014-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
12014-10-20 Glenn Morris <rgm@gnu.org> 222014-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
2029month (1 is the first day of the month). 2029month (1 is the first day of the month).
2030If you can combine both, the month starting day will have priority." 2030If 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.
416TIME defaults to the current time." 417TIME 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)