unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Agustin Martin <agustin.martin@hispalinux.es>
Subject: Re: flyspell bug
Date: Fri, 18 Nov 2005 15:51:51 +0100	[thread overview]
Message-ID: <20051118145151.GA2419@agmartin.aq.upm.es> (raw)
In-Reply-To: <loom.20051116T161627-701@post.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 2606 bytes --]

On Wed, Nov 16, 2005 at 03:22:42PM +0000, Agustin Martin wrote:
> Slawomir Nowaczyk <slawomir.nowaczyk.847 <at> 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

[-- Attachment #2: flyspell-external-point-words.debug.el --]
[-- Type: text/plain, Size: 3933 bytes --]


(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

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2005-11-18 14:51 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-02 17:08 flyspell bug Richard M. Stallman
2005-10-02 20:10 ` Slawomir Nowaczyk
2005-10-02 21:45   ` Kim F. Storm
2005-10-02 23:28     ` Slawomir Nowaczyk
2005-10-03 15:34     ` Richard M. Stallman
2005-10-03 16:14       ` Kim F. Storm
2005-10-03 19:31         ` Richard M. Stallman
2005-10-04  8:58           ` Kim F. Storm
2005-10-05  3:32             ` Richard M. Stallman
2005-10-05  8:34               ` David Kastrup
2005-10-03 15:35     ` Richard M. Stallman
2005-10-05 10:41       ` Slawomir Nowaczyk
2005-10-05 13:16         ` Slawomir Nowaczyk
2005-10-10  4:15           ` Richard M. Stallman
2005-10-12  8:43             ` Slawomir Nowaczyk
2005-10-13  4:52               ` Richard M. Stallman
2005-10-13 10:40                 ` Slawomir Nowaczyk
2005-10-14  5:11                   ` Richard M. Stallman
2005-10-14 11:59                     ` Slawomir Nowaczyk
2005-10-23  4:42                       ` Richard M. Stallman
2005-10-23 11:50                         ` Piet van Oostrum
2005-10-24  1:00                           ` Richard M. Stallman
2005-10-24  7:16                             ` Piet van Oostrum
2005-10-24 13:39                               ` Piet van Oostrum
2005-10-24 14:49                                 ` Piet van Oostrum
2005-10-24 23:22                                 ` Slawomir Nowaczyk
2005-10-25 13:40                                 ` Agustin Martin
2005-10-25 15:59                                 ` Richard M. Stallman
2005-11-18 15:54                                 ` Agustin Martin
2005-11-19 23:26                                   ` Richard M. Stallman
2005-11-20 20:36                                     ` Agustin Martin
2005-11-21  8:10                                       ` Richard M. Stallman
2005-10-24 16:27                               ` Richard M. Stallman
2005-10-24 17:51                                 ` Piet van Oostrum
2005-10-24 23:22                                 ` Slawomir Nowaczyk
2005-10-26 16:46                                   ` Richard M. Stallman
2005-10-27 17:20                                     ` Slawomir Nowaczyk
2005-10-28 16:19                                       ` Richard M. Stallman
2005-10-28 13:32                                     ` Agustin Martin
2005-10-28 21:57                                       ` Piet van Oostrum
2005-10-29  0:18                                       ` Slawomir Nowaczyk
2005-10-29 20:33                                         ` Richard M. Stallman
2005-10-31 14:50                                           ` Slawomir Nowaczyk
2005-11-01 10:19                                             ` Piet van Oostrum
2005-11-02 10:18                                               ` Slawomir Nowaczyk
2005-11-02 21:30                                                 ` Piet van Oostrum
2005-11-03 14:35                                                   ` Slawomir Nowaczyk
2005-11-04  9:20                                                     ` Piet van Oostrum
2005-11-04 12:27                                                       ` Agustin Martin
2005-11-04 14:04                                                       ` Slawomir Nowaczyk
2005-11-04 17:41                                                         ` Agustin Martin
2005-11-05  1:37                                                       ` Richard M. Stallman
2005-11-02 10:27                                               ` Richard M. Stallman
2005-11-07 15:35                                             ` Richard M. Stallman
2005-11-07 15:51                                             ` Slawomir Nowaczyk
2005-11-16 15:22                                               ` Agustin Martin
2005-11-18 14:51                                                 ` Agustin Martin [this message]
2005-11-23 10:19                                                 ` flyspell bug [possible patch] Agustin Martin
2005-11-24  3:58                                                   ` Richard M. Stallman
2005-11-24 14:53                                                     ` Agustin Martin
2005-10-29  5:13                                       ` flyspell bug Richard M. Stallman
2005-10-29 10:12                                         ` Piet van Oostrum
2005-10-29 12:11                                           ` David Kastrup
2005-10-29 19:51                                             ` Piet van Oostrum
2005-10-29 20:34                                           ` Richard M. Stallman
2005-10-30 13:25                                             ` Piet van Oostrum
2005-10-31  1:14                                               ` Richard M. Stallman
2005-10-30  1:14                                         ` Agustin Martin
2005-10-30 12:23                                           ` Piet van Oostrum
2005-10-28 11:11                                 ` Agustin Martin
     [not found] <E1DR6lU-0005vs-O1@fencepost.gnu.org>
2005-05-07 16:06 ` [mange@freemail.hu: Re: flyspell bug] Eli Zaretskii
2005-05-10  0:06   ` flyspell bug Juri Linkov
2005-05-10  3:37     ` Eli Zaretskii
2005-05-10  5:04       ` Juri Linkov
2005-05-10 19:46         ` Eli Zaretskii
2005-05-11  8:23           ` Juri Linkov
2005-05-11 12:40             ` Eli Zaretskii
2005-05-12  5:29               ` Juri Linkov
2005-05-12  6:55                 ` Eli Zaretskii
2005-05-12  6:14               ` Juri Linkov
2005-05-12  9:09                 ` Eli Zaretskii
2005-05-12 17:13                   ` Ken Stevens
2005-05-13 16:09                     ` Richard Stallman
2005-05-13 20:09                       ` Ken Stevens
2005-05-14  4:07                         ` Richard Stallman
2005-05-13  1:34                 ` Richard Stallman
2005-05-12  8:30             ` Richard Stallman
2005-05-23 14:51               ` Kevin Atkinson
2005-05-25  1:18                 ` Richard Stallman
2005-05-25 15:50                   ` Kevin Atkinson
2005-05-26  6:00                     ` Richard Stallman
2005-05-25 16:48                   ` Juri Linkov
2005-05-25 18:11                     ` Kevin Atkinson
2005-05-26  6:00                     ` Richard Stallman
2005-05-11 16:29     ` Richard Stallman
2005-05-12  5:28       ` Juri Linkov
2005-05-13  1:34         ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2005-04-25 11:30 Stephen Eglen
2005-04-26  1:28 ` Peter Heslin
2005-04-26  8:30   ` Stephen Eglen
2005-04-26 22:55     ` Richard Stallman
2005-04-27  9:13       ` Stephen Eglen
2005-04-27 14:04         ` Magnus Henoch
2005-04-27 16:01           ` Stephen Eglen
2005-05-10 10:40   ` Kai Großjohann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051118145151.GA2419@agmartin.aq.upm.es \
    --to=agustin.martin@hispalinux.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).