Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.185
diff -u -d -F^\s*function -r1.185 form.inc
--- includes/form.inc	27 Mar 2007 05:13:53 -0000	1.185
+++ includes/form.inc	3 Apr 2007 19:57:20 -0000
@@ -1425,6 +1425,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.112
diff -u -d -F^\s*function -r1.112 locale.inc
--- includes/locale.inc	28 Mar 2007 14:08:21 -0000	1.112
+++ includes/locale.inc	3 Apr 2007 19:57:29 -0000
@@ -551,6 +551,7 @@ function _locale_string_seek_form() {
     '#size' => 30,
     '#maxlength' => 30,
     '#description' => t('Leave blank to show all strings. The search is case sensitive.'),
+    '#autofocus' => TRUE,
   );
   $form['search']['language'] = array('#type' => 'radios',
     '#title' => t('Language'),
@@ -589,6 +590,7 @@ function _locale_string_edit($lid) {
       '#title' => $languages[$translation->language]->name,
       '#default_value' => $translation->translation,
       '#rows' => $rows,
+      '#autofocus' => TRUE,
     );
     unset($languages[$translation->language]);
   }
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	3 Apr 2007 19:57:29 -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.333
diff -u -d -F^\s*function -r1.333 aggregator.module
--- modules/aggregator/aggregator.module	27 Mar 2007 05:13:53 -0000	1.333
+++ modules/aggregator/aggregator.module	3 Apr 2007 19:57:35 -0000
@@ -316,6 +316,7 @@ function aggregator_form_category($edit 
     '#default_value' => $edit['title'],
     '#maxlength' => 64,
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -421,6 +422,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.79
diff -u -d -F^\s*function -r1.79 contact.module
--- modules/contact/contact.module	27 Mar 2007 05:13:53 -0000	1.79
+++ modules/contact/contact.module	3 Apr 2007 19:57:38 -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.166
diff -u -d -F^\s*function -r1.166 filter.module
--- modules/filter/filter.module	12 Mar 2007 11:31:02 -0000	1.166
+++ modules/filter/filter.module	3 Apr 2007 19:57:44 -0000
@@ -391,6 +391,7 @@ function filter_admin_format_form($forma
     '#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.390
diff -u -d -F^\s*function -r1.390 forum.module
--- modules/forum/forum.module	28 Mar 2007 14:08:22 -0000	1.390
+++ modules/forum/forum.module	3 Apr 2007 19:57:50 -0000
@@ -450,7 +450,8 @@ function forum_form_container($edit = ar
     '#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(
@@ -516,6 +517,7 @@ function forum_form_forum($edit = array(
     '#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.27
diff -u -d -F^\s*function -r1.27 content_types.inc
--- modules/node/content_types.inc	27 Mar 2007 05:13:54 -0000	1.27
+++ modules/node/content_types.inc	3 Apr 2007 19:57:52 -0000
@@ -75,6 +75,7 @@ function node_type_form($type = NULL) {
     '#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.795
diff -u -d -F^\s*function -r1.795 node.module
--- modules/node/node.module	2 Apr 2007 15:15:39 -0000	1.795
+++ modules/node/node.module	3 Apr 2007 19:58:07 -0000
@@ -1956,8 +1956,13 @@ function node_form($node, $form_values =
   }
   // Get the node-specific bits.
   $form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
-  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;
+    }
   }
 
   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
Index: modules/path/path.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.module,v
retrieving revision 1.113
diff -u -d -F^\s*function -r1.113 path.module
--- modules/path/path.module	27 Mar 2007 05:13:54 -0000	1.113
+++ modules/path/path.module	3 Apr 2007 19:58:09 -0000
@@ -196,6 +196,7 @@ function path_form($edit = array('src' =
     '#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.196
diff -u -d -F^\s*function -r1.196 profile.module
--- modules/profile/profile.module	30 Mar 2007 09:38:13 -0000	1.196
+++ modules/profile/profile.module	3 Apr 2007 19:58:13 -0000
@@ -246,6 +246,7 @@ function profile_field_form($arg = NULL)
     '#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.460
diff -u -d -F^\s*function -r1.460 system.module
--- modules/system/system.module	27 Mar 2007 05:13:54 -0000	1.460
+++ modules/system/system.module	3 Apr 2007 19:58:24 -0000
@@ -66,10 +66,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' => array()));
-  $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' => array()));
   $type['radio'] = array('#input' => TRUE, '#default_value' => NULL);
   $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE);
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.344
diff -u -d -F^\s*function -r1.344 taxonomy.module
--- modules/taxonomy/taxonomy.module	27 Mar 2007 05:13:54 -0000	1.344
+++ modules/taxonomy/taxonomy.module	3 Apr 2007 19:58:28 -0000
@@ -231,6 +231,7 @@ function taxonomy_form_vocabulary($edit 
     '#maxlength' => 255,
     '#description' => t('The name for this vocabulary. Example: "Topic".'),
     '#required' => TRUE,
+    '#autofocus' => TRUE,
   );
   $form['description'] = array('#type' => 'textarea',
     '#title' => t('Description'),
@@ -397,7 +398,9 @@ function taxonomy_form_term($vocabulary,
     '#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.763
diff -u -d -F^\s*function -r1.763 user.module
--- modules/user/user.module	30 Mar 2007 07:45:19 -0000	1.763
+++ modules/user/user.module	3 Apr 2007 19:58:35 -0000
@@ -2013,6 +2013,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',
