Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!leah!itsgw!steinmetz!uunet!munnari!vuwcomp!mark
From: mark@comp.vuw.ac.nz (Mark Davies)
Newsgroups: comp.emacs
Subject: ispell.el (Yet again)
Message-ID: <13865@comp.vuw.ac.nz>
Date: 26 Jun 88 03:07:17 GMT
Organization: Comp Sci, Victoria Univ., Wellington, New Zealand
Lines: 137

What follows are (deep breath) my changes to Ashwin Ram's changes to my
changes to Perry Smith's changes to Walt Buehring's ispell.el!

But first a description/justification of the changes.

	o In previous versions of ispell.el space in answer to
ispell-choose meant accept just this instance of the word (ie. it is correct
here but may not be further down in the document so query it again later if
it reoccurs).  Ashwin changed it to mean accept the word for this
invocation of ispell-region.  I have reverted to the original action.
Perhaps we need an additional option to handle both cases?

	o When choosing the (r)eplace option in ispell-choose it is
preferable to provide the original word to edit rather than forcing the
user to type the whole word in again as it is likely that only a few
changes need to be made.  This was a trivial modification to the
read-string call.

	o Having selected a replacement for a word I object to being asked
by query-replace if I want to make the replacement (after all I just
selected it!) and generally I prefer to move sequentially through a
document when correcting spelling rather than jumping all around the show
as query-replace causes you to do so I have modified ispell-region to
unconditionally replace the first occurance (the one ispell queried you
about) and further if the variable ispell-query-replace-rest is nil not try
and query-replace further occurances, rather let ispell itself complain
about them when you get to them.

So having said that here are the diffs

mark

*** ispell.el~	Tue May 24 21:26:16 1988
--- ispell.el	Sun Jun 26 14:11:46 1988
***************
*** 21,26 ****
--- 21,33 ----
  
  ;;; MODIFICATION HISTORY:
  
+ ;;; Mark Davies	    (mark@comp.vuw.ac.nz)
+ ;;; Sun Jun 26 14:01:35 NZST 1988
+ ;;; Make Query-replace of further occurrences optional
+ ;;; Automatically replace the first instance
+ ;;; Give original word as default when use (r)eplace option
+ ;;;
+ 
  ;;; Ashwin Ram      ARPA:    Ram-Ashwin@cs.yale.edu
  ;;;                 UUCP:    ...!{decvax, linus, seismo}!yale!Ram-Ashwin
  ;;;                 BITNET:  Ram@yalecs
***************
*** 87,92 ****
--- 94,103 ----
  nroff/troff, where a misspelled word may be hidded (e.g., \fIword\fB), and a
  pain otherwise.")
  
+ (defvar ispell-query-replace-rest t
+   "If nil, don't try and query-replace further occurances of a misspelt word.
+ Instead treat them individually as you find them.")
+ 
  (defvar ispell-syntax-table nil)
  
  (if (null ispell-syntax-table)
***************
*** 194,201 ****
  			     (message "%s: a(dd), c(orrect), r(eplace), space or s(kip) [default], ? (help)" (upcase word)) ; q(uit)
  			     (setq char (read-char))
  			     (setq num (- char ?0))
! 			     (cond ((or (= char ? ) (= char ?s))           ; Skip for this invocation
!                                     (ispell-ignore-later-occurrences word)
                                      nil)
  				   ((= char ?a)                            ; Add to dictionary
   				    (send-string ispell-process
--- 205,212 ----
  			     (message "%s: a(dd), c(orrect), r(eplace), space or s(kip) [default], ? (help)" (upcase word)) ; q(uit)
  			     (setq char (read-char))
  			     (setq num (- char ?0))
! 			     (cond ((or (= char ? ) (= char ?s))           ; Skip for this instance
! ;;                                    (ispell-ignore-later-occurrences word)
                                      nil)
  				   ((= char ?a)                            ; Add to dictionary
   				    (send-string ispell-process
***************
*** 210,219 ****
                                      (ispell-ignore-later-occurrences word)
  				    nil)
  				   ((= char ?r)                           ; Query replace
!                                     (ispell-ignore-later-occurrences word)
!                                     (read-string (format "Replacement for %s: " (upcase word)) nil))
  				   ((and (>= num 0) (< num count))
!                                     (ispell-ignore-later-occurrences word)
                                      (nth num choices))
  				   ((= char ?\C-r)                        ; Note: does not reset syntax table
  				    (save-excursion (recursive-edit)) t)  ; Dangerous
--- 221,232 ----
                                      (ispell-ignore-later-occurrences word)
  				    nil)
  				   ((= char ?r)                           ; Query replace
! 				    (if ispell-query-replace-rest
! 					(ispell-ignore-later-occurrences word))
!                                     (read-string (format "Replacement for %s: " (upcase word)) word))
  				   ((and (>= num 0) (< num count))
! 				    (if ispell-query-replace-rest
! 					(ispell-ignore-later-occurrences word))
                                      (nth num choices))
  				   ((= char ?\C-r)                        ; Note: does not reset syntax table
  				    (save-excursion (recursive-edit)) t)  ; Dangerous
***************
*** 418,427 ****
                                         ))
                                   (if replace
                                       (save-excursion
!                                         (query-replace-regexp (if ispell-words-have-boundaries
!                                                                   (concat "\\b" (regexp-quote word) "\\b")
!                                                                   (regexp-quote word))
!                                                               replace))))
                                (message "Can't find %s in original text -- Any key to continue" word)
                                (read-char)
  ;;                            (and (= ?\C-z (read-char)) (suspend-emacs))
--- 431,445 ----
                                         ))
                                   (if replace
                                       (save-excursion
! 					; always replace first match
! 				       (delete-region (point) end)
! 				       (insert replace)
! 				       (if ispell-query-replace-rest
! 					   (query-replace-regexp
! 					    (if ispell-words-have-boundaries
! 						(concat "\\b" (regexp-quote word) "\\b")
! 					      (regexp-quote word))
! 					    replace)))))
                                (message "Can't find %s in original text -- Any key to continue" word)
                                (read-char)
  ;;                            (and (= ?\C-z (read-char)) (suspend-emacs))
-- 
Domainised:  mark@comp.vuw.ac.nz	Bang form: ...!uunet!vuwcomp!mark