From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Agustin Martin Newsgroups: gmane.emacs.devel Subject: Re: flyspell bug [possible patch] Date: Wed, 23 Nov 2005 11:19:39 +0100 Message-ID: <20051123101939.GA3312@agmartin.aq.upm.es> References: <20051031164057.1F82.SLAWOMIR.NOWACZYK.847@student.lu.se> <20051107165012.074E.SLAWOMIR.NOWACZYK.847@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Dxnq1zWXvFF0Q93v" X-Trace: sea.gmane.org 1132748678 19718 80.91.229.2 (23 Nov 2005 12:24:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 23 Nov 2005 12:24:38 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 23 13:24:38 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EetdZ-0004Ey-Bv for ged-emacs-devel@m.gmane.org; Wed, 23 Nov 2005 13:22:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EetdY-0006zC-MG for ged-emacs-devel@m.gmane.org; Wed, 23 Nov 2005 07:22:08 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EesdD-0005XJ-92 for emacs-devel@gnu.org; Wed, 23 Nov 2005 06:17:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EesT6-0002Qs-Kf for emacs-devel@gnu.org; Wed, 23 Nov 2005 06:07:17 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EesQV-0001Rn-HE for emacs-devel@gnu.org; Wed, 23 Nov 2005 06:04:35 -0500 Original-Received: from [138.100.4.49] (helo=edison.ccupm.upm.es) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EesQV-0003Z8-3j for emacs-devel@gnu.org; Wed, 23 Nov 2005 06:04:35 -0500 Original-Received: from mala.aq.upm.es (Agmartin.aq.upm.es [138.100.41.131]) by edison.ccupm.upm.es (8.12.10/8.12.10) with ESMTP id jANAMUOH030401; Wed, 23 Nov 2005 11:22:30 +0100 Original-Received: by mala.aq.upm.es (Postfix, from userid 1000) id 78DA2C623; Wed, 23 Nov 2005 11:19:39 +0100 (CET) Original-To: emacs-devel@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:46477 Archived-At: --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Nov 16, 2005 at 03:22:42PM +0000, Agustin Martin wrote: > Slawomir Nowaczyk student.lu.se> writes: > > > > Besides that, I believe the logic in flyspell-external-point-words > > should be simplified significantly -- we should get rid of the "while > > keep" loop, just find the first place where > > (if (= (length (flyspell-get-word nil)) > > (length word)) > > and flyspell-word that. > > I think you need the (while keep) loop for this. > > > And consider cases where ispell and flyspell > > have different ideas about word boundaries to be bugs and fix those. > > Some of these might require a not found word be signalled by something softer > than an error. > > I am also taking a look at this function making keep nil if any of some > conditions is matched. Will send something as soon as looks better (if so), > even if still full of debugging code I am attaching the patch as is currently in my box, seems to work well with aspell, and in my tests failed only with ispell in rather uncommon things like \distribute dist distr where dist is not tagged as misspelled. It however worked well with distribute dist distr In the former case, unsync is backwards, what is not that critical, as opposed to an forward unsync, and since this is also a rather unfrequent example, I think this is acceptable, and anyway better than current situation. Patch includes removal of the "-t" stuff in flyspell-large-region, I think it is no longer needed and was causing problems with ispell. Please check in your boxes -- Agustin --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="flyspell-external-point-words.diff" --- flyspell.el.emacs-cvs 2005-11-22 12:29:26.000000000 +0100 +++ flyspell.el 2005-11-22 12:32:19.000000000 +0100 @@ -1304,50 +1304,70 @@ The list of incorrect words should be in `flyspell-external-ispell-buffer'. \(We finish by killing that buffer and setting the variable to nil.) The buffer to mark them in is `flyspell-large-region-buffer'." - - (with-current-buffer flyspell-external-ispell-buffer - (goto-char (point-min)) - ;; Loop over incorrect words. - (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t) - ;; Bind WORD to the next one. - (let ((word (match-string 1)) (wordpos (point))) - ;; Here there used to be code to see if WORD is the same - ;; as the previous iteration, and count the number of consecutive - ;; identical words, and the loop below would search for that many. - ;; That code seemed to be incorrect, and on principle, should - ;; be unnecessary too. -- rms. - (if flyspell-issue-message-flag - (message "Spell Checking...%d%% [%s]" - (* 100 (/ (float (point)) (point-max))) - word)) - ;; Search the other buffer for occurrences of this word, - ;; and check them. Stop when we find one that reports "incorrect". - ;; (I don't understand the reason for that logic, - ;; but I didn't want to change it. -- rms.) - (with-current-buffer flyspell-large-region-buffer - (goto-char flyspell-large-region-beg) - (let ((keep t)) - (while keep - (if (search-forward word - flyspell-large-region-end t) - (progn - (setq flyspell-large-region-beg (point)) - (goto-char (- (point) 1)) - (setq keep - ;; Detect when WORD can't be checked properly - ;; because flyspell-get-word finds - ;; just part of it, and treat that as ok. - (if (< (length (car (flyspell-get-word nil))) - (length word)) - nil - (flyspell-word)))) - (error "Bug: misspelled word `%s' (output pos %d) not found in buffer" - word wordpos))))))) - ;; we are done - (if flyspell-issue-message-flag (message "Spell Checking completed."))) - ;; Kill and forget the buffer with the list of incorrect words. - (kill-buffer flyspell-external-ispell-buffer) - (setq flyspell-external-ispell-buffer nil)) + (let (words-not-found + (ispell-otherchars (ispell-get-otherchars))) + (with-current-buffer flyspell-external-ispell-buffer + (goto-char (point-min)) + ;; Loop over incorrect words. + (while (re-search-forward "\\([^\n]+\\)\n" (point-max) t) + ;; Bind WORD to the next one. + (let ((word (match-string 1)) (wordpos (point))) + ;; Here there used to be code to see if WORD is the same + ;; as the previous iteration, and count the number of consecutive + ;; identical words, and the loop below would search for that many. + ;; That code seemed to be incorrect, and on principle, should + ;; be unnecessary too. -- rms. + (if flyspell-issue-message-flag + (message "Spell Checking...%d%% [%s]" + (* 100 (/ (float (point)) (point-max))) + word)) + (with-current-buffer flyspell-large-region-buffer + (goto-char flyspell-large-region-beg) + (let ((keep t)) + ;; Iterate on string search until string is found as word, + ;; not as substring, + (while keep + (if (search-forward word + flyspell-large-region-end t) + (progn + (goto-char (- (point) 1)) + (let* ((match-point (point)) ; flyspell-get-word might move it + (flyword-prev-l (flyspell-get-word nil)) + (flyword-endpoint (point)) + (flyword-prev (car flyword-prev-l)) + (size-match (= (length flyword-prev) (length word)))) + (when (or + size-match + ;; Matches as part of a boundary-char separated word + ;; In this case move to end of match, not to end of word + (member word + (split-string flyword-prev ispell-otherchars)) + ;; ispell treats beginning of some TeX commands as nroff + ;; control sequences and strips them in the list of + ;; misspelled words thus giving a non-existent word. + ;; Skip if ispell is used, string is a TeX command and + ;; none of the previous contitions match + (and (not ispell-really-aspell) + (save-excursion + (goto-char (- (nth 1 flyword-prev-l) 1)) + (if (looking-at "[\\]" ) + t + nil)))) + (setq keep nil) + (flyspell-word) + (setq flyspell-large-region-beg + (if size-match flyword-endpoint match-point))))) + (add-to-list 'words-not-found + (concat " -> " word " - " (int-to-string wordpos))) + (setq keep nil) + )))))) + ;; we are done + (if flyspell-issue-message-flag (message "Spell Checking completed."))) + (dolist (word words-not-found) + (message "%s: word not found" word)) + ;; Kill and forget the buffer with the list of incorrect words. + (kill-buffer flyspell-external-ispell-buffer) + (setq flyspell-external-ispell-buffer nil))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-process-localwords ... */ @@ -1416,8 +1436,6 @@ (if ispell-local-dictionary (setq ispell-dictionary ispell-local-dictionary)) (setq args (ispell-get-ispell-args)) - (if (eq ispell-parser 'tex) - (setq args (cons "-t" args))) (if ispell-dictionary ; use specified dictionary (setq args (append (list "-d" ispell-dictionary) args))) --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --Dxnq1zWXvFF0Q93v--