Function: csv--column-widths

csv--column-widths is a natively compiled function defined in csv-mode.el.

Signature

(csv--column-widths BEG END)

Documentation

Return a list of two lists (COLUMN-WIDTHS FIELD-WIDTHS).

COLUMN-WIDTHS is a list of elements (WIDTH START END) indicating the widths of the columns after point (and the position of the widest field that determined the overall width). FIELD-WIDTHS contains the widths of each individual field after point.

Source Code

;; Defined in /nix/store/3gmjnyw9n226b7k7jamikx980vf8267p-emacs-packages-deps/share/emacs/site-lisp/elpa/csv-mode-1.27/csv-mode.el
(defun csv--column-widths (beg end)
  "Return a list of two lists (COLUMN-WIDTHS FIELD-WIDTHS).
COLUMN-WIDTHS is a list of elements (WIDTH START END)
indicating the widths of the columns after point (and the position of the
widest field that determined the overall width).
FIELD-WIDTHS contains the widths of each individual field after
point."
  (let ((column-widths '())
        (field-widths '()))
    (goto-char beg)
    ;; Construct list of column widths:
    (while (< (point) end)              ; for each record...
      (or (csv-not-looking-at-record)
          (let ((w column-widths)
                (col (current-column))
                (beg (point))
                field-width)
            (while (not (eolp))
              (csv-end-of-field)
              (setq field-width (- (current-column) col))
              (push field-width field-widths)
              (if w
                  (if (> field-width (caar w))
                      (setcar w (list field-width beg (point))))
                (setq w (list (list field-width beg (point)))
                      column-widths (nconc column-widths w)))
              (or (eolp) (forward-char)) ; Skip separator.
              (setq w (cdr w) col (current-column) beg (point)))))
      (forward-line))
    (list column-widths (nreverse field-widths))))