Function: semantic-create-imenu-index-1

semantic-create-imenu-index-1 is a byte-compiled function defined in imenu.el.gz.

Signature

(semantic-create-imenu-index-1 STREAM &optional PARENT)

Documentation

Create an imenu index for any buffer which supports Semantic.

Uses the output of the Semantic parser to create the index. STREAM is a stream of tags used to create menus. Optional argument PARENT is a tag parent of STREAM.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/imenu.el.gz
(defun semantic-create-imenu-index-1 (stream &optional parent)
  "Create an imenu index for any buffer which supports Semantic.
Uses the output of the Semantic parser to create the index.
STREAM is a stream of tags used to create menus.
Optional argument PARENT is a tag parent of STREAM."
  (let ((tags stream)
	(semantic-imenu-adopt-external-members
	 semantic-imenu-adopt-external-members))
    ;; If we should regroup, do so.
    (if semantic-imenu-adopt-external-members
        (setq tags (semantic-adopt-external-members tags)
	      ;; Don't allow recursion here.
	      semantic-imenu-adopt-external-members nil))
    ;; Test for bucketing vs not.
    (if semantic-imenu-bucketize-file
	(let ((buckets (semantic-bucketize
			tags parent
			semantic-imenu-sort-bucket-function))
	      item name
	      index)
	  (cond
	   ((null buckets)
	    nil)
	   ((or (cdr-safe buckets) ;; if buckets has more than one item in it.
                (not semantic-imenu-buckets-to-submenu)) ;; to force separators between buckets
	    (while buckets
	      (setq name (car (car buckets))
		    item (cdr (car buckets)))
	      (if semantic-imenu-buckets-to-submenu
		  (progn
		    ;; Make submenus
		    (if item
			(setq index
			      (cons (cons name
					  (semantic-create-imenu-subindex item))
				    index))))
		;; Glom everything together with "---" between
		(if item
		    (setq index
			  (append index
				  ;; do not create a menu separator in the parent menu
				  ;; when creating a sub-menu
				  (if (memq (semantic-tag-class (car item))
                                            semantic-imenu-expandable-tag-classes)
				      (semantic-create-imenu-subindex item)
				    (cons
				     '("---")
				     (semantic-create-imenu-subindex item)))))
		  ))
	      (setq buckets (cdr buckets)))
	    (if semantic-imenu-buckets-to-submenu
		(nreverse index)
	      index))
	   (t
	    (setq name (car (car buckets))
		  item (cdr (car buckets)))
	    (semantic-create-imenu-subindex item))))
      ;; Else, group everything together
      (semantic-create-imenu-subindex tags))))