Bladeren bron

Pass current-time as optional arg for tests

* lisp/org.el (org-read-date-analyze):
* lisp/org-timer.el (org-timer-seconds): Explicitly pass current-time as
  optional time argument and explain reason in comment.

This reverts some changes from 91ab6c4 ("Backport commit 123ddec from
Emacs master branch", 2014-10-28).
Kyle Meyer 10 jaren geleden
bovenliggende
commit
5a01b116a4
2 gewijzigde bestanden met toevoegingen van 13 en 4 verwijderingen
  1. 5 2
      lisp/org-timer.el
  2. 8 2
      lisp/org.el

+ 5 - 2
lisp/org-timer.el

@@ -193,10 +193,13 @@ it in the buffer."
 
 
 (defvar org-timer-timer-is-countdown nil)
 (defvar org-timer-timer-is-countdown nil)
 (defun org-timer-seconds ()
 (defun org-timer-seconds ()
+  ;; Pass `current-time' result to `org-float-time'
+  ;; (instead of calling without arguments) so that only
+  ;; `current-time' has to be overriden in tests.
   (if org-timer-timer-is-countdown
   (if org-timer-timer-is-countdown
       (- (org-float-time org-timer-start-time)
       (- (org-float-time org-timer-start-time)
-	 (org-float-time))
-    (- (org-float-time org-timer-pause-time)
+	 (org-float-time (current-time)))
+    (- (org-float-time (or org-timer-pause-time (current-time)))
        (org-float-time org-timer-start-time))))
        (org-float-time org-timer-start-time))))
 
 
 ;;;###autoload
 ;;;###autoload

+ 8 - 2
lisp/org.el

@@ -16494,7 +16494,10 @@ user."
 (defun org-read-date-analyze (ans org-def org-defdecode)
 (defun org-read-date-analyze (ans org-def org-defdecode)
   "Analyze the combined answer of the date prompt."
   "Analyze the combined answer of the date prompt."
   ;; FIXME: cleanup and comment
   ;; FIXME: cleanup and comment
-  (let ((nowdecode (decode-time))
+  ;; Pass `current-time' result to `decode-time' (instead of calling
+  ;; without arguments) so that only `current-time' has to be
+  ;; overriden in tests.
+  (let ((nowdecode (decode-time (current-time)))
 	delta deltan deltaw deltadef year month day
 	delta deltan deltaw deltadef year month day
 	hour minute second wday pm h2 m2 tl wday1
 	hour minute second wday pm h2 m2 tl wday1
 	iso-year iso-weekday iso-week iso-year iso-date futurep kill-year)
 	iso-year iso-weekday iso-week iso-year iso-date futurep kill-year)
@@ -16652,7 +16655,10 @@ user."
      (deltan
      (deltan
       (setq futurep nil)
       (setq futurep nil)
       (unless deltadef
       (unless deltadef
-	(let ((now (decode-time)))
+	;; Pass `current-time' result to `decode-time' (instead of
+	;; calling without arguments) so that only `current-time' has
+	;; to be overriden in tests.
+	(let ((now (decode-time (current-time))))
 	  (setq day (nth 3 now) month (nth 4 now) year (nth 5 now))))
 	  (setq day (nth 3 now) month (nth 4 now) year (nth 5 now))))
       (cond ((member deltaw '("d" "")) (setq day (+ day deltan)))
       (cond ((member deltaw '("d" "")) (setq day (+ day deltan)))
 	    ((equal deltaw "w") (setq day (+ day (* 7 deltan))))
 	    ((equal deltaw "w") (setq day (+ day (* 7 deltan))))