Function: LaTeX-split-long-menu
LaTeX-split-long-menu is a byte-compiled function defined in latex.el.
Signature
(LaTeX-split-long-menu MENU)
Documentation
Split MENU according to LaTeX-menu-max-items.
Source Code
;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/latex.el
(defun LaTeX-split-long-menu (menu)
"Split MENU according to `LaTeX-menu-max-items'."
(let ((len (length menu)))
(if (or (null LaTeX-menu-max-items)
(null (featurep 'lisp-float-type))
(<= len LaTeX-menu-max-items))
menu
;; Submenu is max 2 entries longer than menu, never shorter, number of
;; entries in submenus differ by at most one (with longer submenus first)
(let* ((outer (floor (sqrt len)))
(inner (/ len outer))
(rest (% len outer))
(result nil))
(setq menu (reverse menu))
(while menu
(let ((in inner)
(sub nil)
(to (car menu)))
(while (> in 0)
(setq in (1- in)
sub (cons (car menu) sub)
menu (cdr menu)))
(setq result
(cons (cons (if (stringp LaTeX-submenu-name-format)
(format LaTeX-submenu-name-format
(aref (car sub) 0) (aref to 0))
(funcall LaTeX-submenu-name-format
(aref (car sub) 0) (aref to 0)))
sub)
result)
rest (1+ rest))
(if (= rest outer) (setq inner (1+ inner)))))
result))))