Last active
July 18, 2016 05:07
-
-
Save jidaikobo-shibata/33e072cea6aa96a19f58 to your computer and use it in GitHub Desktop.
Emacs(Elisp): return t once in a day. 1日一回tを返すelispです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; ------------------------------------------------------------ | |
;;; 1日1回のチェック | |
;; gist-description: Emacs(Elisp): return t once in a day. 1日一回tを返すelispです。 | |
;; gist-id: 33e072cea6aa96a19f58 | |
;; gist-name: is-once-in-a-day.el | |
;; gist-private: nil | |
(defun is-once-in-a-day () | |
"Is once in a day." | |
(interactive) | |
(let* ((target-file (concat dotfiles-dir ".is-once-in-a-day")) | |
(target-update-at (if (file-exists-p target-file) | |
(nth 5 (file-attributes target-file)) | |
(append-to-file "" nil target-file))) | |
(criteria-time (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time)))) | |
(ftime (if target-update-at | |
(float-time (time-subtract criteria-time target-update-at)) | |
nil))) | |
(cond ((and target-update-at ftime (> ftime 0)) | |
(delete-file target-file) | |
(append-to-file "." nil target-file) | |
t) | |
((and target-update-at ftime (< ftime 0)) | |
nil) | |
((not target-update-at) | |
(delete-file target-file) | |
(append-to-file "." nil target-file) | |
t)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment