### Eclipse Workspace Patch 1.0
#P drupal
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.312
diff -u -r1.312 block.module
--- modules/block/block.module	9 Oct 2008 15:15:50 -0000	1.312
+++ modules/block/block.module	16 Oct 2008 17:47:29 -0000
@@ -315,6 +315,7 @@
     '#description' => t('A brief description of your block. Used on the <a href="@overview">block overview page</a>.', array('@overview' => url('admin/build/block'))),
     '#required' => TRUE,
     '#weight' => -19,
+    '#autofocus' => empty($edit['info']),
   );
   $form['body_field']['#weight'] = -17;
   $form['body_field']['body'] = array(
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.189
diff -u -r1.189 locale.inc
--- includes/locale.inc	12 Oct 2008 04:30:05 -0000	1.189
+++ includes/locale.inc	16 Oct 2008 17:47:28 -0000
@@ -558,6 +558,7 @@
     '#title' => t('String contains'),
     '#default_value' => @$query['string'],
     '#description' => t('Leave blank to show all strings. The search is case sensitive.'),
+    '#autofocus' => TRUE,
   );
   $form['search']['language'] = array(
     // Change type of form widget if more the 5 options will
@@ -820,6 +821,7 @@
       '#title' => t($language->name),
       '#rows' => $rows,
       '#default_value' => '',
+      '#autofocus' => TRUE,
     );
   }
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.297
diff -u -r1.297 form.inc
--- includes/form.inc	15 Oct 2008 14:17:26 -0000	1.297
+++ includes/form.inc	16 Oct 2008 17:47:28 -0000
@@ -2214,6 +2214,17 @@
 }
 
 /**
+ * Process function for adding autofocus to a field.
+ */
+function form_process_autofocus($element) {
+  if (!empty($element['#autofocus'])) {
+    drupal_add_js('misc/autofocus.js');
+    drupal_add_js(array('autofocus' => $element['#id']), 'setting');
+  }
+  return $element;
+}
+
+/**
  * Format a file upload field.
  *
  * @param $title
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.31
diff -u -r1.31 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc	14 Oct 2008 20:44:57 -0000	1.31
+++ modules/taxonomy/taxonomy.admin.inc	16 Oct 2008 17:47:31 -0000
@@ -131,6 +131,7 @@
     '#maxlength' => 255,
     '#description' => t('The name for this vocabulary, e.g., <em>"Tags"</em>.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['identification']['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -648,7 +649,9 @@
     '#default_value' => $edit['name'],
     '#maxlength' => 255,
     '#description' => t('The name of this term.'),
-    '#required' => TRUE);
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
+  );
   $form['identification']['description'] = array(
     '#type' => 'textarea',
     '#title' => t('Description'),
Index: modules/contact/contact.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.admin.inc,v
retrieving revision 1.5
diff -u -r1.5 contact.admin.inc
--- modules/contact/contact.admin.inc	2 Jul 2008 20:05:11 -0000	1.5
+++ modules/contact/contact.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -42,6 +42,7 @@
     '#default_value' => $contact['category'],
     '#description' => t("Example: 'website feedback' or 'product information'."),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['recipients'] = array('#type' => 'textarea',
     '#title' => t('Recipients'),
Index: modules/contact/contact.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v
retrieving revision 1.15
diff -u -r1.15 contact.pages.inc
--- modules/contact/contact.pages.inc	13 Oct 2008 00:33:02 -0000	1.15
+++ modules/contact/contact.pages.inc	16 Oct 2008 17:47:29 -0000
@@ -187,6 +187,7 @@
     '#title' => t('Subject'),
     '#maxlength' => 50,
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['message'] = array('#type' => 'textarea',
     '#title' => t('Message'),
Index: modules/forum/forum.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.admin.inc,v
retrieving revision 1.14
diff -u -r1.14 forum.admin.inc
--- modules/forum/forum.admin.inc	12 Oct 2008 04:30:06 -0000	1.14
+++ modules/forum/forum.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -40,6 +40,7 @@
     '#maxlength' => 255,
     '#description' => t('Short but meaningful name for this collection of threaded discussions.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -118,7 +119,8 @@
     '#default_value' => $edit['name'],
     '#maxlength' => 255,
     '#description' => t('Short but meaningful name for this collection of related forums.'),
-    '#required' => TRUE
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   $form['description'] = array(
Index: modules/aggregator/aggregator.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.admin.inc,v
retrieving revision 1.16
diff -u -r1.16 aggregator.admin.inc
--- modules/aggregator/aggregator.admin.inc	17 Sep 2008 07:11:56 -0000	1.16
+++ modules/aggregator/aggregator.admin.inc	16 Oct 2008 17:47:28 -0000
@@ -65,6 +65,7 @@
     '#maxlength' => 255,
     '#description' => t('The name of the feed (or the name of the website providing the feed).'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['url'] = array('#type' => 'textfield',
     '#title' => t('URL'),
@@ -436,6 +437,7 @@
     '#default_value' => $edit['title'],
     '#maxlength' => 64,
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.22
diff -u -r1.22 user.pages.inc
--- modules/user/user.pages.inc	13 Oct 2008 00:33:05 -0000	1.22
+++ modules/user/user.pages.inc	16 Oct 2008 17:47:31 -0000
@@ -35,6 +35,7 @@
     '#size' => 60,
     '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('E-mail new password'));
 
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.928
diff -u -r1.928 user.module
--- modules/user/user.module	12 Oct 2008 04:30:09 -0000	1.928
+++ modules/user/user.module	16 Oct 2008 17:47:31 -0000
@@ -1257,6 +1257,7 @@
     '#maxlength' => USERNAME_MAX_LENGTH,
     '#required' => TRUE,
     '#attributes' => array('tabindex' => '1'),
+    '#autofocus' => TRUE,
   );
 
   $form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
@@ -2387,6 +2388,9 @@
     $form['destination'] = array('#type' => 'hidden', '#value' => $_GET['q']);
   }
 
+  // Automatically focus the user name field.
+  $form['account']['name']['#autofocus'] = TRUE;
+
   // Create a dummy variable for pass-by-reference parameters.
   $null = NULL;
   $extra = _user_forms($null, NULL, NULL, 'register');
Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.29
diff -u -r1.29 user.admin.inc
--- modules/user/user.admin.inc	12 Oct 2008 04:30:09 -0000	1.29
+++ modules/user/user.admin.inc	16 Oct 2008 17:47:31 -0000
@@ -629,6 +629,7 @@
       '#required' => TRUE,
       '#maxlength' => 64,
       '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
+      '#autofocus' => TRUE,
     );
     $form['rid'] = array(
       '#type' => 'value',
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.101
diff -u -r1.101 system.admin.inc
--- modules/system/system.admin.inc	12 Oct 2008 04:30:08 -0000	1.101
+++ modules/system/system.admin.inc	16 Oct 2008 17:47:30 -0000
@@ -1132,6 +1132,7 @@
     '#maxlength' => 32,
     '#default_value' => arg(3),
     '#description' => t('Enter a valid IP address.'),
+    '#autofocus' => TRUE,
   );
   $form['submit'] = array(
     '#type' => 'submit',
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.632
diff -u -r1.632 system.module
--- modules/system/system.module	14 Oct 2008 20:44:57 -0000	1.632
+++ modules/system/system.module	16 Oct 2008 17:47:30 -0000
@@ -241,6 +241,7 @@
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
     '#process' => array('form_process_input_format', 'form_process_ahah'),
+    '#process' => array('form_process_ahah', 'form_process_autofocus'),  
   );
 
   $type['password'] = array(
@@ -261,6 +262,7 @@
     '#rows' => 5,
     '#resizable' => TRUE,
     '#process' => array('form_process_input_format', 'form_process_ahah'),
+    '#process' => array('form_process_ahah', 'form_process_autofocus'),  
   );
 
   $type['radios'] = array(
Index: modules/node/content_types.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v
retrieving revision 1.58
diff -u -r1.58 content_types.inc
--- modules/node/content_types.inc	8 Oct 2008 03:27:56 -0000	1.58
+++ modules/node/content_types.inc	16 Oct 2008 17:47:29 -0000
@@ -67,6 +67,7 @@
     '#default_value' => $type->name,
     '#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>create content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and <strong>spaces</strong>. This name must be unique.'),
     '#required' => TRUE,
+    '#autofocus' => empty($type->name),
   );
 
   if (!$type->locked) {
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.45
diff -u -r1.45 node.pages.inc
--- modules/node/node.pages.inc	13 Oct 2008 00:33:03 -0000	1.45
+++ modules/node/node.pages.inc	16 Oct 2008 17:47:29 -0000
@@ -139,8 +139,13 @@
   if ($extra = node_invoke($node, 'form', $form_state)) {
     $form = array_merge_recursive($form, $extra);
   }
-  if (!isset($form['title']['#weight'])) {
-    $form['title']['#weight'] = -5;
+  if (isset($form['title'])) {
+    if (!isset($node->nid) && !isset($form['title']['#autofocus'])) {
+      $form['title']['#autofocus'] = TRUE;
+    }
+    if (!isset($form['title']['#weight'])) {
+      $form['title']['#weight'] = -5;
+    }
   }
 
   $form['#node'] = $node;
Index: modules/profile/profile.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v
retrieving revision 1.17
diff -u -r1.17 profile.admin.inc
--- modules/profile/profile.admin.inc	13 Oct 2008 00:33:04 -0000	1.17
+++ modules/profile/profile.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -216,6 +216,7 @@
     '#autocomplete_path' => 'admin/user/profile/autocomplete',
     '#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
     '#required' => TRUE,
+    '#autofocus' => empty($edit['category']),
   );
   $form['fields']['title'] = array('#type' => 'textfield',
     '#title' => t('Title'),
Index: modules/filter/filter.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v
retrieving revision 1.16
diff -u -r1.16 filter.admin.inc
--- modules/filter/filter.admin.inc	13 Oct 2008 00:33:02 -0000	1.16
+++ modules/filter/filter.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -119,6 +119,7 @@
     '#default_value' => $format->name,
     '#description' => t('Specify a unique name for this filter format.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   // Add a row of checkboxes for form group.
Index: modules/openid/openid.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v
retrieving revision 1.10
diff -u -r1.10 openid.pages.inc
--- modules/openid/openid.pages.inc	13 Oct 2008 00:33:03 -0000	1.10
+++ modules/openid/openid.pages.inc	16 Oct 2008 17:47:29 -0000
@@ -62,6 +62,7 @@
   $form['openid_identifier'] = array(
     '#type' => 'textfield',
     '#title' => t('OpenID'),
+    '#autofocus' => TRUE,
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Add an OpenID'));
   return $form;
Index: modules/menu/menu.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v
retrieving revision 1.33
diff -u -r1.33 menu.admin.inc
--- modules/menu/menu.admin.inc	18 Sep 2008 10:44:19 -0000	1.33
+++ modules/menu/menu.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -259,6 +259,7 @@
       '#default_value' => $path,
       '#description' => t('The path this menu item links to. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.', array('%front' => '<front>', '%add-node' => 'node/add', '%drupal' => 'http://drupal.org')),
       '#required' => TRUE,
+      '#autofocus' => empty($path),
     );
     $form['delete'] = array(
       '#type' => 'submit',
@@ -404,6 +405,7 @@
       '#maxsize' => MENU_MAX_MENU_NAME_LENGTH_UI,
       '#description' => t('The machine-readable name of this menu. This text will be used for constructing the URL of the <em>menu overview</em> page for this menu. This name must contain only lowercase letters, numbers, and hyphens, and must be unique.'),
       '#required' => TRUE,
+      '#autofocus' => TRUE,
     );
     $form['#insert'] = TRUE;
   }
@@ -413,6 +415,7 @@
     '#title' => t('Title'),
     '#default_value' => $menu['title'],
     '#required' => TRUE,
+    '#autofocus' => isset($form['menu_name']['#value']),
   );
   $form['description'] = array(
     '#type' => 'textarea',
Index: modules/path/path.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v
retrieving revision 1.14
diff -u -r1.14 path.admin.inc
--- modules/path/path.admin.inc	13 Oct 2008 00:33:03 -0000	1.14
+++ modules/path/path.admin.inc	16 Oct 2008 17:47:29 -0000
@@ -96,6 +96,7 @@
     '#description' => t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1+2.'),
     '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
     '#required' => TRUE,
+    '#autofocus' => empty($edit['src']),
   );
   $form['dst'] = array(
     '#type' => 'textfield',
@@ -199,6 +200,7 @@
     '#default_value' => $keys,
     '#maxlength' => 64,
     '#size' => 25,
+    '#autofocus' => TRUE,
   );
   $form['basic']['inline']['submit'] = array(
     '#type' => 'submit',
Index: misc/autofocus.js
===================================================================
RCS file: misc/autofocus.js
diff -N misc/autofocus.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ misc/autofocus.js	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,15 @@
+// $Id$
+
+/**
+ * Focuses a field on page load
+ */
+
+$(function() {
+  if (Drupal.settings && Drupal.settings.autofocus) {
+    var field = $('#'+ Drupal.settings.autofocus);
+    if (field[0].value.length == 0) {
+      field[0].focus();
+      field[0].select();
+    }
+  }
+});
