diff --git a/ChangeLog b/ChangeLog
index f7b0970..3cd28ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2007-09-03  Mathias Hasselmann  <mathias.hasselmann@gmx.de>
+
+	Implement gtk_source_iter_is_verbatim_text which help to figure out if
+	a text iter covers verbatim text which is appliable for instance for
+	spell checking. Currently this information is retrieved by traversing
+	the entire tree Context nodes. Maybe an index should be used here.
+	Fixes bug #472660. 
+
+	TODO: Update language files to use the "verbatim" attribute.
+
+	* gtksourceview/gtksourcebuffer.c (gtk_source_iter_is_verbatim_text):
+	  new function to figure out if a text iter covers verbatim text
+	* gtksourceview/gtksourcecontextengine.c (get_context_for_tag),
+	  (gtk_source_context_engine_is_verbatim_text),
+	  (_gtk_source_context_engine_class_init): implement virtual
+	  is_verbatim_text method
+	* gtksourceview/gtksourcecontextengine.h (GtkSourceContextFlags): 
+	  add GTK_SOURCE_CONTEXT_VERBATIM flag to mark verbatim regions
+	* gtksourceview/gtksourceengine.c
+	  (_gtk_source_engine_is_verbatim_text): new function
+	* gtksourceview/gtksourceengine.h (_GtkSourceEngineClass):
+	  add virtual is_verbatim_text method
+	* gtksourceview/gtksourceiter.c: add comment about where to find
+	  gtk_source_iter_is_verbatim_text.
+	* gtksourceview/gtksourceiter.h: declare new function
+	  gtk_source_iter_is_verbatim_text
+	* gtksourceview/gtksourcelanguage-parser-2.c (get_context_flags):
+	  recognize "verbatim" attribute
+	* gtksourceview/language-specs/language2.rng (context-simple),
+	  (context-container): allow boolean "verbatim" attribute
+	* gtksourceview/language-specs/c.lang: add "verbatim" attributes
+	* tests/test-widget.c (update_cursor_position): 
+	  check result of gtk_source_iter_is_verbatim_text
+
 2007-09-01  Paolo Maggi  <paolo@gnome.org>
 
 	* MAINTAINERS:
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 06f884b..4ff75b7 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -1992,3 +1992,43 @@ gtk_source_buffer_get_prev_marker (GtkSourceBuffer *buffer,
 
 	return marker;
 }
+
+/**
+ * gtk_source_iter_is_verbatim_text:
+ * @iter: a #GtkTextIter to inspect.
+ *
+ * Checks if the text at @iter contains verbatim text, which would be
+ * suitable for spell checking for instance.
+ *
+ * Return value: %TRUE when the text iter is covered by verbatim text.
+ **/
+gboolean
+gtk_source_iter_is_verbatim_text (const GtkTextIter *iter)
+{
+	GSList *tags;
+	GSList *tag_iter;
+
+	gboolean verbatim = FALSE;
+	GtkSourceBuffer *buffer;
+
+	g_return_val_if_fail (iter != NULL, FALSE);
+
+	buffer = (gpointer) gtk_text_iter_get_buffer (iter);
+	g_return_val_if_fail (GTK_IS_SOURCE_BUFFER (buffer), FALSE);
+
+	tags = gtk_text_iter_get_tags (iter);
+
+	for (tag_iter = tags; tag_iter; tag_iter = tag_iter->next)
+	{
+		if (_gtk_source_engine_is_verbatim_text (buffer->priv->highlight_engine,
+							 GTK_TEXT_TAG (tag_iter->data)))
+		{
+			verbatim = TRUE;
+			break;
+		}
+	}
+
+	g_slist_free (tags);
+
+	return verbatim;
+}
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index 8b9f0ea..1ad3960 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -2372,6 +2372,44 @@ gtk_source_context_engine_finalize (GObject *object)
 	G_OBJECT_CLASS (_gtk_source_context_engine_parent_class)->finalize (object);
 }
 
+static Context*
+get_context_for_tag (Context    *context,
+		     GtkTextTag *tag)
+{
+	ContextPtr *ptr;
+
+	if (tag == context->tag)
+		return context;
+
+	ptr = context->children;
+	context = NULL;
+
+	while (NULL == context && NULL != ptr)
+	{
+		if (ptr->fixed)
+			context = get_context_for_tag (ptr->u.context, tag);
+
+		// XXX ok to ignore non fixed nodes?
+
+		ptr = ptr->next;
+	}
+
+	return context;
+}
+
+static gboolean
+gtk_source_context_engine_is_verbatim_text (GtkSourceEngine      *engine,
+					    GtkTextTag           *tag)
+{
+	GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
+	Context *context = get_context_for_tag (ce->priv->root_context, tag);
+
+	if (NULL != context)
+		return HAS_OPTION (context->definition, VERBATIM);
+
+	return FALSE;
+}
+
 static void
 _gtk_source_context_engine_class_init (GtkSourceContextEngineClass *klass)
 {
@@ -2385,6 +2423,7 @@ _gtk_source_context_engine_class_init (GtkSourceContextEngineClass *klass)
 	engine_class->text_deleted = gtk_source_context_engine_text_deleted;
 	engine_class->update_highlight = gtk_source_context_engine_update_highlight;
 	engine_class->set_style_scheme = gtk_source_context_engine_set_style_scheme;
+	engine_class->is_verbatim_text = gtk_source_context_engine_is_verbatim_text;
 
 	g_type_class_add_private (object_class, sizeof (GtkSourceContextEnginePrivate));
 }
diff --git a/gtksourceview/gtksourcecontextengine.h b/gtksourceview/gtksourcecontextengine.h
index f83fb9f..87f0426 100644
--- a/gtksourceview/gtksourcecontextengine.h
+++ b/gtksourceview/gtksourcecontextengine.h
@@ -60,7 +60,8 @@ typedef enum {
 	GTK_SOURCE_CONTEXT_END_AT_LINE_END	= 1 << 2,
 	GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY	= 1 << 3,
 	GTK_SOURCE_CONTEXT_ONCE_ONLY		= 1 << 4,
-	GTK_SOURCE_CONTEXT_STYLE_INSIDE		= 1 << 5
+	GTK_SOURCE_CONTEXT_STYLE_INSIDE		= 1 << 5,
+	GTK_SOURCE_CONTEXT_VERBATIM		= 1 << 6
 } GtkSourceContextFlags;
 
 typedef enum {
diff --git a/gtksourceview/gtksourceengine.c b/gtksourceview/gtksourceengine.c
index 49622af..9fb9e57 100644
--- a/gtksourceview/gtksourceengine.c
+++ b/gtksourceview/gtksourceengine.c
@@ -104,3 +104,15 @@ _gtk_source_engine_set_style_scheme (GtkSourceEngine      *engine,
 
 	GTK_SOURCE_ENGINE_GET_CLASS (engine)->set_style_scheme (engine, scheme);
 }
+
+gboolean    
+_gtk_source_engine_is_verbatim_text (GtkSourceEngine *engine,
+				     GtkTextTag      *tag)
+{
+	g_return_val_if_fail (GTK_IS_SOURCE_ENGINE (engine), FALSE);
+	g_return_val_if_fail (GTK_IS_TEXT_TAG (tag), FALSE);
+	g_return_val_if_fail (GTK_SOURCE_ENGINE_GET_CLASS (engine)->is_verbatim_text != NULL, FALSE);
+
+	return GTK_SOURCE_ENGINE_GET_CLASS (engine)->is_verbatim_text (engine, tag);
+}
+
diff --git a/gtksourceview/gtksourceengine.h b/gtksourceview/gtksourceengine.h
index bc087e9..f36afb2 100644
--- a/gtksourceview/gtksourceengine.h
+++ b/gtksourceview/gtksourceengine.h
@@ -63,6 +63,9 @@ struct _GtkSourceEngineClass
 
 	void     (* set_style_scheme) (GtkSourceEngine      *engine,
 				       GtkSourceStyleScheme *scheme);
+
+	gboolean (*is_verbatim_text)  (GtkSourceEngine      *engine,
+				       GtkTextTag           *tag);
 };
 
 GType       _gtk_source_engine_get_type		(void) G_GNUC_CONST;
@@ -82,6 +85,9 @@ void        _gtk_source_engine_update_highlight	(GtkSourceEngine      *engine,
 void        _gtk_source_engine_set_style_scheme	(GtkSourceEngine      *engine,
 						 GtkSourceStyleScheme *scheme);
 
+gboolean    _gtk_source_engine_is_verbatim_text (GtkSourceEngine      *engine,
+						 GtkTextTag           *tag);
+
 G_END_DECLS
 
 #endif /* __GTK_SOURCE_ENGINE_H__ */
diff --git a/gtksourceview/gtksourceiter.c b/gtksourceview/gtksourceiter.c
index 6061eaa..4c2e0dd 100644
--- a/gtksourceview/gtksourceiter.c
+++ b/gtksourceview/gtksourceiter.c
@@ -791,4 +791,5 @@ gtk_source_iter_backward_search (const GtkTextIter   *iter,
 
 /*
  * gtk_source_iter_find_matching_bracket is implemented in gtksourcebuffer.c
+ * gtk_source_iter_is_verbatim_text is implemented in gtksourcebuffer.c
  */
diff --git a/gtksourceview/gtksourceiter.h b/gtksourceview/gtksourceiter.h
index 069febe..ca98957 100644
--- a/gtksourceview/gtksourceiter.h
+++ b/gtksourceview/gtksourceiter.h
@@ -48,6 +48,8 @@ gboolean gtk_source_iter_backward_search 	(const GtkTextIter   *iter,
 						 GtkTextIter         *match_end,
 						 const GtkTextIter   *limit);
 
+gboolean gtk_source_iter_is_verbatim_text       (const GtkTextIter   *iter);
+
 G_END_DECLS
 
 #endif /* __GTK_SOURCE_ITER_H__ */
diff --git a/gtksourceview/gtksourcelanguage-parser-2.c b/gtksourceview/gtksourcelanguage-parser-2.c
index 767e4a6..6e4c43e 100644
--- a/gtksourceview/gtksourcelanguage-parser-2.c
+++ b/gtksourceview/gtksourcelanguage-parser-2.c
@@ -270,7 +270,8 @@ get_context_flags (ParserState *parser_state)
 	GtkSourceContextFlags flags = GTK_SOURCE_CONTEXT_EXTEND_PARENT;
 	const gchar *names[] = {
 		"extend-parent", "end-parent", "end-at-line-end",
-		"first-line-only", "once-only", "style-inside"
+		"first-line-only", "once-only", "style-inside",
+		"verbatim"
 	};
 	GtkSourceContextFlags values[] = {
 		GTK_SOURCE_CONTEXT_EXTEND_PARENT,
@@ -278,7 +279,8 @@ get_context_flags (ParserState *parser_state)
 		GTK_SOURCE_CONTEXT_END_AT_LINE_END,
 		GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY,
 		GTK_SOURCE_CONTEXT_ONCE_ONLY,
-		GTK_SOURCE_CONTEXT_STYLE_INSIDE
+		GTK_SOURCE_CONTEXT_STYLE_INSIDE,
+		GTK_SOURCE_CONTEXT_VERBATIM
 	};
 
 	g_assert (G_N_ELEMENTS (names) == G_N_ELEMENTS (values));
diff --git a/gtksourceview/language-specs/c.lang b/gtksourceview/language-specs/c.lang
index 407ce08..78313d1 100644
--- a/gtksourceview/language-specs/c.lang
+++ b/gtksourceview/language-specs/c.lang
@@ -81,14 +81,14 @@
                 <context ref="gtk-doc:inline-docs-section"/>
 
                 <!-- Comments -->
-                <context id="comment" style-ref="comment" end-at-line-end="true">
+                <context id="comment" style-ref="comment" end-at-line-end="true" verbatim="true">
                     <start>//</start>
                     <include>
                       <context ref="def:in-line-comment"/>
                     </include>
                 </context>
 
-                <context id="comment-multiline" style-ref="comment">
+                <context id="comment-multiline" style-ref="comment" verbatim="true">
                     <start>/\*</start>
                     <end>\*/</end>
                     <include>
@@ -144,7 +144,7 @@
                     </include>
                 </context>
 
-                <context id="string" style-ref="string" end-at-line-end="true">
+                <context id="string" style-ref="string" end-at-line-end="true" verbatim="true">
                     <start>"</start>
                     <end>"</end>
                     <include>
diff --git a/gtksourceview/language-specs/language2.rng b/gtksourceview/language-specs/language2.rng
index 87ead1c..a114cc8 100644
--- a/gtksourceview/language-specs/language2.rng
+++ b/gtksourceview/language-specs/language2.rng
@@ -236,6 +236,11 @@
                 <ref name="boolean-value"/>
             </attribute>
         </optional>
+        <optional>
+            <attribute name="verbatim">
+                <ref name="boolean-value"/>
+            </attribute>
+        </optional>
 
         <choice>
             <element name="match">
@@ -308,6 +313,11 @@
                 <ref name="boolean-value"/>
             </attribute>
         </optional>
+        <optional>
+            <attribute name="verbatim">
+                <ref name="boolean-value"/>
+            </attribute>
+        </optional>
 
         <element name="start">
             <ref name="regex-options"/>
diff --git a/tests/test-widget.c b/tests/test-widget.c
index 436a7b5..83cd009 100644
--- a/tests/test-widget.c
+++ b/tests/test-widget.c
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <gtk/gtk.h>
 #include <gtksourceview/gtksourceview.h>
+#include <gtksourceview/gtksourceiter.h>
 #include <gtksourceview/gtksourcelanguage.h>
 #include <gtksourceview/gtksourcelanguagemanager.h>
 #include <gtksourceview/gtksourcestyleschememanager.h>
@@ -752,6 +753,7 @@ update_cursor_position (GtkTextBuffer *buffer, gpointer user_data)
 	GtkTextIter iter, start;
 	GtkSourceView *view;
 	GtkLabel *pos_label;
+	gboolean verb;
 
 	g_return_if_fail (GTK_IS_SOURCE_VIEW (user_data));
 
@@ -782,7 +784,10 @@ update_cursor_position (GtkTextBuffer *buffer, gpointer user_data)
 		gtk_text_iter_forward_char (&start);
 	}
 
-	msg = g_strdup_printf ("char: %d, line: %d, column: %d", chars, row, col);
+	verb = gtk_source_iter_is_verbatim_text (&iter);
+
+	msg = g_strdup_printf ("char: %d, line: %d, column: %d, verbatim: %s", 
+			       chars, row, col, verb ? "yes" : "no");
 	gtk_label_set_text (pos_label, msg);
       	g_free (msg);
 }
