Function: texinfo-multitable-widths

texinfo-multitable-widths is a byte-compiled function defined in texinfmt.el.gz.

Signature

(texinfo-multitable-widths)

Documentation

Return list of widths of each column in a multi-column table.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/texinfmt.el.gz
(defun texinfo-multitable-widths ()
  "Return list of widths of each column in a multi-column table."
  (let (texinfo-multitable-width-list)
    ;; Fractions format:
    ;;  @multitable @columnfractions .25 .3 .45
    ;;
    ;; Template format:
    ;;  @multitable {Column 1 template} {Column 2} {Column 3 example}
    ;; Place point before first argument
    (skip-chars-forward " \t")
    (cond
     ;; Check for common misspelling
     ((looking-at "@columnfraction ")
      (error "In @multitable, @columnfractions misspelled"))
     ;; Case 1: @columnfractions .25 .3 .45
     ((looking-at "@columnfractions")
      (forward-word-strictly 1)
      (while (not (eolp))
        (push (truncate
               (1-
                (* fill-column (read (get-buffer (current-buffer))))))
              texinfo-multitable-width-list)))
     ;;
     ;; Case 2: {Column 1 template} {Column 2} {Column 3 example}
     ((looking-at "{")
      ;; (let ((start-of-templates (point)))
      (while (not (eolp))
        (skip-chars-forward " \t")
        (let* ((start-of-template (1+ (point)))
               (end-of-template
                ;; forward-sexp works with braces in Texinfo mode
                (progn (forward-sexp 1) (1- (point)))))
          (push (- end-of-template start-of-template)
                texinfo-multitable-width-list)
          ;; Remove carriage return from within a template, if any.
          ;; This helps those who want to use more than
          ;; one line's worth of words in @multitable line.
          (narrow-to-region start-of-template end-of-template)
          (goto-char (point-min))
          (while (search-forward "
" nil t)
            (delete-char -1))
          (goto-char (point-max))
          (widen)
          (forward-char 1)))) ;; )
     ;;
     ;; Case 3: Trouble
     (t
      (error
       "You probably need to specify column widths for @multitable correctly")))
    ;; Check whether columns fit on page.
    (let ((desired-columns
           (+
            ;; between column spaces
            (length texinfo-multitable-width-list)
            ;; additional between column spaces, if any
            texinfo-extra-inter-column-width
            ;; sum of spaces for each entry
            (apply #'+ texinfo-multitable-width-list))))
      (if (> desired-columns fill-column)
          (error
           "Multi-column table width, %d chars, is greater than page width, %d chars"
            desired-columns fill-column)))
    texinfo-multitable-width-list))