Function: treemacs--find-index-pos

treemacs--find-index-pos is a byte-compiled function defined in treemacs-tag-follow-mode.el.

Signature

(treemacs--find-index-pos POINT LIST)

Documentation

Find the tag at POINT within a flat tag-path LIST.

Returns the tag-path whose tag is the last to be situated before POINT (meaning that the next tag is after POINT and thus too far). Accounts for POINT being located either before the first or after the last tag.

POINT: Int LIST: Sorted Tag Path List

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tag-follow-mode.el
(defun treemacs--find-index-pos (point list)
  "Find the tag at POINT within a flat tag-path LIST.
Returns the tag-path whose tag is the last to be situated before POINT (meaning
that the next tag is after POINT and thus too far).  Accounts for POINT being
located either before the first or after the last tag.

POINT: Int
LIST: Sorted Tag Path List"
  (declare (pure t) (side-effect-free t))
  (when list
    (let ((first (car list))
          (last (nth (1- (length list)) list)))
      (cond
       ((<= point (-> first car cdr))
        first)
       ((>= point (-> last car cdr))
        last)
       (t (treemacs--binary-index-search point list))))))