(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
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