Function: treemacs--create-imenu-index-function

treemacs--create-imenu-index-function is an autoloaded and byte-compiled function defined in treemacs-tags.el.

Signature

(treemacs--create-imenu-index-function)

Documentation

The imenu-create-index-function for treemacs buffers.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-tags.el
;;;###autoload
(defun treemacs--create-imenu-index-function ()
  "The `imenu-create-index-function' for treemacs buffers."
  (declare (side-effect-free t))
  (let (index)
    (pcase treemacs-imenu-scope
      ('everything
       (dolist (project (treemacs-workspace->projects (treemacs-current-workspace)))
         (let ((project-name (treemacs-project->name project))
               (root-dom-node (treemacs-find-in-dom (treemacs-project->path project))))
           (-when-let (index-items (treemacs--get-imenu-index-items root-dom-node))
             (push (cons project-name index-items) index)))))
      ('current-project
       (treemacs-unless-let (project (treemacs-project-at-point))
           (treemacs-pulse-on-failure "Cannot create imenu index because there is no project at point")
         (let ((project-name (treemacs-project->name project))
               (root-dom-node (treemacs-find-in-dom (treemacs-project->path project))))
           (-when-let (index-items (treemacs--get-imenu-index-items root-dom-node))
             (push (cons project-name index-items) index)))))
      (other (error "Invalid imenu scope value `%s'" other)))
    (nreverse index)))