Browse Source

Restore some current-time to nil changes

* lisp/org-colview.el (org-columns-compute-all):
* lisp/org-timer.el (org-timer-start):
(org-timer-pause-or-continue):
(org-timer-seconds):
* lisp/org.el (org-read-date-analyze): Favor nil argument to
explicitly passing current-time result to float-time and decode-time.

Most of these "(current-time) => nil" changes were made in the Emacs
codebase, but we stayed with the original state because we relied on
explicitly overriding current-time in the tests.  As of the last
commit, we no longer need to do this and can use org-test-at-time
instead.
Kyle Meyer 9 months ago
parent
commit
6a5be09c1d
3 changed files with 9 additions and 24 deletions
  1. 1 4
      lisp/org-colview.el
  2. 6 12
      lisp/org-timer.el
  3. 2 8
      lisp/org.el

+ 1 - 4
lisp/org-colview.el

@@ -1224,10 +1224,7 @@ column specification."
   "Compute all columns that have operators defined."
   (with-silent-modifications
     (remove-text-properties (point-min) (point-max) '(org-summaries t)))
-  ;; 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)))
+  (let ((org-columns--time (float-time))
 	seen)
     (dolist (spec org-columns-current-fmt-compiled)
       (let ((property (car spec)))

+ 6 - 12
lisp/org-timer.el

@@ -141,10 +141,7 @@ the region 0:00:00."
 	  (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
 	(setq org-timer-start-time
 	      (seconds-to-time
-	       ;; 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 (current-time)) delta))))
+	       (- (float-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"
@@ -174,7 +171,7 @@ With prefix arg STOP, stop it entirely."
 	    (setq org-timer-start-time
 		  (time-add (current-time) (seconds-to-time new-secs))))
 	(setq org-timer-start-time
-	      (seconds-to-time (- (float-time (current-time))
+	      (seconds-to-time (- (float-time)
 				  (- pause-secs start-secs)))))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
@@ -235,13 +232,10 @@ it in the buffer."
 	   (abs (floor (org-timer-seconds))))))
 
 (defun org-timer-seconds ()
-  ;; Pass `current-time' result to `float-time' (instead of calling
-  ;; without arguments) so that only `current-time' has to be
-  ;; overridden in tests.
   (if org-timer-countdown-timer
       (- (float-time org-timer-start-time)
-	 (float-time (or org-timer-pause-time (current-time))))
-    (- (float-time (or org-timer-pause-time (current-time)))
+	 (float-time org-timer-pause-time))
+    (- (float-time org-timer-pause-time)
        (float-time org-timer-start-time))))
 
 ;;;###autoload
@@ -465,8 +459,8 @@ 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.
+	  ;; Pass `current-time' result to `time-add' (instead of nil)
+	  ;; for for Emacs 24 compatibility.
 	  (setq org-timer-start-time
 		(time-add (current-time) (seconds-to-time secs)))
 	  (setq org-timer-pause-time nil)

+ 2 - 8
lisp/org.el

@@ -16409,12 +16409,9 @@ user."
 (defun org-read-date-analyze (ans def defdecode)
   "Analyze the combined answer of the date prompt."
   ;; FIXME: cleanup and comment
-  ;; Pass `current-time' result to `decode-time' (instead of calling
-  ;; without arguments) so that only `current-time' has to be
-  ;; overridden in tests.
   (let ((org-def def)
 	(org-defdecode defdecode)
-	(nowdecode (decode-time (current-time)))
+	(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-date futurep kill-year)
@@ -16591,10 +16588,7 @@ user."
      (deltan
       (setq futurep nil)
       (unless deltadef
-	;; 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 (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))))