diff options
Diffstat (limited to 'lisp/org')
-rw-r--r-- | lisp/org/ChangeLog | 21 | ||||
-rw-r--r-- | lisp/org/org-archive.el | 6 | ||||
-rw-r--r-- | lisp/org/org-clock.el | 16 | ||||
-rw-r--r-- | lisp/org/org-compat.el | 8 | ||||
-rw-r--r-- | lisp/org/org-timer.el | 4 | ||||
-rw-r--r-- | lisp/org/org.el | 9 | ||||
-rw-r--r-- | lisp/org/ox-html.el | 3 | ||||
-rw-r--r-- | lisp/org/ox-icalendar.el | 2 |
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 @@ +2014-10-29 Paul Eggert <eggert@cs.ucla.edu> + + Simplify use of current-time and friends. + * org-archive.el (org-archive-subtree) + (org-archive-to-archive-sibling): + * org-clock.el (org-resolve-clocks, org-clock-get-sum-start) + (org-clock-special-range): + * org-timer.el (org-timer-seconds): + * org.el (org-read-date-analyze, org-get-cursor-date): + * ox-html.el (org-html-format-spec): + * ox-icalendar.el (org-icalendar--vtodo): + Omit unnecessary call to current-time. + * 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. + * org-compat.el (org-float-time): Simplify to an alias because + time-to-seconds now behaves like float-time with respect to nil arg. + * 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. + 2014-10-20 Glenn Morris <rgm@gnu.org> * 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." (error "No file associated to buffer")))) (olpath (mapconcat 'identity (org-get-outline-path) "/")) (time (format-time-string - (substring (cdr org-time-stamp-formats) 1 -1) - (current-time))) + (substring (cdr org-time-stamp-formats) 1 -1))) category todo priority ltags itags atags ;; end of variables that will be used for saving context 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." (org-set-property "ARCHIVE_TIME" (format-time-string - (substring (cdr org-time-stamp-formats) 1 -1) - (current-time))) + (substring (cdr org-time-stamp-formats) 1 -1))) (outline-up-heading 1 t) (hide-subtree) (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 (lambda (clock) (format "Dangling clock started %d mins ago" - (floor - (/ (- (org-float-time (current-time)) - (org-float-time (cdr clock))) 60)))))) + (floor (- (org-float-time) + (org-float-time (cdr clock))) + 60))))) (or last-valid (cdr clock))))))))))) @@ -1368,7 +1368,7 @@ decides which time to use." (current-time)) ((equal cmt "today") (setq org--msg-extra "showing today's task time.") - (let* ((dt (decode-time (current-time)))) + (let* ((dt (decode-time))) (setq dt (append (list 0 0 0) (nthcdr 3 dt))) (if org-extend-today-until (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 month (1 is the first day of the month). If you can combine both, the month starting day will have priority." (if (integerp key) (setq key (intern (number-to-string key)))) - (let* ((tm (decode-time (or time (current-time)))) + (let* ((tm (decode-time time)) (s 0) (m (nth 1 tm)) (h (nth 2 tm)) (d (nth 3 tm)) (month (nth 4 tm)) (y (nth 5 tm)) (dow (nth 6 tm)) @@ -2670,10 +2670,8 @@ TIME: The sum of all time spend in this tree, in minutes. This time (when (and te (listp te)) (setq te (format "%4d-%02d-%02d" (nth 2 te) (car te) (nth 1 te)))) ;; Now the times are strings we can parse. - (if ts (setq ts (org-float-time - (seconds-to-time (org-matcher-time ts))))) - (if te (setq te (org-float-time - (seconds-to-time (org-matcher-time te))))) + (if ts (setq ts (org-matcher-time ts))) + (if te (setq te (org-matcher-time te))) (save-excursion (org-clock-sum ts te (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'." (when focus-follows-mouse (set-mouse-position frame (1- (frame-width frame)) 0))))) -(defun org-float-time (&optional time) +(defalias 'org-float-time + (if (featurep 'xemacs) 'time-to-seconds 'float-time) "Convert time value TIME to a floating point number. -TIME defaults to the current time." - (if (featurep 'xemacs) - (time-to-seconds (or time (current-time))) - (float-time time))) +TIME defaults to the current time.") ;; `user-error' is only available from 24.2.50 on (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." (defun org-timer-seconds () (if org-timer-timer-is-countdown (- (org-float-time org-timer-start-time) - (org-float-time (current-time))) - (- (org-float-time (or org-timer-pause-time (current-time))) + (org-float-time)) + (- (org-float-time org-timer-pause-time) (org-float-time org-timer-start-time)))) ;;;###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." (defun org-read-date-analyze (ans org-def org-defdecode) "Analyze the combined answer of the date prompt." ;; FIXME: cleanup and comment - (let ((nowdecode (decode-time (current-time))) + (let ((nowdecode (decode-time)) delta deltan deltaw deltadef year month day hour minute second wday pm h2 m2 tl wday1 iso-year iso-weekday iso-week iso-year iso-date futurep kill-year) @@ -16648,7 +16648,7 @@ user." (deltan (setq futurep nil) (unless deltadef - (let ((now (decode-time (current-time)))) + (let ((now (decode-time))) (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) (cond ((member deltaw '("d" "")) (setq day (+ day deltan))) ((equal deltaw "w") (setq day (+ day (* 7 deltan)))) @@ -22062,8 +22062,9 @@ the agenda) or the current time of the day." (when (and tp (string-match "\\([0-9][0-9]\\):\\([0-9][0-9]\\)" tp)) (setq hod (string-to-number (match-string 1 tp)) mod (string-to-number (match-string 2 tp)))) - (or tp (setq hod (nth 2 (decode-time (current-time))) - mod (nth 1 (decode-time (current-time)))))) + (or tp (let ((now (decode-time))) + (setq hod (nth 2 now) + mod (nth 1 now))))) (cond ((eq major-mode 'calendar-mode) (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." (?c . ,(plist-get info :creator)) (?C . ,(let ((file (plist-get info :input-file))) (format-time-string org-html-metadata-timestamp-format - (if file (nth 5 (file-attributes file)) - (current-time))))) + (if file (nth 5 (file-attributes file)))))) (?v . ,(or org-html-validation-link "")))) (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." (org-element-property :scheduled entry)) ;; If we can't use a scheduled time for some ;; reason, start task now. - (let ((now (decode-time (current-time)))) + (let ((now (decode-time))) (list 'timestamp (list :type 'active :minute-start (nth 1 now) |