(defun fix-index ()
  "Remove duplicate lines from the KSOS calling tree index."
  (interactive "*")
  (make-local-variable 'name)
  (make-local-variable 'old-fold)
  (setq old-fold case-fold-search)
  (setq case-fold-search nil)
  (while (not (equal (point) (point-max)))
    (forward-char 5)
    (setq name (buffer-substring (point) (progn
					   (end-of-line)
					   (forward-char 1)
					   (point))
				 ))
    (while (search-forward name nil t)
      (kill-line -1)
      )
    )
  (make-local-variable 'length)
  (make-local-variable 'line)
  (goto-char (point-min))
  (while (not (equal (point) (point-max)))
    (setq length (- (- (point) (progn (end-of-line) (point)))))
    (if (equal (% length 2) 0)
	(progn
	  (insert-string " ")
	  (setq length (1+ length)))
      )
    (while (< length 48)
      (insert-string " .")
      (setq length (+ length 2))
      )
    (beginning-of-line)
    (setq line (buffer-substring (point) (+ (point) 4)))
    (delete-char 6)
    (end-of-line)
    (insert-string (concat " " line))
    (beginning-of-line)
    (next-line 1)
    )
  (setq case-fold-search old-fold)
  )
