emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master f9cbe8e: use full time objects (lists) instead of f


From: Sam Steingold
Subject: [Emacs-diffs] master f9cbe8e: use full time objects (lists) instead of floats when possible
Date: Sun, 16 Oct 2016 03:27:56 +0000 (UTC)

branch: master
commit f9cbe8ee63f911650dcd273cb980eed5b8f58396
Author: Sam Steingold <address@hidden>
Commit: Sam Steingold <address@hidden>

    use full time objects (lists) instead of floats when possible
    
    * midnight.el (midnight-buffer-display-time): Remove
    (clean-buffer-list): Use float time only for time comparison
---
 lisp/midnight.el |   32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/lisp/midnight.el b/lisp/midnight.el
index 878c5a7..814621f 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -60,13 +60,6 @@ the time when it is run.")
   (when (timerp midnight-timer) (cancel-timer midnight-timer))
   (if midnight-mode (timer-activate midnight-timer)))
 
-;;; time conversion
-
-(defun midnight-buffer-display-time (buffer)
-  "Return the time-stamp of BUFFER, or current buffer, as float."
-  (with-current-buffer buffer
-    (when buffer-display-time (float-time buffer-display-time))))
-
 ;;; clean-buffer-list stuff
 
 (defcustom clean-buffer-list-delay-general 3
@@ -167,25 +160,28 @@ the current date/time, buffer name, how many seconds ago 
it was
 displayed (can be nil if the buffer was never displayed) and its
 lifetime, i.e., its \"age\" when it will be purged."
   (interactive)
-  (let ((tm (float-time)) bts (ts (format-time-string "%Y-%m-%d %T"))
+  (let ((tm (current-time)) bts (ts (format-time-string "%Y-%m-%d %T"))
         delay cbld bn)
     (dolist (buf (buffer-list))
       (when (buffer-live-p buf)
-       (setq bts (midnight-buffer-display-time buf) bn (buffer-name buf)
-             delay (if bts (- tm bts) 0) cbld (clean-buffer-list-delay bn))
-       (message "[%s] `%s' [%s %d]" ts bn (if bts (round delay)) cbld)
-       (unless (or (cl-find bn clean-buffer-list-kill-never-regexps
+        (setq bts (with-current-buffer buf buffer-display-time)
+              bn (buffer-name buf)
+              delay (if bts (round (float-time (time-subtract tm bts))) 0)
+              cbld (clean-buffer-list-delay bn))
+        (message "[%s] `%s' [%s %d]" ts bn delay cbld)
+        (unless (or (cl-find bn clean-buffer-list-kill-never-regexps
                              :test (lambda (bn re)
                                      (if (functionp re)
                                          (funcall re bn)
                                        (string-match re bn))))
-                   (cl-find bn clean-buffer-list-kill-never-buffer-names
+                    (cl-find bn clean-buffer-list-kill-never-buffer-names
                              :test #'string-equal)
-                   (get-buffer-process buf)
-                   (and (buffer-file-name buf) (buffer-modified-p buf))
-                   (get-buffer-window buf 'visible) (< delay cbld))
-         (message "[%s] killing `%s'" ts bn)
-         (kill-buffer buf))))))
+                    (get-buffer-process buf)
+                    (and (buffer-file-name buf) (buffer-modified-p buf))
+                    (get-buffer-window buf 'visible)
+                    (< delay cbld))
+          (message "[%s] killing `%s'" ts bn)
+          (kill-buffer buf))))))
 
 ;;; midnight hook
 



reply via email to

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