Fix recursive load errors and some byte compiler warnings
chronometrist-open-log, chronometrist-common-create-file, and chronometrist-current-task have been moved from chronometrist-common.el to chronometrist.el Comment out unused function chronometrist-file-clean, removing chronometrist-events.el's dependency on chronometrist-plist-pp.el. In the reference, use "Keymap" for keymap variables.
This commit is contained in:
parent
97dc94e70c
commit
b62301e870
|
@ -19,7 +19,11 @@
|
|||
(require 'chronometrist-custom)
|
||||
(require 'chronometrist-report-custom)
|
||||
(require 'chronometrist-time)
|
||||
(require 'chronometrist-sexp)
|
||||
;; (require 'chronometrist-sexp)
|
||||
|
||||
;; (declare-function chronometrist-sexp-open-log "chronometrist-sexp")
|
||||
;; (declare-function chronometrist-sexp-create-file "chronometrist-sexp")
|
||||
;; (declare-function chronometrist-sexp-current-task "chronometrist-sexp")
|
||||
|
||||
;; ## VARIABLES ##
|
||||
;;; Code:
|
||||
|
@ -111,18 +115,6 @@ supplied, 3 spaces are used."
|
|||
(format "%02d" s))))
|
||||
(concat h m s)))))
|
||||
|
||||
(defun chronometrist-open-log (&optional _button)
|
||||
"Open `chronometrist-file' in another window.
|
||||
|
||||
Argument _BUTTON is for the purpose of using this command as a
|
||||
button action."
|
||||
(interactive)
|
||||
(chronometrist-sexp-open-log))
|
||||
|
||||
(defun chronometrist-common-create-file ()
|
||||
"Create `chronometrist-file' if it doesn't already exist."
|
||||
(chronometrist-sexp-create-file))
|
||||
|
||||
(defun chronometrist-common-file-empty-p (file)
|
||||
"Return t if FILE is empty."
|
||||
(let ((size (elt (file-attributes file) 7)))
|
||||
|
@ -206,10 +198,6 @@ DATE-STRING must be in the form \"YYYY-MM-DD\"."
|
|||
(time-subtract date-unix `(0 ,(* gap 86400)))
|
||||
date-unix)))
|
||||
|
||||
(defun chronometrist-current-task ()
|
||||
"Return the name of the currently clocked-in task, or nil if not clocked in."
|
||||
(chronometrist-sexp-current-task))
|
||||
|
||||
;; Local Variables:
|
||||
;; nameless-current-name: "chronometrist-common"
|
||||
;; End:
|
||||
|
|
|
@ -11,9 +11,14 @@
|
|||
;;
|
||||
;; For more information, please refer to <https://unlicense.org>
|
||||
|
||||
(require 'chronometrist-plist-pp)
|
||||
;; (require 'chronometrist-plist-pp)
|
||||
(require 'chronometrist-common)
|
||||
|
||||
;; external -
|
||||
;; chronometrist-day-start-time (-custom)
|
||||
;; chronometrist-midnight-spanning-p (-time)
|
||||
;; chronometrist-date-less-p (-time)
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
|
@ -44,44 +49,44 @@ Return value is a time value (see `current-time')."
|
|||
(append it timestamp-date-list)
|
||||
(apply #'encode-time it))))
|
||||
|
||||
(defun chronometrist-file-clean ()
|
||||
"Clean `chronometrist-file' so that events can be processed accurately.
|
||||
NOTE - currently unused.
|
||||
;; (defun chronometrist-file-clean ()
|
||||
;; "Clean `chronometrist-file' so that events can be processed accurately.
|
||||
;; NOTE - currently unused.
|
||||
|
||||
This function splits midnight-spanning intervals into two. It
|
||||
must be called before running `chronometrist-populate'.
|
||||
;; This function splits midnight-spanning intervals into two. It
|
||||
;; must be called before running `chronometrist-populate'.
|
||||
|
||||
It returns t if the table was modified, else nil."
|
||||
(let ((buffer (find-file-noselect chronometrist-file))
|
||||
modified
|
||||
expr)
|
||||
(with-current-buffer buffer
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (setq expr (ignore-errors (read (current-buffer))))
|
||||
(when (plist-get expr :stop)
|
||||
(let ((split-time (chronometrist-midnight-spanning-p (plist-get expr :start)
|
||||
(plist-get expr :stop))))
|
||||
(when split-time
|
||||
(let ((first-start (plist-get (cl-first split-time) :start))
|
||||
(first-stop (plist-get (cl-first split-time) :stop))
|
||||
(second-start (plist-get (cl-second split-time) :start))
|
||||
(second-stop (plist-get (cl-second split-time) :stop)))
|
||||
(backward-list 1)
|
||||
(chronometrist-sexp-delete-list)
|
||||
(-> expr
|
||||
(plist-put :start first-start)
|
||||
(plist-put :stop first-stop)
|
||||
(chronometrist-plist-pp buffer))
|
||||
(when (looking-at-p "\n\n")
|
||||
(delete-char 2))
|
||||
(-> expr
|
||||
(plist-put :start second-start)
|
||||
(plist-put :stop second-stop)
|
||||
(chronometrist-plist-pp buffer))
|
||||
(setq modified t))))))
|
||||
(save-buffer)))
|
||||
modified))
|
||||
;; It returns t if the table was modified, else nil."
|
||||
;; (let ((buffer (find-file-noselect chronometrist-file))
|
||||
;; modified
|
||||
;; expr)
|
||||
;; (with-current-buffer buffer
|
||||
;; (save-excursion
|
||||
;; (goto-char (point-min))
|
||||
;; (while (setq expr (ignore-errors (read (current-buffer))))
|
||||
;; (when (plist-get expr :stop)
|
||||
;; (let ((split-time (chronometrist-midnight-spanning-p (plist-get expr :start)
|
||||
;; (plist-get expr :stop))))
|
||||
;; (when split-time
|
||||
;; (let ((first-start (plist-get (cl-first split-time) :start))
|
||||
;; (first-stop (plist-get (cl-first split-time) :stop))
|
||||
;; (second-start (plist-get (cl-second split-time) :start))
|
||||
;; (second-stop (plist-get (cl-second split-time) :stop)))
|
||||
;; (backward-list 1)
|
||||
;; (chronometrist-sexp-delete-list)
|
||||
;; (-> expr
|
||||
;; (plist-put :start first-start)
|
||||
;; (plist-put :stop first-stop)
|
||||
;; (chronometrist-plist-pp buffer))
|
||||
;; (when (looking-at-p "\n\n")
|
||||
;; (delete-char 2))
|
||||
;; (-> expr
|
||||
;; (plist-put :start second-start)
|
||||
;; (plist-put :stop second-stop)
|
||||
;; (chronometrist-plist-pp buffer))
|
||||
;; (setq modified t))))))
|
||||
;; (save-buffer)))
|
||||
;; modified))
|
||||
|
||||
(defun chronometrist-events-maybe-split (event)
|
||||
"Split EVENT if it spans midnight.
|
||||
|
|
|
@ -3,10 +3,16 @@
|
|||
;;; Commentary:
|
||||
;;
|
||||
|
||||
(require 'chronometrist)
|
||||
(require 'chronometrist-custom)
|
||||
(require 'chronometrist-events)
|
||||
(require 'chronometrist-plist-pp)
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; chronometrist-file (-custom)
|
||||
;; chronometrist-events, chronometrist-events-maybe-split (-events)
|
||||
;; chronometrist-plist-pp (-plist-pp)
|
||||
|
||||
;;;; Queries
|
||||
(defun chronometrist-sexp-open-log ()
|
||||
"Open `chronometrist-file' in another window."
|
||||
|
@ -74,8 +80,6 @@ were none."
|
|||
|
||||
(cl-defun chronometrist-sexp-new (plist &optional (buffer (find-file-noselect chronometrist-file)))
|
||||
"Add new PLIST at the end of `chronometrist-file'.
|
||||
Afterwards, save it and refresh the Chronometrist buffer.
|
||||
|
||||
BUFFER is the buffer to operate in - default is one accessing `chronometrist-file'."
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-max))
|
||||
|
@ -84,8 +88,7 @@ BUFFER is the buffer to operate in - default is one accessing `chronometrist-fil
|
|||
(unless (bobp) (insert "\n"))
|
||||
(unless (bolp) (insert "\n"))
|
||||
(chronometrist-plist-pp plist buffer)
|
||||
(save-buffer))
|
||||
(chronometrist-refresh))
|
||||
(save-buffer)))
|
||||
|
||||
(defun chronometrist-sexp-delete-list (&optional arg)
|
||||
"Delete ARG lists after point."
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
(require 'chronometrist-custom)
|
||||
(require 'chronometrist-statistics-custom)
|
||||
(require 'chronometrist-report-custom)
|
||||
(require 'chronometrist-common)
|
||||
(require 'chronometrist)
|
||||
|
||||
(declare-function chronometrist-refresh "chronometrist.el")
|
||||
(declare-function chronometrist-report-refresh "chronometrist-report.el")
|
||||
|
|
|
@ -12,13 +12,17 @@
|
|||
(require 'subr-x)
|
||||
|
||||
(require 'chronometrist-common)
|
||||
(require 'chronometrist-timer)
|
||||
(require 'chronometrist-custom)
|
||||
(require 'chronometrist-report)
|
||||
(require 'chronometrist-statistics)
|
||||
(require 'chronometrist-key-values)
|
||||
(require 'chronometrist-queries)
|
||||
(require 'chronometrist-migrate)
|
||||
(require 'chronometrist-sexp)
|
||||
|
||||
(defvar chronometrist-goals-list)
|
||||
(declare-function 'chronometrist-get-goal "chronometrist-goals")
|
||||
(autoload 'chronometrist-maybe-start-timer "chronometrist-timer" nil t)
|
||||
(autoload 'chronometrist-report "chronometrist-report" nil t)
|
||||
(autoload 'chronometrist-statistics "chronometrist-statistics" nil t)
|
||||
|
||||
;; This is free and unencumbered software released into the public domain.
|
||||
;;
|
||||
|
@ -67,6 +71,22 @@
|
|||
(defvar chronometrist-mode-map)
|
||||
|
||||
;; ## FUNCTIONS ##
|
||||
(defun chronometrist-open-log (&optional _button)
|
||||
"Open `chronometrist-file' in another window.
|
||||
|
||||
Argument _BUTTON is for the purpose of using this command as a
|
||||
button action."
|
||||
(interactive)
|
||||
(chronometrist-sexp-open-log))
|
||||
|
||||
(defun chronometrist-common-create-file ()
|
||||
"Create `chronometrist-file' if it doesn't already exist."
|
||||
(chronometrist-sexp-create-file))
|
||||
|
||||
(defun chronometrist-current-task ()
|
||||
"Return the name of the currently clocked-in task, or nil if not clocked in."
|
||||
(chronometrist-sexp-current-task))
|
||||
|
||||
(defun chronometrist-task-active? (task)
|
||||
"Return t if TASK is currently clocked in, else nil."
|
||||
(equal (chronometrist-current-task) task))
|
||||
|
@ -99,13 +119,15 @@ See custom variable `chronometrist-activity-indicator'."
|
|||
(indicator (if (chronometrist-task-active? task)
|
||||
(chronometrist-activity-indicator)
|
||||
""))
|
||||
(target (chronometrist-get-goal task))
|
||||
(target (when (featurep 'chronometrist-goals)
|
||||
(chronometrist-get-goal task)))
|
||||
(target-str (if target
|
||||
(format "% 4d" target)
|
||||
"")))
|
||||
(list task
|
||||
(vconcat (vector index task-button task-time indicator)
|
||||
(when (bound-and-true-p chronometrist-goals-list)
|
||||
(when (and target
|
||||
(bound-and-true-p chronometrist-goals-list))
|
||||
(vector target-str))))))))
|
||||
|
||||
(defun chronometrist-task-at-point ()
|
||||
|
@ -241,7 +263,8 @@ PREFIX is ignored."
|
|||
(interactive "P")
|
||||
(let ((plist `(:name ,task
|
||||
:start ,(format-time-string "%FT%T%z"))))
|
||||
(chronometrist-sexp-new plist)))
|
||||
(chronometrist-sexp-new plist)
|
||||
(chronometrist-refresh)))
|
||||
|
||||
(defun chronometrist-out (&optional _prefix)
|
||||
"Record current moment as stop time to last s-exp in `chronometrist-file'.
|
||||
|
|
|
@ -73,17 +73,14 @@
|
|||
* Buffer | String -> Boolean
|
||||
8. Function - chronometrist-format-time (duration &optional blank)
|
||||
* vector-duration | list-duration -> "h:m:s"
|
||||
9. Command - chronometrist-open-log (&optional button)
|
||||
10. Function - chronometrist-common-create-file ()
|
||||
11. Function - chronometrist-common-file-empty-p (file)
|
||||
12. Function - chronometrist-common-clear-buffer (buffer)
|
||||
13. Function - chronometrist-format-keybinds (command map &optional firstonly)
|
||||
14. Function - chronometrist-events->time-list (events)
|
||||
9. Function - chronometrist-common-file-empty-p (file)
|
||||
10. Function - chronometrist-common-clear-buffer (buffer)
|
||||
11. Function - chronometrist-format-keybinds (command map &optional firstonly)
|
||||
12. Function - chronometrist-events->time-list (events)
|
||||
* (event ...) -> ((encode-time encode-time) ...)
|
||||
15. Function - chronometrist-time-list->sum-of-intervals (time-value-lists)
|
||||
13. Function - chronometrist-time-list->sum-of-intervals (time-value-lists)
|
||||
* ((encode-time encode-time) ...) -> encode-time
|
||||
16. Function - chronometrist-previous-week-start (date-string)
|
||||
17. Function - chronometrist-current-task ()
|
||||
14. Function - chronometrist-previous-week-start (date-string)
|
||||
*** chronometrist-custom.el
|
||||
1. Custom variable - chronometrist-file
|
||||
2. Custom variable - chronometrist-buffer-name
|
||||
|
@ -102,40 +99,44 @@
|
|||
*** chronometrist.el
|
||||
1. Internal Variable - chronometrist--task-history
|
||||
2. Internal Variable - chronometrist--point
|
||||
3. Variable - chronometrist-mode-map
|
||||
4. Function - chronometrist-task-active? (task)
|
||||
3. Keymap - chronometrist-mode-map
|
||||
4. Command - chronometrist-open-log (&optional button)
|
||||
5. Function - chronometrist-common-create-file ()
|
||||
6. Function - chronometrist-current-task ()
|
||||
7. Function - chronometrist-task-active? (task)
|
||||
* String -> Boolean
|
||||
5. Function - chronometrist-activity-indicator ()
|
||||
6. Function - chronometrist-entries ()
|
||||
7. Function - chronometrist-task-at-point ()
|
||||
8. Function - chronometrist-goto-last-task ()
|
||||
9. Function - chronometrist-print-keybind (command &optional description firstonly)
|
||||
10. Function - chronometrist-print-non-tabular ()
|
||||
11. Function - chronometrist-goto-nth-task (n)
|
||||
12. Function - chronometrist-refresh (&optional ignore-auto noconfirm)
|
||||
13. Function - chronometrist-refresh-file (fs-event)
|
||||
14. Command - chronometrist-query-stop ()
|
||||
15. Command - chronometrist-in (task &optional prefix)
|
||||
16. Command - chronometrist-out (&optional prefix)
|
||||
17. Variable - chronometrist-before-in-functions
|
||||
18. Variable - chronometrist-after-in-functions
|
||||
19. Variable - chronometrist-before-out-functions
|
||||
20. Variable - chronometrist-after-out-functions
|
||||
21. Function - chronometrist-run-functions-and-clock-in (task)
|
||||
22. Function - chronometrist-run-functions-and-clock-out (task)
|
||||
23. Variable - chronometrist-mode-map
|
||||
24. Major Mode - chronometrist-mode
|
||||
25. Function - chronometrist-toggle-task-button (button)
|
||||
26. Function - chronometrist-add-new-task-button (button)
|
||||
27. Command - chronometrist-toggle-task (&optional prefix inhibit-hooks)
|
||||
28. Command - chronometrist-toggle-task-no-hooks (&optional prefix)
|
||||
29. Command - chronometrist-add-new-task ()
|
||||
30. Command - chronometrist (&optional arg)
|
||||
8. Function - chronometrist-activity-indicator ()
|
||||
9. Function - chronometrist-entries ()
|
||||
10. Function - chronometrist-task-at-point ()
|
||||
11. Function - chronometrist-goto-last-task ()
|
||||
12. Function - chronometrist-print-keybind (command &optional description firstonly)
|
||||
13. Function - chronometrist-print-non-tabular ()
|
||||
14. Function - chronometrist-goto-nth-task (n)
|
||||
15. Function - chronometrist-refresh (&optional ignore-auto noconfirm)
|
||||
16. Function - chronometrist-refresh-file (fs-event)
|
||||
17. Command - chronometrist-query-stop ()
|
||||
18. Command - chronometrist-in (task &optional prefix)
|
||||
19. Command - chronometrist-out (&optional prefix)
|
||||
20. Variable - chronometrist-before-in-functions
|
||||
21. Variable - chronometrist-after-in-functions
|
||||
22. Variable - chronometrist-before-out-functions
|
||||
23. Variable - chronometrist-after-out-functions
|
||||
24. Function - chronometrist-run-functions-and-clock-in (task)
|
||||
25. Function - chronometrist-run-functions-and-clock-out (task)
|
||||
26. Keymap - chronometrist-mode-map
|
||||
27. Major Mode - chronometrist-mode
|
||||
28. Function - chronometrist-toggle-task-button (button)
|
||||
29. Function - chronometrist-add-new-task-button (button)
|
||||
30. Command - chronometrist-toggle-task (&optional prefix inhibit-hooks)
|
||||
31. Command - chronometrist-toggle-task-no-hooks (&optional prefix)
|
||||
32. Command - chronometrist-add-new-task ()
|
||||
33. Command - chronometrist (&optional arg)
|
||||
*** chronometrist-events.el
|
||||
1. Variable - chronometrist-events
|
||||
2. Function - chronometrist-list-midnight-spanning-events ()
|
||||
3. Function - chronometrist-day-start (timestamp)
|
||||
4. Function - chronometrist-file-clean ()
|
||||
* commented out, unused
|
||||
5. Function - chronometrist-events-maybe-split (event)
|
||||
6. Function - chronometrist-events-populate ()
|
||||
7. Function - chronometrist-tasks-from-table ()
|
||||
|
@ -180,7 +181,7 @@
|
|||
10. Function - chronometrist-report-print-non-tabular ()
|
||||
11. Function - chronometrist-report-refresh (&optional ignore-auto noconfirm)
|
||||
12. Function - chronometrist-report-refresh-file (fs-event)
|
||||
13. Variable - chronometrist-report-mode-map
|
||||
13. Keymap - chronometrist-report-mode-map
|
||||
14. Major Mode - chronometrist-report-mode
|
||||
15. Function - chronometrist-report (&optional keep-date)
|
||||
16. Function - chronometrist-report-previous-week (arg)
|
||||
|
@ -204,7 +205,7 @@
|
|||
16. Function - chronometrist-ht-history-prep (table)
|
||||
17. Function - chronometrist-key-history-populate ()
|
||||
18. Function - chronometrist-value-history-populate ()
|
||||
19. Variable - chronometrist-kv-read-mode-map
|
||||
19. Keymap - chronometrist-kv-read-mode-map
|
||||
20. Major Mode - chronometrist-kv-read-mode
|
||||
21. Function - chronometrist-kv-completion-quit-key ()
|
||||
22. Function - chronometrist-string-has-whitespace-p (string)
|
||||
|
@ -219,7 +220,7 @@
|
|||
*** chronometrist-statistics.el
|
||||
1. Internal Variable - chronometrist-statistics--ui-state
|
||||
2. Internal Variable - chronometrist-statistics--point
|
||||
3. Variable - chronometrist-statistics-mode-map
|
||||
3. Keymap - chronometrist-statistics-mode-map
|
||||
4. Function - chronometrist-statistics-count-average-time-spent (task &optional table)
|
||||
* string &optional hash-table -> seconds
|
||||
5. Function - chronometrist-statistics-entries-internal (table)
|
||||
|
|
Reference in New Issue