Ihor Radchenko <[email protected]> writes: >> +(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))) >> + ;; Make sure that the first element of the first table >> + ;; was a file-name. >> + (file (and (stringp file) file))
I think this check is probably pointless. >> + (total-time 0) entries) >> + (while-let ((table (pop tables))) >> + (incf total-time (nth 1 table)) >> + (when-let* ((new-entries (car (nthcdr 2 table)))) >> + >> + (setq entries (append new-entries entries)))) >> + (list file total-time >> + entries ))) > > Any particular reason why you don't use the code I suggested? Mostly because I didn't see your reply until I posted the updated patch. But after reading the suggested code now it's also that it didn't seem obvious to me that it can be shortened that much essentially you do the same thin as I'm already doing but without the check if a table contains any data. Also I think it's easier to read wrap the table merging and the expanding of files with their archives into separate functions. The only thing that bothers me that I don't know how to call the get-table-data-with-archives function without the use of a lambda when passing both the parameters and the file. What's the difference between using nthcdr 2 and cddr? Instead of car and then nthcdr or cddr I could probably also do cddar.
