Stefan Monnier writes: > Sounds good. I rarely use large CSV files, but I know the operation is slow. > > I'm OK with the patch, tho please see my comment below. Thanks for reviewing it. > 40s is still slow, but a factor of 2 is good, thanks. Yes (though 40s is the time for all three benchmark runs, so one alignment is 40s/3). > If you're interested in this line, I think there are two avenues to > improve the behavior further: > - align lazily via jit-lock (this way the time is determined by the > amount of text displayed rather than the total file size). Wouldn't that still depend on knowing the column widths? I find that the column width computation is taking about 80% of the time when calling 'csv-align-fields' (after the patch). > - make align-fields' into a mode, where fields are kept aligned even while > the buffer is modified. That sounds nice. >> (defun csv--column-widths () >> - (let ((widths '())) >> + (let ((column-widths '()) >> + (field-widths '())) > > I think the return value is now sufficiently complex that the function > deserves a docstring describing it. Agreed, I'll add one before I install the patch. I've also attached a new suggestion for speeding up the column width computation itself by eliminating another 'current-column'-call. I'm not too sure about its correctness yet, but it seems to work in a few tests I've done, and it sped up 'csv--column-widths' by a factor of 1.3–1.4.