diff options
| author | Richard M. Stallman | 1998-08-10 00:01:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-08-10 00:01:12 +0000 |
| commit | 9cc077f663aac6258e2f3bbcc3f879e58291341b (patch) | |
| tree | 2f2141933cc91ff85e0d26342871b9595717e206 /lisp | |
| parent | 05d5ca258f91e8bf55c473b4243cd5424ddc655c (diff) | |
| download | emacs-9cc077f663aac6258e2f3bbcc3f879e58291341b.tar.gz emacs-9cc077f663aac6258e2f3bbcc3f879e58291341b.zip | |
(clean-buffer-list-kill-buffer-names): Add `*diff*'.
(clean-buffer-list): Check `buffer-modified-p' only when the
buffer is associated with a file.
(midnight-delay-set): Improve doc.
(midnight-find): Don't use `find'.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/midnight.el | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/midnight.el b/lisp/midnight.el index 48e4c203c8f..f2c0b1ec5d4 100644 --- a/lisp/midnight.el +++ b/lisp/midnight.el | |||
| @@ -36,6 +36,8 @@ | |||
| 36 | ;; keeping `clean-buffer-list-kill-never-buffer-names' and | 36 | ;; keeping `clean-buffer-list-kill-never-buffer-names' and |
| 37 | ;; `clean-buffer-list-kill-never-regexps'. | 37 | ;; `clean-buffer-list-kill-never-regexps'. |
| 38 | 38 | ||
| 39 | ;;; Code: | ||
| 40 | |||
| 39 | (eval-when-compile | 41 | (eval-when-compile |
| 40 | (require 'cl) | 42 | (require 'cl) |
| 41 | (require 'timer)) | 43 | (require 'timer)) |
| @@ -110,7 +112,7 @@ See also `clean-buffer-list-kill-buffer-names', | |||
| 110 | 112 | ||
| 111 | (defcustom clean-buffer-list-kill-buffer-names | 113 | (defcustom clean-buffer-list-kill-buffer-names |
| 112 | '("*Help*" "*Apropos*" "*Man " "*Buffer List*" "*Compile-Log*" "*info*" | 114 | '("*Help*" "*Apropos*" "*Man " "*Buffer List*" "*Compile-Log*" "*info*" |
| 113 | "*vc*" "*vc-diff*") | 115 | "*vc*" "*vc-diff*" "*diff*") |
| 114 | "*List of strings saying which buffers will be killed at midnight. | 116 | "*List of strings saying which buffers will be killed at midnight. |
| 115 | Buffers with names in this list, which were not displayed in the last | 117 | Buffers with names in this list, which were not displayed in the last |
| 116 | `clean-buffer-list-delay-special' seconds, are killed by `clean-buffer-list' | 118 | `clean-buffer-list-delay-special' seconds, are killed by `clean-buffer-list' |
| @@ -146,11 +148,9 @@ two lists will NOT be killed if it also matches anything in this list." | |||
| 146 | 148 | ||
| 147 | (defun midnight-find (el ls test &optional key) | 149 | (defun midnight-find (el ls test &optional key) |
| 148 | "A stopgap solution to the absence of `find' in ELisp." | 150 | "A stopgap solution to the absence of `find' in ELisp." |
| 149 | (if (fboundp 'find) | 151 | (dolist (rr ls) |
| 150 | (find el ls :test test :key (or key 'eql)) | 152 | (when (funcall test el (if key (funcall key rr) rr)) |
| 151 | (dolist (rr ls) | 153 | (return rr)))) |
| 152 | (when (funcall test el (if key (funcall key rr) rr)) | ||
| 153 | (return rr))))) | ||
| 154 | 154 | ||
| 155 | (defun clean-buffer-list-delay (name) | 155 | (defun clean-buffer-list-delay (name) |
| 156 | "Return the delay, in seconds, before killing a buffer named NAME. | 156 | "Return the delay, in seconds, before killing a buffer named NAME. |
| @@ -165,21 +165,28 @@ Autokilling is done by `clean-buffer-list'." | |||
| 165 | 165 | ||
| 166 | (defun clean-buffer-list () | 166 | (defun clean-buffer-list () |
| 167 | "Kill old buffers that have not been displayed recently. | 167 | "Kill old buffers that have not been displayed recently. |
| 168 | The relevant vartiables are `clean-buffer-list-delay-general', | 168 | The relevant variables are `clean-buffer-list-delay-general', |
| 169 | `clean-buffer-list-delay-special', `clean-buffer-list-kill-buffer-names', | 169 | `clean-buffer-list-delay-special', `clean-buffer-list-kill-buffer-names', |
| 170 | `clean-buffer-list-kill-never-buffer-names', | 170 | `clean-buffer-list-kill-never-buffer-names', |
| 171 | `clean-buffer-list-kill-regexps' and `clean-buffer-list-kill-never-regexps'." | 171 | `clean-buffer-list-kill-regexps' and |
| 172 | `clean-buffer-list-kill-never-regexps'. | ||
| 173 | While processing buffers, this procedure displays messages containing | ||
| 174 | the current date/time, buffer name, how many seconds ago it was | ||
| 175 | displayed (can be NIL if the buffer was never displayed) and its | ||
| 176 | lifetime, i.e., its `age' when it will be purged." | ||
| 172 | (interactive) | 177 | (interactive) |
| 173 | (let ((tm (float-time)) bts (ts (format-time-string "%Y-%m-%d %T")) bn) | 178 | (let ((tm (float-time)) bts (ts (format-time-string "%Y-%m-%d %T")) bn |
| 174 | (dolist (buf (buffer-list)) | 179 | (bufs (buffer-list)) buf delay cbld) |
| 175 | (message "[%s] processing `%s'..." ts buf) | 180 | (while (setq buf (pop bufs)) |
| 176 | (setq bts (buffer-display-time buf) bn (buffer-name buf)) | 181 | (setq bts (buffer-display-time buf) bn (buffer-name buf) |
| 182 | delay (if bts (- tm bts) 0) cbld (clean-buffer-list-delay bn)) | ||
| 183 | (message "[%s] `%s' [%s %d]" ts bn (if bts (round delay)) cbld) | ||
| 177 | (unless (or (midnight-find bn clean-buffer-list-kill-never-regexps | 184 | (unless (or (midnight-find bn clean-buffer-list-kill-never-regexps |
| 178 | 'string-match) | 185 | 'string-match) |
| 179 | (midnight-find bn clean-buffer-list-kill-never-buffer-names | 186 | (midnight-find bn clean-buffer-list-kill-never-buffer-names |
| 180 | 'string-equal) | 187 | 'string-equal) |
| 181 | (buffer-modified-p buf) (get-buffer-window buf 'visible) | 188 | (and (buffer-file-name buf) (buffer-modified-p buf)) |
| 182 | (null bts) (< (- tm bts) (clean-buffer-list-delay bn))) | 189 | (get-buffer-window buf 'visible) (< delay cbld)) |
| 183 | (message "[%s] killing `%s'" ts bn) | 190 | (message "[%s] killing `%s'" ts bn) |
| 184 | (kill-buffer buf))))) | 191 | (kill-buffer buf))))) |
| 185 | 192 | ||
| @@ -207,10 +214,10 @@ the time when it is run.") | |||
| 207 | ;;;###autoload | 214 | ;;;###autoload |
| 208 | (defun midnight-delay-set (symb tm) | 215 | (defun midnight-delay-set (symb tm) |
| 209 | "Modify `midnight-timer' according to `midnight-delay'. | 216 | "Modify `midnight-timer' according to `midnight-delay'. |
| 210 | Sets the first argument (which must be symbol `midnight-delay') | 217 | Sets the first argument SYMB (which must be symbol `midnight-delay') |
| 211 | to its second argument." | 218 | to its second argument TM." |
| 212 | (unless (eq symb 'midnight-delay) | 219 | (assert (eq symb 'midnight-delay) t |
| 213 | (error "Illegal argument to `midnight-delay-set': `%s'" symb)) | 220 | "Illegal argument to `midnight-delay-set': `%s'" symb) |
| 214 | (set symb tm) | 221 | (set symb tm) |
| 215 | (when (timerp midnight-timer) (cancel-timer midnight-timer)) | 222 | (when (timerp midnight-timer) (cancel-timer midnight-timer)) |
| 216 | (setq midnight-timer | 223 | (setq midnight-timer |