diff options
| author | Sam Steingold | 2016-10-15 23:27:46 -0400 |
|---|---|---|
| committer | Sam Steingold | 2016-10-15 23:27:46 -0400 |
| commit | f9cbe8ee63f911650dcd273cb980eed5b8f58396 (patch) | |
| tree | 79bc56625ef9f19e665cdefd48028fddd4d5a1f7 /lisp/midnight.el | |
| parent | cd726ef68ece4fff6772bd08c0051c294e925505 (diff) | |
| download | emacs-f9cbe8ee63f911650dcd273cb980eed5b8f58396.tar.gz emacs-f9cbe8ee63f911650dcd273cb980eed5b8f58396.zip | |
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
Diffstat (limited to 'lisp/midnight.el')
| -rw-r--r-- | lisp/midnight.el | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/lisp/midnight.el b/lisp/midnight.el index 878c5a7f71f..814621fc4e3 100644 --- a/lisp/midnight.el +++ b/lisp/midnight.el | |||
| @@ -60,13 +60,6 @@ the time when it is run.") | |||
| 60 | (when (timerp midnight-timer) (cancel-timer midnight-timer)) | 60 | (when (timerp midnight-timer) (cancel-timer midnight-timer)) |
| 61 | (if midnight-mode (timer-activate midnight-timer))) | 61 | (if midnight-mode (timer-activate midnight-timer))) |
| 62 | 62 | ||
| 63 | ;;; time conversion | ||
| 64 | |||
| 65 | (defun midnight-buffer-display-time (buffer) | ||
| 66 | "Return the time-stamp of BUFFER, or current buffer, as float." | ||
| 67 | (with-current-buffer buffer | ||
| 68 | (when buffer-display-time (float-time buffer-display-time)))) | ||
| 69 | |||
| 70 | ;;; clean-buffer-list stuff | 63 | ;;; clean-buffer-list stuff |
| 71 | 64 | ||
| 72 | (defcustom clean-buffer-list-delay-general 3 | 65 | (defcustom clean-buffer-list-delay-general 3 |
| @@ -167,25 +160,28 @@ the current date/time, buffer name, how many seconds ago it was | |||
| 167 | displayed (can be nil if the buffer was never displayed) and its | 160 | displayed (can be nil if the buffer was never displayed) and its |
| 168 | lifetime, i.e., its \"age\" when it will be purged." | 161 | lifetime, i.e., its \"age\" when it will be purged." |
| 169 | (interactive) | 162 | (interactive) |
| 170 | (let ((tm (float-time)) bts (ts (format-time-string "%Y-%m-%d %T")) | 163 | (let ((tm (current-time)) bts (ts (format-time-string "%Y-%m-%d %T")) |
| 171 | delay cbld bn) | 164 | delay cbld bn) |
| 172 | (dolist (buf (buffer-list)) | 165 | (dolist (buf (buffer-list)) |
| 173 | (when (buffer-live-p buf) | 166 | (when (buffer-live-p buf) |
| 174 | (setq bts (midnight-buffer-display-time buf) bn (buffer-name buf) | 167 | (setq bts (with-current-buffer buf buffer-display-time) |
| 175 | delay (if bts (- tm bts) 0) cbld (clean-buffer-list-delay bn)) | 168 | bn (buffer-name buf) |
| 176 | (message "[%s] `%s' [%s %d]" ts bn (if bts (round delay)) cbld) | 169 | delay (if bts (round (float-time (time-subtract tm bts))) 0) |
| 177 | (unless (or (cl-find bn clean-buffer-list-kill-never-regexps | 170 | cbld (clean-buffer-list-delay bn)) |
| 171 | (message "[%s] `%s' [%s %d]" ts bn delay cbld) | ||
| 172 | (unless (or (cl-find bn clean-buffer-list-kill-never-regexps | ||
| 178 | :test (lambda (bn re) | 173 | :test (lambda (bn re) |
| 179 | (if (functionp re) | 174 | (if (functionp re) |
| 180 | (funcall re bn) | 175 | (funcall re bn) |
| 181 | (string-match re bn)))) | 176 | (string-match re bn)))) |
| 182 | (cl-find bn clean-buffer-list-kill-never-buffer-names | 177 | (cl-find bn clean-buffer-list-kill-never-buffer-names |
| 183 | :test #'string-equal) | 178 | :test #'string-equal) |
| 184 | (get-buffer-process buf) | 179 | (get-buffer-process buf) |
| 185 | (and (buffer-file-name buf) (buffer-modified-p buf)) | 180 | (and (buffer-file-name buf) (buffer-modified-p buf)) |
| 186 | (get-buffer-window buf 'visible) (< delay cbld)) | 181 | (get-buffer-window buf 'visible) |
| 187 | (message "[%s] killing `%s'" ts bn) | 182 | (< delay cbld)) |
| 188 | (kill-buffer buf)))))) | 183 | (message "[%s] killing `%s'" ts bn) |
| 184 | (kill-buffer buf)))))) | ||
| 189 | 185 | ||
| 190 | ;;; midnight hook | 186 | ;;; midnight hook |
| 191 | 187 | ||