Function: org-table--align-field

org-table--align-field is an autoloaded and byte-compiled function defined in org-table.el.gz.

Signature

(org-table--align-field FIELD WIDTH ALIGN)

Documentation

Format FIELD according to column WIDTH and alignment ALIGN.

FIELD is a string. WIDTH is a number. ALIGN is either "c",
"l" or"r".

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table--align-field (field width align)
  "Format FIELD according to column WIDTH and alignment ALIGN.
FIELD is a string.  WIDTH is a number.  ALIGN is either \"c\",
\"l\" or\"r\"."
  (let* ((spaces (- width (org-string-width field)))
	 (prefix (pcase align
		   ("l" "")
		   ("r" (make-string spaces ?\s))
		   ("c" (make-string (/ spaces 2) ?\s))))
	 (suffix (make-string (- spaces (length prefix)) ?\s)))
    (concat org-table--separator-space-pre
	    prefix
	    field
	    suffix
	    org-table--separator-space-post)))