+;; This can be made a no-op once all modes that use text-mode-hook
+;; are "derived" from text-mode.
+(defun text-mode-hook-identify ()
+ "Mark that this mode has run `text-mode-hook'.
+This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
+ (set (make-local-variable 'text-mode-variant) t))
+
+(add-hook 'text-mode-hook 'text-mode-hook-identify)
+