Ver Fonte

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 há 6 anos atrás
pai
commit
6df3e8880e
3 ficheiros alterados com 17 adições e 12 exclusões
  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."
   "Compute all columns that have operators defined."
   (with-silent-modifications
   (with-silent-modifications
     (remove-text-properties (point-min) (point-max) '(org-summaries t)))
     (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)
 	seen)
     (dolist (spec org-columns-current-fmt-compiled)
     (dolist (spec org-columns-current-fmt-compiled)
       (let ((property (car spec)))
       (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
 	       ;; Pass `current-time' result to `float-time' (instead
 	       ;; of calling without arguments) so that only
 	       ;; of calling without arguments) so that only
 	       ;; `current-time' has to be overridden in tests.
 	       ;; `current-time' has to be overridden in tests.
-	       (- (float-time) delta))))
+	       (- (float-time (current-time)) delta))))
       (setq org-timer-pause-time nil)
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (org-timer-set-mode-line 'on)
       (message "Timer start time set to %s, current value is %s"
       (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
    (org-timer-pause-time
     (let ((start-secs (float-time org-timer-start-time))
     (let ((start-secs (float-time org-timer-start-time))
 	  (pause-secs (float-time org-timer-pause-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
       (if org-timer-countdown-timer
 	  (let ((new-secs (- start-secs pause-secs)))
 	  (let ((new-secs (- start-secs pause-secs)))
 	    (setq org-timer-countdown-timer
 	    (setq org-timer-countdown-timer
 		  (org-timer--run-countdown-timer
 		  (org-timer--run-countdown-timer
 		   new-secs org-timer-countdown-timer-title))
 		   new-secs org-timer-countdown-timer-title))
 	    (setq org-timer-start-time
 	    (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
 	(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)))))
 				  (- pause-secs start-secs)))))
       (setq org-timer-pause-time nil)
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (org-timer-set-mode-line 'on)
@@ -240,8 +240,8 @@ it in the buffer."
   ;; overridden in tests.
   ;; overridden in tests.
   (if org-timer-countdown-timer
   (if org-timer-countdown-timer
       (- (float-time org-timer-start-time)
       (- (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))))
        (float-time org-timer-start-time))))
 
 
 ;;;###autoload
 ;;;###autoload
@@ -465,8 +465,10 @@ using three `C-u' prefix arguments."
 		(org-timer--run-countdown-timer
 		(org-timer--run-countdown-timer
 		 secs org-timer-countdown-timer-title))
 		 secs org-timer-countdown-timer-title))
 	  (run-hooks 'org-timer-set-hook)
 	  (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
 	  (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)
 	  (setq org-timer-pause-time nil)
 	  (org-timer-set-mode-line 'on))))))
 	  (org-timer-set-mode-line 'on))))))
 
 

+ 2 - 2
lisp/org.el

@@ -16399,7 +16399,7 @@ user."
   ;; overridden in tests.
   ;; overridden in tests.
   (let ((org-def def)
   (let ((org-def def)
 	(org-defdecode defdecode)
 	(org-defdecode defdecode)
-	(nowdecode (decode-time))
+	(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-date futurep kill-year)
 	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
 	;; Pass `current-time' result to `decode-time' (instead of
 	;; calling without arguments) so that only `current-time' has
 	;; calling without arguments) so that only `current-time' has
 	;; to be overridden in tests.
 	;; 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))))
 	  (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))))