 ;; make some variables permanently buffer-local
 (dolist (var '(hs-minor-mode
                hs-c-start-regexp
+	       hs-marker-begin-regexp
+	       hs-marker-end-regexp
                hs-block-start-regexp
                hs-block-start-mdata-select
                hs-block-end-regexp

(defun hs-already-hidden-p ()
  "Return non-nil if point is in an already-hidden block, otherwise nil."
  (save-excursion
    (let ((c-reg (hs-inside-comment-p)))
      (if (and c-reg (nth 0 c-reg))
          ;; point is inside a comment, and that comment is hidable
          (goto-char (nth 0 c-reg))

	     (not (looking-at "\\<")))
	(forward-word -1))
    ;; look if current line is block start
    (if (hs-on-marker-line)
	(progn (beginning-of-line)
	       (skip-chars-forward " \t")
	       (point))
      (if (looking-at hs-block-start-regexp)
	  (point)
	;; look backward for the start of a block that contains the end of the line
	(progn (end-of-line)
	       (let ((start (point))) 
		 (while (and (re-search-backward hs-block-start-regexp nil t)
			     (not (setq done
					(< start (save-excursion
						   (hs-forward-sexp (hs-match-data t) 1)
						   (point)))))))))
	(if done
	    (point)
	  (goto-char here)
	  nil)))))

(defun hs-hide-level-recursive (arg minp maxp)
  "Recursively hide blocks ARG levels below point in region (MINP MAXP)."
  (when (hs-find-block-beginning)
    (setq minp (hs-next-line))
    (funcall hs-forward-sexp-func 1)
    (setq maxp (1- (point))))
  (unless hs-allow-nesting
    (hs-discard-overlays minp maxp))
  (goto-char minp)
  (while (progn
           (unless t ;(hs-on-marker-line)
	     (forward-comment (buffer-size)))
           (and (< (point) maxp)
                (re-search-forward hs-block-start-regexp maxp t)))
    (goto-char (match-beginning hs-block-start-mdata-select))
    (if (> arg 1)
        (hs-hide-level-recursive (1- arg) minp maxp)
      ;(goto-char (match-beginning hs-block-start-mdata-select))
      (hs-hide-block-at-point t)))
  (goto-char maxp))

(defun hs-next-line ()
  (save-excursion
    (forward-line 1)
    (beginning-of-line)
    (point)))

(defmacro hs-life-goes-on (&rest body)
  "Evaluate BODY forms iff variable `hs-minor-mode' is non-nil.
