summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el34
1 files changed, 34 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index b13c9b6..0f78c79 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -42,5 +42,39 @@ the filesystem, unless INHIBIT-MKDIR is non-nil."
42 (make-directory (file-name-directory file-name) :parents)) 42 (make-directory (file-name-directory file-name) :parents))
43 file-name)))) 43 file-name))))
44 44
45
46(defun +suppress-messages (oldfn &rest args) ; from pkal
47 "Advice wrapper for suppressing `message'.
48OLDFN is the wrapped function, that is passed the arguments
49ARGS."
50 (let ((msg (current-message)))
51 (prog1
52 (let ((inhibit-message t))
53 (apply oldfn args))
54 (when msg
55 (message "%s" msg)))))
56
57
58(defun +sunrise-sunset (sunrise-command sunset-command)
59 "Run SUNRISE-COMMAND at sunrise, and SUNSET-COMMAND at sunset."
60 (let* ((times-regex (rx (* nonl)
61 (: (any ?s ?S) "unrise") " "
62 (group (repeat 1 2 digit) ":"
63 (repeat 1 2 digit)
64 (: (any ?a ?A ?p ?P) (any ?m ?M)))
65 (* nonl)
66 (: (any ?s ?S) "unset") " "
67 (group (repeat 1 2 digit) ":"
68 (repeat 1 2 digit)
69 (: (any ?a ?A ?p ?P) (any ?m ?M)))
70 (* nonl)))
71 (ss (+suppress-messages #'sunrise-sunset))
72 (_m (string-match times-regex ss))
73 (sunrise-time (match-string 1 ss))
74 (sunset-time (match-string 2 ss)))
75 (run-at-time sunrise-time (* 60 60 24) sunrise-command)
76 (run-at-time sunset-time (* 60 60 24) sunset-command)
77 (run-at-time "12:00am" (* 60 60 24) sunset-command))))
78
45(provide 'acdw) 79(provide 'acdw)
46;;; acdw.el ends here 80;;; acdw.el ends here