Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.343
diff -u -r1.343 theme.inc
--- includes/theme.inc	2 Mar 2007 09:40:13 -0000	1.343
+++ includes/theme.inc	18 Mar 2007 12:12:46 -0000
@@ -1123,6 +1123,18 @@
 }
 
 /**
+ * Highlight the user input in a matched string in autocomplete responses.
+ *
+ * @param $input
+ *   The user input string that will be surrounded by <strong> tags.
+ * @param $match
+ *   The autocomplete match in which the user input shall be highlighted.
+ */
+function theme_autocomplete_highlight ($input, $match) {
+  return preg_replace('/'.preg_quote(check_plain($input)).'/i', '<strong>$0</strong>', check_plain($match));
+}
+
+/**
  * @} End of "defgroup themeable".
  */
 
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.194
diff -u -r1.194 profile.module
--- modules/profile/profile.module	11 Feb 2007 09:30:51 -0000	1.194
+++ modules/profile/profile.module	16 Mar 2007 16:24:24 -0000
@@ -707,9 +707,9 @@
 function profile_autocomplete($field, $string) {
   if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
     $matches = array();
-    $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
+    $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = %d AND LOWER(value) LIKE LOWER('%%%s%%') GROUP BY value ORDER BY value ASC", $field, $string, 0, 10);
     while ($data = db_fetch_object($result)) {
-      $matches[$data->value] = check_plain($data->value);
+      $matches[$data->value] = theme('autocomplete_highlight', $string, $data->value);
     }
 
     print drupal_to_js($matches);
@@ -830,9 +830,9 @@
  */
 function profile_admin_settings_autocomplete($string) {
   $matches = array();
-  $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%s%%')", $string, 0, 10);
+  $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER('%%%s%%')", $string, 0, 10);
   while ($data = db_fetch_object($result)) {
-    $matches[$data->category] = check_plain($data->category);
+    $matches[$data->category] = theme('autocomplete_highlight', $string, $data->category);
   }
   print drupal_to_js($matches);
   exit();
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.341
diff -u -r1.341 taxonomy.module
--- modules/taxonomy/taxonomy.module	27 Feb 2007 12:48:33 -0000	1.341
+++ modules/taxonomy/taxonomy.module	16 Mar 2007 16:25:36 -0000
@@ -1490,7 +1490,7 @@
       if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
         $n = '"'. str_replace('"', '""', $tag->name) .'"';
       }
-      $matches[$prefix . $n] = check_plain($tag->name);
+      $matches[$prefix . $n] = theme('autocomplete_highlight', $last_string, $tag->name);
     }
     print drupal_to_js($matches);
     exit();
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.758
diff -u -r1.758 user.module
--- modules/user/user.module	8 Mar 2007 19:03:48 -0000	1.758
+++ modules/user/user.module	16 Mar 2007 16:23:02 -0000
@@ -2543,9 +2543,9 @@
 function user_autocomplete($string = '') {
   $matches = array();
   if ($string) {
-    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%s%%')", $string, 0, 10);
+    $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", $string, 0, 10);
     while ($user = db_fetch_object($result)) {
-      $matches[$user->name] = check_plain($user->name);
+      $matches[$user->name] = theme('autocomplete_highlight',$string, $user->name);
    }
   }
   print drupal_to_js($matches);
