]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/ispell.el
Doc fix in Commentary section.
[gnu-emacs] / lisp / textmodes / ispell.el
index a8c3cb3d80916319d989dd2efbfb53532fc77146..60cf46da30d006f03f2f79671f6f876419c30006 100644 (file)
-;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: emacs-lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; GNU EMACS interface for International Ispell Version 3.1 by Geoff Kuenning.
-;;;
-;;;
-;;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
-;;;
-;;;
-;;; Authors         : Ken Stevens <k.stevens@ieee.org>
-;;; Note: version numbers and time stamp are not updated
-;;;   when this file is edited for release with GNU Emacs.
-;;; Last Modified On: Mon Feb  6 17:39:38 EST 1995
-;;; Update Revision : 2.36
-;;; Syntax          : emacs-lisp
-;;; Status         : Release with 3.1.12+ ispell.
-;;; Version        : International Ispell Version 3.1 by Geoff Kuenning.
-;;; Bug Reports            : ispell-el-bugs@itcorp.com
-;;;
-;;; This file is part of GNU Emacs.
-;;;
-;;; GNU Emacs is free software; you can redistribute it and/or modify
-;;; it under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 2, or (at your option)
-;;; any later version.
-;;;
-;;; GNU Emacs is distributed in the hope that it will be useful,
-;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Emacs; see the file COPYING.  If not, write to
-;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-;;;
-;;; Commentary:
-;;;
-;;; INSTRUCTIONS
-;;;
-;;;  This code contains a section of user-settable variables that you should
-;;; inspect prior to installation.  Look past the end of the history list.
-;;; Set them up for your locale and the preferences of the majority of the
-;;; users.  Otherwise the users may need to set a number of variables
-;;; themselves.
-;;;  You particularly may want to change the default dictionary for your
-;;; country and language.
-;;;
-;;;
-;;; To fully install this, add this file to your Emacs Lisp directory and
-;;; compile it with M-X byte-compile-file.  Then add the following to the
-;;; appropriate init file:
-;;;
-;;;  (autoload 'ispell-word "ispell"
-;;;    "Check the spelling of word in buffer." t)
-;;;  (global-set-key "\e$" 'ispell-word)
-;;;  (autoload 'ispell-region "ispell"
-;;;    "Check the spelling of region." t)
-;;;  (autoload 'ispell-buffer "ispell"
-;;;    "Check the spelling of buffer." t)
-;;;  (autoload 'ispell-complete-word "ispell"
-;;;    "Look up current word in dictionary and try to complete it." t)
-;;;  (autoload 'ispell-change-dictionary "ispell"
-;;;    "Change ispell dictionary." t)
-;;;  (autoload 'ispell-message "ispell"
-;;;    "Check spelling of mail message or news post.")
-;;;
-;;;  Depending on the mail system you use, you may want to include these:
-;;;
-;;;  (add-hook 'news-inews-hook 'ispell-message)
-;;;  (add-hook 'mail-send-hook  'ispell-message)
-;;;  (add-hook 'mh-before-send-letter-hook 'ispell-message)
-;;;
-;;;
-;;; Ispell has a TeX parser and a nroff parser (the default).
-;;; The parsing is controlled by the variable ispell-parser.  Currently
-;;; it is just a "toggle" between TeX and nroff, but if more parsers are
-;;; added it will be updated.  See the variable description for more info.
-;;;
-;;;
-;;; TABLE OF CONTENTS
-;;;
-;;;   ispell-word
-;;;   ispell-region
-;;;   ispell-buffer
-;;;   ispell-message
-;;;   ispell-continue
-;;;   ispell-complete-word
-;;;   ispell-complete-word-interior-frag
-;;;   ispell-change-dictionary
-;;;   ispell-kill-ispell
-;;;   ispell-pdict-save
-;;;
-;;;
-;;; Commands in ispell-region:
-;;; Character replacement: Replace word with choice.  May query-replace.
-;;; ' ': Accept word this time.
-;;; 'i': Accept word and insert into private dictionary.
-;;; 'a': Accept word for this session.
-;;; 'A': Accept word and place in buffer-local dictionary.
-;;; 'r': Replace word with typed-in value.  Rechecked.
-;;; 'R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
-;;; '?': Show these commands
-;;; 'x': Exit spelling buffer.  Move cursor to original point.
-;;; 'X': Exit spelling buffer.  Leave cursor at the current point.
-;;; 'q': Quit spelling session (Kills ispell process).
-;;; 'l': Look up typed-in replacement in alternate dictionary.  Wildcards okay.
-;;; 'u': Like 'i', but the word is lower-cased first.
-;;; 'm': Like 'i', but allows one to include dictionary completion info.
-;;; 'C-l': redraws screen
-;;; 'C-r': recursive edit
-;;; 'C-z': suspend emacs or iconify frame
-;;;
-;;; Buffer-Local features:
-;;; There are a number of buffer-local features that can be used to customize
-;;;  ispell for the current buffer.  This includes language dictionaries,
-;;;  personal dictionaries, parsing, and local word spellings.  Each of these
-;;;  local customizations are done either through local variables, or by
-;;;  including the keyword and argument(s) at the end of the buffer (usually
-;;;  prefixed by the comment characters).  See the end of this file for
-;;;  examples.  The local keywords and variables are:
-;;;
-;;;  ispell-dictionary-keyword   language-dictionary
-;;;      uses local variable ispell-local-dictionary
-;;;  ispell-pdict-keyword        personal-dictionary
-;;;      uses local variable ispell-local-pdict
-;;;  ispell-parsing-keyword      mode-arg extended-char-arg
-;;;  ispell-words-keyword        any number of local word spellings
-;;;
-;;;
-;;; BUGS:
-;;;  Highlighting in version 19 still doesn't work on tty's.
-;;;  On some versions of emacs, growing the minibuffer fails.
-;;;
-;;; HISTORY
-;;;
-;;; Revision 2.36  1995/2/6 17:39:38   stevens
-;;; Properly adjust screen with different ispell-choices-win-default-height
-;;; settings.  Skips SGML entity references.
-;;;
-;;; Revision 2.35  1995/1/13 14:16:46  stevens
-;;; Skips SGML tags, ispell-change-dictionary fix for add-hook, assure personal
-;;; dictionary is saved when called from the menu
-;;;
-;;; Revision 2.34  1994/12/08 13:17:41  stevens
-;;; Interaction corrected to function with all 3.1 ispell versions.
-;;;
-;;; Revision 2.33  1994/11/24 02:31:20  stevens
-;;; Repaired bug introduced in 2.32 that corrupts buffers when correcting.
-;;; Improved buffer scrolling. Nondestructive buffer selections allowed.
-;;;
-;;; Revision 2.32  1994/10/31 21:10:08  geoff
-;;; Many revisions accepted from RMS/FSF.  I think (though I don't know) that
-;;; this represents an 'official' version.
-;;;
-;;; Revision 2.31  1994/5/31 10:18:17  stevens
-;;; Repaired comments.  buffer-local commands executed in `ispell-word' now.
-;;; German dictionary described for extended character mode.  Dict messages.
-;;;
-;;; Revision 2.30  1994/5/20 22:18:36  stevens
-;;; Continue ispell from ispell-word, C-z functionality fixed.
-;;;
-;;; Revision 2.29  1994/5/12 09:44:33  stevens
-;;; Restored ispell-use-ptys-p, ispell-message aborts sends with interrupt.
-;;; defined fn ispell
-;;;
-;;; Revision 2.28  1994/4/28 16:24:40  stevens
-;;; Window checking when ispell-message put on gnus-inews-article-hook jwz.
-;;; prefixed ispell- to highlight functions and horiz-scroll fn.
-;;; Try and respect case of word in ispell-complete-word.
-;;; Ignore non-char events.  Ispell-use-ptys-p commented out. Lucid menu.
-;;; Better interrupt handling.  ispell-message improvements from Ethan.
-;;;
-;;; Revision 2.27
-;;; version 18 explicit C-g handling disabled as it didn't work. Added
-;;; ispell-extra-args for ispell customization (jwz)
-;;;
-;;; Revision 2.26  1994/2/15 16:11:14  stevens
-;;; name changes for copyright assignment.  Added word-frags in complete-word.
-;;; Horizontal scroll (John Conover). Query-replace matches words now.  bugs.
-;;;
-;;; Revision 2.25
-;;; minor mods, upgraded ispell-message
-;;;
-;;; Revision 2.24
-;;; query-replace more robust, messages, defaults, ispell-change-dict.
-;;;
-;;; Revision 2.23  1993/11/22 23:47:03  stevens
-;;; ispell-message, Fixed highlighting, added menu-bar, fixed ispell-help, ...
-;;;
-;;; Revision 2.22
-;;; Added 'u' command.  Fixed default in ispell-local-dictionary.
-;;; fixed affix rules display.  Tib skipping more robust.  Contributions by
-;;; Per Abraham (parser selection), Denis Howe, and Eberhard Mattes.
-;;;
-;;; Revision 2.21  1993/06/30 14:09:04  stevens
-;;; minor bugs. (nroff word skipping fixed)
-;;;
-;;; Revision 2.20  1993/06/30 14:09:04  stevens
-;;;
-;;; Debugging and contributions by: Boris Aronov, Rik Faith, Chris Moore,
-;;;  Kevin Rodgers, Malcolm Davis.
-;;; Particular thanks to Michael Lipp, Jamie Zawinski, Phil Queinnec
-;;;  and John Heidemann for suggestions and code.
-;;; Major update including many tweaks.
-;;; Many changes were integrations of suggestions.
-;;; lookup-words rehacked to use call-process (Jamie).
-;;; ispell-complete-word rehacked to be compatible with the rest of the
-;;; system for word searching and to include multiple wildcards,
-;;; and it's own dictionary.
-;;; query-replace capability added.  New options 'X', 'R', and 'A'.
-;;; buffer-local modes for dictionary, word-spelling, and formatter-parsing.
-;;; Many random bugs, like commented comments being skipped, fix to
-;;; keep-choices-win, fix for math mode, added pipe mode choice,
-;;; fixed 'q' command, ispell-word checks previous word and leave cursor
-;;; in same location.  Fixed tib code which could drop spelling regions.
-;;; Cleaned up setq calls for efficiency. Gave more context on window overlays.
-;;; Assure context on ispell-command-loop.  Window lossage in look cmd fixed.
-;;; Due to pervasive opinion, common-lisp package syntax removed. Display
-;;; problem when not highlighting.
-;;;
-;;; Revision 2.19  1992/01/10  10:54:08  geoff
-;;; Make another attempt at fixing the "Bogus, dude" problem.  This one is
-;;; less elegant, but has the advantage of working.
-;;;
-;;; Revision 2.18  1992/01/07  10:04:52  geoff
-;;; Fix the "Bogus, Dude" problem in ispell-word.
-;;;
-;;; Revision 2.17  1991/09/12  00:01:42  geoff
-;;; Add some changes to make ispell-complete-word work better, though
-;;; still not perfectly.
-;;;
-;;; Revision 2.16  91/09/04  18:00:52  geoff
-;;; More updates from Sebastian, to make the multiple-dictionary support
-;;; more flexible.
-;;;
-;;; Revision 2.15  91/09/04  17:30:02  geoff
-;;; Sebastian Kremer's tib support
-;;;
-;;; Revision 2.14  91/09/04  16:19:37  geoff
-;;; Don't do set-window-start if the move-to-window-line moved us
-;;; downward, rather than upward.  This prevents getting the buffer all
-;;; confused.  Also, don't use the "not-modified" function to clear the
-;;; modification flag;  instead use set-buffer-modified-p.  This prevents
-;;; extra messages from flashing.
-;;;
-;;; Revision 2.13  91/09/04  14:35:41  geoff
-;;; Fix a spelling error in a comment.  Add code to handshake with the
-;;; ispell process before sending anything to it.
-;;;
-;;; Revision 2.12  91/09/03  20:14:21  geoff
-;;; Add Sebastian Kremer's multiple-language support.
-;;;
-;;;
-;;; Walt Buehring
-;;; Texas Instruments - Computer Science Center
-;;; ARPA:  Buehring%TI-CSL@CSNet-Relay
-;;; UUCP:  {smu, texsun, im4u, rice} ! ti-csl ! buehring
-;;;
-;;; ispell-region and associated routines added by
-;;; Perry Smith
-;;; pedz@bobkat
-;;; Tue Jan 13 20:18:02 CST 1987
-;;;
-;;; extensively modified by Mark Davies and Andrew Vignaux
-;;; {mark,andrew}@vuwcomp
-;;; Sun May 10 11:45:04 NZST 1987
-;;;
-;;; Ken Stevens  ARPA: k.stevens@ieee.org
-;;; Tue Jan  3 16:59:07 PST 1989
-;;; This file has overgone a major overhaul to be compatible with ispell
-;;; version 2.1.  Most of the functions have been totally rewritten, and
-;;; many user-accessible variables have been added.  The syntax table has
-;;; been removed since it didn't work properly anyway, and a filter is
-;;; used rather than a buffer.  Regular expressions are used based on
-;;; ispell's internal definition of characters (see ispell(4)).
-;;; Some new updates:
-;;; - Updated to version 3.0 to include terse processing.
-;;; - Added a variable for the look command.
-;;; - Fixed a bug in ispell-word when cursor is far away from the word
-;;;   that is to be checked.
-;;; - Ispell places the incorrect word or guess in the minibuffer now.
-;;; - fixed a bug with 'l' option when multiple windows are on the screen.
-;;; - lookup-words just didn't work with the process filter.  Fixed.
-;;; - Rewrote the process filter to make it cleaner and more robust
-;;;   in the event of a continued line not being completed.
-;;; - Made ispell-init-process more robust in handling errors.
-;;; - Fixed bug in continuation location after a region has been modified by
-;;;   correcting a misspelling.
-;;; Mon 17 Sept 1990
-;;;
-;;; Sebastian Kremer <sk@thp.uni-koeln.de>
-;;; Wed Aug  7 14:02:17 MET DST 1991
-;;; - Ported ispell-complete-word from Ispell 2 to Ispell 3.
-;;; - Added ispell-kill-ispell command.
-;;; - Added ispell-dictionary and ispell-dictionary-alist variables to
-;;;   support other than default language.  See their docstrings and
-;;;   command ispell-change-dictionary.
-;;; - (ispelled it :-)
-;;; - Added ispell-skip-tib variable to support the tib bibliography
-;;;   program.
-;;;
-;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; ispell.el --- spell checking using Ispell
 
+;; Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
 
+;; Authors         : Ken Stevens <k.stevens@ieee.org>
+;; Last Modified On: Tue Jun 13 12:05:28 EDT 1995
+;; Update Revision : 2.37
+;; Syntax          : emacs-lisp
+;; Status         : Release with 3.1.12+ ispell.
+;; Version        : International Ispell Version 3.1 by Geoff Kuenning.
+;; Bug Reports    : ispell-el-bugs@itcorp.com
 
-;;; **********************************************************************
-;;; The following variables should be set according to personal preference
-;;; and location of binaries:
-;;; **********************************************************************
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;; Note: version numbers and time stamp are not updated
+;;   when this file is edited for release with GNU Emacs.
+
+;;; Commentary:
 
+;; INSTRUCTIONS
+;;
+;;  This code contains a section of user-settable variables that you should
+;; inspect prior to installation.  Look past the end of the history list.
+;; Set them up for your locale and the preferences of the majority of the
+;; users.  Otherwise the users may need to set a number of variables
+;; themselves.
+;;  You particularly may want to change the default dictionary for your
+;; country and language.
+;;
+;;
+;; To fully install this, add this file to your Emacs Lisp directory and
+;; compile it with M-X byte-compile-file.  Then add the following to the
+;; appropriate init file:
+;;
+;;  (autoload 'ispell-word "ispell"
+;;    "Check the spelling of word in buffer." t)
+;;  (global-set-key "\e$" 'ispell-word)
+;;  (autoload 'ispell-region "ispell"
+;;    "Check the spelling of region." t)
+;;  (autoload 'ispell-buffer "ispell"
+;;    "Check the spelling of buffer." t)
+;;  (autoload 'ispell-complete-word "ispell"
+;;    "Look up current word in dictionary and try to complete it." t)
+;;  (autoload 'ispell-change-dictionary "ispell"
+;;    "Change ispell dictionary." t)
+;;  (autoload 'ispell-message "ispell"
+;;    "Check spelling of mail message or news post.")
+;;
+;;  Depending on the mail system you use, you may want to include these:
+;;
+;;  (add-hook 'news-inews-hook 'ispell-message)
+;;  (add-hook 'mail-send-hook  'ispell-message)
+;;  (add-hook 'mh-before-send-letter-hook 'ispell-message)
+;;
+;;
+;; Ispell has a TeX parser and a nroff parser (the default).
+;; The parsing is controlled by the variable ispell-parser.  Currently
+;; it is just a "toggle" between TeX and nroff, but if more parsers are
+;; added it will be updated.  See the variable description for more info.
+;;
+;;
+;; TABLE OF CONTENTS
+;;
+;;   ispell-word
+;;   ispell-region
+;;   ispell-buffer
+;;   ispell-message
+;;   ispell-comments-and-strings
+;;   ispell-continue
+;;   ispell-complete-word
+;;   ispell-complete-word-interior-frag
+;;   ispell-change-dictionary
+;;   ispell-kill-ispell
+;;   ispell-pdict-save
+;;
+;;
+;; Commands in ispell-region:
+;; Character replacement: Replace word with choice.  May query-replace.
+;; ' ': Accept word this time.
+;; 'i': Accept word and insert into private dictionary.
+;; 'a': Accept word for this session.
+;; 'A': Accept word and place in buffer-local dictionary.
+;; 'r': Replace word with typed-in value.  Rechecked.
+;; 'R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
+;; '?': Show these commands
+;; 'x': Exit spelling buffer.  Move cursor to original point.
+;; 'X': Exit spelling buffer.  Leave cursor at the current point.
+;; 'q': Quit spelling session (Kills ispell process).
+;; 'l': Look up typed-in replacement in alternate dictionary.  Wildcards okay.
+;; 'u': Like 'i', but the word is lower-cased first.
+;; 'm': Like 'i', but allows one to include dictionary completion info.
+;; 'C-l': redraws screen
+;; 'C-r': recursive edit
+;; 'C-z': suspend emacs or iconify frame
+;;
+;; Buffer-Local features:
+;; There are a number of buffer-local features that can be used to customize
+;;  ispell for the current buffer.  This includes language dictionaries,
+;;  personal dictionaries, parsing, and local word spellings.  Each of these
+;;  local customizations are done either through local variables, or by
+;;  including the keyword and argument(s) at the end of the buffer (usually
+;;  prefixed by the comment characters).  See the end of this file for
+;;  examples.  The local keywords and variables are:
+;;
+;;  ispell-dictionary-keyword   language-dictionary
+;;      uses local variable ispell-local-dictionary
+;;  ispell-pdict-keyword        personal-dictionary
+;;      uses local variable ispell-local-pdict
+;;  ispell-parsing-keyword      mode-arg extended-char-arg
+;;  ispell-words-keyword        any number of local word spellings
+;;
+;;
+;; BUGS:
+;;  Highlighting in version 19 still doesn't work on tty's.
+;;  On some versions of emacs, growing the minibuffer fails.
+;;
+;; HISTORY
+;;
+;; Revision 2.38  1996/5/30    ethanb@phys.washington.edu
+;; Update ispell-message for gnus 5 (news-inews-hook => message-send-hook;
+;; different header for quoted message).
+;;
+;; Revision 2.37  1995/6/13 12:05:28   stevens
+;; Removed autoload from ispell-dictionary-alist. *choices* mode-line shows
+;; misspelled word.  Block skip for pgp & forwarded messages added.
+;; RMS: the autoload changes had problems and I removed them.
+;;
+;; Revision 2.36  1995/2/6 17:39:38    stevens
+;; Properly adjust screen with different ispell-choices-win-default-height
+;; settings.  Skips SGML entity references.
+;;
+;; Revision 2.35  1995/1/13 14:16:46   stevens
+;; Skips SGML tags, ispell-change-dictionary fix for add-hook, assure personal
+;; dictionary is saved when called from the menu
+;;
+;; Revision 2.34  1994/12/08 13:17:41  stevens
+;; Interaction corrected to function with all 3.1 ispell versions.
+;;
+;; Revision 2.33  1994/11/24 02:31:20  stevens
+;; Repaired bug introduced in 2.32 that corrupts buffers when correcting.
+;; Improved buffer scrolling. Nondestructive buffer selections allowed.
+;;
+;; Revision 2.32  1994/10/31 21:10:08  geoff
+;; Many revisions accepted from RMS/FSF.  I think (though I don't know) that
+;; this represents an 'official' version.
+;;
+;; Revision 2.31  1994/5/31 10:18:17  stevens
+;; Repaired comments.  buffer-local commands executed in `ispell-word' now.
+;; German dictionary described for extended character mode.  Dict messages.
+;;
+;; Revision 2.30  1994/5/20 22:18:36  stevens
+;; Continue ispell from ispell-word, C-z functionality fixed.
+;;
+;; Revision 2.29  1994/5/12 09:44:33  stevens
+;; Restored ispell-use-ptys-p, ispell-message aborts sends with interrupt.
+;; defined fn ispell
+;;
+;; Revision 2.28  1994/4/28 16:24:40  stevens
+;; Window checking when ispell-message put on gnus-inews-article-hook jwz.
+;; prefixed ispell- to highlight functions and horiz-scroll fn.
+;; Try and respect case of word in ispell-complete-word.
+;; Ignore non-char events.  Ispell-use-ptys-p commented out. Lucid menu.
+;; Better interrupt handling.  ispell-message improvements from Ethan.
+;;
+;; Revision 2.27
+;; version 18 explicit C-g handling disabled as it didn't work. Added
+;; ispell-extra-args for ispell customization (jwz)
+;;
+;; Revision 2.26  1994/2/15 16:11:14  stevens
+;; name changes for copyright assignment.  Added word-frags in complete-word.
+;; Horizontal scroll (John Conover). Query-replace matches words now.  bugs.
+;;
+;; Revision 2.25
+;; minor mods, upgraded ispell-message
+;;
+;; Revision 2.24
+;; query-replace more robust, messages, defaults, ispell-change-dict.
+;;
+;; Revision 2.23  1993/11/22 23:47:03  stevens
+;; ispell-message, Fixed highlighting, added menu-bar, fixed ispell-help, ...
+;;
+;; Revision 2.22
+;; Added 'u' command.  Fixed default in ispell-local-dictionary.
+;; fixed affix rules display.  Tib skipping more robust.  Contributions by
+;; Per Abraham (parser selection), Denis Howe, and Eberhard Mattes.
+;;
+;; Revision 2.21  1993/06/30 14:09:04  stevens
+;; minor bugs. (nroff word skipping fixed)
+;;
+;; Revision 2.20  1993/06/30 14:09:04  stevens
+;;
+;; Debugging and contributions by: Boris Aronov, Rik Faith, Chris Moore,
+;;  Kevin Rodgers, Malcolm Davis.
+;; Particular thanks to Michael Lipp, Jamie Zawinski, Phil Queinnec
+;;  and John Heidemann for suggestions and code.
+;; Major update including many tweaks.
+;; Many changes were integrations of suggestions.
+;; lookup-words rehacked to use call-process (Jamie).
+;; ispell-complete-word rehacked to be compatible with the rest of the
+;; system for word searching and to include multiple wildcards,
+;; and its own dictionary.
+;; query-replace capability added.  New options 'X', 'R', and 'A'.
+;; buffer-local modes for dictionary, word-spelling, and formatter-parsing.
+;; Many random bugs, like commented comments being skipped, fix to
+;; keep-choices-win, fix for math mode, added pipe mode choice,
+;; fixed 'q' command, ispell-word checks previous word and leave cursor
+;; in same location.  Fixed tib code which could drop spelling regions.
+;; Cleaned up setq calls for efficiency. Gave more context on window overlays.
+;; Assure context on ispell-command-loop.  Window lossage in look cmd fixed.
+;; Due to pervasive opinion, common-lisp package syntax removed. Display
+;; problem when not highlighting.
+;;
+;; Revision 2.19  1992/01/10  10:54:08  geoff
+;; Make another attempt at fixing the "Bogus, dude" problem.  This one is
+;; less elegant, but has the advantage of working.
+;;
+;; Revision 2.18  1992/01/07  10:04:52  geoff
+;; Fix the "Bogus, Dude" problem in ispell-word.
+;;
+;; Revision 2.17  1991/09/12  00:01:42  geoff
+;; Add some changes to make ispell-complete-word work better, though
+;; still not perfectly.
+;;
+;; Revision 2.16  91/09/04  18:00:52  geoff
+;; More updates from Sebastian, to make the multiple-dictionary support
+;; more flexible.
+;;
+;; Revision 2.15  91/09/04  17:30:02  geoff
+;; Sebastian Kremer's tib support
+;;
+;; Revision 2.14  91/09/04  16:19:37  geoff
+;; Don't do set-window-start if the move-to-window-line moved us
+;; downward, rather than upward.  This prevents getting the buffer all
+;; confused.  Also, don't use the "not-modified" function to clear the
+;; modification flag;  instead use set-buffer-modified-p.  This prevents
+;; extra messages from flashing.
+;;
+;; Revision 2.13  91/09/04  14:35:41  geoff
+;; Fix a spelling error in a comment.  Add code to handshake with the
+;; ispell process before sending anything to it.
+;;
+;; Revision 2.12  91/09/03  20:14:21  geoff
+;; Add Sebastian Kremer's multiple-language support.
+;;
+;;
+;; Walt Buehring
+;; Texas Instruments - Computer Science Center
+;; ARPA:  Buehring%TI-CSL@CSNet-Relay
+;; UUCP:  {smu, texsun, im4u, rice} ! ti-csl ! buehring
+;;
+;; ispell-region and associated routines added by
+;; Perry Smith
+;; pedz@bobkat
+;; Tue Jan 13 20:18:02 CST 1987
+;;
+;; extensively modified by Mark Davies and Andrew Vignaux
+;; {mark,andrew}@vuwcomp
+;; Sun May 10 11:45:04 NZST 1987
+;;
+;; Ken Stevens  ARPA: k.stevens@ieee.org
+;; Tue Jan  3 16:59:07 PST 1989
+;; This file has overgone a major overhaul to be compatible with ispell
+;; version 2.1.  Most of the functions have been totally rewritten, and
+;; many user-accessible variables have been added.  The syntax table has
+;; been removed since it didn't work properly anyway, and a filter is
+;; used rather than a buffer.  Regular expressions are used based on
+;; ispell's internal definition of characters (see ispell(4)).
+;; Some new updates:
+;; - Updated to version 3.0 to include terse processing.
+;; - Added a variable for the look command.
+;; - Fixed a bug in ispell-word when cursor is far away from the word
+;;   that is to be checked.
+;; - Ispell places the incorrect word or guess in the minibuffer now.
+;; - fixed a bug with 'l' option when multiple windows are on the screen.
+;; - lookup-words just didn't work with the process filter.  Fixed.
+;; - Rewrote the process filter to make it cleaner and more robust
+;;   in the event of a continued line not being completed.
+;; - Made ispell-init-process more robust in handling errors.
+;; - Fixed bug in continuation location after a region has been modified by
+;;   correcting a misspelling.
+;; Mon 17 Sept 1990
+;;
+;; Sebastian Kremer <sk@thp.uni-koeln.de>
+;; Wed Aug  7 14:02:17 MET DST 1991
+;; - Ported ispell-complete-word from Ispell 2 to Ispell 3.
+;; - Added ispell-kill-ispell command.
+;; - Added ispell-dictionary and ispell-dictionary-alist variables to
+;;   support other than default language.  See their docstrings and
+;;   command ispell-change-dictionary.
+;; - (ispelled it :-)
+;; - Added ispell-skip-tib variable to support the tib bibliography
+;;   program.
+
+
+;; **********************************************************************
+;; The following variables should be set according to personal preference
+;; and location of binaries:
+;; **********************************************************************
+
+;;  ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1
 
-;;;  ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1
 ;;; Code:
 
-(defvar ispell-highlight-p t
-  "*Highlight spelling errors when non-nil.")
+(defgroup ispell nil
+  "Spell checking using ispell"
+  :group 'processes)
 
-(defvar ispell-highlight-face 'highlight
+
+(defcustom ispell-highlight-p t
+  "*Highlight spelling errors when non-nil."
+  :type 'boolean
+  :group 'ispell)
+
+(defcustom ispell-highlight-face 'highlight
   "*The face used for Ispell highlighting.  For Emacses with overlays.
 Possible values are `highlight', `modeline', `secondary-selection',
 `region', and `underline'.
 This variable can be set by the user to whatever face they desire.
 It's most convenient if the cursor color and highlight color are
-slightly different.")
+slightly different."
+  :type 'face
+  :group 'ispell)
 
-(defvar ispell-check-comments nil
-  "*Spelling of comments checked when non-nil.")
+(defcustom ispell-check-comments t
+  "*If nil, don't check spelling of comments."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-query-replace-choices nil
+(defcustom ispell-query-replace-choices nil
   "*Corrections made throughout region when non-nil.
-Uses `query-replace' (\\[query-replace]) for corrections.")
+Uses `query-replace' (\\[query-replace]) for corrections."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-skip-tib nil
+(defcustom ispell-skip-tib nil
   "*Does not spell check `tib' bibliography references when non-nil.
 Skips any text between strings matching regular expressions
 `ispell-tib-ref-beginning' and `ispell-tib-ref-end'.
 
 TeX users beware:  Any field starting with [. will skip until a .] -- even
 your whole buffer -- unless you set `ispell-skip-tib' to nil.  That includes
-a [.5mm] type of number....")
+a [.5mm] type of number...."
+  :type 'boolean
+  :group 'ispell)
 
 (defvar ispell-tib-ref-beginning "[[<]\\."
   "Regexp matching the beginning of a Tib reference.")
@@ -344,18 +364,24 @@ a [.5mm] type of number....")
 (defvar ispell-tib-ref-end "\\.[]>]"
   "Regexp matching the end of a Tib reference.")
 
-(defvar ispell-keep-choices-win t
+(defcustom ispell-keep-choices-win t
   "*When not nil, the `*Choices*' window remains for spelling session.
-This minimizes redisplay thrashing.")
+This minimizes redisplay thrashing."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-choices-win-default-height 2
+(defcustom ispell-choices-win-default-height 2
   "*The default size of the `*Choices*' window, including status line.
-Must be greater than 1.")
+Must be greater than 1."
+  :type 'integer
+  :group 'ispell)
 
-(defvar ispell-program-name "ispell"
-  "Program invoked by \\[ispell-word] and \\[ispell-region] commands.")
+(defcustom ispell-program-name "ispell"
+  "Program invoked by \\[ispell-word] and \\[ispell-region] commands."
+  :type 'string
+  :group 'ispell)
 
-(defvar ispell-alternate-dictionary
+(defcustom ispell-alternate-dictionary
   (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2")
        ((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2")
        ((file-exists-p "/usr/dict/words") "/usr/dict/words")
@@ -363,10 +389,14 @@ Must be greater than 1.")
        ((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words")
        ((file-exists-p "/sys/dict") "/sys/dict")
        (t "/usr/dict/words"))
-  "*Alternate dictionary for spelling help.")
+  "*Alternate dictionary for spelling help."
+  :type 'file
+  :group 'ispell)
 
-(defvar ispell-complete-word-dict ispell-alternate-dictionary
-  "*Dictionary used for word completion.")
+(defcustom ispell-complete-word-dict ispell-alternate-dictionary
+  "*Dictionary used for word completion."
+  :type 'file
+  :group 'ispell)
 
 (defvar ispell-grep-command "egrep"
   "Name of the grep command for search processes.")
@@ -380,12 +410,16 @@ Some machines (like the NeXT) don't support \"-i\"")
   "Name of the look command for search processes.
 This must be an absolute file name.")
 
-(defvar ispell-look-p (file-exists-p ispell-look-command)
+(defcustom ispell-look-p (file-exists-p ispell-look-command)
   "*Non-nil means use `look' rather than `grep'.
-Default is based on whether `look' seems to be available.")
+Default is based on whether `look' seems to be available."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-have-new-look nil
-  "*Non-nil means use the `-r' option (regexp) when running `look'.")
+(defcustom ispell-have-new-look nil
+  "*Non-nil means use the `-r' option (regexp) when running `look'."
+  :type 'boolean
+  :group 'ispell)
 
 (defvar ispell-look-options (if ispell-have-new-look "-dfr" "-df")
   "String of command options for `ispell-look-command'.")
@@ -394,29 +428,42 @@ Default is based on whether `look' seems to be available.")
   "When non-nil, Emacs uses ptys to communicate with Ispell.
 When nil, Emacs uses pipes.")
 
-(defvar ispell-following-word nil
+(defcustom ispell-following-word nil
   "*Non-nil means `ispell-word' checks the word around or after point.
-Otherwise `ispell-word' checks the preceding word.")
+Otherwise `ispell-word' checks the preceding word."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-help-in-bufferp nil
+(defcustom ispell-help-in-bufferp nil
   "*Non-nil means display interactive keymap help in a buffer.
-Otherwise use the minibuffer.")
+Otherwise use the minibuffer."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-quietly nil
-  "*Non-nil means suppress messages in `ispell-word'.")
+(defcustom ispell-quietly nil
+  "*Non-nil means suppress messages in `ispell-word'."
+  :type 'boolean
+  :group 'ispell)
 
-(defvar ispell-format-word (function upcase)
+(defcustom ispell-format-word (function upcase)
   "*Formatting function for displaying word being spell checked.
-The function must take one string argument and return a string.")
+The function must take one string argument and return a string."
+  :type 'function
+  :group 'ispell)
 
 ;;;###autoload
-(defvar ispell-personal-dictionary nil
+(defcustom ispell-personal-dictionary nil
   "*File name of your personal spelling dictionary, or nil.
 If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used,
-where DICTNAME is the name of your default dictionary.")
+where DICTNAME is the name of your default dictionary."
+  :type '(choice file
+                (const :tag "default" nil))
+  :group 'ispell)
 
-(defvar ispell-silently-savep nil
-  "*When non-nil, save the personal dictionary without confirmation.")
+(defcustom ispell-silently-savep nil
+  "*When non-nil, save the personal dictionary without confirmation."
+  :type 'boolean
+  :group 'ispell)
 
 ;;; This variable contains the current dictionary being used if the ispell
 ;;; process is running.  Otherwise it contains the global default.
@@ -430,34 +477,42 @@ commands in the Emacs session, or else use the \\[ispell-change-dictionary]
 command to change it.  Otherwise, this variable only takes effect in a newly
 started Ispell process.")
 
-(defvar ispell-extra-args nil
+(defcustom ispell-extra-args nil
   "*If non-nil, a list of extra switches to pass to the Ispell program.
 For example, '(\"-W\" \"3\") to cause it to accept all 1-3 character
 words as correct.  See also `ispell-dictionary-alist', which may be used
-for language-specific arguments.")
+for language-specific arguments."
+  :type '(repeat string)
+  :group 'ispell)
+
+;;; The preparation of the menu bar menu must be autoloaded
+;;; because otherwise this file gets autoloaded every time Emacs starts
+;;; so that it can set up the menus and determine keyboard equivalents.
 
 ;;;###autoload
 (defvar ispell-dictionary-alist-1      ; sk  9-Aug-1991 18:28
   '((nil                               ; default (english.aff)
      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil)
-    ("english"                         ; make english explicitly selectable
+    ("english"                         ; make English explicitly selectable
      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil)
-    ("british"                         ; british version
+    ("british"                         ; British version
      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "british") nil)
+    ("american"                                ; American version
+     "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "american") nil)
     ("deutsch"                         ; deutsch.aff
      "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex")
     ("deutsch8"
      "[a-zA-Z\304\326\334\344\366\337\374]"
      "[^a-zA-Z\304\326\334\344\366\337\374]"
-     "[']" t ("-C" "-d" "deutsch") "~latin1")
+     "[']" t ("-C" "-d" "deutsch") "~latin1" iso-latin-1)
     ("nederlands"                              ; nederlands.aff
      "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
      "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
-     "[']" t ("-C") nil)
+     "[']" t ("-C") nil iso-latin-1)
     ("nederlands8"                             ; dutch8.aff
      "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
      "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
-     "[']" t ("-C") nil)))
+     "[']" t ("-C") nil iso-latin-1)))
 
 ;;;###autoload
 (defvar ispell-dictionary-alist-2
@@ -466,20 +521,21 @@ for language-specific arguments.")
      "[']" nil ("-C") nil)
     ("svenska8"                                ;8 bit swedish mode
      "[A-Za-z\345\344\366\305\304\366]"  "[^A-Za-z\345\344\366\305\304\366]"
-     "[']" nil ("-C" "-d" "svenska") "~list") ; Add `"-T" "list"' instead?
+     "[']" nil ("-C" "-d" "svenska") "~list" ; Add `"-T" "list"' instead?
+     iso-latin-1)
     ("francais7"
      "[A-Za-z]" "[^A-Za-z]" "[`'^---]" t nil nil)
     ("francais"                                ; francais.aff
      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
-     "[---']" t nil "~list")
+     "[---']" t nil "~list" iso-latin-1)
     ("francais-tex"                    ; francais.aff
      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
-     "[---'^`\"]" t nil "~tex")
+     "[---'^`\"]" t nil "~tex" iso-latin-1)
     ("dansk"                           ; dansk.aff
      "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]"
-     "" nil ("-C") nil)
+      "[']" nil ("-C") nil iso-latin-1)
     ))
 
 
@@ -503,15 +559,19 @@ word.
 
 NOT-CASECHARS is the opposite regexp of CASECHARS.
 
-OTHERCHARS is a regular expression of other characters that are valid
-in word constructs.  Otherchars cannot be adjacent to each other in a
-word, nor can they begin or end a word.  This implies we can't check
-\"Stevens'\" as a correct possessive and other correct formations.
-
+OTHERCHARS are characters in the NOT-CASECHARS set but which can be used to
+construct words in some special way.  If OTHERCHARS characters follow and
+precede characters from CASECHARS, they are parsed as part of a word,
+otherwise they become word-breaks.  As an example in English, assume the
+set ['] (as a regular expression) for OTHERCHARS.  Then \"they're\" and
+\"Steven's\" are parsed as single words including the \"'\" character, but
+\"Stevens'\" does not include the quote character as part of the word.
+If you want OTHERCHARS to be empty, use nil.
 Hint: regexp syntax requires the hyphen to be declared first here.
 
-MANY-OTHERCHARS-P is non-nil if many otherchars are to be allowed in a
-word instead of only one.
+MANY-OTHERCHARS-P is non-nil when multiple OTHERCHARS are allowed in a word.
+Otherwise only a single OTHERCHARS character is allowed to be part of any
+single word.
 
 ISPELL-ARGS is a list of additional arguments passed to the ispell
 subprocess.
@@ -529,7 +589,6 @@ Note that the CASECHARS and OTHERCHARS slots of the alist should
 contain the same character set as casechars and otherchars in the
 language.aff file \(e.g., english.aff\).")
 
-
 ;;;###autoload
 (defvar ispell-menu-map nil "Key map for ispell menu")
 
@@ -546,10 +605,9 @@ language.aff file \(e.g., english.aff\).")
 ;;; due to the fact that menu-bar is loaded much later than loaddefs.
 ;;;       ;; make sure this isn't Lucid Emacs
 ;;;       (featurep 'menu-bar)
-       (string-lessp "19" emacs-version)))
-
+       (not (string-match "Lucid" emacs-version))))
 
-;;; setup dictionary
+;;; Set up dictionary
 ;;;###autoload
 (if ispell-menu-map-needed
     (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist)))
@@ -645,24 +703,36 @@ language.aff file \(e.g., english.aff\).")
 
 
 ;;; The version must be 3.1 or greater for this version of ispell.el
-;;; There is an incompatibility between versin 3.1.12 and lower versions.
+;;; There is an incompatibility between version 3.1.12 and lower versions.
 (defconst ispell-required-version '("3.1." 12)
   "Ispell versions with which this version of ispell.el is known to work.")
 (defvar ispell-offset 1
   "Offset that maps protocol differences between ispell 3.1 versions.")
 
+(defun ispell-decode-string (str)
+  (let (coding-system)
+    (if (and enable-multibyte-characters
+            (setq coding-system (ispell-get-coding-system)))
+       (decode-coding-string str coding-system)
+    str)))
+
 (defun ispell-get-casechars ()
-  (nth 1 (assoc ispell-dictionary ispell-dictionary-alist)))
+  (ispell-decode-string
+   (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))))
 (defun ispell-get-not-casechars ()
-  (nth 2 (assoc ispell-dictionary ispell-dictionary-alist)))
+  (ispell-decode-string
+   (nth 2 (assoc ispell-dictionary ispell-dictionary-alist))))
 (defun ispell-get-otherchars ()
-  (nth 3 (assoc ispell-dictionary ispell-dictionary-alist)))
+  (ispell-decode-string
+   (nth 3 (assoc ispell-dictionary ispell-dictionary-alist))))
 (defun ispell-get-many-otherchars-p ()
   (nth 4 (assoc ispell-dictionary ispell-dictionary-alist)))
 (defun ispell-get-ispell-args ()
   (nth 5 (assoc ispell-dictionary ispell-dictionary-alist)))
 (defun ispell-get-extended-character-mode ()
   (nth 6 (assoc ispell-dictionary ispell-dictionary-alist)))
+(defun ispell-get-coding-system ()
+  (nth 7 (assoc ispell-dictionary ispell-dictionary-alist)))
 
 (defvar ispell-process nil
   "The process object for Ispell.")
@@ -736,9 +806,8 @@ a `~' followed by an extended-character mode -- such as `~.tex'.")
 
 (defvar ispell-skip-sgml nil
   "Skips spell checking of SGML tags and entity references when non-nil.
-This variable is set when major-mode is sgml-mode.")
+This variable is set when major-mode is sgml-mode or html-mode.")
 
-;;;###autoload
 (defvar ispell-local-pdict ispell-personal-dictionary
   "A buffer local variable containing the current personal dictionary.
 If non-nil, the value must be a string, which is a file name.
@@ -783,7 +852,8 @@ You can set this variable in hooks in your init file -- eg:
      (not (boundp 'epoch::version))
      (defalias 'ispell 'ispell-buffer))
 
-;;;###autoload (define-key global-map "\M-$" 'ispell-word)
+;;;###autoload
+(define-key global-map "\M-$" 'ispell-word)
 
 ;;;###autoload
 (defun ispell-word (&optional following quietly continue)
@@ -924,7 +994,7 @@ Word syntax described by `ispell-dictionary-alist' (which see)."
        (error "No word found to check!"))
     (setq start (match-beginning 0)
          end (point)
-         word (buffer-substring start end))
+         word (buffer-substring-no-properties start end))
     (list word start end)))
 
 
@@ -968,12 +1038,14 @@ used."
                                ispell-choices-win-default-height))
        (command-characters '( ?  ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m ))
        (skipped 0)
+       (window (selected-window))
+       (dedicated (window-dedicated-p (selected-window)))
        char num result textwin highlighted)
 
     ;; setup the *Choices* buffer with valid data.
     (save-excursion
       (set-buffer (get-buffer-create ispell-choices-buffer))
-      (setq mode-line-format "--  %b  --")
+      (setq mode-line-format (concat "--  %b  --  word: " word))
       (erase-buffer)
       (if guess
          (progn
@@ -1052,8 +1124,9 @@ used."
                result
                (progn
                  (undo-boundary)
-                 (message (concat "C-h or ? for more options; SPC to leave "
-                                  "unchanged, Character to replace word"))
+                 (let (message-log-max)
+                   (message (concat "C-h or ? for more options; SPC to leave "
+                                    "unchanged, Character to replace word")))
                  (let ((inhibit-quit t))
                    (setq char (if (fboundp 'read-char-exclusive)
                                   (read-char-exclusive)
@@ -1098,7 +1171,7 @@ used."
                   ;; Quit and preserve point.
                   ((= char ?X)
                    (ispell-pdict-save ispell-silently-savep)
-                   (message
+                   (message "%s"
                     (substitute-command-keys
                      (concat "Spell-checking suspended;"
                              " use C-u \\[ispell-word] to resume")))
@@ -1126,7 +1199,9 @@ used."
                              (erase-buffer)
                              (setq count ?0
                                    skipped 0
-                                   mode-line-format "--  %b  --"
+                                   mode-line-format (concat
+                                                     "--  %b  --  word: "
+                                                     new-word)
                                    miss (lookup-words new-word)
                                    choices miss)
                              (while (and choices ; adjust choices window.
@@ -1192,7 +1267,8 @@ used."
       (if ispell-highlight-p           ; unhighlight
          (save-window-excursion
            (select-window textwin)
-           (ispell-highlight-spelling-error start end))))))
+           (ispell-highlight-spelling-error start end)))
+      (set-window-dedicated-p window dedicated))))
 
 
 ;;;###autoload
@@ -1248,6 +1324,9 @@ SPC:   Accept word this time.
               (if (string-lessp "19" emacs-version)
                   (message nil))
               (enlarge-window 2)
+              ;; Make sure we display the minibuffer
+              ;; in this window, not some other.
+              (set-minibuffer-window (selected-window))
               (insert (concat help-1 "\n" help-2 "\n" help-3))))
        (sit-for 5)
        (erase-buffer)))))
@@ -1315,7 +1394,7 @@ Optional second argument contains the dictionary to use; the default is
 ;;;   multiple lines.
 ;;; "ispell-filter-continue" is true when we have received only part of a
 ;;;   line as output from a generating function ("output" did not end with \n)
-;;; NOTE THAT THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESNT END WITH \n!
+;;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
 ;;;   This is the case when a process dies or fails. The default behavior
 ;;;   in this case treats the next input received as fresh input.
 
@@ -1361,7 +1440,7 @@ otherwise it is displayed normally."
        (inhibit-quit t)                ; inhibit interrupt processing here.
        (buffer-undo-list t))           ; don't clutter the undo list.
     (delete-region start end)
-    (insert-char ?  (- end start))     ; mimimize amount of redisplay
+    (insert-char ?  (- end start))     ; minimize amount of redisplay
     (sit-for 0)                                ; update display
     (if highlight (setq inverse-video (not inverse-video))) ; toggle video
     (delete-region start end)          ; delete whitespace
@@ -1423,6 +1502,12 @@ scrolling the current window.  Leave the new window selected."
       (if (string-match "19\.9.*Lucid" (emacs-version))
          (setq height (1+ height)))
       (split-window nil height)
+      ;; The lower of the two windows is the logical successor
+      ;; of the original window, so move the dedicated flag to there.
+      ;; The new upper window should not be dedicated.
+      (set-window-dedicated-p (next-window)
+                             (window-dedicated-p (selected-window)))
+      (set-window-dedicated-p (selected-window) nil)
       (set-window-start (next-window) top))))
 
 
@@ -1544,6 +1629,9 @@ scrolling the current window.  Leave the new window selected."
          ispell-filter-continue nil
          ispell-process-directory default-directory)
     (set-process-filter ispell-process 'ispell-filter)
+    (if (and enable-multibyte-characters
+            ispell-dictionary)
+       (set-process-coding-system ispell-process (ispell-get-coding-system)))
     (accept-process-output ispell-process) ; Get version ID line
     (cond ((null ispell-filter)
           (error "%s did not output version line" ispell-program-name))
@@ -1587,7 +1675,7 @@ With NO-ERROR, just return non-nil if there was no Ispell running."
     nil))
 
 
-;;; ispell-change-dictionary is set in some people's hooks.  Maybe it should
+;;; ispell-change-dictionary is set in some people's hooks.  Maybe this should
 ;;;  call ispell-init-process rather than wait for a spell checking command?
 
 ;;;###autoload
@@ -1621,7 +1709,7 @@ With prefix argument, set the default directory."
                   (setq ispell-dictionary dict))
               (if (null arg)           ; set local dictionary
                   (setq ispell-local-dictionary dict)))
-          (error "Illegal dictionary: %s" dict))
+          (error "Invalid Ispell dictionary: %s" dict))
         (ispell-kill-ispell t)
         (message "(Next %sIspell command will use %s dictionary)"
                  (cond ((equal ispell-local-dictionary ispell-dictionary)
@@ -1693,7 +1781,7 @@ With prefix argument, set the default directory."
                           (re-search-forward ispell-tib-ref-beginning end t)
                           (setq ref-type 'tib))
                      (and ispell-skip-sgml
-                          (search-forward "[<&]" end t)
+                          (re-search-forward "[<&]" end t)
                           (setq ref-type 'sgml)))
                  (if (or (and (eq 'tib ref-type) ; tib tag is 2 chars.
                               (= (- (point) 2) start))
@@ -1707,7 +1795,7 @@ With prefix argument, set the default directory."
                            (not
                             (re-search-forward ispell-tib-ref-end reg-end t)))
                           (and (eq 'sgml ref-type)
-                               (not (search-forward "[>;]" reg-end t))))
+                               (not (re-search-forward "[>;]" reg-end t))))
                          (progn
                            (ispell-pdict-save ispell-silently-savep)
                            (ding)
@@ -1753,8 +1841,20 @@ With prefix argument, set the default directory."
                      (while (and (not ispell-quit) ispell-filter)
                        (setq poss (ispell-parse-output (car ispell-filter)))
                        (if (listp poss) ; spelling error occurred.
-                           (let* ((word-start (+ start offset-change
-                                                 (car (cdr poss))))
+                           (let* ((word-start
+                                   (if (and enable-multibyte-characters
+                                            (ispell-get-coding-system))
+                                       ;; OFFSET returned by ispell
+                                       ;; counts non-ASCII chars as
+                                       ;; one, so just adding OFFSET
+                                       ;; to START will cause an
+                                       ;; error.
+                                       (save-excursion
+                                         (goto-char (+ start offset-change))
+                                         (forward-char (car (cdr poss)))
+                                         (point))
+                                     (+ start offset-change
+                                        (car (cdr poss)))))
                                   (word-end (+ word-start
                                                (length (car poss))))
                                   replace)
@@ -1851,10 +1951,9 @@ With prefix argument, set the default directory."
                                        offset-change (+ offset-change change)
                                        end (+ end change)))))
                              (if (not ispell-quit)
-                                 (message
-                                  (concat "Continuing spelling check using "
-                                          (or ispell-dictionary "default")
-                                          " dictionary...")))
+                                 (let (message-log-max)
+                                   (message "Continuing spelling check using %s dictionary..."
+                                            (or ispell-dictionary "default"))))
                              (sit-for 0)))
                        ;; finished with line!
                        (setq ispell-filter (cdr ispell-filter)))))
@@ -1883,6 +1982,25 @@ With prefix argument, set the default directory."
       (message "Spell-checking done"))))
 
 
+;;;###autoload
+(defun ispell-comments-and-strings ()
+  "Check comments and strings in the current buffer for spelling errors."
+  (interactive)
+  (goto-char (point-min))
+  (let (state done)
+    (while (not done)
+      (setq done t)
+      (setq state (parse-partial-sexp (point) (point-max)
+                                     nil nil state 'syntax-table))
+      (when (or (nth 3 state) (nth 4 state))
+       (let ((start (point)))
+         (setq state (parse-partial-sexp start (point-max)
+                                         nil nil state 'syntax-table))
+         (when (or (nth 3 state) (nth 4 state))
+           (error "Unterminated string or comment."))
+         (save-excursion
+           (setq done (not (ispell-region start (point))))))))))
+
 
 ;;;###autoload
 (defun ispell-buffer ()
@@ -2038,35 +2156,64 @@ warns you if the previous word is incorrectly spelled."
   (mapconcat (function identity)
             '(
               ;; Matches postscript files.
-              "^%!PS-Adobe-[23].0"
+              "^%!PS-Adobe-[123].0"
               ;; Matches uuencoded text
               "^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM"
               ;; Matches shell files (esp. auto-decoding)
               "^#! /bin/[ck]?sh"
               ;; Matches context difference listing
               "\\(diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*"
+               ;; Matches reporter.el bug report
+               "^current state:\n==============\n"
               ;; Matches "----------------- cut here"
-              ;; and "------- Start of forwarded message"
-              "^[-=_]+\\s ?\\(cut here\\|Start of forwarded message\\)")
+               ;; and "------- Start of forwarded message",
+              ;; or either one with "- " in front.
+               "^\\(- \\)?[-=_]+\\s ?\\(cut here\\|\\(Start of \\)?forwarded message\\)")
             "\\|")
   "*End of text which will be checked in ispell-message.
 If it is a string, limit at first occurrence of that regular expression.
 Otherwise, it must be a function which is called to get the limit.")
 
 
+(defvar ispell-message-start-skip
+  (mapconcat (function identity)
+            '(
+              ;; Matches forwarded messages
+              "^---* Forwarded Message"
+              ;; Matches PGP Public Key block
+              "^---*BEGIN PGP [A-Z ]*--*"
+              )
+            "\\|")
+  "Spelling is skipped inside these start/end groups by ispell-message.
+Assumed that blocks are not mutually inclusive.")
+
+
+(defvar ispell-message-end-skip
+  (mapconcat (function identity)
+            '(
+              ;; Matches forwarded messages
+              "^--- End of Forwarded Message"
+              ;; Matches PGP Public Key block
+              "^---*END PGP [A-Z ]*--*"
+              )
+            "\\|")
+  "Spelling is skipped inside these start/end groups by ispell-message.
+Assumed that blocks are not mutually inclusive.")
+
+
 ;;;###autoload
 (defun ispell-message ()
   "Check the spelling of a mail message or news post.
 Don't check spelling of message headers except the Subject field.
 Don't check included messages.
 
-To abort spell checking of a message REGION and send the message anyway,
-use the `x' or `q' command.  (Any subsequent regions will be checked.)
+To abort spell checking of a message region and send the message anyway,
+use the `x' command.  (Any subsequent regions will be checked.)
 The `X' command aborts the message send so that you can edit the buffer.
 
 To spell-check whenever a message is sent, include the appropriate lines
 in your .emacs file:
-   (add-hook 'news-inews-hook 'ispell-message)
+   (add-hook 'message-send-hook 'ispell-message)
    (add-hook 'mail-send-hook  'ispell-message)
    (add-hook 'mh-before-send-letter-hook 'ispell-message)
 
@@ -2098,11 +2245,16 @@ You can bind this to the key C-c i in GNUS or mail by adding to
             ((featurep 'sc)            ; sc 2.3
              (concat "\\(" sc-cite-regexp "\\)" "\\|"
                      (ispell-non-empty-string sc-reference-tag-string)))
-            ((equal major-mode 'news-reply-mode) ;GNUS
+            ((equal major-mode 'news-reply-mode) ;GNUS 4 & below
              (concat "In article <" "\\|"
                      (if mail-yank-prefix
                          (ispell-non-empty-string mail-yank-prefix)
                        "^   \\|^\t")))
+            ((equal major-mode 'message-mode) ;GNUS 5
+             (concat ".*@.* writes:$" "\\|"
+                     (if mail-yank-prefix
+                         (ispell-non-empty-string mail-yank-prefix)
+                       "^   \\|^\t")))
             ((equal major-mode 'mh-letter-mode) ; mh mail message
              (ispell-non-empty-string mh-ins-buf-prefix))
             ((not internal-messagep)   ; Assume n sent us this message.
@@ -2155,20 +2307,22 @@ You can bind this to the key C-c i in GNUS or mail by adding to
                   ;; Check the next batch of lines that *aren't* cited.
                   (end-c (and (re-search-forward cite-regexp-end limit 'end)
                               (match-beginning 0)))
-                  ;; skip a forwarded message
+                  ;; Skip a block of included text.
                   (end-fwd (and (goto-char start)
-                                (re-search-forward "---* Forwarded Message"
-                                                   limit 'end)))
+                                (re-search-forward ispell-message-start-skip
+                                                   limit 'end)
+                                (progn (beginning-of-line)
+                                       (point))))
                   (end (or (and end-c end-fwd (min end-c end-fwd))
                            end-c end-fwd
-                           ;; defalut to limit of text.
+                           ;; default to limit of text.
                            (marker-position limit))))
              (goto-char start)
              (ispell-region start end)
              (if (and end-fwd (= end end-fwd))
                  (progn
                    (goto-char end)
-                   (search-forward "--- End of Forwarded Message" limit 'end))
+                   (re-search-forward ispell-message-end-skip limit 'end))
                (goto-char end)))))
       (set-marker limit nil))))
 
@@ -2203,8 +2357,8 @@ Includes latex/nroff modes and extended character mode."
          (eq ispell-parser 'tex))
       (process-send-string ispell-process "+\n") ; set ispell mode to tex
     (process-send-string ispell-process "-\n"))        ; set mode to normal (nroff)
-  ;; Hard-wire test for SGML mode.
-  (setq ispell-skip-sgml (eq 'sgml-mode major-mode))
+  ;; Hard-wire test for SGML & HTML mode.
+  (setq ispell-skip-sgml (memq major-mode '(sgml-mode html-mode)))
   ;; Set default extended character mode for given buffer, if any.
   (let ((extended-char-mode (ispell-get-extended-character-mode)))
     (if extended-char-mode
@@ -2226,7 +2380,7 @@ Includes latex/nroff modes and extended character mode."
                 (process-send-string ispell-process "-\n~nroff"))
                ((string-match "~" string) ; Set extended character mode.
                 (process-send-string ispell-process (concat string "\n")))
-               (t (message "Illegal Ispell Parsing argument!")
+               (t (message "Invalid Ispell Parsing argument!")
                   (sit-for 2))))))))
 
 
@@ -2247,13 +2401,15 @@ Both should not be used to define a buffer-local dictionary."
        (setq end (save-excursion (end-of-line) (point)))
        (if (re-search-forward " *\\([^ \"]+\\)" end t)
            (setq ispell-local-dictionary
-                 (buffer-substring (match-beginning 1) (match-end 1)))))
+                 (buffer-substring-no-properties (match-beginning 1)
+                                                 (match-end 1)))))
       (goto-char (point-min))
       (while (search-forward ispell-pdict-keyword nil t)
        (setq end (save-excursion (end-of-line) (point)))
        (if (re-search-forward " *\\([^ \"]+\\)" end t)
            (setq ispell-local-pdict
-                 (buffer-substring (match-beginning 1) (match-end 1)))))))
+                 (buffer-substring-no-properties (match-beginning 1)
+                                                 (match-end 1)))))))
   ;; Reload if new personal dictionary defined.
   (if (and ispell-local-pdict
           (not (equal ispell-local-pdict ispell-personal-dictionary)))
@@ -2328,7 +2484,7 @@ Both should not be used to define a buffer-local dictionary."
   reg-end)
 
 
-(defconst ispell-version "2.36 -- Mon Feb  6 17:39:38 EST 1995")
+(defconst ispell-version "2.37 -- Tue Jun 13 12:05:28 EDT 1995")
 
 (provide 'ispell)
 
@@ -2345,7 +2501,7 @@ Both should not be used to define a buffer-local dictionary."
 ;;; Local Variables:
 ;;; mode: emacs-lisp
 ;;; comment-column: 40
-;;; ispell-local-dictionary: "english"
+;;; ispell-local-dictionary: "american"
 ;;; End: