emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master ae4bfd5: Don’t assume CURRENT_TIME_LIST


From: Paul Eggert
Subject: [Emacs-diffs] master ae4bfd5: Don’t assume CURRENT_TIME_LIST
Date: Wed, 13 Feb 2019 03:51:20 -0500 (EST)

branch: master
commit ae4bfd52deecfccbbeb20ac852564b75a1bb83ff
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Don’t assume CURRENT_TIME_LIST
    
    * lisp/progmodes/cc-cmds.el (c-progress-init)
    (c-progress-update):
    * lisp/progmodes/cperl-mode.el (cperl-time-fontification):
    * lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info)
    (vhdl-fix-case-region-1):
    Don’t assume (current-time) returns a list.
    Fix unlikely bug if we’re called 65536 seconds apart.
---
 lisp/progmodes/cc-cmds.el    |  4 ++--
 lisp/progmodes/cperl-mode.el |  4 +---
 lisp/progmodes/vhdl-mode.el  | 12 ++++++------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index c0a6881..efc6747 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -3609,7 +3609,7 @@ Otherwise reindent just the current line."
                                    (save-excursion
                                      (goto-char end)
                                      (point-marker))
-                                   (nth 1 (current-time))
+                                   (encode-time nil 'integer)
                                    context))
       (message "Indenting region..."))
    ))
@@ -3617,7 +3617,7 @@ Otherwise reindent just the current line."
 (defun c-progress-update ()
   (if (not (and c-progress-info c-progress-interval))
       nil
-    (let ((now (nth 1 (current-time)))
+    (let ((now (encode-time nil 'integer))
          (start (aref c-progress-info 0))
          (end (aref c-progress-info 1))
          (lastsecs (aref c-progress-info 2)))
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index b83947f..cb69a43 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -8675,9 +8675,7 @@ start with default arguments, then refine the slowdown 
regions."
   (or l (setq l 1))
   (or step (setq step 500))
   (or lim (setq lim 40))
-  (let* ((timems (function (lambda ()
-                            (let ((tt (current-time)))
-                              (+ (* 1000 (nth 1 tt)) (/ (nth 2 tt) 1000))))))
+  (let* ((timems (function (lambda () (car (encode-time nil 1000)))))
         (tt (funcall timems)) (c 0) delta tot)
     (goto-char (point-min))
     (forward-line (1- l))
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index 3bcf9e5..27380b3 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -7392,8 +7392,8 @@ only-lines."
 (defun vhdl-update-progress-info (string pos)
   "Update progress information."
   (when (and vhdl-progress-info (not noninteractive)
-            (< vhdl-progress-interval
-               (- (nth 1 (current-time)) (aref vhdl-progress-info 2))))
+            (time-less-p vhdl-progress-interval
+                         (time-subtract nil (aref vhdl-progress-info 2))))
     (let ((delta (- (aref vhdl-progress-info 1)
                     (aref vhdl-progress-info 0))))
       (message "%s... (%2d%%)" string
@@ -7401,7 +7401,7 @@ only-lines."
                   100
                  (floor (* 100.0 (- pos (aref vhdl-progress-info 0)))
                         delta))))
-    (aset vhdl-progress-info 2 (nth 1 (current-time)))))
+    (aset vhdl-progress-info 2 (encode-time nil 'integer))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Indentation commands
@@ -8142,12 +8142,12 @@ depending on parameter UPPER-CASE."
                 (upcase-word -1)
               (downcase-word -1)))
         (when (and count vhdl-progress-interval (not noninteractive)
-                   (< vhdl-progress-interval
-                      (- (nth 1 (current-time)) last-update)))
+                   (time-less-p vhdl-progress-interval
+                                (time-subtract nil last-update)))
           (message "Fixing case... (%2d%s)"
                    (+ (* count 20) (/ (* 20 (- (point) beg)) (- end beg)))
                    "%")
-          (setq last-update (nth 1 (current-time)))))
+          (setq last-update (encode-time nil 'integer))))
        (goto-char end)))))
 
 (defun vhdl-fix-case-region (beg end &optional arg)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]