ulmo@ssyx.ucsc.edu (scritzifchisted ulmo qzutvchsxik) (06/08/89)
In Emacs 18.54, the spelling checker spell-buffer will take a word such as: The rong spelling in the sentence will be fixed. Rong spellings are bad. and may ask me to replace "Rong" with something, I enter "Wrong" of course! So emacs will ask me if I want to replace it for each instance, I say Yes for both, and it comes out like this: The Wrong spelling in the sentence will be fixed. Wrong spellings are bad. The spelling replacer should not alter case in this particular case. These implications may help Emacs determine what case was intended: - if the case of the replacement string matches the case of the string being replaced, this implies that case should be preserved (as the user preserved it himself) - if the case of the string being replaced does not match the string of the original question string to be replaced, then preserve case of replacee. (This should probably be a stronger rule than the one above.) Obviously user control and awareness would help: Telling what Emacs will do on ambigous replacements when asking for confirmation; Offering a few case possibilities: No - do not replace (current behavoir) Yes - replace with Emacs guess of case (as printed) Preserve - preserve case of word in text Replace - replace case of word in text with new word (this is current behavoir for Yes) Sigh, the issue of What to Do when the user presses R or P at an unambiguous spot comes about. Also, how do I get Emacs to show context before asking for the specific replacement name? I was entering an older document where most of its spellings were correct (about half the spell findings were older spellings, about half were my typos, from a couple of pages I copied verbatim). I wanted context so I could look each one up as it came up, but I ended up having to kludge it by just munging the word to something (to me) obviously wrong and hitting return. Luckily, I didn't have to go back to fix anything later, but luck isn't to be assumed. Perhaps Emacs should draw context after you haven't responded in a bit, but the timeframe would be harder to design than the smaller key oriented help Emacs already has in this manner. (sorry, I admit, I used vi for this posting, so I'm not bothering to use any spelling checkers. I sinned.)
jr@bbn.com (John Robinson) (06/20/89)
In article <2820@portia.Stanford.EDU>, ulmo@ssyx (scritzifchisted ulmo qzutvchsxik) writes: >In Emacs 18.54, the spelling checker spell-buffer will take a word such as: > >The rong spelling in the sentence will be fixed. >Rong spellings are bad. > >and may ask me to replace "Rong" with something, I enter "Wrong" of course! >So emacs will ask me if I want to replace it for each instance, >I say Yes for both, and it comes out like this: > >The Wrong spelling in the sentence will be fixed. >Wrong spellings are bad. > >The spelling replacer should not alter case in this particular case. Actually, it tries to do this right, but fails. Here is a relevant excerpt of the spell function (edited, from spell.el): (let ((case-fold-search t) (case-replace t)) (while ;; there are other spell errors, ;; pick up the next incorrect word: (setq word (buffer-substring (point) (progn (end-of-line) (point)))) Now the word is picked up case and all. However, the let of case-fold-search and case-replace each to t at the top seems to imply that the function wants to let emacs guess the correct capitalization. But for this to work, it is also necessary that the string to be matched to have all lower case. Since capitalized versions of words appear *first* in the spell output, they will not be treated in this way. (Maybe emacs assumes that the spell program collapses all characters to lower case.) To me, this looks like a bug. I think it is corrected thus: (setq word (downcase (buffer-substring (point) (progn (end-of-line) (point))))) >Telling what Emacs will do on ambigous replacements when asking for >confirmation; >Offering a few case possibilities: > No - do not replace (current behavoir) > Yes - replace with Emacs guess of case (as printed) > Preserve - preserve case of word in text > Replace - replace case of word in text with new word > (this is current behavoir for Yes) I don't get the distinction of Yes vs. Preserve. However, with the change above, I think that spell will DWIM (do what I mean) for you. >Also, how do I get Emacs to show context before asking for the specific >replacement name? I was entering an older document where most of its >spellings were correct (about half the spell findings were older spellings, >about half were my typos, from a couple of pages I copied verbatim). >I wanted context so I could look each one up as it came up, but I ended >up having to kludge it by just munging the word to something (to me) >obviously wrong and hitting return. I use this trick a lot, in combination with the recursive-edit feature of query-replace (type C-h to its prompt for help). (In my case, my typing is so bad that at times I don't even know what I mistyped!) It would be handier to be able to look at the first occurrence of the misspelling, but there might always be more than one so you would want to ba able to go to them all. The trick is not much worse at that point. >Perhaps Emacs should draw context after you haven't responded in a bit, >but the timeframe would be harder to design than the smaller key >oriented help Emacs already has in this manner. Maybe the timeout would be useful. Could be a bother over slow lines... -- /jr, nee John Robinson What a waste it is to lose one's mind--or not jr@bbn.com or bbn!jr to have a mind. How true that is. -Dan Quayle