[gedit] Don't check words that are marked no-spell-check



commit 412ef504a4d00b046fbb62501f6baa6da5ed2099
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Sat Jan 2 16:38:19 2010 +0100

    Don't check words that are marked no-spell-check
    
    This uses the no-spell-check context class that can be defined
    in GtkSourceView language files

 plugins/spell/gedit-automatic-spell-checker.c |    9 ++++++++-
 plugins/spell/gedit-spell-plugin.c            |   15 ++++++++++-----
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/plugins/spell/gedit-automatic-spell-checker.c b/plugins/spell/gedit-automatic-spell-checker.c
index 3488a6b..2fb9629 100644
--- a/plugins/spell/gedit-automatic-spell-checker.c
+++ b/plugins/spell/gedit-automatic-spell-checker.c
@@ -72,7 +72,14 @@ static void
 check_word (GeditAutomaticSpellChecker *spell, GtkTextIter *start, GtkTextIter *end) 
 {
 	gchar *word;
-	
+
+	if (gtk_source_buffer_iter_has_context_class (GTK_SOURCE_BUFFER (spell->doc),
+	                                              start,
+	                                              "no-spell-check"))
+	{
+		return;
+	}
+
 	word = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (spell->doc), start, end, FALSE);
 
 	/*
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 9d7ad04..3c0e0bf 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -409,6 +409,7 @@ goto_next_word (GeditDocument *doc)
 	GtkTextIter current_iter;
 	GtkTextIter old_current_iter;
 	GtkTextIter end_iter;
+	gboolean wasatend;
 
 	gedit_debug (DEBUG_PLUGINS);
 
@@ -422,13 +423,17 @@ goto_next_word (GeditDocument *doc)
 					  range->current_mark);
 	gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end_iter);
 
-	if (gtk_text_iter_compare (&current_iter, &end_iter) >= 0)
-		return FALSE;
-
 	old_current_iter = current_iter;
 
-	gtk_text_iter_forward_word_ends (&current_iter, 2);
-	gtk_text_iter_backward_word_start (&current_iter);
+	do
+	{
+		gtk_text_iter_forward_word_ends (&current_iter, 2);
+		wasatend = gtk_text_iter_compare (&current_iter, &end_iter) >= 0;
+
+		gtk_text_iter_backward_word_start (&current_iter);
+	} while (gtk_source_buffer_iter_has_context_class (GTK_SOURCE_BUFFER (doc),
+		                                               &current_iter,
+		                                               "no-spell-check") && !wasatend);
 
 	if ((gtk_text_iter_compare (&old_current_iter, &current_iter) < 0) &&
 	    (gtk_text_iter_compare (&current_iter, &end_iter) < 0))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]