 		"theorem"
 		"type")))
 
-(defvar sw:basic-unit-intro-regexp "^\\(\\sw+\\)\\s-*=\\s-*")
+(defvar sw:whitespace "\\(\n\\|\\s-\\)")
+
+(defvar sw:basic-unit-intro-regexp "^\\(\\sw+\\)\\(\n\\|\\s-\\)*=\\s-*")
 
 (defvar sw:definition-intro-sexp
   (concat "\\s-*\\(" sw:definition-introducing-words "\\)\\>"))

  (unless (sw:re-search-backward sw:basic-unit-intro-regexp)
    (goto-char (point-min))
    (sw:re-search-forward "^\\sw")      ; Find any non-comment word
  (beginning-of-line))
    (beginning-of-line))

(defun sw:end-of-unit ()
  (interactive "")
  (forward-char 1)
  (unless (sw:re-search-forward sw:basic-unit-intro-regexp)
    (goto-char (point-max)))
  (beginning-of-line)
  (forward-char -1)
  (sw:re-search-backward "\\sw")	; Find any non-comment word
  (beginning-of-line)
  (forward-line 1))

(defun sw:next-unit ()
  (interactive "")
  (forward-char 1)
  (unless (sw:re-search-forward sw:basic-unit-intro-regexp)
    (goto-char (point-max)))
  (beginning-of-line))


(defun sw:re-search-backward (regexpr)
  (let ((case-fold-search nil) (found t))
    (if (re-search-backward regexpr nil t)
        (progn
          (condition-case ()
              (while (sw:inside-comment-or-string-p)
                (re-search-backward regexpr))
            (error (setq found nil)))
          (when found
            (re-search-forward regexpr nil t)
            (re-search-backward regexpr nil t))
          found)
      nil)))

