Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.642
diff -u -p -r1.642 comment.module
--- modules/comment/comment.module	13 Jul 2008 15:51:09 -0000	1.642
+++ modules/comment/comment.module	13 Jul 2008 15:50:00 -0000
@@ -518,6 +518,13 @@
       '#options' => array(t('Disabled'), t('Enabled')),
       '#description' => t('Can users provide a unique subject for their comments?'),
     );
+   $form['comment']['comment_subject_from_parent'] = array(
+      '#type' => 'radios',
+      '#title' => t('Email-style comment subjects'),
+      '#default_value' => variable_get('comment_subject_from_parent_'. $form['#node_type']->type, 0),
+      '#options' => array(t('Disabled'), t('Enabled')),
+      '#description' => t('Generate default comment subjects from their parent subjects.'),
+    );
     $form['comment']['comment_preview'] = array(
       '#type' => 'radios',
       '#title' => t('Preview comment'),
@@ -1324,13 +1331,28 @@
     );
   }
 
-  if (variable_get('comment_subject_field_' . $node->type, 1) == 1) {
-    $form['subject'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Subject'),
-      '#maxlength' => 64,
-      '#default_value' => !empty($edit['subject']) ? $edit['subject'] : '',
-    );
+  $subject = array_key_exists('subject', $edit) ? $edit['subject']:'';
+
+  if (empty($subject) && variable_get('comment_subject_from_parent_' . $node->type, 0) == 1) {
+    // Create subject from node title or parent comment subject.
+    if (!empty($edit['pid']) && $edit['pid'] > 0) {
+      $parent = comment_load($edit['pid']);
+      $subject = $parent->subject;
+    }
+    else {
+      $subject = $node->title;
+    }
+    $pattern = '/^' . preg_quote(t('Re:')) . '/i';
+    if (!preg_match($pattern, $subject)) {
+      $subject = t('Re:') . " $subject";
+    }
+  }
+
+  if (variable_get('comment_subject_field_'. $node->type, 1) == 1) {
+    $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $subject);
+  }
+  else if(!empty($subject)) {
+    $form['subject'] = array('#type' => 'hidden', '#value' => $subject);
   }
 
   if (!empty($edit['comment'])) {
