Function: treesit--imenu-merge-entries

treesit--imenu-merge-entries is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit--imenu-merge-entries ENTRIES)

Documentation

Merge ENTRIES by category.

ENTRIES is a list of (CATEGORY . SUB-ENTRIES...). Merge them so there's no duplicate CATEGORY. CATEGORY's are strings. The merge is stable, meaning the order of elements are kept.

This function is destructive, meaning ENTRIES will be modified.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--imenu-merge-entries (entries)
  "Merge ENTRIES by category.

ENTRIES is a list of (CATEGORY . SUB-ENTRIES...).  Merge them so there's
no duplicate CATEGORY.  CATEGORY's are strings.  The merge is stable,
meaning the order of elements are kept.

This function is destructive, meaning ENTRIES will be modified."
  (let ((return-entries nil))
    (dolist (entry entries)
      (let* ((category (car entry))
             (sub-entries (cdr entry))
             (existing-entries
              (alist-get category return-entries nil nil #'equal)))
        (if (not existing-entries)
            (push entry return-entries)
          (setf (alist-get category return-entries nil nil #'equal)
                (append existing-entries sub-entries)))))
    (nreverse return-entries)))