1 ;;;w3-imenu.el,v 1.1.1.1 1998/12/01 22:11:57 wmperry Exp
2 ;;;Description: Build up navigation index for W3 documents:
7 (defvar w3-imenu-index-html-elements
9 "*List of HTML tags whose buffer positions in the W3 presentation
10 should appear in the index")
12 (make-variable-buffer-local 'w3-imenu-index-html-elements)
16 (defsubst w3-html-stack () (get-text-property (point) 'html-stack))
18 (defsubst w3-html-stack-top-element (stack)
19 (first (first stack )))
22 ;;{{{ Move to an element position
24 (defun w3-imenu-goto-next-element (element)
25 "Move forward in the W3 buffer to point where
26 the next occurrence of element element starts.
27 Return nil and leave point at end of buffer if not found."
30 (stack (w3-html-stack)))
31 (while (and (not (eobp))
34 (or (eq (w3-html-stack-top-element stack) element)
35 (and (eq (w3-html-stack-top-element stack) 'a)
36 (eq (first (second stack)) element))))
37 (setq position (point))
39 (next-single-property-change (point) 'html-stack
40 (current-buffer) (point-max)))
41 (setq stack (w3-html-stack)))
42 (if found position nil)))
47 (defun w3-imenu-create-index ()
48 "Returns an alist suitable for use by imenu"
49 (declare (special w3-imenu-index-html-elements))
54 (loop for element in w3-imenu-index-html-elements
56 (goto-char (point-min))
58 (w3-imenu-goto-next-element element))
59 (setq marker (make-marker))
60 (set-marker marker position)
63 (buffer-substring-no-properties position (point))
69 ;;{{{ Tell W3 to start using it:
70 (declaim (special imenu-create-index-function))
75 (setq imenu-create-index-function 'w3-imenu-create-index)
76 (define-key w3-mode-map "j" 'imenu))))