Correct tag generation behavior/max eval depth error

This commit is contained in:
contrapunctus 2021-01-03 08:51:07 +05:30
parent 440ff4ee59
commit c7131e69e6
4 changed files with 23 additions and 11 deletions

View File

@ -229,7 +229,7 @@ ppp.el doesn't align plist values along the same column. It's also GPL, and I'm
2. [ ] =chronometrist-statistics-count-active-days=
4. [ ] Write integration tests using ecukes.
1. Some feature definitions already exist in features/, write step definitions for them.
5. [ ] Remove duplication - the three =chronometrist-*-history-populate= functions seem to have a common pattern of iterating over each hash value (a list of plists) in =chronometrist-events=, and over each element of that list.
5. [X] Remove duplication - the three =chronometrist-*-history-populate= functions
6. [ ] Remove duplication - extracting user key-values from a plist seems to be a common operation.
7. [X] Extensions - redesign =chronometrist= such that it does not need to check for the availability of extensions (such as =chronometrist-goal=)
* Could make two "transformer lists" - =chronometrist-list-format-transformers= and =chronometrist-entry-transformers=.

View File

@ -118,7 +118,7 @@ reversed and will have duplicate elements removed."
Return the new value inserted into HISTORY-TABLE.
HISTORY-TABLE must be a hash table. (see `chronometrist-tags-history')"
(chronometrist-map-file file
(chronometrist-mapc-file file
(lambda (plist)
(let ((new-tag-list (plist-get plist :tags))
(old-tag-lists (gethash task history-table)))
@ -126,7 +126,7 @@ HISTORY-TABLE must be a hash table. (see `chronometrist-tags-history')"
new-tag-list
(puthash task
(if old-tag-lists
(cons old-tag-lists new-tag-list)
(append old-tag-lists (list new-tag-list))
(list new-tag-list))
history-table)))))
(chronometrist-history-prep task history-table))
@ -136,7 +136,7 @@ HISTORY-TABLE must be a hash table. (see `chronometrist-tags-history')"
Return the new value inserted into HISTORY-TABLE.
HISTORY-TABLE must be a hash table (see `chronometrist-key-history')."
(chronometrist-map-file file
(chronometrist-mapc-file file
(lambda (plist)
(catch 'quit
(let* ((name (plist-get plist :name))
@ -157,7 +157,7 @@ HISTORY-TABLE must be a hash table (see `chronometrist-key-history')."
HISTORY-TABLE must be a hash table. (see `chronometrist-value-history')"
;; Note - while keys are Lisp keywords, values may be any Lisp
;; object, including lists
(chronometrist-map-file file
(chronometrist-mapc-file file
(lambda (plist)
;; We call them user-key-values because we filter out Chronometrist's
;; reserved key-values

View File

@ -20,8 +20,9 @@ STREAM (which is the value of `current-buffer')."
`(with-current-buffer (find-file-noselect ,file)
(save-excursion ,@body)))
(defun chronometrist-map-file (file fn)
(defun chronometrist-mapcar-file (file fn)
"Run FN for each s-expression in FILE, from last to first.
Return the values of FN as a list.
FN must be a function accepting one argument."
(declare (indent defun))
(chronometrist-sexp-in-file file
@ -29,13 +30,24 @@ FN must be a function accepting one argument."
(cl-loop with var
while (and (not (bobp))
(backward-list)
(->> (current-buffer)
(read )
(ignore-errors )
(setq var ))
(setq var (ignore-errors (read (current-buffer))))
(backward-list))
collect (funcall fn var))))
(defun chronometrist-mapc-file (file fn)
"Run FN for each s-expression in FILE, from last to first.
Return nil.
FN must be a function accepting one argument."
(declare (indent defun))
(chronometrist-sexp-in-file file
(goto-char (point-max))
(cl-loop with var
while (and (not (bobp))
(backward-list)
(setq var (ignore-errors (read (current-buffer))))
(backward-list))
do (funcall fn var))))
;;;; Queries
(defun chronometrist-sexp-open-log ()
"Open `chronometrist-file' in another window."

View File

@ -352,7 +352,7 @@ Argument _FS-EVENT is ignored."
((null file-change-type) nil)
(t (chronometrist-events-populate))))
(chronometrist-events-populate)
(--> (chronometrist-map-file chronometrist-file
(--> (chronometrist-mapcar-file chronometrist-file
(lambda (plist)
(plist-get plist :name)))
(cl-remove-duplicates it :test #'equal)