Function: eca-table--align-at-point
eca-table--align-at-point is a natively compiled function defined in
eca-table.el.
Signature
(eca-table--align-at-point)
Documentation
Align markdown table at point.
Pads cells by source width when markdown-mode aligns the
separators itself, otherwise by display width, and preserves
separator alignment markers.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-table.el
(defun eca-table--align-at-point ()
"Align markdown table at point.
Pads cells by source width when `markdown-mode' aligns the
separators itself, otherwise by display width, and preserves
separator alignment markers."
(let* ((tbl-beg (markdown-table-begin))
(tbl-end (markdown-table-end))
(width-fn (if (eca-table--markdown-aligns-p)
#'eca-table--source-width
#'eca-table--display-width))
(indent (save-excursion
(goto-char tbl-beg)
(if (looking-at "[ \t]*") (match-string 0) "")))
(lines (split-string (buffer-substring-no-properties tbl-beg tbl-end)
"\n" t))
(parsed-rows '())
(separator-indices '())
(separator-alignments '())
(row-idx 0)
(max-cols 0)
(col-max-display '()))
;; Parse all rows and track separator rows
(dolist (line lines)
(if (eca-table--separator-row-p line)
(progn
(push row-idx separator-indices)
(push (eca-table--parse-separator-alignments line)
separator-alignments)
(push nil parsed-rows))
(let ((cells (eca-table--parse-row line)))
(push cells parsed-rows)
(setq max-cols (max max-cols (length cells)))))
(setq row-idx (1+ row-idx)))
(setq parsed-rows (nreverse parsed-rows))
(setq separator-indices (nreverse separator-indices))
(setq separator-alignments (nreverse separator-alignments))
;; Use first separator row for column alignments
(let ((col-aligns (car separator-alignments)))
;; Calculate max width for each column
(dotimes (col max-cols)
(let ((max-disp 1))
(dolist (row parsed-rows)
(when row
(let* ((cell (or (nth col row) ""))
(disp-w (funcall width-fn cell)))
(setq max-disp (max max-disp disp-w)))))
(push max-disp col-max-display)))
(setq col-max-display (nreverse col-max-display))
;; Rebuild the table
(delete-region tbl-beg tbl-end)
(goto-char tbl-beg)
(let ((row-idx 0)
(sep-idx 0))
(dolist (row parsed-rows)
(insert indent "|")
(if (member row-idx separator-indices)
;; Separator row: preserve alignment markers
(let ((aligns (nth sep-idx separator-alignments)))
(dotimes (col max-cols)
(let ((align (nth col aligns)))
(insert (eca-table--make-separator-cell
(nth col col-max-display) align)
"|")))
(setq sep-idx (1+ sep-idx)))
;; Content row: pad using column alignment
(dotimes (col max-cols)
(let* ((cell (or (nth col row) ""))
(disp-w (funcall width-fn cell))
(target-disp (nth col col-max-display))
(padding (- target-disp disp-w))
(align (nth col col-aligns)))
(eca-table--insert-cell cell padding align))))
(insert "\n")
(setq row-idx (1+ row-idx)))))))