Thread (5 messages) flat view 5 messages, 4 authors, 2016-06-15

Re: [PATCH] git-gui: Automatically spell check commit messages as the user types

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:44:10
Subsystem: library code, the rest · Maintainers: Andrew Morton, Linus Torvalds

Wincent Colaiuta [off-list ref] wrote:
El 4/2/2008, a las 9:41, Shawn O. Pearce escribió:

Rather than sending off the text to be spellchecked at intervals,  
couldn't you refrain from sending it when the cursor hasn't yet moved  
past a word boundary? This is what most "check spelling as you type  
implementations do".

eg. If you type "spellnig" and leave the cursor immediately after the  
"g", the word won't be highlighted until you hit space or otherwise  
cause the cursor to move beyond the word boundary.
Indeed, that's brillant.  Something like this on top would work:
diff --git a/lib/spellcheck.tcl b/lib/spellcheck.tcl
index c032725..088812d 100644
--- a/lib/spellcheck.tcl
+++ b/lib/spellcheck.tcl
@@ -71,6 +71,14 @@ proc spellcheck_commit_buffer {} {
 		SPELL_i SPELL_sent SPELL_last \
 		SPELL_fd SPELL_line SPELL_suggest
 
+	if {![regexp {^\W$} [$ui_comm get {insert -1c} insert]]} {
+		$ui_comm tag remove misspelled \
+			{insert -1c wordstart} \
+			{insert -1c wordend}
+		set SPELL_i [after 300 spellcheck_commit_buffer]
+		return
+	}
+
 	set buf [$ui_comm get 1.0 end]
 	if {$buf ne $SPELL_sent && $buf eq $SPELL_last} {
 		foreach line [split $buf "\n"] {
-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help