Here is a variant of the previous patch, which correctly resets :extend to nil if the user disables the relevant options (after reverting the current buffer, or for newly opened ones). This ends up looking similar to what Org does for org-hide; IMO this seems like the most straightforward short-term fix. In the long run, these user options would probably deserve :set functions.