]> code.delx.au - gnu-emacs/blobdiff - lisp/midnight.el
Merge from emacs-24; up to 2012-12-21T07:35:02Z!ueno@gnu.org
[gnu-emacs] / lisp / midnight.el
index 3c0923d7e587dc0d389cd787363bbeece37f21d9..f207d438e5b89d1b12357fceabded4406b5c3ff0 100644 (file)
@@ -1,6 +1,6 @@
 ;;; midnight.el --- run something every midnight, e.g., kill old buffers
 
-;; Copyright (C) 1998, 2001-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2013 Free Software Foundation, Inc.
 
 ;; Author: Sam Steingold <sds@gnu.org>
 ;; Maintainer: Sam Steingold <sds@gnu.org>
@@ -36,8 +36,7 @@
 
 ;;; Code:
 
-(eval-when-compile
- (require 'cl))
+(eval-when-compile (require 'cl-lib))
 
 (defgroup midnight nil
   "Run something every day at midnight."
@@ -138,9 +137,9 @@ two lists will NOT be killed if it also matches anything in this list."
 
 (defun midnight-find (el ls test &optional key)
   "A stopgap solution to the absence of `find' in ELisp."
-  (dolist (rr ls)
+  (cl-dolist (rr ls)
     (when (funcall test (if key (funcall key rr) rr) el)
-      (return rr))))
+      (cl-return rr))))
 
 (defun clean-buffer-list-delay (name)
   "Return the delay, in seconds, before killing a buffer named NAME.
@@ -196,8 +195,7 @@ The default value is `clean-buffer-list'."
 
 (defun midnight-next ()
   "Return the number of seconds till the next midnight."
-  (multiple-value-bind (sec min hrs)
-      (values-list (decode-time))
+  (pcase-let ((`(,sec ,min ,hrs) (decode-time)))
     (- (* 24 60 60) (* 60 60 hrs) (* 60 min) sec)))
 
 ;;;###autoload
@@ -205,8 +203,8 @@ The default value is `clean-buffer-list'."
   "Modify `midnight-timer' according to `midnight-delay'.
 Sets the first argument SYMB (which must be symbol `midnight-delay')
 to its second argument TM."
-  (assert (eq symb 'midnight-delay) t
-          "Invalid argument to `midnight-delay-set': `%s'")
+  (cl-assert (eq symb 'midnight-delay) t
+             "Invalid argument to `midnight-delay-set': `%s'")
   (set symb tm)
   (when (timerp midnight-timer) (cancel-timer midnight-timer))
   (setq midnight-timer