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 Date: Fri, 18 Nov 2005 15:51:51 +0100 Message-ID: <20051118145151.GA2419@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="xHFwDpU9dbj6ez1V" X-Trace: sea.gmane.org 1132328139 18324 80.91.229.2 (18 Nov 2005 15:35:39 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 18 Nov 2005 15:35:39 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 18 16:35:29 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ed8Bu-00040f-UD for ged-emacs-devel@m.gmane.org; Fri, 18 Nov 2005 16:30:19 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ed8Bt-0007Su-E4 for ged-emacs-devel@m.gmane.org; Fri, 18 Nov 2005 10:30:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ed7eC-0005bo-0S for emacs-devel@gnu.org; Fri, 18 Nov 2005 09:55:28 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ed7e9-0005az-K4 for emacs-devel@gnu.org; Fri, 18 Nov 2005 09:55:26 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ed7e8-0005aa-RL for emacs-devel@gnu.org; Fri, 18 Nov 2005 09:55:25 -0500 Original-Received: from [138.100.4.49] (helo=edison.ccupm.upm.es) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ed7e8-0006Gb-RW for emacs-devel@gnu.org; Fri, 18 Nov 2005 09:55:25 -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 jAIEroOH009991; Fri, 18 Nov 2005 15:53:51 +0100 Original-Received: by mala.aq.upm.es (Postfix, from userid 1000) id 0C604E1D3; Fri, 18 Nov 2005 15:51:51 +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:46223 Archived-At: --xHFwDpU9dbj6ez1V 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 function as currently looks in my system. It is still plenty of debugging code and could surely be simplified, but seems to work reasonably. However much more test is needed. The basic check is the one you proposed, check lengths (seems to suffice, but this might be raised to a 'string=' comparison if needed), but some other checks are added, mostly for ispell benefit: (member word (split-string flyword-prev ispell-otherchars)) will try to see if word has been found as part of a boundary-chars separated compound word. If so, skip word and move point to the match point, not to the end of the flyspell-get-word word found, just in case next element in that compound word is also misspelled (we would lose it otherwise and might unsync the process). (and (not ispell-really-aspell) (save-excursion (goto-char (- (nth 1 flyword-prev-l) 1)) (if (looking-at "[\\]" ) (progn (when mydebug (message "[%s] %s has nroff problems in \\%s" (match-string 0) word flyword-prev)) t) nil )) ispell (not aspell) works in nroff mode as default, for that reason if a tex string is in a non tex file, it might get stripped of the first chars, because they can match a nroff command, \special -> ecial thus making the mispelled word 'ecial' not be found in buffer, or unsync the process if 'ecial' would be a good word present later. If any of these tests matches, word is considered as found and (flyspell-word) is run on it. I still find some problems in tex mode with the '-t' option introduced in flyspell-large-region, but this might be independent of this change. I still have to look better at this. -- Agustin --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="flyspell-external-point-words.debug.el" (defun flyspell-external-point-words () "Mark words from a buffer listing incorrect words in order of appearance. 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'." (let (words-not-found (ispell-otherchars (ispell-get-otherchars)) (mydebug nil)) (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)) ;; 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 mydebug ;; --- debugging code starts (message "word[%s], flyword[%s], wp[%d] flrb[%d] p[%d]" word flyword-prev wordpos flyspell-large-region-beg (point)) (when (not size-match) (message "Size mismatch f:[%s] m:[%s] %s" flyword-prev word flyword-prev-l)) ) ;; --- debugging code ends (when (or size-match (member word (split-string flyword-prev ispell-otherchars)) (and (not ispell-really-aspell) (save-excursion (goto-char (- (nth 1 flyword-prev-l) 1)) (if (looking-at "[\\]" ) (progn (when mydebug (message "[%s] %s has nroff problems in \\%s" (match-string 0) word flyword-prev)) t) nil )) ) ) ; end-or (setq keep nil) (flyspell-word) (setq flyspell-large-region-beg (if size-match flyword-endpoint match-point)) ;; --------------------------- (when mydebug (if size-match (message "+ Moving to %d (match on %d)" flyword-endpoint match-point) (message "+ Moving to %d (point on %d)" match-point flyword-endpoint))) ;; ------------------------------ ) ; end-when ) ; end-let ) ; end-progn (when mydebug (error "Error for word [%s] on flrb[%d] p[%d]" word flyspell-large-region-beg (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)) ;;) ; let keep ;; Kill and forget the buffer with the list of incorrect words. (when (not mydebug) (kill-buffer flyspell-external-ispell-buffer) (setq flyspell-external-ispell-buffer nil)) ) ); let --xHFwDpU9dbj6ez1V 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 --xHFwDpU9dbj6ez1V--