• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +refs:midnight +refs:delay +refs:set

0 ;;; midnight.el --- run something every midnight, e.g., kill old buffers
30 ;; To use the file, put (require 'midnight) into your .emacs. Then, at
31 ;; midnight, Emacs will run the normal hook `midnight-hook'. You can
36 ;; displayed more than `clean-buffer-list-delay-general' days ago,
47 (defgroup midnight nil
48 "Run something every day at midnight."
52 (defvar midnight-timer nil
53 "Timer running the `midnight-hook' `midnight-delay' seconds after midnight.
54 Use `cancel-timer' to stop it and `midnight-delay-set' to change
57 (defcustom midnight-mode nil
58 "*Non-nil means run `midnight-hook' at midnight.
60 call `cancel-timer' or `timer-activate' on `midnight-timer' instead."
62 :group 'midnight
63 :require 'midnight
65 :set (lambda (symb val)
66 (set symb val) (require 'midnight)
67 (if val (timer-activate midnight-timer)
68 (cancel-timer midnight-timer))))
72 (defun midnight-time-float (num)
78 (defun midnight-buffer-display-time (&optional buffer)
85 (defcustom clean-buffer-list-delay-general 3
87 The autokilling is done by `clean-buffer-list' when is it in `midnight-hook'.
92 :group 'midnight)
94 (defcustom clean-buffer-list-delay-special 3600
100 :group 'midnight)
103 "*List of regexps saying which buffers will be killed at midnight.
105 in the last `clean-buffer-list-delay-special' seconds, it is killed by
106 `clean-buffer-list' when is it in `midnight-hook'.
108 the number of seconds to use instead of `clean-buffer-list-delay-special'.
113 :group 'midnight)
118 "*List of strings saying which buffers will be killed at midnight.
120 `clean-buffer-list-delay-special' seconds, are killed by `clean-buffer-list'
121 when is it in `midnight-hook'.
123 the number of seconds to use instead of `clean-buffer-list-delay-special'.
128 :group 'midnight)
138 :group 'midnight)
141 "*List of regexp saying which buffers will never be killed at midnight.
148 :group 'midnight)
150 (defun midnight-find (el ls test &optional key)
156 (defun clean-buffer-list-delay (name)
157 "Return the delay, in seconds, before killing a buffer named NAME.
159 `clean-buffer-list-delay-general' and `clean-buffer-list-delay-special'.
162 clean-buffer-list-delay-special)
164 clean-buffer-list-delay-special)
165 (* clean-buffer-list-delay-general 24 60 60)))
170 The relevant variables are `clean-buffer-list-delay-general',
171 `clean-buffer-list-delay-special', `clean-buffer-list-kill-buffer-names',
181 delay cbld bn)
184 (setq bts (midnight-buffer-display-time buf) bn (buffer-name buf)
185 delay (if bts (- tm bts) 0) cbld (clean-buffer-list-delay bn))
186 (message "[%s] `%s' [%s %d]" ts bn (if bts (round delay)) cbld)
187 (unless (or (midnight-find bn clean-buffer-list-kill-never-regexps
189 (midnight-find bn clean-buffer-list-kill-never-buffer-names
193 (get-buffer-window buf 'visible) (< delay cbld))
197 ;;; midnight hook
199 (defvar midnight-period (* 24 60 60)
200 "The number of seconds in a day--the delta for `midnight-timer'.")
202 (defcustom midnight-hook '(clean-buffer-list)
203 "The hook run `midnight-delay' seconds after midnight every day.
206 :group 'midnight)
208 (defun midnight-next ()
209 "Return the number of seconds till the next midnight."
214 (defun midnight-delay-set (symb tm)
215 "Modify `midnight-timer' according to `midnight-delay'.
216 Sets the first argument SYMB (which must be symbol `midnight-delay')
218 (assert (eq symb 'midnight-delay) t
219 "Invalid argument to `midnight-delay-set': `%s'")
220 (set symb tm)
221 (when (timerp midnight-timer) (cancel-timer midnight-timer))
222 (setq midnight-timer
223 (run-at-time (if (numberp tm) (+ (midnight-next) tm) tm)
224 midnight-period 'run-hooks 'midnight-hook)))
226 (defcustom midnight-delay 3600
227 "*The number of seconds after the midnight when the `midnight-timer' is run.
228 You should set this variable before loading midnight.el, or
229 set it by calling `midnight-delay-set', or use `custom'.
233 :set 'midnight-delay-set
234 :group 'midnight)
236 (provide 'midnight)
239 ;;; midnight.el ends here