Bladeren bron

Partially revert backport of c75f505de

* lisp/org-colview.el (org-columns-compute-all):
* lisp/org-timer.el (org-timer-start):
(org-timer-pause-or-continue):
(org-timer-seconds):
(org-timer-set-timer):
* lisp/org.el (org-read-date-analyze): Restore use of `current-time`
for testing purposes.

In these spots, we call (current-time) so that it can be overriden in
tests.  Add a comment about this in the cases that don't have one.
Kyle Meyer 6 jaren geleden
bovenliggende
commit
6df3e8880e
3 gewijzigde bestanden met toevoegingen van 17 en 12 verwijderingen
  1. 4 1
      lisp/org-colview.el
  2. 11 9
      lisp/org-timer.el
  3. 2 2
      lisp/org.el

+ 4 - 1
lisp/org-colview.el

@@ -1224,7 +1224,10 @@ column specification."
   "Compute all columns that have operators defined."
   (with-silent-modifications
     (remove-text-properties (point-min) (point-max) '(org-summaries t)))
-  (let ((org-columns--time (float-time))
+  ;; Pass `current-time' result to `float-time' (instead of calling
+  ;; without arguments) so that only `current-time' has to be
+  ;; overridden in tests.
+  (let ((org-columns--time (float-time (current-time)))
 	seen)
     (dolist (spec org-columns-current-fmt-compiled)
       (let ((property (car spec)))

+ 11 - 9
lisp/org-timer.el

@@ -144,7 +144,7 @@ the region 0:00:00."
 	       ;; Pass `current-time' result to `float-time' (instead
 	       ;; of calling without arguments) so that only
 	       ;; `current-time' has to be overridden in tests.
-	       (- (float-time) delta))))
+	       (- (float-time (current-time)) delta))))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (message "Timer start time set to %s, current value is %s"
@@ -163,18 +163,18 @@ With prefix arg STOP, stop it entirely."
    (org-timer-pause-time
     (let ((start-secs (float-time org-timer-start-time))
 	  (pause-secs (float-time org-timer-pause-time)))
+      ;; Note: We pass the result of `current-time' to `time-add' and
+      ;; `float-time' below so that we can easily override the value
+      ;; in tests.
       (if org-timer-countdown-timer
 	  (let ((new-secs (- start-secs pause-secs)))
 	    (setq org-timer-countdown-timer
 		  (org-timer--run-countdown-timer
 		   new-secs org-timer-countdown-timer-title))
 	    (setq org-timer-start-time
-		  (time-add nil (seconds-to-time new-secs))))
+		  (time-add (current-time) (seconds-to-time new-secs))))
 	(setq org-timer-start-time
-	      ;; Pass `current-time' result to `float-time' (instead
-	      ;; of calling without arguments) so that only
-	      ;; `current-time' has to be overridden in tests.
-	      (seconds-to-time (- (float-time)
+	      (seconds-to-time (- (float-time (current-time))
 				  (- pause-secs start-secs)))))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
@@ -240,8 +240,8 @@ it in the buffer."
   ;; overridden in tests.
   (if org-timer-countdown-timer
       (- (float-time org-timer-start-time)
-	 (float-time org-timer-pause-time))
-    (- (float-time org-timer-pause-time)
+	 (float-time (or org-timer-pause-time (current-time))))
+    (- (float-time (or org-timer-pause-time (current-time)))
        (float-time org-timer-start-time))))
 
 ;;;###autoload
@@ -465,8 +465,10 @@ using three `C-u' prefix arguments."
 		(org-timer--run-countdown-timer
 		 secs org-timer-countdown-timer-title))
 	  (run-hooks 'org-timer-set-hook)
+	  ;; Pass `current-time' result to `add-time' (instead nil) so
+	  ;; that only `current-time' has to be overridden in tests.
 	  (setq org-timer-start-time
-		(time-add nil (seconds-to-time secs)))
+		(time-add (current-time) (seconds-to-time secs)))
 	  (setq org-timer-pause-time nil)
 	  (org-timer-set-mode-line 'on))))))
 

+ 2 - 2
lisp/org.el

@@ -16399,7 +16399,7 @@ user."
   ;; overridden in tests.
   (let ((org-def def)
 	(org-defdecode defdecode)
-	(nowdecode (decode-time))
+	(nowdecode (decode-time (current-time)))
 	delta deltan deltaw deltadef year month day
 	hour minute second wday pm h2 m2 tl wday1
 	iso-year iso-weekday iso-week iso-date futurep kill-year)
@@ -16579,7 +16579,7 @@ user."
 	;; Pass `current-time' result to `decode-time' (instead of
 	;; calling without arguments) so that only `current-time' has
 	;; to be overridden in tests.
-	(let ((now (decode-time)))
+	(let ((now (decode-time (current-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))))