    (use-local-map ddx-mode-map)
    (set-syntax-table ddx-mode-syntax-table)
    (set (make-local-variable 'ddx-highlighted-label) nil)
+   (set (make-local-variable 'ddx-highlighted-label-marks) nil)
+   (set (make-local-variable 'ddx-highlighted-label-index) 0)
    (ddx-collect-labels)
    (ddx-reset-timer)
    (require 'javadoc))

(defun ddx-indent-line ()
  "Indent the current line as DDX code"
  (interactive)
  
  )

(defun ddx-goto-label (&optional label)

  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((marks ()))
      (while (re-search-forward (concat "\\<" label "\\>") nil t)
        (let ((start (match-beginning 0))
              (end   (match-end 0)))
          (let ((ov (make-overlay start end)))
            (setq marks (cons (copy-marker start) marks))
            (overlay-put ov 'ddx-label-highlight t)
            (overlay-put ov 'face 'ddx-label-highlight))))
      (setq ddx-highlighted-label-marks (vconcat (reverse marks)))))
  (let ((i 0))
    (while (and (< i (length ddx-highlighted-label-marks))
                (< (point)
                   (aref ddx-highlighted-label-marks i)))
      (setq i (+ 1 i)))))

(defun ddx-label-goto-next-reference ()
  (interactive)
  (ddx-label-move-reference 1))

(defun ddx-label-goto-prev-reference ()
  (interactive)
  (ddx-label-move-reference -1))

(defun ddx-label-move-reference (delta)
  (when ddx-highlighted-label-marks
    (setq ddx-highlighted-label-index
          (mod (+ ddx-highlighted-label-index delta)
               (length ddx-highlighted-label-marks)))
    (goto-char (aref ddx-highlighted-label-marks
                     ddx-highlighted-label-index))))

(defun ddx-remove-highlights ()
  (interactive)
  (remove-overlays (point-min) (point-max) 'ddx-label-highlight t)
  (setq ddx-highlighted-label-marks nil))

(defvar ddx-highlighted-label nil
  "The currently-highlighted label")

(defvar ddx-highlighted-label-marks nil
  "A vector of marks for each highlighted label")
(defvar ddx-highlighted-label-index 0
  "The index in `ddx-highlighted-label-marks` of the current label.")

(defvar ddx-all-labels nil
  "All labels in the current buffer")
