diff --git a/ChangeLog b/ChangeLog
index 3aa7e91..826bd4e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
    Fix a bug in editor.c:snippets_make_replacements() with handling of
    {ob} and {cb}. Function template_replace_common() now takes an
    argument that controls if {ob} and {cb} should be replaced.
+ * plugins/geanyfunctions.h, src/plugindata.h, src/plugins.c,
+   src/utils.c, src/utils.h:
+   Add utils_find_open_xml_tag_pos() function which was previously a
+   part of utils_find_open_xml_tag(). Add the new function to API.
 
 
 2010-11-18  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
diff --git a/plugins/geanyfunctions.h b/plugins/geanyfunctions.h
index ab12bbf..e5ee73f 100644
--- a/plugins/geanyfunctions.h
+++ b/plugins/geanyfunctions.h
@@ -250,6 +250,8 @@
 	geany_functions->p_utils->utils_copy_environment
 #define utils_find_open_xml_tag \
 	geany_functions->p_utils->utils_find_open_xml_tag
+#define utils_find_open_xml_tag_pos \
+	geany_functions->p_utils->utils_find_open_xml_tag_pos
 #define ui_dialog_vbox_new \
 	geany_functions->p_ui->ui_dialog_vbox_new
 #define ui_frame_new_with_alignment \
diff --git a/src/plugindata.h b/src/plugindata.h
index 72c84d5..67f5cb4 100644
--- a/src/plugindata.h
+++ b/src/plugindata.h
@@ -50,7 +50,7 @@
 enum {
 	/** The Application Programming Interface (API) version, incremented
 	 * whenever any plugin data types are modified or appended to. */
-	GEANY_API_VERSION = 199,
+	GEANY_API_VERSION = 200,
 
 	/** The Application Binary Interface (ABI) version, incremented whenever
 	 * existing fields in the plugin data types have to be changed or reordered. */
@@ -432,6 +432,7 @@ typedef struct UtilsFuncs
 				GError **error);
 	gchar**		(*utils_copy_environment)(const gchar **exclude_vars, const gchar *first_varname, ...);
 	gchar*		(*utils_find_open_xml_tag) (const gchar sel[], gint size);
+	const gchar*	(*utils_find_open_xml_tag_pos) (const gchar sel[], gint size);
 }
 UtilsFuncs;
 
@@ -621,6 +622,8 @@ typedef struct EditorFuncs
 
 	const gchar* (*editor_find_snippet) (struct GeanyEditor *editor, const gchar *snippet_name);
 	void	(*editor_insert_snippet) (struct GeanyEditor *editor, gint pos, const gchar *snippet);
+	gssize (*editor_snippets_make_replacements)(GeanyEditor *editor, GString *pattern,
+		gsize indent_size);
 }
 EditorFuncs;
 
diff --git a/src/plugins.c b/src/plugins.c
index 745e414..859fd10 100644
--- a/src/plugins.c
+++ b/src/plugins.c
@@ -219,7 +219,8 @@ static UtilsFuncs utils_funcs = {
 	&utils_str_remove_chars,
 	&utils_get_file_list_full,
 	&utils_copy_environment,
-	&utils_find_open_xml_tag
+	&utils_find_open_xml_tag,
+	&utils_find_open_xml_tag_pos
 };
 
 static UIUtilsFuncs uiutils_funcs = {
diff --git a/src/utils.c b/src/utils.c
index 46e9207..e7e5655 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -276,13 +276,34 @@ gint utils_write_file(const gchar *filename, const gchar *text)
 }
 
 
-/** Searches backward through @a size bytes looking for a '<', then returns the tag, if any.
+/** Searches backward through @a size bytes looking for a '<'
  * @param sel .
  * @param size .
- * @return The tag name.
+ * @return The tag name (newly allocated) or @c NULL if no opening tag was found
  */
 gchar *utils_find_open_xml_tag(const gchar sel[], gint size)
 {
+	const gchar *cur, *begin;
+
+	cur = utils_find_open_xml_tag_pos(sel, size);
+	if (cur == NULL)
+		return NULL;
+
+	cur++; /* skip the bracket */
+	begin = cur;
+	while (strchr(":_-.", *cur) || isalnum(*cur))
+		cur++;
+	return g_strndup(begin, cur-begin);
+}
+
+
+/** Searches backward through @a size bytes looking for a '<'
+ * @param sel .
+ * @param size .
+ * @return pointer to '<' of the found opening tag within @a sel, or @c NULL if no opening tag was found
+ */
+const gchar *utils_find_open_xml_tag_pos(const gchar sel[], gint size)
+{
 	/* stolen from anjuta and modified */
 	const gchar *begin, *cur;
 
@@ -310,27 +331,15 @@ gchar *utils_find_open_xml_tag(const gchar sel[], gint size)
 	{
 		if (*cur == '<')
 			break;
+		/* exit immediately if such non-valid XML/HTML is detected, e.g. "<script>if a >" */
 		else if (*cur == '>')
 			break;
 		--cur;
 	}
 
-	if (*cur == '<')
-	{
-		GString *result;
-
-		cur++;
-		if (*cur == '/')
-			return NULL; /* we found a closing tag */
-
-		result = g_string_sized_new(64);
-		while (strchr(":_-.", *cur) || isalnum(*cur))
-		{
-			g_string_append_c(result, *cur);
-			cur++;
-		}
-		return g_string_free(result, FALSE);
-	}
+	if (*cur == '<' && *(cur+1) != '/')
+		/* if the found tag is an opening, not a closing tag */
+		return cur;
 
 	return NULL;
 }
diff --git a/src/utils.h b/src/utils.h
index 7d92751..bccf8c2 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -142,6 +142,8 @@ gint utils_write_file(const gchar *filename, const gchar *text);
 
 gchar *utils_find_open_xml_tag(const gchar sel[], gint size);
 
+const gchar *utils_find_open_xml_tag_pos(const gchar sel[], gint size);
+
 gboolean utils_is_short_html_tag(const gchar *tag_name);
 
 void utils_ensure_same_eol_characters(GString *string, gint target_eol_mode);
