mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-31 04:41:23 -08:00
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
This commit is contained in:
parent
cd726ef68e
commit
f9cbe8ee63
1 changed files with 14 additions and 18 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue