]> git.eshelyaron.com Git - emacs.git/commitdiff
(flyspell-large-region): Call flyspell-accept-buffer-local-defs.
authorRichard M. Stallman <rms@gnu.org>
Mon, 14 Nov 2005 04:53:14 +0000 (04:53 +0000)
committerRichard M. Stallman <rms@gnu.org>
Mon, 14 Nov 2005 04:53:14 +0000 (04:53 +0000)
(flyspell-notify-misspell): Fix misspelling of "Misspelling".
(flyspell-process-localwords): New function.
(flyspell-large-region): Call flyspell-process-localwords and
flyspell-delete-region-overlays.
(flyspell-delete-region-overlays): New function.
(flyspell-delete-all-overlays): Call that.

lisp/ChangeLog
lisp/textmodes/flyspell.el

index bf51221f4a95c58c8ec001b49ed237c8d9078551..35aa5fca167205b975f91dbb24d6d25b18789455 100644 (file)
@@ -1,3 +1,18 @@
+2005-11-13  Richard M. Stallman  <rms@gnu.org>
+
+       * textmodes/flyspell.el (flyspell-large-region):
+       Call flyspell-accept-buffer-local-defs.
+
+2005-11-13  Agustin Martin  <agustin.martin@hispalinux.es>
+
+       * textmodes/flyspell.el (flyspell-notify-misspell):
+       Fix misspelling of "Misspelling".
+       (flyspell-process-localwords): New function.
+       (flyspell-large-region): Call flyspell-process-localwords and
+       flyspell-delete-region-overlays.
+       (flyspell-delete-region-overlays): New function.
+       (flyspell-delete-all-overlays): Call that.
+
 2005-11-13  Richard M. Stallman  <rms@gnu.org>
 
        * help.el (help-for-help-internal): Improve doc of C-h a.
index a4d77213aec4ee12b13ca24c220b9340b834767f..0bfdadc28ab9abb0a4f978db7e0b36fa2354bc34 100644 (file)
@@ -947,7 +947,7 @@ Mostly we check word delimiters."
                            (sort (car (cdr (cdr poss))) 'string<)
                          (car (cdr (cdr poss)))))))
     (if flyspell-issue-message-flag
-       (message "mispelling `%s'  %S" word replacements))))
+       (message "misspelling `%s'  %S" word replacements))))
 
 ;*---------------------------------------------------------------------*/
 ;*    flyspell-word-search-backward ...                                */
@@ -1374,6 +1374,44 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
   (kill-buffer flyspell-external-ispell-buffer)
   (setq flyspell-external-ispell-buffer nil))
 
+;*---------------------------------------------------------------------*/
+;*    flyspell-process-localwords ...                                  */
+;*    -------------------------------------------------------------    */
+;*    This function is used to prevent marking of words explicitly     */
+;*    declared correct.                                                */
+;*---------------------------------------------------------------------*/
+(defun flyspell-process-localwords (misspellings-buffer)
+  (let (localwords
+       (ispell-casechars (ispell-get-casechars)))
+    ;; Get localwords from the original buffer
+    (save-excursion
+      (goto-char (point-min))
+      ;; Localwords parsing copied from ispell.el.
+      (while (search-forward ispell-words-keyword nil t)
+       (let ((end (save-excursion (end-of-line) (point)))
+             string)
+         ;; buffer-local words separated by a space, and can contain
+         ;; any character other than a space.  Not rigorous enough.
+         (while (re-search-forward " *\\([^ ]+\\)" end t)
+           (setq string (buffer-substring-no-properties (match-beginning 1)
+                                                        (match-end 1)))
+           ;; This can fail when string contains a word with invalid chars.
+           ;; Error handling needs to be added between Ispell and Emacs.
+           (if (and (< 1 (length string))     
+                    (equal 0 (string-match ispell-casechars string)))
+               (push string localwords))))))
+    ;; Remove localwords matches from misspellings-buffer.
+    ;; The usual mechanism of communicating the local words to ispell
+    ;; does not affect the special ispell process used by
+    ;; flyspell-large-region.
+    (with-current-buffer misspellings-buffer
+      (save-excursion
+       (dolist (word localwords)
+         (goto-char (point-min))
+         (let ((regexp (concat "^" word "\n")))
+           (while (re-search-forward regexp nil t)
+             (delete-region (match-beginning 0) (match-end 0)))))))))
+
 ;*---------------------------------------------------------------------*/
 ;*    flyspell-large-region ...                                        */
 ;*---------------------------------------------------------------------*/
@@ -1384,6 +1422,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
     (setq flyspell-large-region-buffer curbuf)
     (setq flyspell-large-region-beg beg)
     (setq flyspell-large-region-end end)
+    (flyspell-accept-buffer-local-defs)
     (set-buffer buffer)
     (erase-buffer)
     ;; this is done, we can start checking...
@@ -1416,7 +1455,11 @@ The buffer to mark them in is `flyspell-large-region-buffer'."
                      (setq args (append args ispell-extra-args))
                      args))))
       (if (eq c 0)
-         (flyspell-external-point-words)
+         (progn
+           (flyspell-process-localwords buffer)
+           (with-current-buffer curbuf
+             (flyspell-delete-region-overlays beg end))
+           (flyspell-external-point-words))
        (error "Can't check region...")))))
 
 ;*---------------------------------------------------------------------*/
@@ -1503,19 +1546,24 @@ FLYSPELL-BUFFER."
   (and (overlayp o) (overlay-get o 'flyspell-overlay)))
 
 ;*---------------------------------------------------------------------*/
-;*    flyspell-delete-all-overlays ...                                 */
+;*    flyspell-delete-region-overlays, flyspell-delete-all-overlays    */
 ;*    -------------------------------------------------------------    */
-;*    Remove all the overlays introduced by flyspell.                  */
+;*    Remove overlays introduced by flyspell.                          */
 ;*---------------------------------------------------------------------*/
-(defun flyspell-delete-all-overlays ()
-  "Delete all the overlays used by flyspell."
-  (let ((l (overlays-in (point-min) (point-max))))
+(defun flyspell-delete-region-overlays (beg end)
+  "Delete overlays used by flyspell in a given region."
+  (let ((l (overlays-in beg end)))
     (while (consp l)
       (progn
        (if (flyspell-overlay-p (car l))
            (delete-overlay (car l)))
        (setq l (cdr l))))))
 
+
+(defun flyspell-delete-all-overlays ()
+  "Delete all the overlays used by flyspell."
+  (flyspell-delete-region-overlays (point-min) (point-max)))
+
 ;*---------------------------------------------------------------------*/
 ;*    flyspell-unhighlight-at ...                                      */
 ;*---------------------------------------------------------------------*/