Subject: Re: bug#6761: 23.2; flyspell-prog-mode in TeX mode

From: Agustin Martin <[email-masked]>
Date: Fri, 12 Nov 2010 17:59:14 +0100

On Fri, Jul 30, 2010 at 06:26:00AM +0100, Leo wrote:
> When flyspell-prog-mode is turned on a TeX buffer, anything that has a
> trailing % will be checked, for example
> 
>   bookmarksnumbered%
> 
> This is incorrect as the word is neither doc string nor comment. I run
> into this bug fairly often in LaTeX class and style files.

I finally had time to look at this and seems I found the problem.
flyspell-prog-mode just checks that face is not one of the faces selected as
text faces, but does that in the char right after the word, so in

auto%

checks face in the % char getting font-lock-comment-face instead of nil as
should be for a not-to-be-checked word.

I am playing with attached patch that tries to make sure that check is done 
in the final character of the word, not in the next char outside it.

Will test a bit more and commit if no problems are found.

Thanks for your feedback,

-- 
Agustin
--- flyspell.el.orig	2010-10-20 13:56:38.000000000 +0200
+++ flyspell.el	2010-11-12 17:15:52.000000000 +0100
@@ -1063,7 +1063,9 @@
            start end poss word ispell-filter)
       (if (or (eq flyspell-word nil)
  	      (and (fboundp flyspell-generic-check-word-predicate)
- 		   (not (funcall flyspell-generic-check-word-predicate))))
+		   (save-excursion
+		     (goto-char (- (nth 2 flyspell-word) 1))
+		     (not (funcall flyspell-generic-check-word-predicate)))))
 	  t
 	(progn
 	  ;; destructure return flyspell-word info list.