Function: describe-map--align-section

describe-map--align-section is a byte-compiled function defined in help.el.gz.

Signature

(describe-map--align-section COLUMNS)

Source Code

;; Defined in /usr/src/emacs/lisp/help.el.gz
(defun describe-map--align-section (columns)
  (save-excursion
    (let ((max-key (apply #'max (mapcar #'car columns))))
      (cond
       ;; It's fine to use the minimum, so just do it, but quantize to
       ;; two different widths, because having each block align slightly
       ;; differently looks untidy.
       ((< max-key 16)
        (describe-map--fill-columns columns 16))
       ((< max-key 24)
        (describe-map--fill-columns columns 24))
       ((< max-key 32)
        (describe-map--fill-columns columns 32))
       ;; We have some really wide ones in this block.
       (t
        (let ((window-width (window-width))
              (max-def (apply #'max (mapcar
                                     (lambda (elem)
                                       (- (nth 3 elem) (nth 2 elem)))
                                     columns))))
          (if (< (+ max-def (max 16 max-key)) window-width)
              ;; Can we do the block without continuation lines?  Then do that.
              (describe-map--fill-columns columns (1+ (max 16 max-key)))
            ;; No, do continuation lines for some definitions.
            (dolist (elem columns)
              (goto-char (caddr elem))
              (if (< (+ (car elem) (- (nth 3 elem) (nth 2 elem))) window-width)
                  ;; Indent.
                  (insert-char ?\s (- (1+ max-key) (car elem)))
                ;; Continuation.
                (insert "\n")
                (insert-char ?\t 2))))))))))