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 &optional FIELD-WIDTH)

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". If FIELD-WIDTH is non-nil, then it's used as
FIELD's width. Otherwise, it's calculated.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun org-table--align-field (field width align &optional field-width)
  "Format FIELD according to column WIDTH and alignment ALIGN.
FIELD is a string.  WIDTH is a number.  ALIGN is either \"c\",
\"l\" or\"r\".  If FIELD-WIDTH is non-nil, then it's used as
FIELD's width.  Otherwise, it's calculated."
  (let* ((spaces (- width (or field-width (org-string-width field nil 'org-table))))
	 (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)))