all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Agustin Martin <agustin.martin@hispalinux.es>
Subject: Re: flyspell bug [possible patch]
Date: Thu, 24 Nov 2005 15:53:16 +0100	[thread overview]
Message-ID: <20051124145316.GA4759@agmartin.aq.upm.es> (raw)
In-Reply-To: <E1Ef8Fv-00082x-DK@fencepost.gnu.org>

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

On Wed, Nov 23, 2005 at 10:58:43PM -0500, Richard M. Stallman wrote:
> I asked Eli Z to install your patch.  But could you provide a change log
> explaining the changes?

A short summary can be something like

(flyspell-external-point-words) Improve misspelling match reliability. Warn
                                about non found misspellings
(flyspell-large-region)  No longer needs setting ispell-parser to tex in TeX mode.

This is a verbose summary of the changes, so the above can be improved:

 *  (flyspell-external-point-words) Consider a misspelling as found in the
    string search if any of:

    (a) misspelling and found string lengths match
    (b) misspelling is found as element in a boundary-chars separated
        longer string (possible boundary-chars mismatch)
    (c) ispell-program-name is really ispell and misspelling is found as
        part of a TeX string (in base mode ispell considers the beginning of
        some of those TeX strings a nroff sequences and strips them when
	writing, thus producing not-found misspellings or, worse, bad
        unsyncs. Setting mode to TeX produces other problems).
  
    After successful match move beginning of search region to end of match

    Warn about not found misspellings once the process is done. (This
    should mostly affect ispell when ispell dict allows more >7bit chars
    than those in (not-)casechars (or are passed to ispell via -w) and 
    there are words in the text with them.
  
 *  (flyspell-large-region) Do not set ispell-parser to tex if in TeX mode.
    This is no longer needed for (flyspell-external-point-words) and has
    some drawbacks when real ispell is used and TeX files use an 8bit
    encoding.
  
> Also, I think a few more comments are needed in the new code
> to make it really clear.

I am attaching a new version of the patch, slightly simplified, just move
always to end of match if a misspelling is considered found by any of (a),
(b) or (c). In the only case (a) where end of word was used, both end of
match and end of word should be the same, so seems simpler to use end of
match for all.

I have added some extra comments, but you might want to add some more. I
also left the coments about

;; Here there used to be ...

present,

-- 
Agustin

[-- Attachment #2: flyspell-external-point-words.diff3 --]
[-- Type: text/plain, Size: 5627 bytes --]

--- flyspell.el.emacs-cvs	2005-11-22 12:29:26.000000000 +0100
+++ flyspell.el	2005-11-24 13:30:19.000000000 +0100
@@ -1304,50 +1304,71 @@
 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-prev (car flyword-prev-l)) 
+			     (size-match (= (length flyword-prev) (length word))))
+			(when (or
+			       ;; size matches, we are done
+			       size-match
+			       ;; Matches as part of a boundary-char separated 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
+			       ;; (char before beginning of word is backslash) 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)
+			  ;; Next search will begin from end of last match
+			  (setq flyspell-large-region-beg match-point))))
+		  ;; Record if misspelling is not found and try new one
+		  (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.")))
+    ;; Warn about not found misspellings
+    (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 +1437,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)))

[-- 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-24 14:53 UTC|newest]

Thread overview: 70+ 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
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 [this message]
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

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

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

  git send-email \
    --in-reply-to=20051124145316.GA4759@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.