Commit f9cbe8ee authored by Sam Steingold's avatar Sam Steingold

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
parent cd726ef6
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment