Allow function as value for break time variable

This commit is contained in:
contrapunctus 2022-02-13 11:03:41 +05:30
parent a8f213bbd2
commit 267f17e57d
2 changed files with 39 additions and 4 deletions

View File

@ -37,10 +37,27 @@
;; [[file:chronometrist-third.org::*working-hours][working-hours:1]]
(defcustom chronometrist-third-working-hours nil
"Pair of ISO-8601 timestamps specifying user's working hours.
"User's working hours for today.
This can be nil, a pair of ISO-8601 timestamps, or a function
which takes no arguments and returns a pair of ISO-8601
timestamps.
Setting this currently has no effect."
:type '(choice (const :tag "No defined working hours" nil)
(cons :tag "Time range" string string)))
(cons :tag "Time range" string string)
function)
:group 'chronometrist-third)
;; working-hours:1 ends here
;; [[file:chronometrist-third.org::*working-hours][working-hours:1]]
(defun chronometrist-third-working-hours (default-hours)
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(cl-typecase default-hours
(cons default-hours)
(function (funcall default-hours))
(nil nil)))
;; working-hours:1 ends here
;; [[file:chronometrist-third.org::*divisor][divisor:1]]

View File

@ -50,10 +50,28 @@
** TODO working-hours :custom:variable:
#+BEGIN_SRC emacs-lisp
(defcustom chronometrist-third-working-hours nil
"Pair of ISO-8601 timestamps specifying user's working hours.
"User's working hours for today.
This can be nil, a pair of ISO-8601 timestamps, or a function
which takes no arguments and returns a pair of ISO-8601
timestamps.
Setting this currently has no effect."
:type '(choice (const :tag "No defined working hours" nil)
(cons :tag "Time range" string string)))
(cons :tag "Time range" string string)
function)
:group 'chronometrist-third)
#+END_SRC
** working-hours :procedure:
#+BEGIN_SRC emacs-lisp
(defun chronometrist-third-working-hours (default-hours)
"Return the user's working hours based on DEFAULT-HOURS.
For the possible values of DEFAULT-HOURS, see the variable
`chronometrist-third-working-hours' ."
(cl-typecase default-hours
(cons default-hours)
(function (funcall default-hours))
(nil nil)))
#+END_SRC
** divisor :custom:variable: