Dateianhang 'ispell.el'

Herunterladen

   1 ;;; ispell.el --- Interface to International Ispell Versions 3.1 and 3.2
   2 
   3 ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
   4 
   5 ;; Author:	     Ken Stevens <k.stevens@ieee.org>
   6 ;; Maintainer:	     Ken Stevens <k.stevens@ieee.org>
   7 ;; Stevens Mod Date: Mon Jan  7 12:32:44 PST 2003
   8 ;; Stevens Revision: 3.6
   9 ;; Status          : Release with 3.1.12+ and 3.2.0+ ispell.
  10 ;; Bug Reports     : ispell-el-bugs@itcorp.com
  11 ;; Web Site        : http://kdstevens.com/~stevens/ispell-page.html
  12 ;; Keywords: unix wp
  13 
  14 ;; This file is part of GNU Emacs.
  15 
  16 ;; GNU Emacs is free software; you can redistribute it and/or modify
  17 ;; it under the terms of the GNU General Public License as published by
  18 ;; the Free Software Foundation; either version 2, or (at your option)
  19 ;; any later version.
  20 
  21 ;; GNU Emacs is distributed in the hope that it will be useful,
  22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24 ;; GNU General Public License for more details.
  25 
  26 ;; You should have received a copy of the GNU General Public License
  27 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  28 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  29 ;; Boston, MA 02111-1307, USA.
  30 
  31 ;; Note: version numbers and time stamp are not updated
  32 ;;   when this file is edited for release with GNU emacs.
  33 
  34 ;;; Commentary:
  35 
  36 ;; INSTRUCTIONS
  37 
  38 ;;   This code contains a section of user-settable variables that you
  39 ;; should inspect prior to installation.  Look past the end of the history
  40 ;; list.  Set them up for your locale and the preferences of the majority
  41 ;; of the users.  Otherwise the users may need to set a number of variables
  42 ;; themselves.
  43 ;;   You particularly may want to change the default dictionary for your
  44 ;; country and language.
  45 ;;   Most dictionary changes should be made in this file so all users can
  46 ;; enjoy them.  Local or modified dictionaries are supported in your .emacs
  47 ;; file.  Modify the variable `ispell-local-dictionary-alist' to include
  48 ;; these dictionaries, and they will be installed when ispell.el is loaded.
  49 
  50 ;;  Depending on the mail system you use, you may want to include these:
  51 ;;  (add-hook 'news-inews-hook 'ispell-message)
  52 ;;  (add-hook 'mail-send-hook  'ispell-message)
  53 ;;  (add-hook 'mh-before-send-letter-hook 'ispell-message)
  54 
  55 ;;   Ispell has a TeX parser and a nroff parser (the default).
  56 ;; The parsing is controlled by the variable ispell-parser.  Currently
  57 ;; it is just a "toggle" between TeX and nroff, but if more parsers are
  58 ;; added it will be updated.  See the variable description for more info.
  59 
  60 
  61 ;; TABLE OF CONTENTS
  62 
  63 ;;   ispell-word
  64 ;;   ispell-region
  65 ;;   ispell-buffer
  66 ;;   ispell-message
  67 ;;   ispell-comments-and-strings
  68 ;;   ispell-continue
  69 ;;   ispell-complete-word
  70 ;;   ispell-complete-word-interior-frag
  71 ;;   ispell-change-dictionary
  72 ;;   ispell-kill-ispell
  73 ;;   ispell-pdict-save
  74 ;;   ispell-skip-region-alist
  75 
  76 ;; Commands in ispell-region:
  77 ;; Character replacement: Replace word with choice.  May query-replace.
  78 ;; ` ': Accept word this time.
  79 ;; `i': Accept word and insert into private dictionary.
  80 ;; `a': Accept word for this session.
  81 ;; `A': Accept word and place in buffer-local dictionary.
  82 ;; `r': Replace word with typed-in value.  Rechecked.
  83 ;; `R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
  84 ;; `?': Show these commands
  85 ;; `x': Exit spelling buffer.  Move cursor to original point.
  86 ;; `X': Exit spelling buffer.  Leaves cursor at the current point, and permits
  87 ;;      the check to be completed later.
  88 ;; `q': Quit spelling session (Kills ispell process).
  89 ;; `l': Look up typed-in replacement in alternate dictionary.  Wildcards okay.
  90 ;; `u': Like `i', but the word is lower-cased first.
  91 ;; `m': Place entered value in personal dictionary, then recheck current word.
  92 ;; `C-l': redraws screen
  93 ;; `C-r': recursive edit
  94 ;; `C-z': suspend emacs or iconify frame
  95 
  96 ;; Buffer-Local features:
  97 ;; There are a number of buffer-local features that can be used to customize
  98 ;;  ispell for the current buffer.  This includes language dictionaries,
  99 ;;  personal dictionaries, parsing, and local word spellings.  Each of these
 100 ;;  local customizations are done either through local variables, or by
 101 ;;  including the keyword and argument(s) at the end of the buffer (usually
 102 ;;  prefixed by the comment characters).  See the end of this file for
 103 ;;  examples.  The local keywords and variables are:
 104 
 105 ;;  ispell-dictionary-keyword   language-dictionary
 106 ;;      uses local variable ispell-local-dictionary
 107 ;;  ispell-pdict-keyword        personal-dictionary
 108 ;;      uses local variable ispell-local-pdict
 109 ;;  ispell-parsing-keyword      mode-arg extended-char-arg
 110 ;;  ispell-words-keyword        any number of local word spellings
 111 
 112 ;; Region skipping:
 113 ;;  Place new regular expression definitions of regions you prefer not to
 114 ;;  spell check in `ispell-skip-region-alist'.  Mode-dependent features can
 115 ;;  be added to latex by modifying `ispell-tex-skip-alists'.
 116 ;;  `ispell-message' contains some custom skipping code for e-mail messages.
 117 
 118 ;; BUGS:
 119 ;;  Need a way to select between different character mappings without separate
 120 ;;    dictionary entries.
 121 ;;  Multi-byte characters if not defined by current dictionary may result in the
 122 ;;    evil "misalignment error" in some versions of MULE emacs.
 123 ;;  On some versions of emacs, growing the minibuffer fails.
 124 ;;    see `ispell-help-in-bufferp'.
 125 ;;  Recursive edits (?C-r or ?R) inside a keyboard text replacement check (?r)
 126 ;;    can cause misalignment errors.
 127 
 128 ;; HISTORY
 129 
 130 ;; Modifications made in latest versions:
 131 
 132 ;; Revision 3.6 2003/01/07 12:32:44	kss
 133 ;; Removed extra -d LIB in dictionary defs. (Pavel Janik)
 134 ;; Filtered process calls with duplicate dictionary entries.
 135 ;; Fixed bug where message-text-end is inside a mime skipped region.
 136 ;; Minor fixes to get ispell menus right in XEmacs
 137 ;; Fixed skip regexp so it doesn't match stuff like `/.\w'.
 138 ;; Detecting dictionary change not working.  Fixed.  kss
 139 ;; function `ispell-change-dictionary' now only completes valid dicts.
 140 
 141 ;; Revision 3.5 2001/7/11 18:43:57	kss
 142 ;; Added fix for aspell to work in XEmacs (check-ispell-version).
 143 ;; Added Portuguese dictionary definition.
 144 ;; New feature: MIME mail message support, Fcc support.
 145 ;; Bug fix: retain comment syntax on lines with region skipping. (TeX $ bug...)
 146 ;; Improved allocation for graphic mode lines.  (Miles Bader)
 147 ;; Support -v flag for old versions of aspell.  (Eli Zaretskii)
 148 ;; Clear minibuffer on ^G from ispell-help (Tak Ota)
 149 
 150 ;; Revision 3.4 2000/8/4 09:41:50	kss
 151 ;; Support new color display functions.
 152 ;; Fixed misalignment offset bug when replacing a string after a shift made.
 153 ;; Set to standard Author/Maintainer heading,
 154 ;; ensure localwords lists are separated from the text by newline. (Dave Love)
 155 ;; Added dictionary definition for Italian (William Deakin)
 156 ;; HTML region skipping greatly improved. (Chuck D. Phillips)
 157 ;; improved menus.  Fixed regexp matching http/email addresses.
 158 ;; one arg always for XEmacs sleep-for (gunnar Evermann)
 159 ;; support for synchronous processes (Eli Zaretskii)
 160 
 161 ;; Revision 3.3  1999/11/29 11:38:34     kss
 162 ;; Only word replacements entered in from the keyboard are rechecked.
 163 ;; This fixes a bug in tex parsing and misalignment.
 164 ;; Exceptions exist for recursive edit and query-replace, with tex error
 165 ;; condition tested.  Recursive editing improved.
 166 ;; XEmacs repair for when `enable-multibyte-characters' defined - Didier Verna.
 167 ;; ispell-help fixed for XEmacs.  Choices minibuffer now displayed in XEmacs.
 168 ;; Only list valid dictionaries in Spell menu.  Russian dictionary doesn't allow
 169 ;; run-together words, and uses koi8-r font.  Don't skip text in html <TT>
 170 ;; fonts.
 171 
 172 ;; Revision 3.2  1999/5/7 14:25:14	kss
 173 ;; Accept ispell versions 3.X.Y where X>=1
 174 ;; fine tuned latex region skipping.  Fixed bug in ispell-word that did not
 175 ;; point in right place on words < 2 chars.  Simplified ispell-minor-mode.
 176 ;; Fixed bug in TeX parsing when math commands are in the comments.
 177 ;; Removed calls to `when' macro.
 178 
 179 ;; Revision 3.1  1998/12/1 13:21:52	kss
 180 ;; Improved and fixed customize support.
 181 ;; Improved and fixed comments in variables and messages.
 182 ;; A coding system is now required for all languages.
 183 ;; casechars improved for castellano, castellano8, and norsk dictionaries.
 184 ;; Dictionary norsk7-tex removed.  Dictionary polish added.
 185 ;; Dictionaries redefined at load-time to support dictionary changes.
 186 ;; Menu redefined at load time to support dictionary changes.
 187 ;; ispell-check-version added as an alias for `check-ispell-version'.
 188 ;; Spelling suggestions returned in order generated by ispell.
 189 ;; Small bug fixed in matching ispell error messages.
 190 ;; Robustness added to ensure `case-fold-search' doesn't get redefined.
 191 ;; Fixed bug that didn't respect case of word in `ispell-complete-word'.
 192 ;; Multibyte character coding support added for process interactions.
 193 ;; Ensure ispell process has terminated before starting new process.
 194 ;;  This can otherwise confuse process filters and hang ispell.
 195 ;; Improved skipping support for SGML.
 196 ;; Fixed bug using ^M rather than \r in `ispell-minor-check'.
 197 ;; Improved message reference matching in `ispell-message'.
 198 ;; Fixed bug in returning to nroff mode from tex mode.
 199 
 200 
 201 ;;; Code:
 202 
 203 ;;; Custom.el macros require recompiling this when they are not present.
 204 ;;; Add in backward compatible custom support.
 205 (eval-when-compile
 206   (if (not (fboundp 'defcustom))
 207       (defmacro defcustom (symbol value doc &rest args)
 208 	"Empty replacement for defcustom when not supplied."
 209 	`(defvar ,symbol ,value ,doc))))
 210 
 211 (if (fboundp 'defgroup)
 212     (defgroup ispell nil
 213       "User variables for emacs ispell interface."
 214       :group 'applications))
 215 
 216 (if (not (fboundp 'buffer-substring-no-properties))
 217     (defun buffer-substring-no-properties (start end)
 218       (buffer-substring start end)))
 219 
 220 ;;;###autoload
 221 (defconst xemacsp (string-match "Lucid\\|XEmacs" emacs-version)
 222   "Non nil if using XEmacs.")
 223 
 224 ;;;###autoload
 225 (defconst version18p (string-match "18\\.[0-9]+\\.[0-9]+" emacs-version)
 226   "Non nil if using emacs version 18.")
 227 
 228 ;;;###autoload
 229 (defconst version20p (string-match "20\\.[0-9]+\\.[0-9]+" emacs-version)
 230   "Non nil if using emacs version 20.")
 231 
 232 (and (not version18p)
 233      (not (boundp 'epoch::version))
 234      (defalias 'ispell-check-version 'check-ispell-version))
 235 
 236 
 237 ;;; **********************************************************************
 238 ;;; The following variables should be set according to personal preference
 239 ;;; and location of binaries:
 240 ;;; **********************************************************************
 241 
 242 
 243 ;;;  ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1+
 244 
 245 (defcustom ispell-highlight-p 'block
 246   "*Highlight spelling errors when non-nil.
 247 When set to `block', assumes a block cursor with TTY displays."
 248   :type '(choice (const block) (const :tag "off" nil) (const :tag "on" t))
 249   :group 'ispell)
 250 
 251 (defcustom ispell-highlight-face 'highlight
 252   "*The face used for Ispell highlighting.  For Emacses with overlays.
 253 Possible values are `highlight', `modeline', `secondary-selection',
 254 `region', and `underline'.
 255 This variable can be set by the user to whatever face they desire.
 256 It's most convenient if the cursor color and highlight color are
 257 slightly different."
 258   :type 'face
 259   :group 'ispell)
 260 
 261 (defcustom ispell-check-comments t
 262   "*Spelling of comments checked when non-nil.
 263 When set to `exclusive', ONLY comments are checked.  (For code comments).
 264 Warning!  Not checking comments, when a comment start is embedded in strings,
 265 may produce undesired results."
 266   :type '(choice (const exclusive) (const :tag "off" nil) (const :tag "on" t))
 267   :group 'ispell)
 268 
 269 (defcustom ispell-query-replace-choices nil
 270   "*Corrections made throughout region when non-nil.
 271 Uses `query-replace' (\\[query-replace]) for corrections."
 272   :type 'boolean
 273   :group 'ispell)
 274 
 275 (defcustom ispell-skip-tib nil
 276   "*Does not spell check `tib' bibliography references when non-nil.
 277 Skips any text between strings matching regular expressions
 278 `ispell-tib-ref-beginning' and `ispell-tib-ref-end'.
 279 
 280 TeX users beware:  Any field starting with [. will skip until a .] -- even
 281 your whole buffer -- unless you set `ispell-skip-tib' to nil.  That includes
 282 a [.5mm] type of number...."
 283   :type 'boolean
 284   :group 'ispell)
 285 
 286 (defvar ispell-tib-ref-beginning "[[<]\\."
 287   "Regexp matching the beginning of a Tib reference.")
 288 
 289 (defvar ispell-tib-ref-end "\\.[]>]"
 290   "Regexp matching the end of a Tib reference.")
 291 
 292 (defcustom ispell-keep-choices-win t
 293   "*When not nil, the `*Choices*' window remains for spelling session.
 294 This minimizes redisplay thrashing."
 295   :type 'boolean
 296   :group 'ispell)
 297 
 298 (defcustom ispell-choices-win-default-height 2
 299   "*The default size of the `*Choices*' window, including mode line.
 300 Must be greater than 1."
 301   :type 'integer
 302   :group 'ispell)
 303 
 304 (defcustom ispell-program-name "ispell"
 305   "Program invoked by \\[ispell-word] and \\[ispell-region] commands."
 306   :type 'string
 307   :group 'ispell)
 308 
 309 (defcustom ispell-alternate-dictionary
 310   (cond ((file-exists-p "/usr/lib/ispell") "/usr/lib/ispell")
 311 	((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2")
 312 	((file-exists-p "/usr/dict/words") "/usr/dict/words")
 313 	((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words")
 314 	((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words")
 315 	((file-exists-p "/usr/share/lib/dict/words")
 316 	 "/usr/share/lib/dict/words")
 317 	((file-exists-p "/sys/dict") "/sys/dict")
 318 	(t "/usr/dict/words"))
 319   "*Alternate dictionary for spelling help."
 320   :type '(choice file (const :tag "None" nil))
 321   :group 'ispell)
 322 
 323 (defcustom ispell-complete-word-dict ispell-alternate-dictionary
 324   "*Dictionary used for word completion."
 325   :type '(choice file (const :tag "None" nil))
 326   :group 'ispell)
 327 
 328 (defcustom ispell-message-dictionary-alist nil
 329   "*List used by `ispell-message' to select a new dictionary.
 330 It consists of pairs (REGEXP . DICTIONARY).  If REGEXP is found
 331 in the message headers, `ispell-local-dictionary' will be set to
 332 DICTIONARY if `ispell-local-dictionary' is not buffer-local.
 333 E.g. you may use the following value:
 334   '((\"^Newsgroups:[ \\t]*de\\\\.\" . \"deutsch8\")
 335     (\"^To:[^\\n,]+\\\\.de[ \\t\\n,>]\" . \"deutsch8\"))"
 336   :type '(repeat (cons regexp string))
 337   :group 'ispell)
 338 
 339 
 340 (defcustom ispell-message-fcc-skip 50000
 341   "*Query before saving Fcc message copy if attachment larger than this value.
 342 Nil always stores Fcc copy of message."
 343   :type '(choice integer (const :tag "off" nil))
 344   :group 'ispell)
 345 
 346 
 347 (defcustom ispell-grep-command "egrep"
 348   "Name of the grep command for search processes."
 349   :type 'string
 350   :group 'ispell)
 351 
 352 (defcustom ispell-grep-options "-i"
 353   "String of options to use when running the program in `ispell-grep-command'.
 354 Should probably be \"-i\" or \"-e\".
 355 Some machines (like the NeXT) don't support \"-i\""
 356   :type 'string
 357   :group 'ispell)
 358 
 359 (defcustom ispell-look-command
 360   (cond ((file-exists-p "/bin/look") "/bin/look")
 361 	((file-exists-p "/usr/local/bin/look") "/usr/local/bin/look")
 362 	((file-exists-p "/usr/bin/look") "/usr/bin/look")
 363 	(t "look"))
 364   "Name of the look command for search processes.
 365 This must be an absolute file name."
 366   :type 'file
 367   :group 'ispell)
 368 
 369 (defcustom ispell-look-p (file-exists-p ispell-look-command)
 370   "*Non-nil means use `look' rather than `grep'.
 371 Default is based on whether `look' seems to be available."
 372   :type 'boolean
 373   :group 'ispell)
 374 
 375 (defcustom ispell-have-new-look nil
 376   "*Non-nil means use the `-r' option (regexp) when running `look'."
 377   :type 'boolean
 378   :group 'ispell)
 379 
 380 (defcustom ispell-look-options (if ispell-have-new-look "-dfr" "-df")
 381   "String of command options for `ispell-look-command'."
 382   :type 'string
 383   :group 'ispell)
 384 
 385 (defcustom ispell-use-ptys-p nil
 386   "When non-nil, Emacs uses ptys to communicate with Ispell.
 387 When nil, Emacs uses pipes."
 388   :type 'boolean
 389   :group 'ispell)
 390 
 391 (defcustom ispell-following-word nil
 392   "*Non-nil means `ispell-word' checks the word around or after point.
 393 Otherwise `ispell-word' checks the preceding word."
 394   :type 'boolean
 395   :group 'ispell)
 396 
 397 (defcustom ispell-help-in-bufferp nil
 398   "*Non-nil means display interactive keymap help in a buffer.
 399 The following values are supported:
 400   nil        Expand the minibuffer and display a short help message
 401              there for a couple of seconds.
 402   t          Pop up a new buffer and display a short help message there
 403              for a couple of seconds.
 404   electric   Pop up a new buffer and display a long help message there.
 405              User can browse and then exit the help mode."
 406   :type '(choice (const electric) (const :tag "off" nil) (const :tag "on" t))
 407   :group 'ispell)
 408 
 409 (defcustom ispell-quietly nil
 410   "*Non-nil means suppress messages in `ispell-word'."
 411   :type 'boolean
 412   :group 'ispell)
 413 
 414 (defcustom ispell-format-word (function upcase)
 415   "*Formatting function for displaying word being spell checked.
 416 The function must take one string argument and return a string."
 417   :type 'function
 418   :group 'ispell)
 419 
 420 (defcustom ispell-use-framepop-p nil
 421   "When non-nil ispell uses framepop to display choices in a dedicated frame.
 422 You can set this variable to dynamically use framepop if you are in a
 423 window system by evaluating the following on startup to set this variable:
 424   (and window-system (condition-case () (require 'framepop) (error nil)))"
 425   :type 'boolean
 426   :group 'ispell)
 427 
 428 ;;;###autoload
 429 (defcustom ispell-personal-dictionary nil
 430   "*File name of your personal spelling dictionary, or nil.
 431 If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used,
 432 where DICTNAME is the name of your default dictionary."
 433   :type '(choice file
 434 		 (const :tag "default" nil))
 435   :group 'ispell)
 436 
 437 (defcustom ispell-silently-savep nil
 438   "*When non-nil, save the personal dictionary without confirmation."
 439   :type 'boolean
 440   :group 'ispell)
 441 
 442 ;;; This is the local dictionary to use.  When nil the default dictionary will
 443 ;;; be used.  Change set-default call to use a new default dictionary.
 444 (defcustom ispell-local-dictionary nil
 445   "If non-nil, the dictionary to be used for Ispell commands.
 446 The value must be a string dictionary name in `ispell-dictionary-alist'.
 447 This variable becomes buffer-local when set in any fashion.
 448 
 449 Setting `ispell-local-dictionary' to a value has the same effect as
 450 calling \\[ispell-change-dictionary] with that value.  This variable
 451 is automatically set when defined in the file with either
 452 `ispell-dictionary-keyword' or the Local Variable syntax.
 453 
 454 To create a non-standard default dictionary (not from `ispell-dictionary-alist')
 455 call function `set-default' with the new dictionary name."
 456   :type '(choice string
 457 		 (const :tag "default" nil))
 458   :group 'ispell)
 459 
 460 (make-variable-buffer-local 'ispell-local-dictionary)
 461 
 462 ;; Call this function set up the default dictionary if not English.
 463 ;;(set-default 'ispell-local-dictionary nil)
 464 
 465 
 466 (defcustom ispell-extra-args nil
 467   "*If non-nil, a list of extra switches to pass to the Ispell program.
 468 For example, (\"-W\" \"3\") to cause it to accept all 1-3 character
 469 words as correct.  See also `ispell-dictionary-alist', which may be used
 470 for language-specific arguments."
 471   :type '(repeat string)
 472   :group 'ispell)
 473 
 474 
 475 
 476 (defcustom ispell-skip-html 'use-mode-name
 477   "*Indicates whether ispell should skip spell checking of SGML markup.
 478 If t, always skip SGML markup; if nil, never skip; if non-t and non-nil,
 479 guess whether SGML markup should be skipped according to the name of the
 480 buffer's major mode.
 481 
 482 This is a local variable.  To change the default value use `set-default'."
 483   :type '(choice (const :tag "always" t) (const :tag "never" nil)
 484 		 (const :tag "use-mode-name" use-mode-name))
 485   :group 'ispell)
 486 
 487 (make-variable-buffer-local 'ispell-skip-html)
 488 
 489 
 490 ;;; Define definitions here only for personal dictionaries.
 491 ;;;###autoload
 492 (defcustom ispell-local-dictionary-alist nil
 493   "*Contains local or customized dictionary definitions.
 494 
 495 These will override the values in `ispell-dictionary-alist'.
 496 
 497 Customization changes made to `ispell-dictionary-alist' will not operate
 498 over emacs sessions.  To make permanent changes to your dictionary
 499 definitions, you will need to make your changes in this variable, save,
 500 and then re-start emacs."
 501   :type '(repeat (list (choice :tag "Dictionary"
 502 			       (string :tag "Dictionary name")
 503 			       (const :tag "default" nil))
 504 		       (regexp :tag "Case characters")
 505 		       (regexp :tag "Non case characters")
 506 		       (regexp :tag "Other characters")
 507 		       (boolean :tag "Many other characters")
 508 		       (repeat :tag "Ispell command line args"
 509 			       (string :tag "Arg"))
 510 		       (choice :tag "Extended character mode"
 511 			       (const "~tex") (const "~plaintex")
 512 			       (const "~nroff") (const "~list")
 513 			       (const "~latin1") (const "~latin3")
 514  			       (const :tag "default" nil))
 515 		       (choice :tag "Coding system"
 516 			       (const iso-8859-1)
 517 			       (const iso-8859-2)
 518 			       (const koi8-r))))
 519   :group 'ispell)
 520 
 521 
 522 ;;; split dictionary so line length is smaller in loaddefs.el
 523 
 524 ;;; First part of dictionary, shortened for loaddefs.el
 525 ;;;###autoload
 526 (setq
 527  ispell-dictionary-alist-1
 528  '((nil					; default (English.aff)
 529     "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
 530    ("american"				; Yankee English
 531     "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
 532    ("brasileiro"			; Brazilian mode
 533     "[A-Z\301\311\315\323\332\300\310\314\322\331\303\325\307\334\302\312\324a-z\341\351\355\363\372\340\350\354\362\371\343\365\347\374\342\352\364]"
 534     "[^A-Z\301\311\315\323\332\300\310\314\322\331\303\325\307\334\302\312\324a-z\341\351\355\363\372\340\350\354\362\371\343\365\347\374\342\352\364]"
 535     "[']" nil nil nil iso-8859-1)
 536    ("british"				; British version
 537     "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
 538    ("castellano"			; Spanish mode
 539     "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
 540     "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
 541     "[-]" nil ("-B") "~tex" iso-8859-1)
 542    ("castellano8"			; 8 bit Spanish mode
 543     "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
 544     "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
 545     "[-]" nil ("-B" "-d" "castellano") "~latin1" iso-8859-1)))
 546 
 547 
 548 ;;; Second part of dictionary, shortened for loaddefs.el
 549 ;;;###autoload
 550 (setq
 551  ispell-dictionary-alist-2
 552  '(("czech"
 553     "[A-Za-z\301\311\314\315\323\332\331\335\256\251\310\330\317\253\322\341\351\354\355\363\372\371\375\276\271\350\370\357\273\362]"
 554     "[^A-Za-z\301\311\314\315\323\332\331\335\256\251\310\330\317\253\322\341\351\354\355\363\372\371\375\276\271\350\370\357\273\362]"
 555     "" nil ("-B") nil iso-8859-2)
 556    ("dansk"				; Dansk.aff
 557     "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]"
 558     "[']" nil ("-C") nil iso-8859-1)
 559    ("deutsch"				; Deutsch.aff
 560     "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" iso-8859-1)
 561    ("deutsch8"
 562     "[a-zA-Z\304\326\334\344\366\337\374]"
 563     "[^a-zA-Z\304\326\334\344\366\337\374]"
 564     "[']" t ("-C" "-d" "deutsch") "~latin1" iso-8859-1)
 565    ("german"
 566     "[a-zA-Z\304\326\334\344\366\337\374]"
 567     "[^a-zA-Z\304\326\334\344\366\337\374]"
 568     "[']" t ("-C" "-d" "german") "~latin1" iso-8859-1)
 569    ("english"				; make English explicitly selectable
 570     "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)))
 571 
 572 
 573 ;;; Third part of dictionary, shortened for loaddefs.el
 574 ;;;###autoload
 575 (setq
 576  ispell-dictionary-alist-3
 577  '(("esperanto"
 578     "[A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
 579     "[^A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
 580     "[-']" t ("-C") "~latin3" iso-8859-1)
 581    ("esperanto-tex"
 582     "[A-Za-z^\\]" "[^A-Za-z^\\]"
 583     "[-'`\"]" t ("-C" "-d" "esperanto") "~tex" iso-8859-1)
 584    ("francais7"
 585     "[A-Za-z]" "[^A-Za-z]" "[`'^---]" t nil nil iso-8859-1)
 586    ("francais"				; Francais.aff
 587     "[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]"
 588     "[^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]"
 589     "[-']" t nil "~list" iso-8859-1)))
 590 
 591 
 592 ;;; Fourth part of dictionary, shortened for loaddefs.el
 593 ;;;###autoload
 594 (setq
 595  ispell-dictionary-alist-4
 596  '(("francais-tex"			; Francais.aff
 597     "[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\\]"
 598     "[^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\\]"
 599     "[-'^`\"]" t nil "~tex" iso-8859-1)
 600    ("italiano"                         ; Italian.aff
 601     "[A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
 602     "[^A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
 603     "[-]" nil ("-B") "~tex" iso-8859-1)
 604    ("nederlands"			; Nederlands.aff
 605     "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
 606     "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
 607     "[']" t ("-C") nil iso-8859-1)
 608    ("nederlands8"			; Dutch8.aff
 609     "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
 610     "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
 611     "[']" t ("-C") nil iso-8859-1)))
 612 
 613 
 614 ;;; Fifth part of dictionary, shortened for loaddefs.el
 615 ;;;###autoload
 616 (setq
 617  ispell-dictionary-alist-5
 618  '(("norsk"				; 8 bit Norwegian mode
 619     "[A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
 620     "[^A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
 621     "[\"]" nil nil "~list" iso-8859-1)
 622    ("norsk7-tex"			; 7 bit Norwegian TeX mode
 623     "[A-Za-z{}\\'^`]" "[^A-Za-z{}\\'^`]"
 624     "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1)
 625    ("polish"				; Polish mode
 626     "[A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"
 627     "[^A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"
 628     "" nil nil nil iso-8859-2)
 629    ("portugues"				; Portuguese mode
 630     "[a-zA-Z\301\302\311\323\340\341\342\351\352\355\363\343\372]"
 631     "[^a-zA-Z\301\302\311\323\340\341\342\351\352\355\363\343\372]"
 632     "[']" t ("-C") "~latin1" iso-8859-1)))
 633 
 634 
 635 ;;; Sixth part of dictionary, shortened for loaddefs.el
 636 ;;;###autoload
 637 (setq
 638  ispell-dictionary-alist-6
 639  ;; include Russian iso coding system too?
 640  ;;   "[']" t ("-d" "russian") "~latin1" iso-8859-1
 641  '(("russian"				; Russian.aff (KOI8-R charset)
 642     "[\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
 643     "[^\341\342\367\347\344\345\263\366\372\351\352\353\354\355\356\357\360\362\363\364\365\346\350\343\376\373\375\370\371\377\374\340\361\301\302\327\307\304\305\243\326\332\311\312\313\314\315\316\317\320\322\323\324\325\306\310\303\336\333\335\330\331\337\334\300\321]"
 644     "" nil nil nil koi8-r)
 645    ("slovak"				; Slovakian
 646     "[A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]"
 647     "[^A-Za-z\301\304\311\315\323\332\324\300\305\245\335\256\251\310\317\253\322\341\344\351\355\363\372\364\340\345\265\375\276\271\350\357\273\362]"
 648     "" nil ("-B") nil iso-8859-2)
 649    ("svenska"				; Swedish mode
 650     "[A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
 651     "[^A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
 652     "[']" nil ("-C") "~list" iso-8859-1)))
 653 
 654 
 655 ;;;###autoload
 656 (defcustom ispell-dictionary-alist
 657   (append ispell-local-dictionary-alist	; dictionary customizations
 658 	  ispell-dictionary-alist-1 ispell-dictionary-alist-2
 659 	  ispell-dictionary-alist-3 ispell-dictionary-alist-4
 660 	  ispell-dictionary-alist-5 ispell-dictionary-alist-6)
 661   "An alist of dictionaries and their associated parameters.
 662 
 663 Each element of this list is also a list:
 664 
 665 \(DICTIONARY-NAME CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P
 666         ISPELL-ARGS EXTENDED-CHARACTER-MODE CHARACTER-SET\)
 667 
 668 DICTIONARY-NAME is a possible string value of variable `ispell-dictionary',
 669 nil means the default dictionary.
 670 
 671 CASECHARS is a regular expression of valid characters that comprise a
 672 word.
 673 
 674 NOT-CASECHARS is the opposite regexp of CASECHARS.
 675 
 676 OTHERCHARS is a regexp of characters in the NOT-CASECHARS set but which can be
 677 used to construct words in some special way.  If OTHERCHARS characters follow
 678 and precede characters from CASECHARS, they are parsed as part of a word,
 679 otherwise they become word-breaks.  As an example in English, assume the
 680 regular expression \"[']\" for OTHERCHARS.  Then \"they're\" and
 681 \"Steven's\" are parsed as single words including the \"'\" character, but
 682 \"Stevens'\" does not include the quote character as part of the word.
 683 If you want OTHERCHARS to be empty, use the empty string.
 684 Hint: regexp syntax requires the hyphen to be declared first here.
 685 
 686 MANY-OTHERCHARS-P is non-nil when multiple OTHERCHARS are allowed in a word.
 687 Otherwise only a single OTHERCHARS character is allowed to be part of any
 688 single word.
 689 
 690 ISPELL-ARGS is a list of additional arguments passed to the ispell
 691 subprocess.
 692 
 693 EXTENDED-CHARACTER-MODE should be used when dictionaries are used which
 694 have been configured in an Ispell affix file.  (For example, umlauts
 695 can be encoded as \\\"a, a\\\", \"a, ...)  Defaults are ~tex and ~nroff
 696 in English.  This has the same effect as the command-line `-T' option.
 697 The buffer Major Mode controls Ispell's parsing in tex or nroff mode,
 698 but the dictionary can control the extended character mode.
 699 Both defaults can be overruled in a buffer-local fashion. See
 700 `ispell-parsing-keyword' for details on this.
 701 
 702 CHARACTER-SET used for languages with multibyte characters.
 703 
 704 Note that the CASECHARS and OTHERCHARS slots of the alist should
 705 contain the same character set as casechars and otherchars in the
 706 LANGUAGE.aff file \(e.g., english.aff\)."
 707   :type '(repeat (list (choice :tag "Dictionary"
 708 			       (string :tag "Dictionary name")
 709 			       (const :tag "default" nil))
 710 		       (regexp :tag "Case characters")
 711 		       (regexp :tag "Non case characters")
 712 		       (regexp :tag "Other characters")
 713 		       (boolean :tag "Many other characters")
 714 		       (repeat :tag "Ispell command line args"
 715 			       (string :tag "Arg"))
 716 		       (choice :tag "Extended character mode"
 717 			       (const "~tex") (const "~plaintex")
 718 			       (const "~nroff") (const "~list")
 719 			       (const "~latin1") (const "~latin3")
 720  			       (const :tag "default" nil))
 721 		       (choice :tag "Coding System"
 722 			       (const iso-8859-1)
 723 			       (const iso-8859-2)
 724 			       (const koi8-r))))
 725   :group 'ispell)
 726 
 727 ;;; update the dictionaries at load time
 728 (setq ispell-dictionary-alist
 729       (append ispell-local-dictionary-alist	; dictionary customizations
 730 	      ispell-dictionary-alist-1 ispell-dictionary-alist-2
 731 	      ispell-dictionary-alist-3 ispell-dictionary-alist-4
 732 	      ispell-dictionary-alist-5 ispell-dictionary-alist-6))
 733 
 734 
 735 
 736 
 737 ;;; **********************************************************************
 738 ;;; The following are used by ispell, and should not be changed.
 739 ;;; **********************************************************************
 740 
 741 
 742 
 743 ;;; The version must be 3.1 or greater for this version of ispell.el
 744 ;;; There is an incompatibility between version 3.1.12 and lower versions.
 745 (defconst ispell-required-version '(3 1 12)
 746   "Ispell versions with which this version of ispell.el is known to work.")
 747 (defvar ispell-offset -1
 748   "Offset that maps protocol differences between ispell 3.1 versions.")
 749 
 750 (defconst ispell-version "ispell.el 3.6 - 01/07/2003")
 751 
 752 
 753 ;;;###autoload
 754 (defun check-ispell-version (&optional interactivep)
 755   "Ensure that `ispell-program-name' is valid and the correct version.
 756 Returns version number if called interactively.
 757 Otherwise returns the library path if defined."
 758   ;; This is a little wasteful as we actually launch ispell twice: once
 759   ;; to make sure it's the right version, and once for real.  But people
 760   ;; get confused by version mismatches *all* the time (and I've got the
 761   ;; email to prove it) so I think this is worthwhile.  And the -v[ersion]
 762   ;; option is the only way I can think of to do this that works with
 763   ;; all versions, since versions earlier than 3.0.09 didn't identify
 764   ;; themselves on startup.
 765   (interactive "p")
 766   (let ((case-fold-search-val case-fold-search)
 767 	;; avoid bugs when syntax of `.' changes in various default modes
 768 	(default-major-mode 'fundamental-mode)
 769 	result status)
 770     (save-excursion
 771       (set-buffer (get-buffer-create " *ispell-tmp*"))
 772       (erase-buffer)
 773       (setq status (call-process
 774 		    ispell-program-name nil t nil
 775 		    ;; aspell doesn't accept the -vv switch.
 776 		    (let ((case-fold-search
 777 			   (memq system-type '(ms-dos windows-nt)))
 778 			  (speller
 779 			   (file-name-nondirectory ispell-program-name)))
 780 		      ;; Assume anything that isn't `aspell' is Ispell.
 781 		      (if (string-match "\\`aspell" speller) "-v" "-vv"))))
 782       (goto-char (point-min))
 783       (if (not interactivep)
 784 	  ;; return library path.
 785 	  (if (re-search-forward "LIBDIR = \\\"\\([^ \t\n]*\\)\\\"" nil t)
 786 	      (setq result (buffer-substring (match-beginning 1)
 787 					     (match-end 1))))
 788 	;; write message string to minibuffer
 789 	(end-of-line)
 790 	(message (concat (buffer-substring-no-properties (point-min) (point))
 791 			 ", " ispell-version)))
 792       (goto-char (point-min))
 793       (if (not (memq status '(0 nil)))
 794 	  (error "%s exited with %s %s" ispell-program-name
 795 		 (if (stringp status) "signal" "code") status))
 796       (setq case-fold-search t
 797 	    status (re-search-forward
 798 		    (concat "\\<\\("
 799 			    (format "%d" (car ispell-required-version))
 800 			    "\\)\\.\\([0-9]*\\)\\.\\([0-9]*\\)\\>")
 801 		    nil t)
 802 	    case-fold-search case-fold-search-val)
 803       (if (or (not status)	; major version mismatch
 804 	      (< (car (read-from-string (buffer-substring-no-properties
 805 					 (match-beginning 2) (match-end 2))))
 806 		 (car (cdr ispell-required-version)))) ; minor version mismatch
 807 	  (error "%s version 3 release %d.%d.%d or greater is required"
 808 		 ispell-program-name (car ispell-required-version)
 809 		 (car (cdr ispell-required-version))
 810 		 (car (cdr (cdr ispell-required-version))))
 811 	;; check that it is the correct version.
 812 	(if (and (= (car (read-from-string (buffer-substring-no-properties
 813 					    (match-beginning 2)(match-end 2))))
 814 		    (car (cdr ispell-required-version)))
 815 		 (< (car (read-from-string (buffer-substring-no-properties
 816 					    (match-beginning 3)(match-end 3))))
 817 		    (car (cdr (cdr ispell-required-version)))))
 818 	    (setq ispell-offset 0)))
 819       (kill-buffer (current-buffer)))
 820     result))
 821 
 822 
 823 
 824 ;;; The preparation of the menu bar menu must be autoloaded
 825 ;;; because otherwise this file gets autoloaded every time Emacs starts
 826 ;;; so that it can set up the menus and determine keyboard equivalents.
 827 
 828 
 829 ;;;###autoload
 830 (defvar ispell-menu-map nil "Key map for ispell menu.")
 831 ;;; redo menu when loading ispell to get dictionary modifications
 832 (setq ispell-menu-map nil)
 833 
 834 ;;;###autoload
 835 (defvar ispell-menu-xemacs nil
 836   "Spelling menu for XEmacs.
 837 If nil when package is loaded, a standard menu will be set,
 838 and added as a submenu of the \"Edit\" menu.")
 839 
 840 ;;; Break out XEmacs menu and split into several calls to avoid having
 841 ;;; long lines in loaddefs.el.  Detect need off following constant.
 842 
 843 ;;; Set up dictionary
 844 ;;;###autoload
 845 (defvar ispell-menu-map-needed
 846   ;; only needed when not version 18 and not XEmacs.
 847   (and (not ispell-menu-map)
 848        (not version18p)
 849        (not xemacsp)
 850        'reload))
 851 
 852 (defvar ispell-library-path (if (or (not (fboundp 'byte-compiling-files-p))
 853 				    (not (byte-compiling-files-p)))
 854 				(check-ispell-version))
 855   "The directory where ispell dictionaries reside.")
 856 
 857 (defvar ispell-process nil
 858   "The process object for Ispell.")
 859 
 860 (defvar ispell-async-processp (and (fboundp 'kill-process)
 861 				   (fboundp 'process-send-string)
 862 				   (fboundp 'accept-process-output)
 863 				   ;;(fboundp 'start-process)
 864 				   ;;(fboundp 'set-process-filter)
 865 				   ;;(fboundp 'process-kill-without-query)
 866 				   )
 867   "Non-nil means that the OS supports asynchronous processes.")
 868 
 869 ;;;###autoload
 870 (defun valid-dictionary-list ()
 871   "Returns a list of valid dictionaries.
 872 The variable `ispell-library-path' defines the library location."
 873   (let ((dicts ispell-dictionary-alist)
 874 	;; `ispell-library-path' intentionally not defined in autoload
 875 	(path (and (boundp 'ispell-library-path) ispell-library-path))
 876 	(dict-list (cons "default" nil))
 877 	name load-dict)
 878     (while dicts
 879       (setq name (car (car dicts))
 880 	    load-dict (car (cdr (member "-d" (nth 5 (car dicts)))))
 881 	    dicts (cdr dicts))
 882 	;; Include if the dictionary is in the library, or path not defined.
 883 	(if (and (stringp name)
 884 		 (or (not path)
 885 		     (file-exists-p (concat path "/" name ".hash"))
 886 		     (file-exists-p (concat path "/" name ".has"))
 887 		     (and load-dict
 888 			  (or (file-exists-p (concat path "/"
 889 						     load-dict ".hash"))
 890 			      (file-exists-p (concat path "/"
 891 						     load-dict ".has"))))))
 892 	    (setq dict-list (cons name dict-list))))
 893     dict-list))
 894 
 895 
 896 
 897 ;;;###autoload
 898 (if (and ispell-menu-map-needed
 899 	 (or (not (fboundp 'byte-compiling-files-p))
 900 	     (not (byte-compiling-files-p))))
 901     (let ((dicts (valid-dictionary-list)))
 902       (setq ispell-menu-map (make-sparse-keymap "Spell"))
 903       ;; add the dictionaries to the bottom of the list.
 904       (while dicts
 905 	(if (string-equal "default" (car dicts))
 906 	    (define-key ispell-menu-map (vector 'default)
 907 	      (cons "Select Default Dict"
 908 		    (cons "Dictionary for which Ispell was configured"
 909 			  (list 'lambda () '(interactive)
 910 				(list
 911 				  'ispell-change-dictionary "default")))))
 912 	  (define-key ispell-menu-map (vector (intern (car dicts)))
 913 	    (cons (concat "Select " (capitalize (car dicts)) " Dict")
 914 		  (list 'lambda () '(interactive)
 915 			(list 'ispell-change-dictionary (car dicts))))))
 916 	(setq dicts (cdr dicts)))))
 917 
 918 
 919 ;;; define commands in menu in opposite order you want them to appear.
 920 ;;;###autoload
 921 (if (and ispell-menu-map-needed
 922 	 (or (not (fboundp 'byte-compiling-files-p))
 923 	     (not (byte-compiling-files-p))))
 924     (progn
 925       (define-key ispell-menu-map [ispell-change-dictionary]
 926 	'(menu-item "Change Dictionary..." ispell-change-dictionary
 927 		    :help "Supply explicit path to dictionary"))
 928       (define-key ispell-menu-map [ispell-kill-ispell]
 929 	'(menu-item "Kill Process" ispell-kill-ispell
 930 		    :enable (and (boundp 'ispell-process) ispell-process
 931 				 (eq (ispell-process-status) 'run))
 932 		    :help "Terminate Ispell subprocess"))
 933       (define-key ispell-menu-map [ispell-pdict-save]
 934 	'(menu-item "Save Dictionary"
 935 		    (lambda () (interactive) (ispell-pdict-save t t))
 936 		    :help "Save personal dictionary"))
 937       (define-key ispell-menu-map [ispell-help]
 938 	;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ?
 939 	'(menu-item "Help"
 940 		    (lambda () (interactive) (describe-function 'ispell-help))
 941 		    :help "Show standard Ispell keybindings and commands"))
 942       (define-key ispell-menu-map [ispell-complete-word]
 943 	'(menu-item "Complete Word" ispell-complete-word
 944 		    :help "Complete word at cursor using dictionary"))
 945       (define-key ispell-menu-map [ispell-complete-word-interior-frag]
 946 	'(menu-item "Complete Word Fragment" ispell-complete-word-interior-frag
 947 		    :help "Complete word fragment at cursor"))))
 948 
 949 ;;;###autoload
 950 (if (and ispell-menu-map-needed
 951 	 (or (not (fboundp 'byte-compiling-files-p))
 952 	     (not (byte-compiling-files-p))))
 953     (progn
 954       (define-key ispell-menu-map [ispell-continue]
 955 	'(menu-item "Continue Spell-Checking" ispell-continue
 956 		    :enable (and (boundp 'ispell-region-end)
 957 				 (marker-position ispell-region-end)
 958 				 (equal (marker-buffer ispell-region-end)
 959 					(current-buffer)))
 960 		    :help "Continue spell checking last region"))
 961       (define-key ispell-menu-map [ispell-word]
 962 	'(menu-item "Spell-Check Word" ispell-word
 963 		    :help "Spell-check word at cursor"))
 964       (define-key ispell-menu-map [ispell-comments-and-strings]
 965 	'(menu-item "Spell-Check Comments" ispell-comments-and-strings
 966 		    :help "Spell-check only comments and strings"))))
 967 
 968 ;;;###autoload
 969 (if (and ispell-menu-map-needed
 970 	 (or (not (fboundp 'byte-compiling-files-p))
 971 	     (not (byte-compiling-files-p))))
 972     (progn
 973       (define-key ispell-menu-map [ispell-region]
 974 	'(menu-item "Spell-Check Region" ispell-region
 975 		    :enable mark-active
 976 		    :help "Spell-check text in marked region"))
 977       (define-key ispell-menu-map [ispell-message]
 978 	'(menu-item "Spell-Check Message" ispell-message
 979 		    :help "Skip headers and included message text"))
 980       (define-key ispell-menu-map [ispell-buffer]
 981 	'(menu-item "Spell-Check Buffer" ispell-buffer
 982 		    :help "Check spelling of selected buffer"))
 983 ;; JW xxxxx
 984       (define-key ispell-menu-map [flyspell-region]
 985 	'(menu-item "Fly-spell-region" flyspell-region
 986 		    :enable mark-active
 987 		    :help "Fly-spell-check text and highlight in marked region"))
 988       (define-key ispell-menu-map [flyspell-buffer]
 989 	'(menu-item "Fly-spell-buffer (slow!)" flyspell-buffer
 990 		    :help "Fly-spell-check text and highlight in buffer (is slow)"))
 991       (define-key ispell-menu-map [flyspell-mode]
 992 	'(menu-item "Toggle flyspell-mode (on/off)" flyspell-mode
 993 		    :help "turn on flyspell-mode"))
 994       ;;(put 'ispell-region 'menu-enable 'mark-active)
 995       (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
 996 
 997 ;;; XEmacs versions 19+
 998 (if (and xemacsp
 999 	 (not version18p)
1000 	 (featurep 'menubar)
1001 	 ;;(null ispell-menu-xemacs)
1002 	 (not (and (boundp 'infodock-version) infodock-version)))
1003     (let ((dicts (valid-dictionary-list))
1004 	  (current-menubar (or current-menubar default-menubar))
1005 	  (menu
1006 	   '(["Help"		(describe-function 'ispell-help) t]
1007 	     ;;["Help"		(popup-menu ispell-help-list)	t]
1008 	     ["Check Message"	ispell-message			t]
1009 	     ["Check Buffer"	ispell-buffer			t]
1010 	     ["Check Comments"	ispell-comments-and-strings	t]
1011 	     ["Check Word"	ispell-word			t]
1012 	     ["Check Region"	ispell-region  (or (not zmacs-regions) (mark))]
1013 	     ["Continue Check"	ispell-continue			t]
1014 	     ["Complete Word Frag"ispell-complete-word-interior-frag t]
1015 	     ["Complete Word"	ispell-complete-word		t]
1016 	     ["Kill Process"	ispell-kill-ispell		t]
1017 	     "-"
1018 	     ["Save Personal Dict"(ispell-pdict-save t t)	t]
1019 	     ["Change Dictionary" ispell-change-dictionary	t]
1020 	     ["Select Default"  (ispell-change-dictionary "default") t])))
1021       (while dicts
1022 	(setq menu (append menu
1023 			   (list
1024 			     (vector
1025 			      (concat "Select " (capitalize (car dicts)))
1026 			      (list 'ispell-change-dictionary (car dicts))
1027 			      t)))
1028 	      dicts (cdr dicts)))
1029       (setq ispell-menu-xemacs menu)
1030       (if current-menubar
1031 	  (progn
1032 	    (if (car (find-menu-item current-menubar '("Cmds")))
1033 		(progn
1034 		  ;; XEmacs 21.2
1035 		  (delete-menu-item '("Cmds" "Spell-Check"))
1036 		  (add-menu '("Cmds") "Spell-Check" ispell-menu-xemacs))
1037 	      ;; previous
1038 	      (delete-menu-item '("Edit" "Spell")) ; in case already defined
1039 	      (add-menu '("Edit") "Spell" ispell-menu-xemacs))))))
1040 
1041 ;;; Allow incrementing characters as integers in XEmacs 20+
1042 (if (and xemacsp
1043 	 (fboundp 'int-char))
1044     (fset 'ispell-int-char 'int-char)
1045   ;; Emacs and XEmacs 19 or earlier
1046   (fset 'ispell-int-char 'identity))
1047 
1048 
1049 ;;; **********************************************************************
1050 
1051 
1052 ;;; This variable contains the current dictionary being used if the ispell
1053 ;;; process is running.  Otherwise it contains the global default.
1054 (defvar ispell-dictionary nil
1055   "The name of the current dictionary, or nil for the default.
1056 When `ispell-local-dictionary' is nil, `ispell-dictionary' is used to select
1057 the dictionary for new buffers.
1058 
1059 This is passed to the ispell process using the `-d' switch and is
1060 used as key in `ispell-dictionary-alist' (which see).")
1061 
1062 (defun ispell-decode-string (str)
1063   "Decodes multibyte character strings.
1064 Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
1065   (if (and (or xemacsp
1066 	       (and (boundp 'enable-multibyte-characters)
1067 		    enable-multibyte-characters))
1068 	   (fboundp 'decode-coding-string)
1069 	   (ispell-get-coding-system))
1070       (decode-coding-string str (ispell-get-coding-system))
1071     str))
1072 
1073 (defun ispell-get-casechars ()
1074   (ispell-decode-string
1075    (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))))
1076 (defun ispell-get-not-casechars ()
1077   (ispell-decode-string
1078    (nth 2 (assoc ispell-dictionary ispell-dictionary-alist))))
1079 (defun ispell-get-otherchars ()
1080   (ispell-decode-string
1081    (nth 3 (assoc ispell-dictionary ispell-dictionary-alist))))
1082 (defun ispell-get-many-otherchars-p ()
1083   (nth 4 (assoc ispell-dictionary ispell-dictionary-alist)))
1084 (defun ispell-get-ispell-args ()
1085   (nth 5 (assoc ispell-dictionary ispell-dictionary-alist)))
1086 (defun ispell-get-extended-character-mode ()
1087   (nth 6 (assoc ispell-dictionary ispell-dictionary-alist)))
1088 (defun ispell-get-coding-system ()
1089   (nth 7 (assoc ispell-dictionary ispell-dictionary-alist)))
1090 
1091 
1092 (defvar ispell-pdict-modified-p nil
1093   "Non-nil means personal dictionary has modifications to be saved.")
1094 
1095 ;;; If you want to save the dictionary when quitting, must do so explicitly.
1096 ;;; When non-nil, the spell session is terminated.
1097 ;;; When numeric, contains cursor location in buffer, and cursor remains there.
1098 (defvar ispell-quit nil)
1099 
1100 (defvar ispell-process-directory nil
1101   "The directory where `ispell-process' was started.")
1102 
1103 (defvar ispell-filter nil
1104   "Output filter from piped calls to Ispell.")
1105 
1106 (defvar ispell-filter-continue nil
1107   "Control variable for Ispell filter function.")
1108 
1109 (defvar ispell-output-buffer nil
1110   "Buffer used for reading output of a synchronous Ispell subprocess.")
1111 
1112 (defvar ispell-session-buffer nil
1113   "Buffer used for passing input to a synchronous Ispell subprocess.")
1114 
1115 (defvar ispell-cmd-args nil
1116   "Command-line arguments to pass to a synchronous Ispell subprocess.")
1117 
1118 (defvar ispell-query-replace-marker (make-marker)
1119   "Marker for `query-replace' processing.")
1120 
1121 (defvar ispell-recursive-edit-marker (make-marker)
1122   "Marker for return point from recursive edit.")
1123 
1124 (defvar ispell-checking-message nil
1125   "Non-nil when we're checking a mail message.
1126 Used to hold MIME boundaries.")
1127 
1128 (defconst ispell-choices-buffer "*Choices*")
1129 
1130 (defvar ispell-overlay nil "Overlay variable for Ispell highlighting.")
1131 
1132 ;;; *** Buffer Local Definitions ***
1133 
1134 (defconst ispell-words-keyword "LocalWords: "                                 
1135   "The keyword for local oddly-spelled words to accept.
1136 The keyword will be followed by any number of local word spellings.
1137 There can be multiple of these keywords in the file.")
1138 
1139 (defconst ispell-dictionary-keyword "Local IspellDict: "
1140   "The keyword for a local dictionary to use.
1141 The keyword must be followed by a correct dictionary name in
1142 `ispell-dictionary-alist'.  When multiple occurrences exist, the last keyword
1143 definition is used.")
1144 
1145 (defconst ispell-pdict-keyword "Local IspellPersDict: "
1146   "The keyword for defining buffer local dictionaries.
1147 Keyword must be followed by the filename of a personal dictionary.
1148 The last occurring definition in the buffer will be used.")
1149 
1150 (defconst ispell-parsing-keyword "Local IspellParsing: "
1151   "The keyword for overriding default Ispell parsing.
1152 The above keyword string should be followed by `latex-mode' or
1153 `nroff-mode' to put the current buffer into the desired parsing mode.
1154 
1155 Extended character mode can be changed for this buffer by placing
1156 a `~' followed by an extended-character mode -- such as `~.tex'.
1157 The last occurring definition in the buffer will be used.")
1158 
1159 ;;;###autoload
1160 (defvar ispell-skip-region-alist
1161   '((ispell-words-keyword	   forward-line)
1162     (ispell-dictionary-keyword	   forward-line)
1163     (ispell-pdict-keyword	   forward-line)
1164     (ispell-parsing-keyword	   forward-line)
1165     ("^---*BEGIN PGP [A-Z ]*--*" . "^---*END PGP [A-Z ]*--*")
1166     ;; assume multiline uuencoded file? "\nM.*$"?
1167     ("^begin [0-9][0-9][0-9] [^ \t]+$" . "\nend\n")
1168     ("^%!PS-Adobe-[123].0"	 . "\n%%EOF\n")
1169     ("^---* \\(Start of \\)?[Ff]orwarded [Mm]essage"
1170      . "^---* End of [Ff]orwarded [Mm]essage")
1171     ;; Matches e-mail addresses, file names, http addresses, etc.  The `-+'
1172     ;; pattern necessary for performance reasons when `-' part of word syntax.
1173     ("\\(--+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")
1174     ;; above checks /.\w sequences
1175     ;;("\\(--+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")
1176     ;; This is a pretty complex regexp.  It can be simplified to the following:
1177     ;; "\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_]\\|~\\)+\\)+"
1178     ;; but some valid text will be skipped, e.g. "his/her".  This could be
1179     ;; fixed up (at the expense of a moderately more complex regexp)
1180     ;; by not allowing "/" to be the character which triggers the
1181     ;; identification of the computer name, e.g.:
1182     ;; "\\(\\w\\|[-_]\\)+[.:@]\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_]\\|~\\)+\\)+"
1183     )
1184   "Alist expressing beginning and end of regions not to spell check.
1185 The alist key must be a regular expression.
1186 Valid forms include:
1187   (KEY) - just skip the key.
1188   (KEY . REGEXP) - skip to the end of REGEXP.  REGEXP may be string or symbol.
1189   (KEY REGEXP) - skip to end of REGEXP.  REGEXP must be a string.
1190   (KEY FUNCTION ARGS) - FUNCTION called with ARGS returns end of region.")
1191 
1192 
1193 
1194 ;;;###autoload
1195 (defvar ispell-tex-skip-alists
1196   '((;;("%\\[" . "%\\]") ; AMStex block comment...
1197      ;; All the standard LaTeX keywords from L. Lamport's guide:
1198      ;; \cite, \hspace, \hspace*, \hyphenation, \include, \includeonly, \input,
1199      ;; \label, \nocite, \rule (in ispell - rest included here)
1200      ("\\\\addcontentsline"              ispell-tex-arg-end 2)
1201      ("\\\\add\\(tocontents\\|vspace\\)" ispell-tex-arg-end)
1202      ("\\\\\\([aA]lph\\|arabic\\)"	 ispell-tex-arg-end)
1203      ;;("\\\\author"			 ispell-tex-arg-end)
1204      ("\\\\bibliographystyle"		 ispell-tex-arg-end)
1205      ("\\\\makebox"			 ispell-tex-arg-end 0)
1206      ("\\\\e?psfig"			 ispell-tex-arg-end)
1207      ("\\\\document\\(class\\|style\\)" .
1208       "\\\\begin[ \t\n]*{[ \t\n]*document[ \t\n]*}"))
1209     (;; delimited with \begin.  In ispell: displaymath, eqnarray, eqnarray*,
1210      ;; equation, minipage, picture, tabular, tabular* (ispell)
1211      ("\\(figure\\|table\\)\\*?"	 ispell-tex-arg-end 0)
1212      ("list"				 ispell-tex-arg-end 2)
1213      ("program"		. "\\\\end[ \t\n]*{[ \t\n]*program[ \t\n]*}")
1214      ("verbatim\\*?"	. "\\\\end[ \t\n]*{[ \t\n]*verbatim\\*?[ \t\n]*}")))
1215   "*Lists of regions to be skipped in TeX mode.
1216 First list is used raw.
1217 Second list has key placed inside \\begin{}.
1218 
1219 Delete or add any regions you want to be automatically selected
1220 for skipping in latex mode.")
1221 
1222 
1223 ;;;###autoload
1224 (defvar ispell-html-skip-alists
1225   '(("<[cC][oO][dD][eE]\\>[^>]*>"	  "</[cC][oO][dD][eE]*>")
1226     ("<[sS][cC][rR][iI][pP][tT]\\>[^>]*>" "</[sS][cC][rR][iI][pP][tT]>")
1227     ("<[aA][pP][pP][lL][eE][tT]\\>[^>]*>" "</[aA][pP][pP][lL][eE][tT]>")
1228     ("<[vV][eE][rR][bB]\\>[^>]*>"         "<[vV][eE][rR][bB]\\>[^>]*>")
1229     ;;("<[tT][tT]\\>[^>]*>"		  "<[tT][tT]\\>[^>]*>")
1230     ("<[tT][tT]/"			  "/")
1231     ("<[^ \t\n>]"			  ">")
1232     ("&[^ \t\n;]"			  "[; \t\n]"))
1233   "*Lists of start and end keys to skip in HTML buffers.
1234 Same format as `ispell-skip-region-alist'
1235 Note - substrings of other matches must come last
1236  (e.g. \"<[tT][tT]/\" and \"<[^ \t\n>]\").")
1237 
1238 
1239 (defvar ispell-local-pdict ispell-personal-dictionary
1240   "A buffer local variable containing the current personal dictionary.
1241 If non-nil, the value must be a string, which is a file name.
1242 
1243 If you specify a personal dictionary for the current buffer which is
1244 different from the current personal dictionary, the effect is similar
1245 to calling \\[ispell-change-dictionary].  This variable is automatically
1246 set when defined in the file with either `ispell-pdict-keyword' or the
1247 local variable syntax.")
1248 
1249 (make-variable-buffer-local 'ispell-local-pdict)
1250 
1251 (defvar ispell-buffer-local-name nil
1252   "Contains the buffer name if local word definitions were used.
1253 Ispell is then restarted because the local words could conflict.")
1254 
1255 (defvar ispell-parser 'use-mode-name
1256    "*Indicates whether ispell should parse the current buffer as TeX Code.
1257 Special value `use-mode-name' tries to guess using the name of `major-mode'.
1258 Default parser is `nroff'.
1259 Currently the only other valid parser is `tex'.
1260 
1261 You can set this variable in hooks in your init file -- eg:
1262 
1263 (add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))")
1264 
1265 (defvar ispell-region-end (make-marker)
1266   "Marker that allows spelling continuations.")
1267 
1268 (defvar ispell-check-only nil
1269   "If non-nil, `ispell-word' does not try to correct the word.")
1270 
1271 (defun ispell-mode-line-window-height-fudge ()
1272   "Return 1 if using a wide mode-line that covers text, otherwise 0."
1273   (if (and xemacsp window-system) 1 0))
1274 
1275 
1276 ;;; **********************************************************************
1277 ;;; **********************************************************************
1278 
1279 
1280 
1281 ;;;###autoload
1282 (define-key esc-map "$" 'ispell-word)
1283 
1284 
1285 (defun ispell-accept-output (&optional timeout-secs timeout-msecs)
1286   "Wait for output from ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS.
1287 If asynchronous subprocesses are not supported, call `ispell-filter' and
1288 pass it the output of the last ispell invocation."
1289   (if ispell-async-processp
1290       (accept-process-output ispell-process timeout-secs timeout-msecs)
1291     (if (null ispell-process)
1292 	(error "No Ispell process to read output from!")
1293       (let ((buf ispell-output-buffer)
1294 	    ispell-output)
1295 	(if (not (bufferp buf))
1296 	    (setq ispell-filter nil)
1297 	  (save-excursion
1298 	    (set-buffer buf)
1299 	    (setq ispell-output (buffer-substring-no-properties
1300 				 (point-min) (point-max))))
1301 	  (ispell-filter t ispell-output)
1302 	  (save-excursion
1303 	    (set-buffer buf)
1304 	    (erase-buffer)))))))
1305 
1306 
1307 (defun ispell-send-string (string)
1308   "Send the string STRING to the Ispell process."
1309   (if ispell-async-processp
1310       (process-send-string ispell-process string)
1311     ;; Asynchronous subprocesses aren't supported on this losing system.
1312     ;; We keep all the directives passed to Ispell during the entire
1313     ;; session in a buffer, and pass them anew each time we invoke
1314     ;; Ispell to process another chunk of text.  (Yes, I know this is a
1315     ;; terrible kludge, and it's a bit slow, but it does get the work done.)
1316     (let ((cmd (aref string 0))
1317 	  ;; The following commands are not passed to Ispell until
1318 	  ;; we have a *real* reason to invoke it.
1319 	  (cmds-to-defer '(?* ?@ ?~ ?+ ?- ?! ?%))
1320 	  (default-major-mode 'fundamental-mode)
1321 	  (session-buf ispell-session-buffer)
1322 	  (output-buf ispell-output-buffer)
1323 	  (ispell-args ispell-cmd-args)
1324 	  (defdir ispell-process-directory)
1325 	  prev-pos)
1326       (save-excursion
1327 	(set-buffer session-buf)
1328 	(setq prev-pos (point))
1329 	(setq default-directory defdir)
1330 	(insert string)
1331 	(if (not (memq cmd cmds-to-defer))
1332 	    (let (coding-system-for-read coding-system-for-write status)
1333 	      (if (and (boundp 'enable-multibyte-characters)
1334 		       enable-multibyte-characters)
1335 		  (setq coding-system-for-read (ispell-get-coding-system)
1336 			coding-system-for-write (ispell-get-coding-system)))
1337 	      (set-buffer output-buf)
1338 	      (erase-buffer)
1339 	      (set-buffer session-buf)
1340 	      (setq status
1341 		    (apply 'call-process-region (point-min) (point-max)
1342 			   ispell-program-name nil
1343 			   output-buf nil
1344 			   "-a" "-m" ispell-args))
1345 	      (set-buffer output-buf)
1346 	      (goto-char (point-min))
1347 	      (save-match-data
1348 		(if (not (looking-at "@(#) "))
1349 		    (error "Ispell error: %s"
1350 			   (buffer-substring-no-properties
1351 			    (point) (progn (end-of-line) (point)))))
1352 		;; If STRING is "^Z\n", we just started Ispell and need
1353 		;; to retain its version ID line in the output buffer.
1354 		;; Otherwise, remove the ID line, as it will confuse
1355 		;; `ispell-filter'.
1356 		(or (string= string "\032\n")
1357 		    (progn
1358 		      (forward-line)
1359 		      (delete-region (point-min) (point))))
1360 		;; If STRING begins with ^ or any normal character, we need
1361 		;; to remove the last line from the session buffer, since it
1362 		;; was just spell-checked, and we don't want to check it again.
1363 		;; The same goes for the # command, since Ispell already saved
1364 		;; the personal dictionary.
1365 		(set-buffer session-buf)
1366 		(delete-region prev-pos (point))
1367 		;; Ispell run synchronously saves the personal dictionary
1368 		;; after each successful command.  So we can remove any
1369 		;; lines in the session buffer that insert words into the
1370 		;; dictionary.
1371 		(if (memq status '(0 nil))
1372 		    (let ((more-lines t))
1373 		      (goto-char (point-min))
1374 		      (while more-lines
1375 			(if (looking-at "^\\*")
1376 			    (let ((start (point)))
1377 			      (forward-line)
1378 			      (delete-region start (point)))
1379 			  (setq more-lines (= 0 (forward-line))))))))))))))
1380 
1381 
1382 
1383 ;;;###autoload
1384 (defun ispell-word (&optional following quietly continue)
1385   "Check spelling of word under or before the cursor.
1386 If the word is not found in dictionary, display possible corrections
1387 in a window allowing you to choose one.
1388 
1389 If optional argument FOLLOWING is non-nil or if `ispell-following-word'
1390 is non-nil when called interactively, then the following word
1391 \(rather than preceding\) is checked when the cursor is not over a word.
1392 When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil
1393 when called interactively, non-corrective messages are suppressed.
1394 
1395 With a prefix argument (or if CONTINUE is non-nil),
1396 resume interrupted spell-checking of a buffer or region.
1397 
1398 Word syntax described by `ispell-dictionary-alist' (which see).
1399 
1400 This will check or reload the dictionary.  Use \\[ispell-change-dictionary]
1401 or \\[ispell-region] to update the Ispell process.
1402 
1403 return values:
1404 nil           word is correct or spelling is accepted.
1405 0             word is inserted into buffer-local definitions.
1406 \"word\"        word corrected from word list.
1407 \(\"word\" arg\)  word is hand entered.
1408 quit          spell session exited."
1409 
1410   (interactive (list nil nil current-prefix-arg))
1411   (if continue
1412       (ispell-continue)
1413     (if (interactive-p)
1414 	(setq following ispell-following-word
1415 	      quietly ispell-quietly))
1416     (ispell-accept-buffer-local-defs)	; use the correct dictionary
1417     (let ((cursor-location (point))	; retain cursor location
1418 	  (word (ispell-get-word following))
1419 	  start end poss new-word replace)
1420       ;; De-structure return word info list.
1421       (setq start (car (cdr word))
1422 	    end (car (cdr (cdr word)))
1423 	    word (car word))
1424 
1425       ;; now check spelling of word if it has 3 or more characters.
1426       (cond
1427        ((> (length word) 2)
1428 	(or quietly
1429 	    (message "Checking spelling of %s..."
1430 		     (funcall ispell-format-word word)))
1431 	(ispell-send-string "%\n")	; put in verbose mode
1432 	(ispell-send-string (concat "^" word "\n"))
1433 	;; wait until ispell has processed word
1434 	(while (progn
1435 		 (ispell-accept-output)
1436 		 (not (string= "" (car ispell-filter)))))
1437 	;;(ispell-send-string "!\n") ;back to terse mode.
1438 	(setq ispell-filter (cdr ispell-filter)) ; remove extra \n
1439 	(if (and ispell-filter (listp ispell-filter))
1440 	    (if (> (length ispell-filter) 1)
1441 		(error "Ispell and its process have different character maps.")
1442 	      (setq poss (ispell-parse-output (car ispell-filter)))))
1443 	(cond ((eq poss t)
1444 	       (or quietly
1445 		   (message "%s is correct"
1446 			    (funcall ispell-format-word word)))
1447 	       (and (fboundp 'extent-at)
1448 		    (extent-at start)
1449 		    (delete-extent (extent-at start))))
1450 	      ((stringp poss)
1451 	       (or quietly
1452 		   (message "%s is correct because of root %s"
1453 			    (funcall ispell-format-word word)
1454 			    (funcall ispell-format-word poss)))
1455 	       (and (fboundp 'extent-at)
1456 		    (extent-at start)
1457 		    (delete-extent (extent-at start))))
1458 	      ((null poss) (message "Error in ispell process"))
1459 	      (ispell-check-only	; called from ispell minor mode.
1460 	       (if (fboundp 'make-extent)
1461 		   (let ((ext (make-extent start end)))
1462 		     (set-extent-property ext 'face ispell-highlight-face)
1463 		     (set-extent-property ext 'priority 2000))
1464 		 (beep)
1465 		 (message "%s is incorrect"(funcall ispell-format-word word))))
1466 	      (t			; prompt for correct word.
1467 	       (save-window-excursion
1468 		 (setq replace (ispell-command-loop
1469 				(car (cdr (cdr poss)))
1470 				(car (cdr (cdr (cdr poss))))
1471 				(car poss) start end)))
1472 	       (cond ((equal 0 replace)
1473 		      (ispell-add-per-file-word-list (car poss)))
1474 		     (replace
1475 		      (setq new-word (if (atom replace) replace (car replace))
1476 			    cursor-location (+ (- (length word) (- end start))
1477 					       cursor-location))
1478 		      (if (not (equal new-word (car poss)))
1479 			  (progn
1480 			    (delete-region start end)
1481 			    (setq start (point))
1482 			    (insert new-word)
1483 			    (setq end (point))))
1484 		      (if (not (atom replace)) ;recheck spelling of replacement
1485 			  (progn
1486 			    (if (car (cdr replace)) ; query replace requested
1487 				(save-window-excursion
1488 				  (query-replace word new-word t)))
1489 			    (goto-char start)
1490 			    ;; single word could be split into multiple words
1491 			    (setq ispell-quit (not (ispell-region start end)))
1492 			    ))))
1493 	       ;; keep if rechecking word and we keep choices win.
1494 	       (if (get-buffer ispell-choices-buffer)
1495 		   (kill-buffer ispell-choices-buffer))))
1496 	(ispell-pdict-save ispell-silently-savep)
1497 	;; NB: Cancels ispell-quit incorrectly if called from ispell-region
1498 	(if ispell-quit (setq ispell-quit nil replace 'quit))))
1499       (goto-char cursor-location)	; return to original location
1500       replace)))
1501 
1502 
1503 (defun ispell-get-word (following &optional extra-otherchars)
1504   "Return the word for spell-checking according to ispell syntax.
1505 If optional argument FOLLOWING is non-nil or if `ispell-following-word'
1506 is non-nil when called interactively, then the following word
1507 \(rather than preceding\) is checked when the cursor is not over a word.
1508 Optional second argument contains otherchars that can be included in word
1509 many times.
1510 
1511 Word syntax described by `ispell-dictionary-alist' (which see)."
1512   (let* ((ispell-casechars (ispell-get-casechars))
1513 	 (ispell-not-casechars (ispell-get-not-casechars))
1514 	 (ispell-otherchars (ispell-get-otherchars))
1515 	 (ispell-many-otherchars-p (ispell-get-many-otherchars-p))
1516 	 (word-regexp (concat ispell-casechars
1517 			      "+\\("
1518 			      (if (not (string= "" ispell-otherchars))
1519 				  (concat ispell-otherchars "?"))
1520 			      (if extra-otherchars
1521 				  (concat extra-otherchars "?"))
1522 			      ispell-casechars
1523 			      "+\\)"
1524 			      (if (or ispell-many-otherchars-p
1525 				      extra-otherchars)
1526 				  "*" "?")))
1527 	 did-it-once prevpt
1528 	 start end word)
1529     ;; find the word
1530     (if (not (looking-at ispell-casechars))
1531 	(if following
1532 	    (re-search-forward ispell-casechars (point-max) t)
1533 	  (re-search-backward ispell-casechars (point-min) t)))
1534     ;; move to front of word
1535     (re-search-backward ispell-not-casechars (point-min) 'start)
1536     (while (and (or (and (not (string= "" ispell-otherchars))
1537 			 (looking-at ispell-otherchars))
1538 		    (and extra-otherchars (looking-at extra-otherchars)))
1539 		(not (bobp))
1540 		(or (not did-it-once)
1541 		    ispell-many-otherchars-p)
1542 		(not (eq prevpt (point))))
1543       (if (and extra-otherchars (looking-at extra-otherchars))
1544 	  (progn
1545 	    (backward-char 1)
1546 	    (if (looking-at ispell-casechars)
1547 		(re-search-backward ispell-not-casechars (point-min) 'move)))
1548 	(setq did-it-once t
1549 	      prevpt (point))
1550 	(backward-char 1)
1551 	(if (looking-at ispell-casechars)
1552 	    (re-search-backward ispell-not-casechars (point-min) 'move)
1553 	  (backward-char -1))))
1554     ;; Now mark the word and save to string.
1555     (if (not (re-search-forward word-regexp (point-max) t))
1556 	(if ispell-check-only
1557 	    ;; return dummy word when just flagging misspellings
1558 	    (list "" (point) (point))
1559 	  (error "No word found to check!"))
1560       (setq start (match-beginning 0)
1561 	    end (point)
1562 	    word (buffer-substring-no-properties start end))
1563       (list word start end))))
1564 
1565 
1566 ;;; Global ispell-pdict-modified-p is set by ispell-command-loop and
1567 ;;; tracks changes in the dictionary.  The global may either be
1568 ;;; a value or a list, whose value is the state of whether the
1569 ;;; dictionary needs to be saved.
1570 
1571 ;;;###autoload
1572 (defun ispell-pdict-save (&optional no-query force-save)
1573   "Check to see if the personal dictionary has been modified.
1574 If so, ask if it needs to be saved."
1575   (interactive (list ispell-silently-savep t))
1576   (if (and ispell-pdict-modified-p (listp ispell-pdict-modified-p))
1577       (setq ispell-pdict-modified-p (car ispell-pdict-modified-p)))
1578   (if (or ispell-pdict-modified-p force-save)
1579       (if (or no-query (y-or-n-p "Personal dictionary modified.  Save? "))
1580 	  (progn
1581 	    (ispell-send-string "#\n")	; save dictionary
1582 	    (message "Personal dictionary saved."))))
1583   ;; unassert variable, even if not saved to avoid questioning.
1584   (setq ispell-pdict-modified-p nil))
1585 
1586 
1587 (defun ispell-choices-win-default-height ()
1588   "Return the default height of the `*Choices*' window for this display.
1589 This is the value of of the variable `ispell-choices-win-default-height',
1590 plus a possible fudge factor to work around problems with mode-lines that
1591 obscure the last buffer line on graphics capable displays."
1592   (+ ispell-choices-win-default-height (ispell-mode-line-window-height-fudge)))
1593 
1594 
1595 (defun ispell-command-loop (miss guess word start end)
1596   "Display possible corrections from list MISS.
1597 GUESS lists possibly valid affix construction of WORD.
1598 Returns nil to keep word.
1599 Returns 0 to insert locally into buffer-local dictionary.
1600 Returns string for new chosen word.
1601 Returns list for new replacement word (will be rechecked).
1602   Query-replace when list length is 2.
1603   Automatic query-replace when second element is `query-replace'.
1604 Highlights the word, which is assumed to run from START to END.
1605 Global `ispell-pdict-modified-p' becomes a list where the only value
1606 indicates whether the dictionary has been modified when option `a' or `i' is
1607 used.
1608 Global `ispell-quit' set to start location to continue spell session."
1609   (let ((count ?0)
1610 	(line (ispell-choices-win-default-height))
1611 	(max-lines (- (window-height) 4)) ; ensure 4 context lines.
1612 	(choices miss)
1613 	(window-min-height (min window-min-height
1614 				(ispell-choices-win-default-height)))
1615 	(command-characters '( ?  ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m ))
1616 	(dedicated (window-dedicated-p (selected-window)))
1617 	(skipped 0)
1618 	char num result textwin dedicated-win)
1619 
1620     ;; setup the *Choices* buffer with valid data.
1621     (save-excursion
1622       (set-buffer (get-buffer-create ispell-choices-buffer))
1623       (setq mode-line-format (concat "--  %b  --  word: " word))
1624       ;; XEmacs: no need for horizontal scrollbar in choices window
1625       (and (fboundp 'set-specifier)
1626 	   (boundp 'horizontal-scrollbar-visible-p)
1627            (set-specifier horizontal-scrollbar-visible-p nil
1628 			  (cons (current-buffer) nil)))
1629       (erase-buffer)
1630       (if guess
1631 	  (progn
1632 	    (insert "Affix rules generate and capitalize "
1633 		    "this word as shown below:\n\t")
1634 	    (while guess
1635 	      (if (> (+ 4 (current-column) (length (car guess)))
1636 		     (window-width))
1637 		  (progn
1638 		    (insert "\n\t")
1639 		    (setq line (1+ line))))
1640 	      (insert (car guess) "    ")
1641 	      (setq guess (cdr guess)))
1642 	    (insert "\nUse option `i' if this is a correct composition"
1643 		    " from the derivative root.\n")
1644 	    (setq line (+ line (if choices 3 2)))))
1645       (while (and choices
1646 		  (< (if (> (+ 7 (current-column) (length (car choices))
1647 			       (if (> count ?~) 3 0))
1648 			    (window-width))
1649 			 (progn
1650 			   (insert "\n")
1651 			   (setq line (1+ line)))
1652 		       line)
1653 		     max-lines))
1654 	;; not so good if there are over 20 or 30 options, but then, if
1655 	;; there are that many you don't want to scan them all anyway...
1656 	(while (memq count command-characters) ; skip command characters.
1657 	  (setq count (ispell-int-char (1+ count))
1658 		skipped (1+ skipped)))
1659 	(insert "(" count ") " (car choices) "  ")
1660 	(setq choices (cdr choices)
1661 	      count (ispell-int-char (1+ count))))
1662       (setq count (ispell-int-char (- count ?0 skipped))))
1663 
1664     ;; ensure word is visible
1665     (if (not (pos-visible-in-window-p end))
1666 	(sit-for 0))
1667 
1668     ;; allow temporary split of dedicated windows...
1669     (if dedicated
1670 	(progn
1671 	  (setq dedicated-win (selected-window))
1672 	  (set-window-dedicated-p dedicated-win nil)))
1673 
1674     ;; Display choices for misspelled word.
1675     (ispell-show-choices line end)
1676     (select-window (setq textwin (next-window)))
1677 
1678     ;; highlight word, protecting current buffer status
1679     (unwind-protect
1680 	(progn
1681 	  (and ispell-highlight-p
1682 	       (ispell-highlight-spelling-error start end t))
1683 	  ;; Loop until a valid choice is made.
1684 	  (while
1685 	      (eq
1686 	       t
1687 	       (setq
1688 		result
1689 		(progn
1690 		  (undo-boundary)
1691 		  (let (message-log-max)
1692 		    (message (concat "C-h or ? for more options; SPC to leave "
1693 				     "unchanged, Character to replace word")))
1694 		  (let ((inhibit-quit t))
1695 		    (setq char (if (fboundp 'read-char-exclusive)
1696 				   (read-char-exclusive)
1697 				 (read-char))
1698 			  skipped 0)
1699 		    (if (or quit-flag (= char ?\C-g)) ; C-g is like typing X
1700 			(setq char ?X
1701 			      quit-flag nil)))
1702 		  ;; Adjust num to array offset skipping command characters.
1703 		  (let ((com-chars command-characters))
1704 		    (while com-chars
1705 		      (if (and (> (car com-chars) ?0) (< (car com-chars) char))
1706 			  (setq skipped (1+ skipped)))
1707 		      (setq com-chars (cdr com-chars)))
1708 		    (setq num (- char ?0 skipped)))
1709 
1710 		  (cond
1711 		   ((= char ? ) nil)	; accept word this time only
1712 		   ((= char ?i)		; accept and insert word into pers dict
1713 		    (ispell-send-string (concat "*" word "\n"))
1714 		    (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1715 		    nil)
1716 		   ((or (= char ?a) (= char ?A)) ; accept word without insert
1717 		    (ispell-send-string (concat "@" word "\n"))
1718 		    (if (null ispell-pdict-modified-p)
1719 			(setq ispell-pdict-modified-p
1720 			      (list ispell-pdict-modified-p)))
1721 		    (if (= char ?A) 0))	; return 0 for ispell-add buffer-local
1722 		   ((or (= char ?r) (= char ?R)) ; type in replacement
1723 		    (and (eq 'block ispell-highlight-p) ; refresh tty's
1724 			 (ispell-highlight-spelling-error start end nil t))
1725 		    (let ((result
1726 			   (if (or (= char ?R) ispell-query-replace-choices)
1727 			       (list (read-string
1728 				      (format "Query-replacement for %s: "word)
1729 				      word)
1730 				     t)
1731 			     (cons (read-string "Replacement for: " word)
1732 				   nil))))
1733 		      (and (eq 'block ispell-highlight-p)
1734 			   (ispell-highlight-spelling-error start end nil
1735 							    'block))
1736 		      result))
1737 		   ((or (= char ??) (= char help-char) (= char ?\C-h))
1738 		    (and (eq 'block ispell-highlight-p)
1739 			 (ispell-highlight-spelling-error start end nil t))
1740 		    (ispell-help)
1741 		    (and (eq 'block ispell-highlight-p)
1742 			 (ispell-highlight-spelling-error start end nil
1743 							  'block))
1744 		    t)
1745 		   ;; Quit and move point back.
1746 		   ((= char ?x)
1747 		    (ispell-pdict-save ispell-silently-savep)
1748 		    (message "Exited spell-checking")
1749 		    (setq ispell-quit t)
1750 		    nil)
1751 		   ;; Quit and preserve point.
1752 		   ((= char ?X)
1753 		    (ispell-pdict-save ispell-silently-savep)
1754 		    (message "%s"
1755 		     (substitute-command-keys
1756 		      (concat "Spell-checking suspended;"
1757 			      " use C-u \\[ispell-word] to resume")))
1758 		    (setq ispell-quit start)
1759 		    nil)
1760 		   ((= char ?q)
1761 		    (if (y-or-n-p "Really kill Ispell process? ")
1762 			(progn
1763 			  (ispell-kill-ispell t) ; terminate process.
1764 			  (setq ispell-quit (or (not ispell-checking-message)
1765 						(point))
1766 				ispell-pdict-modified-p nil))
1767 		      t))		; continue if they don't quit.
1768 		   ((= char ?l)
1769 		    (and (eq 'block ispell-highlight-p) ; refresh tty displays
1770 			 (ispell-highlight-spelling-error start end nil t))
1771 		    (let ((new-word (read-string
1772 				     "Lookup string (`*' is wildcard): "
1773 				     word)))
1774 		      (if new-word
1775 			  (progn
1776 			    (save-excursion
1777 			      (set-buffer (get-buffer-create
1778 					   ispell-choices-buffer))
1779 			      (erase-buffer)
1780 			      (setq count ?0
1781 				    skipped 0
1782 				    mode-line-format (concat
1783 						      "--  %b  --  word: "
1784 						      new-word)
1785 				    miss (lookup-words new-word)
1786 				    choices miss
1787 				    line (ispell-choices-win-default-height))
1788 			      (while (and choices ; adjust choices window.
1789 					  (< (if (> (+ 7 (current-column)
1790 						       (length (car choices))
1791 						       (if (> count ?~) 3 0))
1792 						    (window-width))
1793 						 (progn
1794 						   (insert "\n")
1795 						   (setq line (1+ line)))
1796 					       line)
1797 					     max-lines))
1798 				(while (memq count command-characters)
1799 				  (setq count (ispell-int-char (1+ count))
1800 					skipped (1+ skipped)))
1801 				(insert "(" count ") " (car choices) "  ")
1802 				(setq choices (cdr choices)
1803 				      count (ispell-int-char (1+ count))))
1804 			      (setq count (ispell-int-char
1805 					   (- count ?0 skipped))))
1806 			    (ispell-show-choices line end)
1807 			    (select-window (next-window)))))
1808 		    (and (eq 'block ispell-highlight-p)
1809 			 (ispell-highlight-spelling-error start end nil
1810 							  'block))
1811 		    t)			; reselect from new choices
1812 		   ((= char ?u)		; insert lowercase into dictionary
1813 		    (ispell-send-string (concat "*" (downcase word) "\n"))
1814 		    (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1815 		    nil)
1816 		   ((= char ?m)		; type in what to insert
1817 		    (ispell-send-string
1818 		     (concat "*" (read-string "Insert: " word) "\n"))
1819 		    (setq ispell-pdict-modified-p '(t))
1820 		    (cons word nil))
1821 		   ((and (>= num 0) (< num count))
1822 		    (if ispell-query-replace-choices ; Query replace flag
1823 			(list (nth num miss) 'query-replace)
1824 		      (nth num miss)))
1825 		   ((= char ?\C-l)
1826 		    (redraw-display) t)
1827 		   ((= char ?\C-r)
1828 		    ;; This may have alignment errors if current line is edited
1829 		    (if (marker-position ispell-recursive-edit-marker)
1830 			(progn
1831 			  (message "Only one recursive edit session supported")
1832 			  (beep)
1833 			  (sit-for 2))
1834 		      (set-marker ispell-recursive-edit-marker start)
1835 		      ;;(set-marker ispell-region-end reg-end)
1836 		      (and ispell-highlight-p		; unhighlight
1837 			   (ispell-highlight-spelling-error start end))
1838 		      (unwind-protect
1839 			  (progn
1840 			    (message
1841 			     "%s"
1842 			     (substitute-command-keys
1843 			      (concat "Exit recursive edit with"
1844 				      " \\[exit-recursive-edit]")))
1845 			    (save-window-excursion (save-excursion
1846 						     (recursive-edit))))
1847 			;; protected
1848 			(goto-char ispell-recursive-edit-marker)
1849 			(if (not (equal (marker-buffer
1850 					 ispell-recursive-edit-marker)
1851 					(current-buffer)))
1852 			    (progn
1853 			      (set-marker ispell-recursive-edit-marker nil)
1854 			      (error
1855 			       "Cannot continue ispell from this buffer.")))
1856 			(set-marker ispell-recursive-edit-marker nil)))
1857 		    (list word nil))	; recheck starting at this word.
1858 		   ((= char ?\C-z)
1859 		    (funcall (key-binding "\C-z"))
1860 		    t)
1861 		   (t (ding) t))))))
1862 	  result)
1863       ;; protected
1864       (and ispell-highlight-p		; unhighlight
1865 	   (save-window-excursion
1866 	     (select-window textwin)
1867 	     (ispell-highlight-spelling-error start end)))
1868       (if dedicated
1869 	  (set-window-dedicated-p dedicated-win t)))))
1870 
1871 
1872 
1873 (defun ispell-show-choices (line end)
1874   "Shows the choices in another buffer or frame."
1875   (if (and ispell-use-framepop-p (fboundp 'framepop-display-buffer))
1876       (progn
1877 	(framepop-display-buffer (get-buffer ispell-choices-buffer))
1878 	(get-buffer-window ispell-choices-buffer t)
1879 	(select-window (previous-window))) ; *Choices* window
1880     ;; standard selection by splitting a small buffer out of this window.
1881     (let ((choices-window (get-buffer-window ispell-choices-buffer)))
1882       (if choices-window
1883 	  (if (= line (window-height choices-window))
1884 	      (select-window choices-window)
1885 	    ;; *Choices* window changed size.  Adjust the choices window
1886 	    ;; without scrolling the spelled window when possible
1887 	    (let ((window-line (- line (window-height choices-window)))
1888 		  (visible (progn (vertical-motion -1) (point))))
1889 	      (if (< line (ispell-choices-win-default-height))
1890 		  (setq window-line (+ window-line
1891 				       (- (ispell-choices-win-default-height)
1892 					  line))))
1893 	      (move-to-window-line 0)
1894 	      (vertical-motion window-line)
1895 	      (set-window-start (selected-window)
1896 				(if (> (point) visible) visible (point)))
1897 	      (goto-char end)
1898 	      (select-window choices-window)
1899 	      (enlarge-window window-line)))
1900 	;; Overlay *Choices* window when it isn't showing
1901 	(ispell-overlay-window (max line (ispell-choices-win-default-height))))
1902       (switch-to-buffer ispell-choices-buffer)
1903       (goto-char (point-min)))))
1904 
1905 
1906 ;;;###autoload
1907 (defun ispell-help ()
1908   "Display a list of the options available when a misspelling is encountered.
1909 
1910 Selections are:
1911 
1912 DIGIT: Replace the word with a digit offered in the *Choices* buffer.
1913 SPC:   Accept word this time.
1914 `i':   Accept word and insert into private dictionary.
1915 `a':   Accept word for this session.
1916 `A':   Accept word and place in `buffer-local dictionary'.
1917 `r':   Replace word with typed-in value.  Rechecked.
1918 `R':   Replace word with typed-in value. Query-replaced in buffer. Rechecked.
1919 `?':   Show these commands.
1920 `x':   Exit spelling buffer.  Move cursor to original point.
1921 `X':   Exit spelling buffer.  Leaves cursor at the current point, and permits
1922         the aborted check to be completed later.
1923 `q':   Quit spelling session (Kills ispell process).
1924 `l':   Look up typed-in replacement in alternate dictionary.  Wildcards okay.
1925 `u':   Like `i', but the word is lower-cased first.
1926 `m':   Place typed-in value in personal dictionary, then recheck current word.
1927 `C-l':  redraws screen
1928 `C-r':  recursive edit
1929 `C-z':  suspend emacs or iconify frame"
1930 
1931   (if (equal ispell-help-in-bufferp 'electric)
1932       (progn
1933 	(require 'ehelp)
1934 	(with-electric-help
1935 	 (function (lambda ()
1936 		     ;;This shouldn't be necessary: with-electric-help needs
1937 		     ;; an optional argument telling it about the smallest
1938 		     ;; acceptable window-height of the help buffer.
1939 		     ;(if (< (window-height) 15)
1940 		     ;	 (enlarge-window (- 15 (window-height))))
1941 		     (princ "Selections are:
1942 
1943 DIGIT: Replace the word with a digit offered in the *Choices* buffer.
1944 SPC:   Accept word this time.
1945 `i':   Accept word and insert into private dictionary.
1946 `a':   Accept word for this session.
1947 `A':   Accept word and place in `buffer-local dictionary'.
1948 `r':   Replace word with typed-in value.  Rechecked.
1949 `R':   Replace word with typed-in value. Query-replaced in buffer. Rechecked.
1950 `?':   Show these commands.
1951 `x':   Exit spelling buffer.  Move cursor to original point.
1952 `X':   Exit spelling buffer.  Leaves cursor at the current point, and permits
1953         the aborted check to be completed later.
1954 `q':   Quit spelling session (Kills ispell process).
1955 `l':   Look up typed-in replacement in alternate dictionary.  Wildcards okay.
1956 `u':   Like `i', but the word is lower-cased first.
1957 `m':   Place typed-in value in personal dictionary, then recheck current word.
1958 `C-l':  redraws screen
1959 `C-r':  recursive edit
1960 `C-z':  suspend emacs or iconify frame")
1961 		     nil	;undocumented requirement of with-electric-help
1962 		     ))))
1963 
1964 
1965     (let ((help-1 (concat "[r/R]eplace word; [a/A]ccept for this session; "
1966 			  "[i]nsert into private dictionary"))
1967 	  (help-2 (concat "[l]ook a word up in alternate dictionary;  "
1968 			  "e[x/X]it;  [q]uit session"))
1969 	  (help-3 (concat "[u]ncapitalized insert into dict.  "
1970 			  "Type 'x C-h d ispell-help' for more help")))
1971       (save-window-excursion
1972 	(if ispell-help-in-bufferp
1973 	    (progn
1974 	      (ispell-overlay-window
1975 	       (+ 4 (ispell-mode-line-window-height-fudge)))
1976 	      (switch-to-buffer (get-buffer-create "*Ispell Help*"))
1977 	      (insert (concat help-1 "\n" help-2 "\n" help-3))
1978 	      (sit-for 5)
1979 	      (kill-buffer "*Ispell Help*"))
1980 	  (unwind-protect
1981 	      (progn
1982 		(select-window (minibuffer-window))
1983 		(erase-buffer)
1984 		(if (not version18p) (message nil))
1985 		;;(set-minibuffer-window (selected-window))
1986 		(enlarge-window 2)
1987 		(insert (concat help-1 "\n" help-2 "\n" help-3))
1988 		(sit-for 5))
1989 	    (erase-buffer)))))))
1990 
1991 
1992 (defun lookup-words (word &optional lookup-dict)
1993   "Look up WORD in optional word-list dictionary LOOKUP-DICT.
1994 A `*' serves as a wild card.  If no wild cards, `look' is used if it exists.
1995 Otherwise the variable `ispell-grep-command' contains the command used to
1996 search for the words (usually egrep).
1997 
1998 Optional second argument contains the dictionary to use; the default is
1999 `ispell-alternate-dictionary'."
2000   ;; We don't use the filter for this function, rather the result is written
2001   ;; into a buffer.  Hence there is no need to save the filter values.
2002   (if (null lookup-dict)
2003       (setq lookup-dict ispell-alternate-dictionary))
2004 
2005   (let* ((process-connection-type ispell-use-ptys-p)
2006 	 (wild-p (string-match "\\*" word))
2007 	 (look-p (and ispell-look-p	; Only use look for an exact match.
2008 		      (or ispell-have-new-look (not wild-p))))
2009 	 (ispell-grep-buffer (get-buffer-create "*Ispell-Temp*")) ; result buf
2010 	 (prog (if look-p ispell-look-command ispell-grep-command))
2011 	 (args (if look-p ispell-look-options ispell-grep-options))
2012 	 status results loc)
2013     (unwind-protect
2014 	(save-window-excursion
2015 	  (message "Starting \"%s\" process..." (file-name-nondirectory prog))
2016 	  (set-buffer ispell-grep-buffer)
2017 	  (if look-p
2018 	      nil
2019 	    ;; convert * to .*
2020 	    (insert "^" word "$")
2021 	    (while (search-backward "*" nil t) (insert "."))
2022 	    (setq word (buffer-string))
2023 	    (erase-buffer))
2024 	  (setq status (call-process prog nil t nil args word lookup-dict))
2025 	  ;; grep returns status 1 and no output when word not found, which
2026 	  ;; is a perfectly normal thing.
2027 	  (if (stringp status)
2028 	      (setq results (cons (format "error: %s exited with signal %s"
2029 					  (file-name-nondirectory prog) status)
2030 				  results))
2031 	    ;; else collect words into `results' in FIFO order
2032 	    (goto-char (point-max))
2033 	    ;; assure we've ended with \n
2034 	    (or (bobp) (= (preceding-char) ?\n) (insert ?\n))
2035 	    (while (not (bobp))
2036 	      (setq loc (point))
2037 	      (forward-line -1)
2038 	      (setq results (cons (buffer-substring-no-properties (point)
2039 								  (1- loc))
2040 				  results)))))
2041       ;; protected
2042       (kill-buffer ispell-grep-buffer)
2043       (if (and results (string-match ".+: " (car results)))
2044 	  (error "%s error: %s" ispell-grep-command (car results))))
2045     results))
2046 
2047 
2048 ;;; "ispell-filter" is a list of output lines from the generating function.
2049 ;;;   Each full line (ending with \n) is a separate item on the list.
2050 ;;; "output" can contain multiple lines, part of a line, or both.
2051 ;;; "start" and "end" are used to keep bounds on lines when "output" contains
2052 ;;;   multiple lines.
2053 ;;; "ispell-filter-continue" is true when we have received only part of a
2054 ;;;   line as output from a generating function ("output" did not end with \n)
2055 ;;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
2056 ;;;   This is the case when a process dies or fails. The default behavior
2057 ;;;   in this case treats the next input received as fresh input.
2058 
2059 (defun ispell-filter (process output)
2060   "Output filter function for ispell, grep, and look."
2061   (let ((start 0)
2062 	(continue t)
2063 	end)
2064     (while continue
2065       (setq end (string-match "\n" output start)) ; get text up to the newline.
2066       ;; If we get out of sync and ispell-filter-continue is asserted when we
2067       ;; are not continuing, treat the next item as a separate list.  When
2068       ;; ispell-filter-continue is asserted, ispell-filter *should* always be a
2069       ;; list!
2070 
2071       ;; Continue with same line (item)?
2072       (if (and ispell-filter-continue ispell-filter (listp ispell-filter))
2073 	  ;; Yes.  Add it to the prev item
2074 	  (setcar ispell-filter
2075 		  (concat (car ispell-filter) (substring output start end)))
2076 	;; No. This is a new line and item.
2077 	(setq ispell-filter
2078 	      (cons (substring output start end) ispell-filter)))
2079       (if (null end)
2080 	  ;; We've completed reading the output, but didn't finish the line.
2081 	  (setq ispell-filter-continue t continue nil)
2082 	;; skip over newline, this line complete.
2083 	(setq ispell-filter-continue nil end (1+ end))
2084 	(if (= end (length output))	; No more lines in output
2085 	    (setq continue nil)		;  so we can exit the filter.
2086 	  (setq start end))))))		; else move start to next line of input
2087 
2088 
2089 ;;; This function destroys the mark location if it is in the word being
2090 ;;; highlighted.
2091 (defun ispell-highlight-spelling-error-generic (start end &optional highlight
2092 						      refresh)
2093   "Highlight the word from START to END with a kludge using `inverse-video'.
2094 When the optional third arg HIGHLIGHT is set, the word is highlighted;
2095 otherwise it is displayed normally.
2096 Uses block cursor to highlight one character.
2097 Optional REFRESH will unhighlighted then highlight, using block cursor
2098  highlighting when REFRESH is equal to `block'."
2099   (and (eq 'block ispell-highlight-p)
2100        (or (eq 'block refresh)
2101 	   (setq start (1+ start))))	; On block non-refresh, inc start.
2102   (let ((modified (buffer-modified-p))	; don't allow this fn to modify buffer
2103 	(buffer-read-only nil)		; Allow highlighting read-only buffers.
2104 	(text (buffer-substring-no-properties start end)) ; Save hilight region
2105 	(inhibit-quit t)		; inhibit interrupt processing here.
2106 	(buffer-undo-list t))		; don't clutter the undo list.
2107     (goto-char end)
2108     (delete-region start end)
2109     (insert-char ?  (- end start))	; minimize amount of redisplay
2110     (sit-for 0)				; update display
2111     (if highlight (setq inverse-video (not inverse-video))) ; toggle video
2112     (delete-region start end)		; delete whitespace
2113     (insert text)			; insert text in inverse video.
2114     (sit-for 0)				; update display showing inverse video.
2115     (if (not highlight)
2116 	(goto-char end)
2117       (setq inverse-video (not inverse-video)) ; toggle video
2118       (and (eq 'block ispell-highlight-p)
2119 	   (goto-char (1- start))))	; use block cursor to "highlight" char
2120     (set-buffer-modified-p modified)	; don't modify if flag not set.
2121     (and refresh			; re-highlight
2122 	 (ispell-highlight-spelling-error-generic
2123 	  (if (eq 'block refresh) start (- start 2)) end t))))
2124 
2125 
2126 (defun ispell-highlight-spelling-error-xemacs (start end &optional highlight)
2127   "Highlight the word from START to END using `isearch-highlight'.
2128 When the optional third arg HIGHLIGHT is set, the word is highlighted,
2129 otherwise it is displayed normally."
2130   (if highlight
2131       (isearch-highlight start end)
2132     (isearch-dehighlight t))
2133   ;;(sit-for 0)
2134   )
2135 
2136 
2137 (defun ispell-highlight-spelling-error-overlay (start end &optional highlight)
2138   "Highlight the word from START to END using overlays.
2139 When the optional third arg HIGHLIGHT is set, the word is highlighted
2140 otherwise it is displayed normally.
2141 
2142 The variable `ispell-highlight-face' selects the face to use for highlighting."
2143   (if highlight
2144       (progn
2145 	(setq ispell-overlay (make-overlay start end))
2146 	(overlay-put ispell-overlay 'face ispell-highlight-face))
2147     (delete-overlay ispell-overlay)))
2148 
2149 
2150 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)
2151   (cond
2152    (xemacsp
2153     (ispell-highlight-spelling-error-xemacs start end highlight))
2154    ((and (not version18p)
2155 	 (featurep 'faces)
2156 	 (or (and (fboundp 'display-color-p) (display-color-p))
2157 	     window-system))
2158     (ispell-highlight-spelling-error-overlay start end highlight))
2159    (t (ispell-highlight-spelling-error-generic start end highlight refresh))))
2160 
2161 
2162 (defun ispell-overlay-window (height)
2163   "Create a window covering the top HEIGHT lines of the current window.
2164 Ensure that the line above point is still visible but otherwise avoid
2165 scrolling the current window.  Leave the new window selected."
2166   (save-excursion
2167     (let ((oldot (save-excursion (vertical-motion -1) (point)))
2168 	  (top (save-excursion (move-to-window-line height) (point))))
2169       ;; If line above old point (line starting at oldot) would be
2170       ;; hidden by new window, scroll it to just below new win
2171       ;; otherwise set top line of other win so it doesn't scroll.
2172       (if (< oldot top) (setq top oldot))
2173       ;; if frame is unsplitable, temporarily disable that...
2174       (if (cdr (assq 'unsplittable (frame-parameters (selected-frame))))
2175 	  (let ((frame (selected-frame)))
2176 	    (modify-frame-parameters frame '((unsplittable . nil)))
2177 	    (split-window nil height)
2178 	    (modify-frame-parameters frame '((unsplittable . t))))
2179 	(split-window nil height))
2180       (set-window-start (next-window) top))))
2181 
2182 
2183 ;;; Should we add a compound word match return value?
2184 (defun ispell-parse-output (output &optional accept-list shift)
2185   "Parse the OUTPUT string from Ispell process and return:
2186 1: t for an exact match.
2187 2: A string containing the root word matched via suffix removal.
2188 3: A list of possible correct spellings of the format:
2189    (\"ORIGINAL-WORD\" OFFSET MISS-LIST GUESS-LIST)
2190    ORIGINAL-WORD is a string of the possibly misspelled word.
2191    OFFSET is an integer giving the line offset of the word.
2192    MISS-LIST and GUESS-LIST are possibly null lists of guesses and misses.
2193 4: Nil when an error has occurred.
2194 
2195 Optional second arg ACCEPT-LIST is list of words already accepted.
2196 Optional third arg SHIFT is an offset to apply based on previous corrections."
2197   (cond
2198    ((string= output "") t)		; for startup with pipes...
2199    ((string= output "*") t)		; exact match
2200    ((string= output "-") t)		; compound word match
2201    ((string= (substring output 0 1) "+") ; found because of root word
2202     (substring output 2))		; return root word
2203    ((equal 0 (string-match "[\ra-zA-Z]" output))
2204     (ding)				; error message from ispell!
2205     (message (concat "Ispell error: " output))
2206     (sit-for 5)
2207     nil)
2208    (t					; need to process &, ?, and #'s
2209     (let ((type (substring output 0 1))	; &, ?, or #
2210 	  (original-word (substring output 2 (string-match " " output 2)))
2211 	  (cur-count 0)			; contains number of misses + guesses
2212 	  count miss-list guess-list offset)
2213       (setq output (substring output (match-end 0))) ; skip over misspelling
2214       (if (string= type "#")
2215 	  (setq count 0)		; no misses for type #
2216 	(setq count (string-to-int output) ; get number of misses.
2217 	      output (substring output (1+ (string-match " " output 1)))))
2218       (setq offset (string-to-int output))
2219       (if (string= type "#")		; No miss or guess list.
2220 	  (setq output nil)
2221 	(setq output (substring output (1+ (string-match " " output 1)))))
2222       (while output
2223 	(let ((end (string-match ", \\|\\($\\)" output))) ; end of miss/guess.
2224 	  (setq cur-count (1+ cur-count))
2225 	  (if (> cur-count count)
2226 	      (setq guess-list (cons (substring output 0 end) guess-list))
2227 	    (setq miss-list (cons (substring output 0 end) miss-list)))
2228 	  (if (match-end 1)		; True only when at end of line.
2229 	      (setq output nil)		; no more misses or guesses
2230 	    (setq output (substring output (+ end 2))))))
2231       ;; return results.  Accept word if it was already accepted.
2232       ;; adjust offset.
2233       (if (member original-word accept-list)
2234 	  t
2235 	(list original-word
2236 	      (if (numberp shift) (+ shift offset) offset)
2237 	      (nreverse miss-list) (nreverse guess-list)))))))
2238 
2239 
2240 (defun ispell-process-status ()
2241   "Return the status of the Ispell process.
2242 When asynchronous processes are not supported, `run' is always returned."
2243   (if ispell-async-processp
2244       (process-status ispell-process)
2245     (and ispell-process 'run)))
2246 
2247 
2248 (defun ispell-start-process ()
2249   "Start the ispell process, with support for no asynchronous processes.
2250 Keeps argument list for future ispell invocations for no async support."
2251   (let (args)
2252     ;; Local dictionary becomes the global dictionary in use.
2253     (if ispell-local-dictionary
2254 	(setq ispell-dictionary ispell-local-dictionary))
2255     (setq args (ispell-get-ispell-args))
2256     (if (and ispell-dictionary		; use specified dictionary
2257 	     (not (member "-d" args)))	; only define if not overriden
2258 	(setq args
2259 	      (append (list "-d" ispell-dictionary) args)))
2260     (if ispell-personal-dictionary	; use specified pers dict
2261 	(setq args
2262 	      (append args
2263 		      (list "-p"
2264 			    (expand-file-name ispell-personal-dictionary)))))
2265     (setq args (append args ispell-extra-args))
2266 
2267     (if ispell-async-processp
2268 	(let ((process-connection-type ispell-use-ptys-p))
2269 	  (apply 'start-process
2270 		 "ispell" nil ispell-program-name
2271 		 "-a"			; accept single input lines
2272 		 "-m"			; make root/affix combos not in dict
2273 		 args))
2274       (setq ispell-cmd-args args
2275 	    ispell-output-buffer (generate-new-buffer " *ispell-output*")
2276 	    ispell-session-buffer (generate-new-buffer " *ispell-session*"))
2277       (ispell-send-string "\032\n")	; so Ispell prints version and exits
2278       t)))
2279 
2280 
2281 
2282 (defun ispell-init-process ()
2283   "Check status of Ispell process and start if necessary."
2284   (if (and ispell-process
2285 	   (eq (ispell-process-status) 'run)
2286 	   ;; If we're using a personal dictionary, ensure
2287 	   ;; we're in the same default directory!
2288 	   (or (not ispell-personal-dictionary)
2289 	       (equal ispell-process-directory default-directory)))
2290       (setq ispell-filter nil ispell-filter-continue nil)
2291     ;; may need to restart to select new personal dictionary.
2292     (ispell-kill-ispell t)
2293     (message "Starting new Ispell process...")
2294     (sit-for 0)
2295     (setq ispell-library-path (check-ispell-version)
2296 	  ispell-process-directory default-directory
2297 	  ispell-process (ispell-start-process)
2298 	  ispell-filter nil
2299 	  ispell-filter-continue nil)
2300     (if ispell-async-processp
2301 	(set-process-filter ispell-process 'ispell-filter))
2302     ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs
2303     (if (and (or xemacsp
2304 		 (and (boundp 'enable-multibyte-characters)
2305 		      enable-multibyte-characters))
2306 	     (fboundp 'set-process-coding-system))
2307 	(set-process-coding-system ispell-process (ispell-get-coding-system)
2308 				   (ispell-get-coding-system)))
2309     ;; Get version ID line
2310     (if (not version18p)
2311 	(ispell-accept-output 3)
2312       (ispell-accept-output))
2313     ;; get more output if filter empty?
2314     (if (null ispell-filter) (ispell-accept-output 3))
2315     (cond ((null ispell-filter)
2316 	   (error "%s did not output version line" ispell-program-name))
2317 	  ((and
2318 	    (stringp (car ispell-filter))
2319 	    (if (string-match "warning: " (car ispell-filter))
2320 		(progn
2321 		  (if (not version18p)
2322 		      (ispell-accept-output 3) ; was warn msg.
2323 		    (ispell-accept-output))
2324 		  (stringp (car ispell-filter)))
2325 	      (null (cdr ispell-filter)))
2326 	    (string-match "^@(#) " (car ispell-filter)))
2327 	   ;; got the version line as expected (we already know it's the right
2328 	   ;; version, so don't bother checking again.)
2329 	   nil)
2330 	  (t
2331 	   ;; Otherwise, it must be an error message.  Show the user.
2332 	   ;; But first wait to see if some more output is going to arrive.
2333 	   ;; Otherwise we get cool errors like "Can't open ".
2334 	   (sleep-for 1)
2335 	   (ispell-accept-output 3)
2336 	   (error "%s" (mapconcat 'identity ispell-filter "\n"))))
2337     (setq ispell-filter nil)		; Discard version ID line
2338     (let ((extended-char-mode (ispell-get-extended-character-mode)))
2339       (if extended-char-mode		; ~ extended character mode
2340 	  (ispell-send-string (concat extended-char-mode "\n"))))
2341     (if ispell-async-processp
2342 	(process-kill-without-query ispell-process))))
2343 
2344 ;;;###autoload
2345 (defun ispell-kill-ispell (&optional no-error)
2346   "Kill current Ispell process (so that you may start a fresh one).
2347 With NO-ERROR, just return non-nil if there was no Ispell running."
2348   (interactive)
2349   (if (not (and ispell-process
2350 		(eq (ispell-process-status) 'run)))
2351       (or no-error
2352 	  (error "There is no ispell process running!"))
2353     (if ispell-async-processp
2354 	(progn
2355 	  (process-send-eof ispell-process)
2356 	  (if (eq (ispell-process-status) 'run)
2357 	      (ispell-accept-output 1))
2358 	  (if (eq (ispell-process-status) 'run)
2359 	      (kill-process ispell-process))
2360 	  (while (not (or (eq (ispell-process-status) 'exit)
2361 			  (eq (ispell-process-status) 'signal)))
2362 	    (if (or xemacsp version20p) (sleep-for 0.25)
2363 	      (sleep-for 0 250))))
2364       ;; synchronous processes
2365       (ispell-send-string "\n")		; make sure side effects occurred.
2366       (kill-buffer ispell-output-buffer)
2367       (kill-buffer ispell-session-buffer)
2368       (setq ispell-output-buffer nil
2369 	    ispell-session-buffer nil))
2370     (setq ispell-process nil)
2371     (message "Ispell process killed")
2372     nil))
2373 
2374 
2375 ;;; ispell-change-dictionary is set in some people's hooks.  Maybe this should
2376 ;;;  call ispell-init-process rather than wait for a spell checking command?
2377 
2378 ;;;###autoload
2379 (defun ispell-change-dictionary (dict &optional arg)
2380   "Change `ispell-dictionary' (q.v.) to DICT and kill old Ispell process.
2381 A new one will be started as soon as necessary.
2382 
2383 By just answering RET you can find out what the current dictionary is.
2384 
2385 With prefix argument, set the default dictionary."
2386   (interactive
2387    (list (completing-read
2388 	  "Use new dictionary (RET for current, SPC to complete): "
2389 	  (mapcar (function (lambda (dict) (setf dict (cons dict nil))))
2390 		  (valid-dictionary-list))
2391 	  nil t)
2392 	 current-prefix-arg))
2393   (if (equal dict "default") (setq dict nil))
2394   ;; This relies on completing-read's bug of returning "" for no match
2395   (cond ((equal dict "")
2396 	 (message "Using %s dictionary"
2397 		  (or ispell-local-dictionary ispell-dictionary "default")))
2398 	((and (equal dict ispell-dictionary)
2399 	      (or (null ispell-local-dictionary)
2400 		  (equal dict ispell-local-dictionary)))
2401 	 ;; Specified dictionary is the default already.  No-op
2402 	 (and (interactive-p)
2403 	      (message "No change, using %s dictionary" (or dict "default"))))
2404 	(t				; reset dictionary!
2405 	 (if (assoc dict ispell-dictionary-alist)
2406 	     (progn
2407 	       (if (or arg (null dict))	; set default dictionary
2408 		   (setq ispell-dictionary dict))
2409 	       (if (null arg)		; set local dictionary
2410 		   (setq ispell-local-dictionary dict)))
2411 	   (error "Undefined dictionary: %s" dict))
2412 	 (ispell-kill-ispell t)
2413 	 (message "(Next %sIspell command will use %s dictionary)"
2414 		  (cond ((equal ispell-local-dictionary ispell-dictionary)
2415 			 "")
2416 			(arg "global ")
2417 			(t "local "))
2418 		  (or (if (or (equal ispell-local-dictionary ispell-dictionary)
2419 			      (null arg))
2420 			  ispell-local-dictionary
2421 			ispell-dictionary)
2422 		      "default")))))
2423 
2424 
2425 ;;; Spelling of comments are checked when ispell-check-comments is non-nil.
2426 
2427 ;;;###autoload
2428 (defun ispell-region (reg-start reg-end &optional recheckp shift)
2429   "Interactively check a region for spelling errors.
2430 Return nil if spell session is quit,
2431  otherwise returns shift offset amount for last line processed."
2432   (interactive "r")			; Don't flag errors on read-only bufs.
2433   (if (not recheckp)
2434       (ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc.
2435   (let ((skip-region-start (make-marker))
2436 	(rstart (make-marker)))
2437   (unwind-protect
2438       (save-excursion
2439 	(message "Spell checking %s using %s dictionary..."
2440 		 (if (and (= reg-start (point-min)) (= reg-end (point-max)))
2441 		     (buffer-name) "region")
2442 		 (or ispell-dictionary "default"))
2443 	;; Returns cursor to original location.
2444 	(save-window-excursion
2445 	  (goto-char reg-start)
2446 	  (let ((transient-mark-mode)
2447 		(case-fold-search case-fold-search)
2448 		(query-fcc t)
2449 		in-comment
2450 		key)
2451 	    (let (message-log-max)
2452 	      (message "searching for regions to skip"))
2453 	    (if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t)
2454 		(progn
2455 		  (setq key (buffer-substring-no-properties
2456 			     (match-beginning 0) (match-end 0)))
2457 		  (set-marker skip-region-start (- (point) (length key)))
2458 		  (goto-char reg-start)))
2459 	    (let (message-log-max)
2460 	      (message "Continuing spelling check using %s dictionary..."
2461 		       (or ispell-dictionary "default")))
2462 	    (set-marker rstart reg-start)
2463 	    (set-marker ispell-region-end reg-end)
2464 	    (while (and (not ispell-quit)
2465 			(< (point) ispell-region-end))
2466 	      ;; spell-check region with skipping
2467 	      (if (and (marker-position skip-region-start)
2468 		       (<= skip-region-start (point)))
2469 		  (progn
2470 		    ;; If region inside line comment, must keep comment start.
2471 		    (setq in-comment (point)
2472 			  in-comment
2473 			  (and comment-start
2474 			       (or (null comment-end) (string= "" comment-end))
2475 			       (save-excursion
2476 				 (beginning-of-line)
2477 				 (re-search-forward comment-start in-comment t))
2478 			       comment-start))
2479 		    ;; Can change skip-regexps (in ispell-message)
2480 		    (ispell-skip-region key) ; moves pt past region.
2481 		    (set-marker rstart (point))
2482 		    ;; check for saving large attachments...
2483 		    (setq query-fcc (and query-fcc
2484 					 (ispell-ignore-fcc skip-region-start
2485 							    rstart)))
2486 		    (if (and (< rstart ispell-region-end)
2487 			     (re-search-forward
2488 			      (ispell-begin-skip-region-regexp)
2489 			      ispell-region-end t))
2490 			(progn
2491 			  (setq key (buffer-substring-no-properties
2492 				     (car (match-data))
2493 				     (car (cdr (match-data)))))
2494 			  (set-marker skip-region-start
2495 				      (- (point) (length key)))
2496 			  (goto-char rstart))
2497 		      (set-marker skip-region-start nil))))
2498 	      (setq reg-end (max (point)
2499 				 (if (marker-position skip-region-start)
2500 				     (min skip-region-start ispell-region-end)
2501 				   (marker-position ispell-region-end))))
2502 	      (let* ((start (point))
2503 		     (end (save-excursion (end-of-line) (min (point) reg-end)))
2504 		     (string (ispell-get-line start end reg-end in-comment)))
2505 		(if in-comment		; account for comment chars added
2506 		    (setq start (- start (length in-comment))
2507 			  in-comment nil))
2508 		(setq end (point))	; "end" tracks region retrieved.
2509 		(if string		; there is something to spell check!
2510 		    ;; (special start end)
2511 		    (setq shift (ispell-process-line string
2512 						     (and recheckp shift))))
2513 		(goto-char end)))))
2514 	(if ispell-quit
2515 	    nil
2516 	  (or shift 0)))
2517     ;; protected
2518     (if (and (not (and recheckp ispell-keep-choices-win))
2519 	     (get-buffer ispell-choices-buffer))
2520 	(kill-buffer ispell-choices-buffer))
2521     (set-marker skip-region-start nil)
2522     (set-marker rstart nil)
2523     (if ispell-quit
2524 	(progn
2525 	  ;; preserve or clear the region for ispell-continue.
2526 	  (if (not (numberp ispell-quit))
2527 	      (set-marker ispell-region-end nil)
2528 	    ;; Ispell-continue enabled - ispell-region-end is set.
2529 	    (goto-char ispell-quit))
2530 	  ;; Check for aborting
2531 	  (if (and ispell-checking-message (numberp ispell-quit))
2532 	      (progn
2533 		(setq ispell-quit nil)
2534 		(error "Message send aborted")))
2535 	  (if (not recheckp) (setq ispell-quit nil)))
2536       (if (not recheckp) (set-marker ispell-region-end nil))
2537       ;; Only save if successful exit.
2538       (ispell-pdict-save ispell-silently-savep)
2539       (message "Spell-checking done")))))
2540 
2541 
2542 (defun ispell-begin-skip-region-regexp ()
2543   "Returns a regexp of the search keys for region skipping.
2544 Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys.
2545 Must call after ispell-buffer-local-parsing due to dependence on mode."
2546   ;; start with regions generic to all buffers
2547   (let ((skip-regexp (ispell-begin-skip-region ispell-skip-region-alist)))
2548     ;; Comments
2549     (if (and (null ispell-check-comments) comment-start)
2550 	(setq skip-regexp (concat (regexp-quote comment-start) "\\|"
2551 				  skip-regexp)))
2552     (if (and (eq 'exclusive ispell-check-comments) comment-start)
2553 	;; search from end of current comment to start of next comment.
2554 	(setq skip-regexp (concat (if (string= "" comment-end) "^"
2555 				    (regexp-quote comment-end))
2556 				  "\\|" skip-regexp)))
2557     ;; tib
2558     (if ispell-skip-tib
2559 	(setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp)))
2560     ;; html stuff
2561     (if ispell-skip-html
2562 	(setq skip-regexp (concat
2563 			   (ispell-begin-skip-region ispell-html-skip-alists)
2564 			   "\\|"
2565 			   skip-regexp)))
2566     ;; tex
2567     (if (eq ispell-parser 'tex)
2568 	(setq skip-regexp (concat (ispell-begin-tex-skip-regexp) "\\|"
2569 				  skip-regexp)))
2570     ;; messages
2571     (if (and ispell-checking-message
2572 	     (not (eq t ispell-checking-message)))
2573 	(setq skip-regexp (concat
2574 			   (mapconcat
2575 			    (function (lambda (lst) (car lst)))
2576 			    ispell-checking-message
2577 			    "\\|")
2578 			   "\\|"
2579 			   skip-regexp)))
2580 
2581     ;; return new regexp
2582     skip-regexp))
2583 
2584 
2585 (defun ispell-begin-skip-region (skip-alist)
2586   "Regular expression for start of regions to skip generated from SKIP-ALIST.
2587 Each selection should be a key of SKIP-ALIST;
2588 otherwise, the current line is skipped."
2589   (mapconcat (function (lambda (lst)
2590 			 (if (stringp (car lst))
2591 			     (car lst)
2592 			   (eval (car lst)))))
2593 	     skip-alist
2594 	     "\\|"))
2595 
2596 
2597 (defun ispell-begin-tex-skip-regexp ()
2598   "Regular expression of tex commands to skip.
2599 Generated from `ispell-tex-skip-alists'."
2600   (concat
2601    ;; raw tex keys
2602    (mapconcat (function (lambda (lst) (car lst)))
2603 	      (car ispell-tex-skip-alists)
2604 	      "\\|")
2605    "\\|"
2606    ;; keys wrapped in begin{}
2607    (mapconcat (function (lambda (lst)
2608 			  (concat "\\\\begin[ \t\n]*{[ \t\n]*"
2609 				  (car lst)
2610 				  "[ \t\n]*}")))
2611 	      (car (cdr ispell-tex-skip-alists))
2612 	      "\\|")))
2613 
2614 
2615 (defun ispell-skip-region-list ()
2616   "Returns a list describing key and body regions to skip for this buffer.
2617 Includes regions defined by `ispell-skip-region-alist', tex mode,
2618 `ispell-html-skip-alists', and `ispell-checking-message'.
2619 Manual checking must include comments and tib references.
2620 The list is of the form described by variable `ispell-skip-region-alist'.
2621 Must call after `ispell-buffer-local-parsing' due to dependence on mode."
2622   (let ((skip-alist ispell-skip-region-alist))
2623     ;; only additional explicit region definition is tex.
2624     (if (eq ispell-parser 'tex)
2625 	(setq case-fold-search nil
2626 	      skip-alist (append (car ispell-tex-skip-alists)
2627 				 (car (cdr ispell-tex-skip-alists))
2628 				 skip-alist)))
2629     (if ispell-skip-html
2630 	(setq skip-alist (append ispell-html-skip-alists skip-alist)))
2631     (if (and ispell-checking-message
2632 	     (not (eq t ispell-checking-message)))
2633 	(setq skip-alist (append ispell-checking-message skip-alist)))
2634     skip-alist))
2635 
2636 
2637 (defun ispell-tex-arg-end (&optional arg)
2638   "Skip across ARG number of braces."
2639   (condition-case nil
2640       (progn
2641 	(while (looking-at "[ \t\n]*\\[") (forward-sexp))
2642 	(forward-sexp (or arg 1)))
2643     (error
2644      (message "error skipping s-expressions at point %d." (point))
2645      (beep)
2646      (sit-for 2))))
2647 
2648 
2649 (defun ispell-ignore-fcc (start end)
2650   "Deletes the Fcc: message header when large attachments are included.
2651 Return value `nil' if file with large attachments are saved.
2652 This can be used to avoid multiple questions for multiple large attachments.
2653 Returns point to starting location afterwards."
2654   (let ((result t))
2655     (if (and ispell-checking-message ispell-message-fcc-skip)
2656 	(if (< ispell-message-fcc-skip (- end start))
2657 	    (let (case-fold-search head-end)
2658 	      (goto-char (point-min))
2659 	      (setq head-end
2660 		    (or (re-search-forward
2661 			 (concat "^" (regexp-quote mail-header-separator) "$")
2662 			 nil t)
2663 			(re-search-forward "^$" nil t)
2664 			(point-min)))
2665 	      (goto-char (point-min))
2666 	      (if (re-search-forward "^Fcc:" head-end t)
2667 		  (if (y-or-n-p
2668 		       "Save copy of this message with large attachments? ")
2669 		      (setq result nil)
2670 		    (beginning-of-line)
2671 		    (kill-line 1)))
2672 	      (goto-char end))))
2673     result))
2674 
2675 
2676 (defun ispell-skip-region (key)
2677   "Skips across KEY and then to end of region.
2678 Key lookup determines region to skip.
2679 Point is placed at end of skipped region."
2680   ;; move over key to begin checking.
2681   (forward-char (length key))
2682   (let ((start (point))
2683 	;; Regenerate each call... This function can change region definition.
2684 	(alist (ispell-skip-region-list))
2685 	alist-key null-skip)
2686     (cond
2687      ;; what about quoted comment, or comment inside strings?
2688      ((and (null ispell-check-comments) comment-start
2689 	   (string= key comment-start))
2690       (if (string= "" comment-end)
2691 	  (forward-line)
2692 	(search-forward comment-end ispell-region-end t)))
2693      ((and (eq 'exclusive ispell-check-comments) comment-start
2694 	   (string= key comment-end))
2695       (search-forward comment-start ispell-region-end :end))
2696      ((and ispell-skip-tib (string-match ispell-tib-ref-beginning key))
2697       (re-search-forward ispell-tib-ref-end ispell-region-end t))
2698      ;; markings from alist
2699      (t
2700       (while alist
2701 	(setq alist-key (eval (car (car alist))))
2702 	(if (string-match alist-key key)
2703 	    (progn
2704 	      (setq alist (cdr (car alist)))
2705 	      (cond
2706 	       ((null alist) (setq null-skip t)) ; done!  Just skip key.
2707 	       ((not (consp alist))
2708 		;; Search past end of spell region to find this region end.
2709 		(re-search-forward (eval alist) (point-max) t))
2710 	       ((and (= 1 (length alist))
2711 		     (stringp (car alist)))
2712 		(re-search-forward (car alist) (point-max) t))
2713 	       (t
2714 		(setq null-skip t)	; error handling in functions!
2715 		(if (consp (cdr alist))
2716 		    (apply (car alist) (cdr alist))
2717 		  (funcall (car alist)))))
2718 	      (setq alist nil))
2719 	  (setq alist (cdr alist))))))
2720     (if (and (= start (point)) (null null-skip))
2721 	(progn
2722 	  (message "Matching region end for `%s' point %d not found"
2723 		   key (point))
2724 	  (beep)
2725 	  (sit-for 2)))))
2726 
2727 
2728 ;;; Grab the next line of data.
2729 ;;; Returns a string with the line data
2730 (defun ispell-get-line (start end reg-end in-comment)
2731   (let ((ispell-casechars (ispell-get-casechars))
2732 	string)
2733     (cond				; LOOK AT THIS LINE AND SKIP OR PROCESS
2734      ((eolp)				; END OF LINE, just go to next line.
2735       (forward-line))
2736      ;;((looking-at "[-#@*+!%~^]")	; SKIP SPECIAL ISPELL CHARACTERS
2737      ;; (forward-char 1))		; not needed as quoted below.
2738      ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS
2739 	  (re-search-forward "[][()${}]" end t)) ; or MATH COMMANDS
2740       (setq string (concat "^" in-comment
2741 			   (buffer-substring-no-properties start end)
2742 			   "\n"))
2743       (goto-char end))
2744      (t (goto-char end)))		; EMPTY LINE, skip it.
2745     string))
2746 
2747 
2748 ;;; Avoid error messages when compiling for these dynamic variables.
2749 (eval-when-compile
2750   (defvar start)
2751   (defvar end))
2752 
2753 (defun ispell-process-line (string shift)
2754   "Sends a LINE of text to ispell and processes the result.
2755 This will modify the buffer for spelling errors.
2756 Requires variables START and END to be defined in its lexical scope.
2757 Returns the sum shift due to changes in word replacements."
2758   ;;(declare special start end)
2759   (let (poss accept-list)
2760     (if (not (numberp shift))
2761 	(setq shift 0))
2762     ;; send string to spell process and get input.
2763     (ispell-send-string string)
2764     (while (progn
2765 	     (ispell-accept-output)
2766 	     ;; Last item of output contains a blank line.
2767 	     (not (string= "" (car ispell-filter)))))
2768     ;; parse all inputs from the stream one word at a time.
2769     ;; Place in FIFO order and remove the blank item.
2770     (setq ispell-filter (nreverse (cdr ispell-filter)))
2771     (while (and (not ispell-quit) ispell-filter)
2772       ;; get next word, accounting for accepted words and start shifts
2773       (setq poss (ispell-parse-output (car ispell-filter)
2774 				      accept-list shift))
2775       (if (and poss (listp poss))	; spelling error occurred.
2776 	  ;; Whenever we have misspellings, we can change
2777 	  ;; the buffer.  Keep boundaries as markers.
2778 	  ;; Markers can move with highlighting!  This destroys
2779 	  ;; end of region markers line-end and ispell-region-end
2780 	  (let ((word-start
2781 		 (copy-marker (+ start ispell-offset (car (cdr poss)))))
2782 		(word-len (length (car poss)))
2783 		(line-end (copy-marker end))
2784 		(line-start (copy-marker start))
2785 		recheck-region replace)
2786 	    (goto-char word-start)
2787 	    ;; Adjust the horizontal scroll & point
2788 	    (ispell-horiz-scroll)
2789 	    (goto-char (+ word-len word-start))
2790 	    (ispell-horiz-scroll)
2791 	    (goto-char word-start)
2792 	    (ispell-horiz-scroll)
2793 
2794 	    ;; Alignment cannot be tracked and this error will occur when
2795 	    ;; `query-replace' makes multiple corrections on the starting line.
2796 	    (if (/= (+ word-len (point))
2797 		    (progn
2798 		      ;; NB: Search can fail with Mule coding systems that don't
2799 		      ;;  display properly.  Ignore the error in this case?
2800 		      (search-forward (car poss) (+ word-len (point)) t)
2801 		      (point)))
2802 		;; This occurs due to filter pipe problems
2803 		(error (concat "Ispell misalignment: word "
2804 			       "`%s' point %d; probably incompatible versions")
2805 		       (car poss) (marker-position word-start)))
2806 	    ;; ispell-cmd-loop can go recursive & change buffer
2807 	    (if ispell-keep-choices-win
2808 		(setq replace (ispell-command-loop
2809 			       (car (cdr (cdr poss)))
2810 			       (car (cdr (cdr (cdr poss))))
2811 			       (car poss) (marker-position word-start)
2812 			       (+ word-len (marker-position word-start))))
2813 	      (save-window-excursion
2814 		(setq replace (ispell-command-loop
2815 			       (car (cdr (cdr poss)))
2816 			       (car (cdr (cdr (cdr poss))))
2817 			       (car poss) (marker-position word-start)
2818 			       (+ word-len (marker-position word-start))))))
2819 
2820 	    (goto-char word-start)
2821 	    ;; Recheck when query replace edit changes misspelled word.
2822 	    ;; Error in tex mode when a potential math mode change exists.
2823 	    (if (and replace (listp replace) (= 2 (length replace)))
2824 		(if (and (eq ispell-parser 'tex)
2825 			 (string-match "[\\\\][]()[]\\|\\\\begin\\|\\$"
2826 				       (regexp-quote string)))
2827 		    (error
2828 		     "Don't start query replace on a line with math characters"
2829 		     )
2830 		  (set-marker line-end (point))
2831 		  (setq ispell-filter nil
2832 			recheck-region t)))
2833 
2834 	    ;; insert correction if needed
2835 	    (cond
2836 	     ((or (null replace)
2837 		  (equal 0 replace))	; ACCEPT/INSERT
2838 	      (if (equal 0 replace)	; BUFFER-LOCAL DICT ADD
2839 		  (ispell-add-per-file-word-list (car poss)))
2840 	      ;; do not recheck accepted word on this line
2841 	      (setq accept-list (cons (car poss) accept-list)))
2842 	     (t				; replacement word selected or entered
2843 	      (delete-region (point) (+ word-len (point)))
2844 	      (if (not (listp replace))
2845 		  (progn
2846 		    (insert replace)	; insert dictionary word
2847 		    (setq accept-list (cons replace accept-list)))
2848 		(let ((replace-word (car replace)))
2849 		  ;; Recheck hand entered replacement word
2850 		  (insert replace-word)
2851 		  (if (car (cdr replace))
2852 		      (save-window-excursion
2853 			(delete-other-windows) ; to correctly show help.
2854 			;; Assume case-replace &
2855 			;; case-fold-search correct?
2856 			(query-replace (car poss) (car replace) t)))
2857 		  (goto-char word-start)
2858 		  ;; do not recheck if already accepted
2859 		  (if (member replace-word accept-list)
2860 		      (setq accept-list (cons replace-word accept-list)
2861 			    replace replace-word)
2862 		    (let ((region-end (copy-marker ispell-region-end)))
2863 		      (setq recheck-region ispell-filter
2864 			    ispell-filter nil ; save filter
2865 			    shift 0	; already accounted
2866 			    shift (ispell-region
2867 				  word-start
2868 				  (+ word-start (length replace-word))
2869 				  t shift))
2870 		      (if (null shift)	; quitting check.
2871 			  (setq shift 0))
2872 		      (set-marker ispell-region-end region-end)
2873 		      (set-marker region-end nil)
2874 		      (setq ispell-filter recheck-region
2875 			    recheck-region nil
2876 			    replace replace-word)))))
2877 
2878 	      (setq shift (+ shift (- (length replace) word-len)))
2879 
2880 	      ;; Move line-start across word...
2881 	      ;; new shift function does this now...
2882 	      ;;(set-marker line-start (+ line-start
2883 	      ;;			(- (length replace)
2884 	      ;;			   (length (car poss)))))
2885 	      ))
2886 	    (if (not ispell-quit)
2887 		(let (message-log-max)
2888 		  (message "Continuing spelling check using %s dictionary..."
2889 			   (or ispell-dictionary "default"))))
2890 	    (sit-for 0)
2891 	    (setq start (marker-position line-start)
2892 		  end (marker-position line-end))
2893 	    ;; Adjust markers when end of region lost from highlighting.
2894 	    (if (and (not recheck-region) (< end (+ word-start word-len)))
2895 		(setq end (+ word-start word-len)))
2896 	    (if (= word-start ispell-region-end)
2897 		(set-marker ispell-region-end (+ word-start word-len)))
2898 	    ;; going out of scope - unneeded
2899 	    (set-marker line-start nil)
2900 	    (set-marker word-start nil)
2901 	    (set-marker line-end nil)))
2902       ;; finished with misspelling!
2903       (setq ispell-filter (cdr ispell-filter)))
2904     shift))
2905 
2906 
2907 ;;;###autoload
2908 (defun ispell-comments-and-strings ()
2909   "Check comments and strings in the current buffer for spelling errors."
2910   (interactive)
2911   (goto-char (point-min))
2912   (let (state done)
2913     (while (not done)
2914       (setq done t)
2915       (setq state (parse-partial-sexp (point) (point-max)
2916 				      nil nil state 'syntax-table))
2917       (if (or (nth 3 state) (nth 4 state))
2918 	  (let ((start (point)))
2919 	    (setq state (parse-partial-sexp start (point-max)
2920 					    nil nil state 'syntax-table))
2921 	    (if (or (nth 3 state) (nth 4 state))
2922 		(error "Unterminated string or comment"))
2923 	    (save-excursion
2924 	      (setq done (not (ispell-region start (point))))))))))
2925 
2926 
2927 ;;;###autoload
2928 (defun ispell-buffer ()
2929   "Check the current buffer for spelling errors interactively."
2930   (interactive)
2931   (ispell-region (point-min) (point-max)))
2932 
2933 
2934 ;;;###autoload
2935 (defun ispell-continue ()
2936   "Continue a halted spelling session beginning with the current word."
2937   (interactive)
2938   (if (not (marker-position ispell-region-end))
2939       (message "No session to continue.  Use 'X' command when checking!")
2940     (if (not (equal (marker-buffer ispell-region-end) (current-buffer)))
2941 	(message "Must continue ispell from buffer %s"
2942 		 (buffer-name (marker-buffer ispell-region-end)))
2943       (ispell-region
2944        ;; find beginning of current word:
2945        (car (cdr (ispell-get-word t)))
2946        (marker-position ispell-region-end)))))
2947 
2948 
2949 ;;; Horizontal scrolling
2950 (defun ispell-horiz-scroll ()
2951   "Places point within the horizontal visibility of its window area."
2952   (if truncate-lines			; display truncating lines?
2953       ;; See if display needs to be scrolled.
2954       (let ((column (- (current-column) (max (window-hscroll) 1))))
2955 	(if (and (< column 0) (> (window-hscroll) 0))
2956 	    (scroll-right (max (- column) 10))
2957 	  (if (>= column (- (window-width) 2))
2958 	      (scroll-left (max (- column (window-width) -3) 10)))))))
2959 
2960 
2961 ;;; Interactive word completion.
2962 ;;; Forces "previous-word" processing.  Do we want to make this selectable?
2963 
2964 ;;;###autoload
2965 (defun ispell-complete-word (&optional interior-frag)
2966   "Try to complete the word before or under point (see `lookup-words')
2967 If optional INTERIOR-FRAG is non-nil then the word may be a character
2968 sequence inside of a word.
2969 
2970 Standard ispell choices are then available."
2971   (interactive "P")
2972   (let ((cursor-location (point))
2973 	(case-fold-search-val case-fold-search)
2974 	(word (ispell-get-word nil "\\*")) ; force "previous-word" processing.
2975 	start end possibilities replacement)
2976     (setq start (car (cdr word))
2977 	  end (car (cdr (cdr word)))
2978 	  word (car word)
2979 	  possibilities
2980 	  (or (string= word "")		; Will give you every word
2981 	      (lookup-words (concat (and interior-frag "*") word
2982 				    (if (or interior-frag (null ispell-look-p))
2983 					"*"))
2984 			    ispell-complete-word-dict)))
2985     (cond ((eq possibilities t)
2986 	   (message "No word to complete"))
2987 	  ((null possibilities)
2988 	   (message "No match for \"%s\"" word))
2989 	  (t				; There is a modification...
2990 	   (setq case-fold-search nil)	; Try and respect case of word.
2991 	   (cond
2992 	    ((string-equal (upcase word) word)
2993 	     (setq possibilities (mapcar 'upcase possibilities)))
2994 	    ((string-equal (upcase (substring word 0 1)) (substring word 0 1))
2995              (setq possibilities (mapcar (function
2996                                           (lambda (pos)
2997                                             (if (string-equal
2998 						 (substring word 0 1)
2999 						 (substring pos 0 1))
3000 						pos
3001                                               (capitalize pos))))
3002                                          possibilities))))
3003 	   (setq case-fold-search case-fold-search-val)
3004 	   (save-window-excursion
3005 	     (setq replacement
3006 		   (ispell-command-loop possibilities nil word start end)))
3007 	   (cond
3008 	    ((equal 0 replacement)	; BUFFER-LOCAL ADDITION
3009 	     (ispell-add-per-file-word-list word))
3010 	    (replacement		; REPLACEMENT WORD
3011 	     (delete-region start end)
3012 	     (setq word (if (atom replacement) replacement (car replacement))
3013 		   cursor-location (+ (- (length word) (- end start))
3014 				      cursor-location))
3015 	     (insert word)
3016 	     (if (not (atom replacement)) ; recheck spelling of replacement.
3017 		 (progn
3018 		   (goto-char cursor-location)
3019 		   (ispell-word nil t)))))
3020 	   (if (get-buffer ispell-choices-buffer)
3021 	       (kill-buffer ispell-choices-buffer))))
3022     (ispell-pdict-save ispell-silently-savep)
3023     (goto-char cursor-location)))
3024 
3025 
3026 ;;;###autoload
3027 (defun ispell-complete-word-interior-frag ()
3028   "Completes word matching character sequence inside a word."
3029   (interactive)
3030   (ispell-complete-word t))
3031 
3032 
3033 ;;;###autoload
3034 (defun ispell ()
3035   "Interactively check a region or buffer for spelling errors.
3036 If `transient-mark-mode' is on, and a region is active, spell-check
3037 that region.  Otherwise spell-check the buffer.
3038 
3039 Ispell dictionaries are not distributed with Emacs.  If you are
3040 looking for a dictionary, please see the distribution of the GNU ispell
3041 program, or do an Internet search; there are various dictionaries
3042 available on the net."
3043   (interactive)
3044   (if (and (boundp 'transient-mark-mode) transient-mark-mode
3045 	   (boundp 'mark-active) mark-active)
3046       (ispell-region (region-beginning) (region-end))
3047     (ispell-buffer)))
3048 
3049 
3050 ;;; **********************************************************************
3051 ;;; 			Ispell Minor Mode
3052 ;;; **********************************************************************
3053 
3054 (defvar ispell-minor-mode nil
3055   "Non-nil if Ispell minor mode is enabled.")
3056 ;; Variable indicating that ispell minor mode is active.
3057 (make-variable-buffer-local 'ispell-minor-mode)
3058 
3059 (or (assq 'ispell-minor-mode minor-mode-alist)
3060     (setq minor-mode-alist
3061           (cons '(ispell-minor-mode " Spell") minor-mode-alist)))
3062 
3063 (defvar ispell-minor-keymap
3064   (let ((map (make-sparse-keymap)))
3065     (define-key map " " 'ispell-minor-check)
3066     (define-key map "\r" 'ispell-minor-check)
3067     map)
3068   "Keymap used for Ispell minor mode.")
3069 
3070 (or (not (boundp 'minor-mode-map-alist))
3071     (assoc 'ispell-minor-mode minor-mode-map-alist)
3072     (setq minor-mode-map-alist
3073           (cons (cons 'ispell-minor-mode ispell-minor-keymap)
3074                 minor-mode-map-alist)))
3075 
3076 ;;;###autoload
3077 (defun ispell-minor-mode (&optional arg)
3078   "Toggle Ispell minor mode.
3079 With prefix arg, turn Ispell minor mode on iff arg is positive.
3080 
3081 In Ispell minor mode, pressing SPC or RET
3082 warns you if the previous word is incorrectly spelled.
3083 
3084 All the buffer-local variables and dictionaries are ignored -- to read
3085 them into the running ispell process, type \\[ispell-word] SPC."
3086   (interactive "P")
3087   (setq ispell-minor-mode
3088 	(not (or (and (null arg) ispell-minor-mode)
3089 		 (<= (prefix-numeric-value arg) 0))))
3090   (force-mode-line-update))
3091 
3092 (defun ispell-minor-check ()
3093   "Check previous word then continue with the normal binding of this key.
3094 Don't check previous word when character before point is a space or newline.
3095 Don't read buffer-local settings or word lists."
3096   (interactive "*")
3097   (let ((ispell-minor-mode nil)
3098 	(ispell-check-only t)
3099 	(last-char (char-after (1- (point)))))
3100     (command-execute (key-binding (this-command-keys)))
3101     (if (not (or (eq last-char ?\ ) (eq last-char ?\n)
3102 		 (and ispell-skip-html (eq last-char ?>))
3103 		 (and ispell-skip-html (eq last-char ?\;))))
3104 	(ispell-word nil t))))
3105 
3106 
3107 ;;; **********************************************************************
3108 ;;; 			Ispell Message
3109 ;;; **********************************************************************
3110 
3111 (defvar ispell-message-text-end
3112   (mapconcat (function identity)
3113 	     '(
3114 	       ;; Don't spell check signatures
3115 	       "^-- $"
3116 	       ;; Matches postscript files.
3117 	       ;;"^%!PS-Adobe-[123].0"
3118 	       ;; Matches uuencoded text
3119 	       ;;"^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM"
3120 	       ;; Matches shell files (especially auto-decoding)
3121 	       "^#! /bin/[ck]?sh"
3122 	       ;; Matches context difference listing
3123 	       "\\(\\(^cd .*\n\\)?diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*"
3124 	       ;; Matches unidiff difference listing
3125 	       "\\(diff -u .*\\)?\n--- .*\n\\+\\+\\+ .*\n@@ [-+][0-9]+,[0-9]+ [-+][0-9]+,[0-9]+ @@\n"
3126 	       ;; Matches reporter.el bug report
3127 	       "^current state:\n==============\n"
3128 	       ;; Matches commonly used "cut" boundaries
3129 	       "^\\(- \\)?[-=_]+\\s ?\\(cut here\\|Environment Follows\\)")
3130 	     "\\|")
3131   "*End of text which will be checked in `ispell-message'.
3132 If it is a string, limit at first occurrence of that regular expression.
3133 Otherwise, it must be a function which is called to get the limit.")
3134 
3135 
3136 (defun ispell-mime-multipartp (&optional limit)
3137   "Return multipart message start boundary or nil if none."
3138   ;; caller must ensure `case-fold-search' is set to `t'
3139   (and
3140    (re-search-forward
3141     "Content-Type: *multipart/\\([^ \t\n]*;[ \t]*[\n]?[ \t]*\\)+boundary="
3142     limit t)
3143    (let (boundary)
3144      (if (looking-at "\"")
3145 	 (let (start)
3146 	   (forward-char)
3147 	   (setq start (point))
3148 	   (while (not (looking-at "\""))
3149 	     (forward-char 1))
3150 	   (setq boundary (buffer-substring-no-properties start (point))))
3151        (let ((start (point)))
3152 	 (while (looking-at "[-0-9a-zA-Z'()+_,./:=?]")
3153 	   (forward-char))
3154 	 (setq boundary (buffer-substring-no-properties start (point)))))
3155      (if (< (length boundary) 1)
3156 	 (setq boundary nil)
3157        (concat "--" boundary)))))
3158 
3159 
3160 (defun ispell-mime-skip-part (boundary)
3161   "Moves point across header, or entire MIME part if message is encoded.
3162 All specified types except `7bit' `8bit' and `quoted-printable' are considered
3163 encoded and therefore skipped.  See rfc 1521, 2183, ...
3164 If no boundary is given, then entire message is skipped.
3165 
3166 This starts one line ABOVE the MIME content messages, on the boundary marker,
3167 for operation with the generic region-skipping code.
3168 This places new MIME boundaries into variable `ispell-checking-message'."
3169   (forward-line)			; skip over boundary to headers
3170   (let ((save-case-fold-search case-fold-search)
3171 	(continuep t)
3172 	textp)
3173     (setq case-fold-search t
3174 	  ispell-skip-html nil)
3175     (while continuep
3176       (setq continuep nil)
3177       (if (looking-at "Content-Type: *text/")
3178 	  (progn
3179 	    (goto-char (match-end 0))
3180 	    (if (looking-at "html")
3181 		(setq ispell-skip-html t))
3182 	    (setq textp t
3183 		  continuep t)
3184 	    (re-search-forward "\\(.*;[ \t]*[\n]\\)*.*$" nil t)
3185 	    (forward-line)))
3186       (if (looking-at "Content-Transfer-Encoding: *\\([^ \t\n]*\\)")
3187 	  (let ((match (buffer-substring (match-beginning 1) (match-end 1))))
3188 	    (setq textp (member (upcase match)
3189 				;; only spell check the following encodings:
3190 				'("7BIT" "8BIT" "QUOTED-PRINTABLE" "BINARY"))
3191 		  continuep t)
3192 	    (goto-char (match-end 0))
3193 	    (re-search-forward "\\(.*;[ \t]*[\n]\\)*.*$" nil t)
3194 	    (forward-line)))
3195       ;; hierarchical boundary definition
3196       (if (looking-at "Content-Type: *multipart/")
3197 	  (let ((new-boundary (ispell-mime-multipartp)))
3198 	    (if (string-match new-boundary boundary)
3199 		(setq continuep t)
3200 	      ;; first pass redefine skip function to include new boundary
3201 	      ;;(re-search-backward boundary nil t)
3202 	      (forward-line)
3203 	      (setq ispell-checking-message
3204 		    (cons
3205 		     (list new-boundary 'ispell-mime-skip-part new-boundary)
3206 		     (if (eq t ispell-checking-message) nil
3207 		       ispell-checking-message))
3208 		    textp t
3209 		    continuep t)))
3210 	;; Skip all MIME headers that don't affect spelling
3211 	(if (looking-at "Content-[^ \t]*: *\\(.*;[ \t]*[\n]\\)*.*$")
3212 	    (progn
3213 	      (setq continuep t)
3214 	      (goto-char (match-end 0))
3215 	      (forward-line)))))
3216 
3217     (setq case-fold-search save-case-fold-search)
3218     (if textp
3219 	(point)
3220       ;; encoded message.  Skip to boundary, or entire message.
3221       (if (not boundary)
3222 	  (goto-char (point-max))
3223 	(re-search-forward boundary nil t)
3224 	(beginning-of-line)
3225 	(point)))))
3226 
3227 
3228 ;;;###autoload
3229 (defun ispell-message ()
3230   "Check the spelling of a mail message or news post.
3231 Don't check spelling of message headers except the Subject field.
3232 Don't check included messages.
3233 
3234 To abort spell checking of a message region and send the message anyway,
3235 use the `x' command.  (Any subsequent regions will be checked.)
3236 The `X' command aborts the message send so that you can edit the buffer.
3237 
3238 To spell-check whenever a message is sent, include the appropriate lines
3239 in your .emacs file:
3240    (add-hook 'message-send-hook 'ispell-message)  ;; GNUS 5
3241    (add-hook 'news-inews-hook 'ispell-message)    ;; GNUS 4
3242    (add-hook 'mail-send-hook  'ispell-message)
3243    (add-hook 'mh-before-send-letter-hook 'ispell-message)
3244 
3245 You can bind this to the key C-c i in GNUS or mail by adding to
3246 `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression:
3247    (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))"
3248   (interactive)
3249   (save-excursion
3250     (goto-char (point-min))
3251     (let* (boundary mimep
3252 	   (ispell-skip-region-alist-save ispell-skip-region-alist)
3253 	   ;; Nil when message came from outside (eg calling emacs as editor)
3254 	   ;; Non-nil marker of end of headers.
3255 	   (internal-messagep
3256 	    (re-search-forward
3257 	     (concat "^" (regexp-quote mail-header-separator) "$") nil t))
3258 	   (end-of-headers		; Start of body.
3259 	    (copy-marker
3260 	     (or internal-messagep
3261 		 (re-search-forward "^$" nil t)
3262 		 (point-min))))
3263 	   (limit (copy-marker		; End of region we will spell check.
3264 		   (cond
3265 		    ((not ispell-message-text-end) (point-max))
3266 		    ((char-or-string-p ispell-message-text-end)
3267 		     (if (re-search-forward ispell-message-text-end nil t)
3268 			 (match-beginning 0)
3269 		       (point-max)))
3270 		    (t (min (point-max) (funcall ispell-message-text-end))))))
3271 	   (default-prefix   ; Vanilla cite prefix (just used for cite-regexp)
3272 	     (if (and (boundp 'mail-yank-prefix) mail-yank-prefix)
3273 		 (ispell-non-empty-string mail-yank-prefix)
3274 	       "   \\|\t"))
3275 	   (cite-regexp			;Prefix of quoted text
3276 	    (cond
3277 	     ((featurep 'supercite)	; sc 3.0
3278 	      (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
3279 		      (ispell-non-empty-string sc-reference-tag-string)))
3280 	     ((featurep 'sc)		; sc 2.3
3281 	      (concat "\\(" sc-cite-regexp "\\)" "\\|"
3282 		      (ispell-non-empty-string sc-reference-tag-string)))
3283 	     ((or (equal major-mode 'news-reply-mode) ;GNUS 4 & below
3284 		  (equal major-mode 'message-mode))   ;GNUS 5
3285 	      (concat "In article <" "\\|"
3286 		      "[^,;&+=\n]+ <[^,;&+=]+> writes:" "\\|"
3287 		      message-yank-prefix "\\|"
3288 		      default-prefix))
3289 	     ((equal major-mode 'mh-letter-mode) ; mh mail message
3290 	      (concat "[^,;&+=\n]+ writes:" "\\|"
3291 		      (ispell-non-empty-string mh-ins-buf-prefix)))
3292 	     ((not internal-messagep)	; Assume nn sent us this message.
3293 	      (concat "In [a-zA-Z.]+ you write:" "\\|"
3294 		      "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|"
3295 		      " *> *"))
3296 	     ((boundp 'vm-included-text-prefix) ; VM mail message
3297 	      (concat "[^,;&+=\n]+ writes:" "\\|"
3298 		      (ispell-non-empty-string vm-included-text-prefix)))
3299 	     (t default-prefix)))
3300 	   (ispell-skip-region-alist
3301 	    (cons (list (concat "^\\(" cite-regexp "\\)")
3302 			(function forward-line))
3303 		  ispell-skip-region-alist))
3304 	   (old-case-fold-search case-fold-search)
3305 	   (dictionary-alist ispell-message-dictionary-alist)
3306 	   (ispell-checking-message t))
3307 
3308       ;; Select dictionary for message
3309       (or (local-variable-p 'ispell-local-dictionary (current-buffer))
3310 	  (while dictionary-alist
3311 	    (goto-char (point-min))
3312 	    (if (re-search-forward (car (car dictionary-alist))
3313 				   end-of-headers t)
3314 		(setq ispell-local-dictionary (cdr (car dictionary-alist))
3315 		      dictionary-alist nil)
3316 	      (setq dictionary-alist (cdr dictionary-alist)))))
3317 
3318       (unwind-protect
3319 	  (progn
3320 	    ;; Spell check any original Subject:
3321 	    (goto-char (point-min))
3322 	    (setq case-fold-search t
3323 		  mimep (re-search-forward "MIME-Version:" end-of-headers t))
3324 	    (goto-char (point-min))
3325 	    (if (re-search-forward "^Subject: *" end-of-headers t)
3326 		(progn
3327 		  (goto-char (match-end 0))
3328 		  (if (and (not (looking-at ".*Re\\>"))
3329 			   (not (looking-at "\\[")))
3330 		      (progn
3331 			(setq case-fold-search old-case-fold-search)
3332 			(ispell-region (point)
3333 				       (progn ;Tab-initiated continuation lns.
3334 					 (end-of-line)
3335 					 (while (looking-at "\n[ \t]")
3336 					   (end-of-line 2))
3337 					 (point)))))))
3338 	    (if mimep
3339 		(progn
3340 		  (goto-char (point-min))
3341 		  (setq boundary (ispell-mime-multipartp end-of-headers))))
3342 	    ;; Adjust message limit to MIME message if necessary.
3343 	    (and boundary
3344 		 (re-search-forward (concat boundary "--") nil t)
3345 		 (re-search-backward boundary nil t)
3346 		 (< (point) (marker-position limit))
3347 		 (set-marker limit (point)))
3348 	    (goto-char (point-min))
3349 	    ;; Select type or skip checking if this is a non-multipart message
3350 	    ;; Point moved to end of buffer if region is encoded.
3351 	    (if (and mimep (not boundary))
3352 		(let (skip-regexp)	; protect from `ispell-mime-skip-part'
3353 		  (goto-char (point-min))
3354 		  (re-search-forward "Content-[^ \t]*:" end-of-headers t)
3355 		  (forward-line -1)	; following fn starts one line above
3356 		  (ispell-mime-skip-part nil)
3357 		  ;; if message-text-end region, limit may be less than point.
3358 		  (if (> (point) limit)
3359 		      (set-marker limit (point)))))
3360 	    (goto-char (max end-of-headers (point)))
3361 	    (forward-line 1)
3362 	    (setq case-fold-search old-case-fold-search)
3363 	    ;; Define MIME regions to skip.
3364 	    (if boundary
3365 		(setq ispell-checking-message
3366 		      (list (list boundary 'ispell-mime-skip-part boundary))))
3367 	    (ispell-region (point) limit))
3368 	(set-marker end-of-headers nil)
3369 	(set-marker limit nil)
3370 	(setq ispell-skip-region-alist ispell-skip-region-alist-save
3371 	      ispell-skip-html nil
3372 	      case-fold-search old-case-fold-search)))))
3373 
3374 
3375 (defun ispell-non-empty-string (string)
3376   (if (or (not string) (string-equal string ""))
3377       "\\'\\`" ; An unmatchable string if string is null.
3378     (regexp-quote string)))
3379 
3380 
3381 ;;; **********************************************************************
3382 ;;; 			Buffer Local Functions
3383 ;;; **********************************************************************
3384 
3385 
3386 (defun ispell-accept-buffer-local-defs ()
3387   "Load all buffer-local information, restarting Ispell when necessary."
3388   (ispell-buffer-local-dict)		; May kill ispell-process.
3389   (ispell-buffer-local-words)		; Will initialize ispell-process.
3390   (ispell-buffer-local-parsing))
3391 
3392 
3393 (defun ispell-buffer-local-parsing ()
3394   "Place Ispell into parsing mode for this buffer.
3395 Overrides the default parsing mode.
3396 Includes Latex/Nroff modes and extended character mode."
3397   ;; (ispell-init-process) must already be called.
3398   (ispell-send-string "!\n")		; Put process in terse mode.
3399   ;; We assume all major modes with "tex-mode" in them should use latex parsing
3400   ;; When exclusively checking comments, set to raw text mode (nroff).
3401   (if (and (not (eq 'exclusive ispell-check-comments))
3402 	   (or (and (eq ispell-parser 'use-mode-name)
3403 		    (string-match "[Tt][Ee][Xx]-mode"
3404 				  (symbol-name major-mode)))
3405 	       (eq ispell-parser 'tex)))
3406       (progn
3407 	(ispell-send-string "+\n")	; set ispell mode to tex
3408 	(if (not (eq ispell-parser 'tex))
3409 	    (set (make-local-variable 'ispell-parser) 'tex)))
3410     (ispell-send-string "-\n"))		; set mode to normal (nroff)
3411   ;; If needed, test for SGML & HTML modes and set a buffer local nil/t value.
3412   (if (and ispell-skip-html (not (eq ispell-skip-html t)))
3413       (setq ispell-skip-html
3414 	    (not (null (string-match "sgml\\|html"
3415 				     (downcase (symbol-name major-mode)))))))
3416   ;; Set default extended character mode for given buffer, if any.
3417   (let ((extended-char-mode (ispell-get-extended-character-mode)))
3418     (if extended-char-mode
3419 	(ispell-send-string (concat extended-char-mode "\n"))))
3420   ;; Set buffer-local parsing mode and extended character mode, if specified.
3421   (save-excursion
3422     (goto-char (point-max))
3423     ;; Uses last occurrence of ispell-parsing-keyword
3424     (if (search-backward ispell-parsing-keyword nil t)
3425 	(let ((end (save-excursion (end-of-line) (point)))
3426 	      string)
3427 	  (search-forward ispell-parsing-keyword)
3428 	  (while (re-search-forward " *\\([^ \"]+\\)" end t)
3429 	    ;; space separated definitions.
3430 	    (setq string (downcase (buffer-substring-no-properties
3431 				    (match-beginning 1) (match-end 1))))
3432 	    (cond ((and (string-match "latex-mode" string)
3433 			(not (eq 'exclusive ispell-check-comments)))
3434 		   (ispell-send-string "+\n~tex\n"))
3435 		  ((string-match "nroff-mode" string)
3436 		   (ispell-send-string "-\n~nroff\n"))
3437 		  ((string-match "~" string) ; Set extended character mode.
3438 		   (ispell-send-string (concat string "\n")))
3439 		  (t (message "Invalid Ispell Parsing argument!")
3440 		     (sit-for 2))))))))
3441 
3442 
3443 ;;; Can kill the current ispell process
3444 
3445 (defun ispell-buffer-local-dict ()
3446   "Initializes local dictionary and local personal dictionary.
3447 When a dictionary is defined in the buffer (see variable
3448 `ispell-dictionary-keyword'), it will override the local setting
3449 from \\[ispell-change-dictionary].
3450 Both should not be used to define a buffer-local dictionary."
3451   (save-excursion
3452     (goto-char (point-min))
3453     (let (end)
3454       ;; Override the local variable definition.
3455       ;; Uses last occurrence of ispell-dictionary-keyword.
3456       (goto-char (point-max))
3457       (if (search-backward ispell-dictionary-keyword nil t)
3458 	  (progn
3459 	    (search-forward ispell-dictionary-keyword)
3460 	    (setq end (save-excursion (end-of-line) (point)))
3461 	    (if (re-search-forward " *\\([^ \"]+\\)" end t)
3462 		(setq ispell-local-dictionary
3463 		      (buffer-substring-no-properties (match-beginning 1)
3464 						      (match-end 1))))))
3465       (goto-char (point-max))
3466       (if (search-backward ispell-pdict-keyword nil t)
3467 	  (progn
3468 	    (search-forward ispell-pdict-keyword)
3469 	    (setq end (save-excursion (end-of-line) (point)))
3470 	    (if (re-search-forward " *\\([^ \"]+\\)" end t)
3471 		(setq ispell-local-pdict
3472 		      (buffer-substring-no-properties (match-beginning 1)
3473 						      (match-end 1))))))))
3474   ;; Reload if new personal dictionary defined.
3475   (if (and ispell-local-pdict
3476 	   (not (equal ispell-local-pdict ispell-personal-dictionary)))
3477       (progn
3478 	(ispell-kill-ispell t)
3479 	(setq ispell-personal-dictionary ispell-local-pdict)))
3480   ;; Reload if new dictionary defined.
3481   (if (not (equal ispell-local-dictionary ispell-dictionary))
3482       (ispell-change-dictionary ispell-local-dictionary)))
3483 
3484 
3485 (defun ispell-buffer-local-words ()
3486   "Loads the buffer-local dictionary in the current buffer."
3487   (if (and ispell-buffer-local-name
3488 	   (not (equal ispell-buffer-local-name (buffer-name))))
3489       (progn
3490 	(ispell-kill-ispell t)
3491 	(setq ispell-buffer-local-name nil)))
3492   (ispell-init-process)
3493   (save-excursion
3494     (goto-char (point-min))
3495     (while (search-forward ispell-words-keyword nil t)
3496       (or ispell-buffer-local-name
3497 	  (setq ispell-buffer-local-name (buffer-name)))
3498       (let ((end (save-excursion (end-of-line) (point)))
3499 	    (ispell-casechars (ispell-get-casechars))
3500 	    string)
3501 	;; buffer-local words separated by a space, and can contain
3502 	;; any character other than a space.  Not rigorous enough.
3503 	(while (re-search-forward " *\\([^ ]+\\)" end t)
3504 	  (setq string (buffer-substring-no-properties (match-beginning 1)
3505 						       (match-end 1)))
3506 	  ;; This can fail when string contains a word with illegal chars.
3507 	  ;; Error handling needs to be added between ispell and emacs.
3508 	  (if (and (< 1 (length string))
3509 		   (equal 0 (string-match ispell-casechars string)))
3510 	      (ispell-send-string (concat "@" string "\n"))))))))
3511 
3512 
3513 ;;; returns optionally adjusted region-end-point.
3514 
3515 (defun ispell-add-per-file-word-list (word)
3516   "Add WORD to the per-file word list."
3517   (or ispell-buffer-local-name
3518       (setq ispell-buffer-local-name (buffer-name)))
3519   (save-excursion
3520     (goto-char (point-min))
3521     (let ((old-case-fold-search case-fold-search)
3522 	  line-okay search done found)
3523       (while (not done)
3524 	(setq case-fold-search nil
3525 	      search (search-forward ispell-words-keyword nil 'move)
3526 	      found (or found search)
3527 	      line-okay (< (+ (length word) 1 ; 1 for space after word..
3528 			      (progn (end-of-line) (current-column)))
3529 			   80)
3530 	      case-fold-search old-case-fold-search)
3531 	(if (or (and search line-okay)
3532 		(null search))
3533 	    (progn
3534 	      (setq done t)
3535 	      (if (null search)
3536 		  (progn
3537 		    (open-line 1)
3538 		    (unless found (newline))
3539 		    (insert (concat comment-start " " ispell-words-keyword))
3540 		    (if (> (length comment-end) 0)
3541 			(save-excursion
3542 			  (newline)
3543 			  (insert comment-end)))))
3544 	      (insert (concat " " word))))))))
3545 
3546 (add-to-list 'debug-ignored-errors "^No word found to check!$")
3547 
3548 (provide 'ispell)
3549 
3550 
3551 ;;; LOCAL VARIABLES AND BUFFER-LOCAL VALUE EXAMPLES.
3552 
3553 ;;; Local Variable options:
3554 ;;; mode: name(-mode)
3555 ;;; eval: expression
3556 ;;; local-variable: value
3557 
3558 ;;; The following sets the buffer local dictionary to `american' English
3559 ;;; and spell checks only comments.
3560 
3561 ;;; Local Variables:
3562 ;;; mode: emacs-lisp
3563 ;;; comment-column: 40
3564 ;;; ispell-check-comments: exclusive
3565 ;;; ispell-local-dictionary: "american"
3566 ;;; End:
3567 
3568 
3569 ;;; MORE EXAMPLES OF ISPELL BUFFER-LOCAL VALUES
3570 
3571 ;;; The following places this file in nroff parsing and extended char modes.
3572 ;;; Local IspellParsing: nroff-mode ~nroff
3573 ;;; Change IspellPersDict to IspellPersDict: to enable the following line.
3574 ;;; Local IspellPersDict ~/.ispell_lisp
3575 ;;; The following were automatically generated by ispell using the 'A' command:
3576 ; LocalWords:  settable alist inews mh frag pdict Wildcards iconify arg tex kss
3577 ; LocalWords:  alists minibuffer bufferp autoload loaddefs aff Dansk KOI SPC op
3578 ; LocalWords:  Francais Nederlands charset autoloaded popup nonmenu regexp num
3579 ; LocalWords:  AMStex hspace includeonly nocite epsfig displaymath eqnarray reg
3580 ; LocalWords:  minipage modeline pers dict unhighlight buf grep sync prev inc
3581 ; LocalWords:  fn hilight oldot NB AIX msg init read's bufs pt cmd eg multibyte
3582 ; LocalWords:  uuencoded unidiff sc nn VM SGML eval IspellPersDict unsplitable
3583 ; LocalWords:  lns XEmacs html casechars Multibyte Aug unix wp iso multiline
3584 ; LocalWords:  multipart aspell Fcc regexps tib russian latin Slovakian
3585 
3586 ;;; ispell.el ends here

Gespeicherte Dateianhänge

Um Dateianhänge in eine Seite einzufügen sollte unbedingt eine Angabe wie attachment:dateiname benutzt werden, wie sie auch in der folgenden Liste der Dateien erscheint. Es sollte niemals die URL des Verweises ("laden") kopiert werden, da sich diese jederzeit ändern kann und damit der Verweis auf die Datei brechen würde.
  • [laden | anzeigen] (2003-05-05 18:50:36, 138.5 KB) [[attachment:ispell.el]]
  • [laden | anzeigen] (2003-05-05 18:51:45, 138.5 KB) [[attachment:ispell.el-3.6+jw]]
 Alle Dateien | Ausgewählte Dateien: löschen verschieben auf Seite kopieren auf Seite

Sie dürfen keine Anhänge an diese Seite anhängen!