diff -urp rules/rules.admin_export.inc rules/rules.admin_export.inc
--- rules/rules.admin_export.inc	2008-08-21 11:18:16.000000000 +0300
+++ rules/rules.admin_export.inc	2008-12-24 15:35:51.000000000 +0200
@@ -128,6 +128,11 @@ function rules_admin_form_export($form_s
         '#default_value' => 0,
       );
     }
+    $form['module'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Module name'),
+      '#description' => t("Optional: Enter the module name that the rules will be exported to. If this is set your rules will be prefixed with the module name, and the #status will be set to 'deault'"),
+    );
     $form['button'] = array('#type' => 'submit', '#weight' => 10, '#value' => t('Export'));
   }
   else {
@@ -135,10 +140,10 @@ function rules_admin_form_export($form_s
     $form['result'] = array(
       '#type' => 'textarea',
       '#title' => t('Exported rule configurations'),
-      '#description' => t('Copy these data and paste them into the import page, to import.'),
+      '#description' => empty($form_state['values']['module']) ? t('Copy these data and paste them into the import page, to import.') : t('Copy these data and paste them into a file called @module.rules_defaults.inc .', array('@module' => check_plain(str_replace(' ', '_', $form_state['values']['module'])))),
       '#rows' => 15,
       '#attributes' => array('readonly' => 'readonly'),
-      '#default_value' => var_export($form_state['export'], TRUE),
+      '#default_value' => $form_state['export'],
     );
   }
   return $form;
@@ -151,10 +156,16 @@ function rules_admin_form_export_submit(
     $export[$item_type] = array_intersect_key($items, array_filter($item_names));
     //allow item specific adaption
     foreach ($export[$item_type] as $item_name => $item) {
-      rules_item_type_invoke($item_type, 'export', array($item_name, &$export[$item_type][$item_name], &$export));
+      rules_item_type_invoke($item_type, 'export', array($item_name, &$export[$item_type][$item_name], &$export, $form_state));
     }
   }
   if ($export) {
+    if (!empty($form_state['values']['module'])) {
+      rules_admin_form_export_module($export, $form_state['values']['module']);
+    }
+    else {
+      $export = var_export($export, TRUE);
+    }
     $form_state['export'] = $export;
   }
   else {
@@ -164,6 +175,38 @@ function rules_admin_form_export_submit(
 }
 
 /**
+ * Helper function; Prepare the export to a module.
+ *
+ */
+function rules_admin_form_export_module(&$export, $module_name) {
+  $api = "/**\n";
+  $api .= " * Implementation of hook_rules_defaults().\n";
+  $api .= " */\n";
+  $api .= "function @module_rules_defaults() {\n";
+  $api .= "  return ";
+  $api .= var_export($export, TRUE) .";\n";
+  $api .= "}";
+
+  $api = strtr($api, array('@module' => check_plain(str_replace(' ', '_', $module_name))));
+  $export = $api;
+}
+
+/**
+ * Helper function; Prefix the exported rules with the module name and change
+ * the status to 'default'.
+ */
+function rules_item_rule_export($item_name, &$rule_export, &$export, $form_state) {
+  if (!empty($form_state['values']['module'])) {
+    $prefix = check_plain(str_replace(' ', '_', $form_state['values']['module']));
+    // Change #status to 'default'.
+    $export['rules'][$item_name]['#status'] = 'default';
+    $export['rules'][$prefix .'_'. $item_name] = $export['rules'][$item_name];
+    // Unset the non-prefixed item.
+    unset($export['rules'][$item_name]);
+  }
+}
+
+/**
  * Item type callback: When exporting a rule set, add its rules to the export.
  */
 function rules_item_rule_set_export($set_name, &$rule_set, &$export) {
