Ihor Radchenko <[email protected]> writes:

> Björn Kettunen <[email protected]> writes:
>
>> -      (org-agenda-prepare-buffers (if (consp files) files (list files)))
>> +      (unless (consp files)
>> +        (org-agenda-prepare-buffers (list files)))
>
> Could you please explain this change?

>> +(defun org-clock--get-table-data1 (file params)
>> +  "Get clocktable-data for FILE with PARAMS."
>> +  (org-agenda-prepare-buffers (list file))
>
> Did you mean that (consp files) imply that the above will happen?

Yes exactly. So that the call would be done after the archive file per
buffer is known.

> Also, (org-agenda-prepare-buffers (list file)) is sub-optimal.
> org-agenda-prepare-buffers updates the menus, which is slow to do when
> adding files one by one. So, it is better to call
> org-agenda-prepare-buffers are few times as possible, on a list of files.

How would you do that? For files without archives calling the function
could be done right before getting the table data.

For the file-with-archives case too but then  the call would be for the
file and it's archives, that would not be perfect but better.

>> +(defun org-clock-merge-table-data (tables &optional file)
>> +  "Merge table data for TABLES for FILE.
>> +When FILE isn't given assume FILE as the file of the first table.
>> +TABLES is list of table data returned in the format returned by
>> +`org-clock-get-table-data'.
>> +Returns the same tables but with each table merged."
>> +  (let* ((file (or file (caaar tables)))
>> +         (total-time 0) entries)
>> +    (while-let ((table (pop tables)))
>> +      (incf total-time (nth 1 table))
>> +      (when-let* ((new-entries (cddar table)))
>> +        (setq entries (append new-entries entries))))
>
> when-let here is redundant.
>
> (append '(1) nil) ; => '(1)
> (append '(1) nil '(2)) ; => '(1 2)

Reply via email to