Function: breadcrumb--ipath-plain

breadcrumb--ipath-plain is a natively compiled function defined in breadcrumb.el.

Signature

(breadcrumb--ipath-plain INDEX-ALIST POS)

Documentation

Compute ipath for plain imenu--index-alist structures.

These structures don't have a breadcrumb-region property on.

Source Code

;; Defined in /nix/store/3gd3jzhj3g7mbwy1i3w6ci5d2md9d8r2-emacs-packages-deps/share/emacs/site-lisp/elpa/breadcrumb-1.0.1/breadcrumb.el
(defun bc--ipath-plain (index-alist pos)
  "Compute ipath for plain `imenu--index-alist' structures.
These structures don't have a `breadcrumb-region' property on."
  (cl-labels ((dfs (n &optional ipath siblings)
                (setq ipath (cons (car n) ipath))
                (if (consp (cdr n))
                    (mapc (lambda (n2) (dfs n2 ipath (cdr n))) (cdr n))
                  (put-text-property 0 1 'breadcrumb-siblings (cdr siblings) (car ipath))
                  (setq bc--ipath-plain-cache
                        (vconcat bc--ipath-plain-cache
                                 `[,(cons (cdr n) ipath)])))))
    (unless bc--ipath-plain-cache
      (mapc (lambda (i) (dfs i nil index-alist)) index-alist)
      (setq bc--ipath-plain-cache (cl-sort bc--ipath-plain-cache #'< :key #'car)))
    (unless (< pos (car (aref bc--ipath-plain-cache 0)))
      (let ((res (bc--bisect bc--ipath-plain-cache pos :key #'car :from-end t)))
        (unless (zerop res) (reverse (cdr (elt bc--ipath-plain-cache (1- res)))))))))