Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.206
diff -u -d -F^\s*function -r1.206 form.inc
--- includes/form.inc	17 Jun 2007 12:07:51 -0000	1.206
+++ includes/form.inc	18 Jun 2007 11:27:07 -0000
@@ -1527,6 +1527,17 @@ function theme_textfield($element) {
 }
 
 /**
+ * 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 form.
  *
  * @param $element
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.140
diff -u -d -F^\s*function -r1.140 locale.inc
--- includes/locale.inc	18 Jun 2007 09:41:30 -0000	1.140
+++ includes/locale.inc	18 Jun 2007 11:27:08 -0000
@@ -537,6 +537,7 @@ function locale_translate_seek_form() {
     '#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('#type' => 'radios',
     '#title' => t('Language'),
@@ -788,6 +789,7 @@ function locale_translate_edit_form(&$fo
       '#title' => t($language->name),
       '#rows' => $rows,
       '#default_value' => '',
+      '#autofocus' => TRUE,
     );
   }
 
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	18 Jun 2007 11:27:08 -0000
@@ -0,0 +1,16 @@
+// $Id$
+
+/**
+ * Focuses a field on page load
+ */
+
+// Global Killswitch
+if (Drupal.jsEnabled) {
+  $(function() {
+    if (Drupal.settings && Drupal.settings.autofocus) {
+      var field = $('#'+ Drupal.settings.autofocus)[0];
+      field.focus();
+      field.select();
+    }
+  });
+}
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.345
diff -u -d -F^\s*function -r1.345 aggregator.module
--- modules/aggregator/aggregator.module	5 Jun 2007 12:13:21 -0000	1.345
+++ modules/aggregator/aggregator.module	18 Jun 2007 11:27:09 -0000
@@ -339,6 +339,7 @@ function aggregator_form_category($edit 
     '#default_value' => $edit['title'],
     '#maxlength' => 64,
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -447,6 +448,7 @@ function aggregator_form_feed($edit = ar
     '#maxlength' => 255,
     '#description' => t('The name of the feed; typically the name of the website you syndicate content from.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['url'] = array('#type' => 'textfield',
     '#title' => t('URL'),
Index: modules/contact/contact.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v
retrieving revision 1.89
diff -u -d -F^\s*function -r1.89 contact.module
--- modules/contact/contact.module	14 Jun 2007 05:44:51 -0000	1.89
+++ modules/contact/contact.module	18 Jun 2007 11:27:10 -0000
@@ -173,6 +173,7 @@ function contact_admin_edit($cid = NULL)
     '#default_value' => $edit['category'],
     '#description' => t("Example: 'website feedback' or 'product information'."),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['recipients'] = array('#type' => 'textarea',
     '#title' => t('Recipients'),
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.177
diff -u -d -F^\s*function -r1.177 filter.module
--- modules/filter/filter.module	4 Jun 2007 07:22:17 -0000	1.177
+++ modules/filter/filter.module	18 Jun 2007 11:27:11 -0000
@@ -384,6 +384,7 @@ function filter_admin_format_form(&$form
     '#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/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.402
diff -u -d -F^\s*function -r1.402 forum.module
--- modules/forum/forum.module	4 Jun 2007 15:56:32 -0000	1.402
+++ modules/forum/forum.module	18 Jun 2007 11:27:11 -0000
@@ -475,7 +475,8 @@ function forum_form_container(&$form_sta
     '#default_value' => $edit['name'],
     '#maxlength' => 255,
     '#description' => t('The container name is used to identify related forums.'),
-    '#required' => TRUE
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   $form['description'] = array(
@@ -541,6 +542,7 @@ function forum_form_forum(&$form_state, 
     '#maxlength' => 255,
     '#description' => t('The forum name is used to identify related discussions.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
Index: modules/node/content_types.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v
retrieving revision 1.35
diff -u -d -F^\s*function -r1.35 content_types.inc
--- modules/node/content_types.inc	4 Jun 2007 15:56:33 -0000	1.35
+++ modules/node/content_types.inc	18 Jun 2007 11:27:12 -0000
@@ -75,6 +75,7 @@ function node_type_form(&$form_state, $t
     '#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 begins with a capital letter and consists only of letters, numbers, and <strong>spaces</strong>. This name must be unique to this content type.'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
 
   if (!$type->locked) {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.832
diff -u -d -F^\s*function -r1.832 node.module
--- modules/node/node.module	17 Jun 2007 14:37:33 -0000	1.832
+++ modules/node/node.module	18 Jun 2007 11:27:13 -0000
@@ -2085,8 +2085,13 @@ function node_form(&$form_state, $node) 
   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 (!$node->nid && !isset($form['title']['#autofocus'])) {
+      $form['title']['#autofocus'] = TRUE;
+    }
+    if (!isset($form['title']['#weight'])) {
+      $form['title']['#weight'] = -5;
+    }
   }
 
   $form['#node'] = $node;
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.122
diff -u -d -F^\s*function -r1.122 path.module
--- modules/path/path.module	18 Jun 2007 06:59:11 -0000	1.122
+++ modules/path/path.module	18 Jun 2007 11:27:13 -0000
@@ -186,6 +186,7 @@ function path_form(&$form_state, $edit =
     '#default_value' => $edit['src'],
     '#maxlength' => 64,
     '#size' => 45,
+    '#autofocus' => TRUE,
     '#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=')
   );
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.206
diff -u -d -F^\s*function -r1.206 profile.module
--- modules/profile/profile.module	15 Jun 2007 21:48:02 -0000	1.206
+++ modules/profile/profile.module	18 Jun 2007 11:27:14 -0000
@@ -259,6 +259,7 @@ function profile_field_form(&$form_state
     '#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' => TRUE,
   );
   $form['fields']['title'] = array('#type' => 'textfield',
     '#title' => t('Title'),
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.493
diff -u -d -F^\s*function -r1.493 system.module
--- modules/system/system.module	17 Jun 2007 10:49:49 -0000	1.493
+++ modules/system/system.module	18 Jun 2007 11:27:16 -0000
@@ -101,10 +101,10 @@ function system_elements() {
   $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
   $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
   $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
-  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
+  $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_process_autofocus' => array()));
   $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
   $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm'));
-  $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE);
+  $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_process_autofocus' => array()));
   $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios'));
   $type['radio'] = array('#input' => TRUE, '#default_value' => NULL);
   $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE);
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.360
diff -u -d -F^\s*function -r1.360 taxonomy.module
--- modules/taxonomy/taxonomy.module	17 Jun 2007 10:47:12 -0000	1.360
+++ modules/taxonomy/taxonomy.module	18 Jun 2007 11:27:16 -0000
@@ -242,6 +242,7 @@ function taxonomy_form_vocabulary(&$form
     '#maxlength' => 255,
     '#description' => t('The name for this vocabulary. Example: "Topic".'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -414,7 +415,9 @@ function taxonomy_form_term(&$form_state
     '#default_value' => $edit['name'],
     '#maxlength' => 255,
     '#description' => t('The name of this term.'),
-    '#required' => TRUE);
+    '#required' => TRUE,
+    '#autofocus' => TRUE,
+  );
 
   $form['description'] = array(
     '#type' => 'textarea',
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.799
diff -u -d -F^\s*function -r1.799 user.module
--- modules/user/user.module	17 Jun 2007 11:59:05 -0000	1.799
+++ modules/user/user.module	18 Jun 2007 11:27:18 -0000
@@ -2088,6 +2088,7 @@ function user_admin_role() {
       '#required' => TRUE,
       '#maxlength' => 64,
       '#description' => t('The name for this role. Example: "moderator", "editorial board", "site architect".'),
+      '#autofocus' => TRUE,
     );
     $form['rid'] = array(
       '#type' => 'value',
