Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Emacs(Elisp): return t once in a day. 1日一回tを返すelispです。
;;; ------------------------------------------------------------
;;; 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
You can’t perform that action at this time.