Function: which-key--pad-column

which-key--pad-column is a byte-compiled function defined in which-key.el.gz.

Signature

(which-key--pad-column COL-KEYS AVL-WIDTH)

Documentation

Pad cells of COL-KEYS to AVL-WIDTH.

Take a column of (key separator description) COL-KEYS, calculate the max width in the column and pad all cells out to that width.

Source Code

;; Defined in /usr/src/emacs/lisp/which-key.el.gz
(defun which-key--pad-column (col-keys avl-width)
  "Pad cells of COL-KEYS to AVL-WIDTH.
Take a column of (key separator description) COL-KEYS,
calculate the max width in the column and pad all cells out to
that width."
  (let* ((col-key-width  (+ which-key-add-column-padding
                            (which-key--max-len col-keys 0)))
         (col-sep-width  (which-key--max-len col-keys 1))
         (avl-width      (- avl-width col-key-width col-sep-width))
         (col-desc-width (min avl-width
                              (which-key--max-len
                               col-keys 2
                               which-key-min-column-description-width)))
         (col-width      (+ col-key-width col-sep-width col-desc-width))
         (col-format     (concat "%" (int-to-string col-key-width) "s%s%s")))
    (cons col-width
          (mapcar (pcase-lambda (`(,key ,sep ,desc ,_doc))
                    (concat
                     (format col-format key sep desc)
                     (make-string (max (- col-desc-width (string-width desc)) 0) ?\s)))
                  col-keys))))