Skip to content

Instantly share code, notes, and snippets.

@jidaikobo-shibata
Last active July 18, 2016 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jidaikobo-shibata/33e072cea6aa96a19f58 to your computer and use it in GitHub Desktop.
Save jidaikobo-shibata/33e072cea6aa96a19f58 to your computer and use it in GitHub Desktop.
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