/[emacs]/emacs/lisp/textmodes/ispell.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/ispell.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.137.4.1 by monnier, Tue May 13 22:51:17 2003 UTC revision 1.137.4.2 by monnier, Tue May 13 22:51:58 2003 UTC
# Line 1  Line 1 
1  ;;; ispell.el --- Interface to International Ispell Versions 3.1 and 3.2  ;;; ispell.el --- Interface to International Ispell Versions 3.1 and 3.2
2    
3  ;; Copyright (C) 1994, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.  ;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
4    
5  ;; Authors         : Ken Stevens <k.stevens@ieee.org>  ;; Author: Ken Stevens <k.stevens@ieee.org>
6  ;; Stevens Mod Date: Mon 29 Nov 11:38:34 PST 1999  ;; Maintainer: <k.stevens@ieee.org>
7  ;; Stevens Revision: 3.3  ;; Stevens Mod Date: Fri Aug  4 09:41:50 PDT 2000
8    ;; Stevens Revision: 3.4
9  ;; Status          : Release with 3.1.12+ and 3.2.0+ ispell.  ;; Status          : Release with 3.1.12+ and 3.2.0+ ispell.
10  ;; Bug Reports     : ispell-el-bugs@itcorp.com  ;; Bug Reports     : ispell-el-bugs@itcorp.com
11  ;; Web Site        : http://kdstevens.com/~stevens/ispell-page.html  ;; Web Site        : http://kdstevens.com/~stevens/ispell-page.html
12    ;; Keywords: unix wp
13    
14  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
15    
# Line 127  Line 129 
129    
130  ;; Modifications made in latest versions:  ;; Modifications made in latest versions:
131    
132    ;; Revision 3.4 2000/8/4 09:41:50       kss
133    ;; Support new color display functions.
134    ;; Fixed misalignment offset bug when replacing a string after a shift made.
135    ;; Set to standard Author/Maintainer heading,
136    ;; ensure localwords lists are separated from the text by newline. (Dave Love)
137    ;; Added dictionary definition for Italian (William Deakin)
138    ;; HTML region skipping greatly improved. (Chuck D. Phillips)
139    ;; improved menus.  Fixed regexp matching http/email addresses.
140    ;; one arg always for xemacs sleep-for (gunnar Evermann)
141    ;; support for synchronous processes (Eli Zaretskii)
142    
143  ;; Revision 3.3  1999/11/29 11:38:34     kss  ;; Revision 3.3  1999/11/29 11:38:34     kss
144  ;; Only word replacements entered in from the keyboard are rechecked.  ;; Only word replacements entered in from the keyboard are rechecked.
145  ;; This fixes a bug in tex parsing and misalignment.  ;; This fixes a bug in tex parsing and misalignment.
# Line 183  Line 196 
196          "User variables for emacs ispell interface."          "User variables for emacs ispell interface."
197          :group 'applications)))          :group 'applications)))
198    
199    (if (not (fboundp 'buffer-substring-no-properties))
200        (defun buffer-substring-no-properties (start end)
201          (buffer-substring start end)))
202    
203  ;;;###autoload  ;;;###autoload
204  (defconst xemacsp (string-match "Lucid\\|XEmacs" emacs-version)  (defconst xemacsp (string-match "Lucid\\|XEmacs" emacs-version)
# Line 196  Line 212 
212  (defconst version20p (string-match "20\\.[0-9]+\\.[0-9]+" emacs-version)  (defconst version20p (string-match "20\\.[0-9]+\\.[0-9]+" emacs-version)
213    "Non nil if using emacs version 20.")    "Non nil if using emacs version 20.")
214    
215    (and (not version18p)
216         (not (boundp 'epoch::version))
217         (defalias 'ispell 'ispell-buffer)
218         (defalias 'ispell-check-version 'check-ispell-version))
219    
220    
221  ;;; **********************************************************************  ;;; **********************************************************************
222  ;;; The following variables should be set according to personal preference  ;;; The following variables should be set according to personal preference
# Line 358  The following values are supported: Line 379  The following values are supported:
379               there for a couple of seconds.               there for a couple of seconds.
380    t          Pop up a new buffer and display a short help message there    t          Pop up a new buffer and display a short help message there
381               for a couple of seconds.               for a couple of seconds.
382    electric   Pop up a new buffer and display a long help message there.    electric   Pop up a new buffer and display a long help message there.
383               User can browse and then exit the help mode."               User can browse and then exit the help mode."
384    :type '(choice (const electric) (const :tag "off" nil) (const :tag "on" t))    :type '(choice (const electric) (const :tag "off" nil) (const :tag "on" t))
385    :group 'ispell)    :group 'ispell)
# Line 429  for language-specific arguments." Line 450  for language-specific arguments."
450    :group 'ispell)    :group 'ispell)
451    
452    
453    
454    (defcustom ispell-skip-html 'use-mode-name
455      "*Indicates whether ispell should skip spell checking of SGML markup.
456    If t, always skip SGML markup; if nil, never skip; if non-t and non-nil,
457    guess whether SGML markup should be skipped according to the name of the
458    buffer's major mode."
459      :type '(choice (const :tag "always" t) (const :tag "never" nil)
460                     (const :tag "use-mode-name" use-mode-name))
461      :group 'ispell)
462    
463    
464  ;;; Define definitions here only for personal dictionaries.  ;;; Define definitions here only for personal dictionaries.
465  ;;;###autoload  ;;;###autoload
466  (defcustom ispell-local-dictionary-alist nil  (defcustom ispell-local-dictionary-alist nil
# Line 446  See `ispell-dictionary-alist'." Line 478  See `ispell-dictionary-alist'."
478                         (choice :tag "Extended character mode"                         (choice :tag "Extended character mode"
479                                 (const "~tex") (const "~plaintex")                                 (const "~tex") (const "~plaintex")
480                                 (const "~nroff") (const "~list")                                 (const "~nroff") (const "~list")
481                                 (const "~latin1") (const "~latin3")                                 (const "~latin1") (const "~latin3")
482                                 (const :tag "default" nil))                                 (const :tag "default" nil))
483                         (choice :tag "Character set"                         (choice :tag "Character set"
484                                 (const iso-8859-1)                                 (const iso-8859-1)
# Line 465  See `ispell-dictionary-alist'." Line 497  See `ispell-dictionary-alist'."
497      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
498     ("american"                          ; Yankee English     ("american"                          ; Yankee English
499      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)      "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
500     ("brasiliano"                        ; Brazilian mode     ("brasileiro"                        ; Brazilian mode
501      "[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]"      "[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]"
502      "[^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]"      "[^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]"
503      "[']" nil ("-d" "brasileiro") nil iso-8859-1)      "[']" nil ("-d" "brasileiro") nil iso-8859-1)
# Line 474  See `ispell-dictionary-alist'." Line 506  See `ispell-dictionary-alist'."
506     ("castellano"                        ; Spanish mode     ("castellano"                        ; Spanish mode
507      "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"      "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
508      "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"      "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
509      "[---]" nil ("-B" "-d" "castellano") "~tex" iso-8859-1)      "[-]" nil ("-B" "-d" "castellano") "~tex" iso-8859-1)
510     ("castellano8"                       ; 8 bit Spanish mode     ("castellano8"                       ; 8 bit Spanish mode
511      "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"      "[A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
512      "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"      "[^A-Z\301\311\315\321\323\332\334a-z\341\351\355\361\363\372\374]"
513      "[---]" nil ("-B" "-d" "castellano") "~latin1" iso-8859-1)))      "[-]" nil ("-B" "-d" "castellano") "~latin1" iso-8859-1)))
514    
515    
516  ;;; Second part of dictionary, shortened for loaddefs.el  ;;; Second part of dictionary, shortened for loaddefs.el
# Line 518  See `ispell-dictionary-alist'." Line 550  See `ispell-dictionary-alist'."
550     ("francais"                          ; Francais.aff     ("francais"                          ; Francais.aff
551      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
552      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
553      "[---']" t nil "~list" iso-8859-1)))      "[-']" t nil "~list" iso-8859-1)))
554    
555    
556  ;;; Fourth part of dictionary, shortened for loaddefs.el  ;;; Fourth part of dictionary, shortened for loaddefs.el
# Line 528  See `ispell-dictionary-alist'." Line 560  See `ispell-dictionary-alist'."
560   '(("francais-tex"                      ; Francais.aff   '(("francais-tex"                      ; Francais.aff
561      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"      "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
562      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"      "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
563      "[---'^`\"]" t nil "~tex" iso-8859-1)      "[-'^`\"]" t nil "~tex" iso-8859-1)
564       ("italiano"                         ; Italian.aff
565        "[A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
566        "[^A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
567        "[-]" nil ("-B" "-d" "italian") "~tex" iso-8859-1)
568     ("nederlands"                        ; Nederlands.aff     ("nederlands"                        ; Nederlands.aff
569      "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"      "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
570      "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"      "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]"
# Line 550  See `ispell-dictionary-alist'." Line 586  See `ispell-dictionary-alist'."
586     ("norsk7-tex"                        ; 7 bit Norwegian TeX mode     ("norsk7-tex"                        ; 7 bit Norwegian TeX mode
587      "[A-Za-z{}\\'^`]" "[^A-Za-z{}\\'^`]"      "[A-Za-z{}\\'^`]" "[^A-Za-z{}\\'^`]"
588      "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1)      "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1)
589     ("polish"                            ; polish mode     ("polish"                            ; polish mode
590      "[A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"      "[A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"
591      "[^A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"      "[^A-Za-z\241\243\246\254\257\261\263\266\274\277\306\312\321\323\346\352\361\363]"
592      "" nil ( "-d" "polish") nil iso-8859-2)))      "" nil ( "-d" "polish") nil iso-8859-2)))
# Line 637  LANGUAGE.aff file \(e.g., english.aff\). Line 673  LANGUAGE.aff file \(e.g., english.aff\).
673                         (choice :tag "Extended character mode"                         (choice :tag "Extended character mode"
674                                 (const "~tex") (const "~plaintex")                                 (const "~tex") (const "~plaintex")
675                                 (const "~nroff") (const "~list")                                 (const "~nroff") (const "~list")
676                                 (const "~latin1") (const "~latin3")                                 (const "~latin1") (const "~latin3")
677                                 (const :tag "default" nil))                                 (const :tag "default" nil))
678                         (choice :tag "Character set"                         (choice :tag "Character set"
679                                 (const iso-8859-1)                                 (const iso-8859-1)
# Line 652  LANGUAGE.aff file \(e.g., english.aff\). Line 688  LANGUAGE.aff file \(e.g., english.aff\).
688                ispell-dictionary-alist-3 ispell-dictionary-alist-4                ispell-dictionary-alist-3 ispell-dictionary-alist-4
689                ispell-dictionary-alist-5 ispell-dictionary-alist-6))                ispell-dictionary-alist-5 ispell-dictionary-alist-6))
690    
691  ;;; The preparation of the menu bar menu must be autoloaded  
692  ;;; because otherwise this file gets autoloaded every time Emacs starts  
693  ;;; so that it can set up the menus and determine keyboard equivalents.  
694    ;;; **********************************************************************
695    ;;; The following are used by ispell, and should not be changed.
696    ;;; **********************************************************************
697    
698    
699    
700  ;;; The version must be 3.1 or greater for this version of ispell.el  ;;; The version must be 3.1 or greater for this version of ispell.el
# Line 664  LANGUAGE.aff file \(e.g., english.aff\). Line 704  LANGUAGE.aff file \(e.g., english.aff\).
704  (defvar ispell-offset -1  (defvar ispell-offset -1
705    "Offset that maps protocol differences between ispell 3.1 versions.")    "Offset that maps protocol differences between ispell 3.1 versions.")
706    
707  (defconst ispell-version "ispell.el 3.3 -- Mon 29 Nov 11:38:34 PST 1999")  (defconst ispell-version "ispell.el 3.4 -- Fri Aug  4 09:41:50 PDT 2000")
708    
709    
710  (defun check-ispell-version (&optional interactivep)  (defun check-ispell-version (&optional interactivep)
# Line 731  Otherwise returns the library path if de Line 771  Otherwise returns the library path if de
771      result))      result))
772    
773    
774    
775    ;;; The preparation of the menu bar menu must be autoloaded
776    ;;; because otherwise this file gets autoloaded every time Emacs starts
777    ;;; so that it can set up the menus and determine keyboard equivalents.
778    
779    
780  ;;;###autoload  ;;;###autoload
781  (defvar ispell-menu-map nil "Key map for ispell menu.")  (defvar ispell-menu-map nil "Key map for ispell menu.")
782  ;;; redo menu when loading ispell to get dictionary modifications  ;;; redo menu when loading ispell to get dictionary modifications
# Line 773  and added as a submenu of the \"Edit\" m Line 819  and added as a submenu of the \"Edit\" m
819          (cond ((not (stringp name))          (cond ((not (stringp name))
820                 (define-key ispell-menu-map (vector 'default)                 (define-key ispell-menu-map (vector 'default)
821                   (cons "Select Default Dict"                   (cons "Select Default Dict"
822                         (list 'lambda () '(interactive)                         (cons "Dictionary for which Ispell was configured"
823                               (list 'ispell-change-dictionary "default")))))                               (list 'lambda () '(interactive)
824                                       (list
825                                         'ispell-change-dictionary "default"))))))
826                ((or (not path)           ; load all if library dir not defined                ((or (not path)           ; load all if library dir not defined
827                     (file-exists-p (concat path "/" name ".hash"))                     (file-exists-p (concat path "/" name ".hash"))
828                     (file-exists-p (concat path "/" name ".has"))                     (file-exists-p (concat path "/" name ".has"))
# Line 782  and added as a submenu of the \"Edit\" m Line 830  and added as a submenu of the \"Edit\" m
830                          (or (file-exists-p(concat path "/" load-dict ".hash"))                          (or (file-exists-p(concat path "/" load-dict ".hash"))
831                              (file-exists-p(concat path "/" load-dict ".has")))))                              (file-exists-p(concat path "/" load-dict ".has")))))
832                 (define-key ispell-menu-map (vector (intern name))                 (define-key ispell-menu-map (vector (intern name))
833                   (cons (concat "Select " (capitalize name))                   (cons (concat "Select " (capitalize name) " Dict")
834                         (list 'lambda () '(interactive)                         (list 'lambda () '(interactive)
835                               (list 'ispell-change-dictionary name)))))))))                               (list 'ispell-change-dictionary name)))))))))
836    
# Line 792  and added as a submenu of the \"Edit\" m Line 840  and added as a submenu of the \"Edit\" m
840  (if ispell-menu-map-needed  (if ispell-menu-map-needed
841      (progn      (progn
842        (define-key ispell-menu-map [ispell-change-dictionary]        (define-key ispell-menu-map [ispell-change-dictionary]
843          '("Change Dictionary" . ispell-change-dictionary))          '(menu-item "Change Dictionary..." ispell-change-dictionary
844                        :help "Supply explicit path to dictionary"))
845        (define-key ispell-menu-map [ispell-kill-ispell]        (define-key ispell-menu-map [ispell-kill-ispell]
846          '("Kill Process" . ispell-kill-ispell))          '(menu-item "Kill Process" ispell-kill-ispell
847                        :enable (and ispell-process
848                                     (eq (ispell-process-status) 'run))
849                        :help "Terminate Ispell subprocess"))
850        (define-key ispell-menu-map [ispell-pdict-save]        (define-key ispell-menu-map [ispell-pdict-save]
851          '("Save Dictionary" . (lambda ()(interactive) (ispell-pdict-save t t))))          '(menu-item "Save Dictionary"
852                        (lambda () (interactive) (ispell-pdict-save t t))
853                        :help "Save personal dictionary"))
854          (define-key ispell-menu-map [ispell-help]
855            ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ?
856            '(menu-item "Help"
857                        (lambda () (interactive) (describe-function 'ispell-help))
858                        :help "Show standard Ispell keybindings and commands"))
859        (define-key ispell-menu-map [ispell-complete-word]        (define-key ispell-menu-map [ispell-complete-word]
860          '("Complete Word" . ispell-complete-word))          '(menu-item "Complete Word" ispell-complete-word
861                        :help "Complete word at cursor using dictionary"))
862        (define-key ispell-menu-map [ispell-complete-word-interior-frag]        (define-key ispell-menu-map [ispell-complete-word-interior-frag]
863          '("Complete Word Frag" . ispell-complete-word-interior-frag))))          '(menu-item "Complete Word Fragment" ispell-complete-word-interior-frag
864                        :help "Complete word fragment at cursor"))))
865    
866  ;;;###autoload  ;;;###autoload
867  (if ispell-menu-map-needed  (if ispell-menu-map-needed
868      (progn      (progn
869        (define-key ispell-menu-map [ispell-continue]        (define-key ispell-menu-map [ispell-continue]
870          '("Continue Check" . ispell-continue))          '(menu-item "Continue Spell-Checking" ispell-continue
871                        :enable (and (boundp 'ispell-region-end)
872                                     (marker-position ispell-region-end)
873                                     (equal (marker-buffer ispell-region-end)
874                                            (current-buffer)))
875                        :help "Continue spell checking last region"))
876        (define-key ispell-menu-map [ispell-word]        (define-key ispell-menu-map [ispell-word]
877          '("Check Word" . ispell-word))          '(menu-item "Spell-Check Word" ispell-word
878                        :help "Spell-check word at cursor"))
879        (define-key ispell-menu-map [ispell-comments-and-strings]        (define-key ispell-menu-map [ispell-comments-and-strings]
880          '("Check Comments" . ispell-comments-and-strings))          '(menu-item "Spell-Check Comments" ispell-comments-and-strings
881        (define-key ispell-menu-map [ispell-region]                      :help "Spell-check only comments and strings"))))
882          '("Check Region" . ispell-region))  
       (define-key ispell-menu-map [ispell-buffer]  
         '("Check Buffer" . ispell-buffer))))  
883    
884  ;;;###autoload  ;;;###autoload
885  (if ispell-menu-map-needed  (if ispell-menu-map-needed
886      (progn      (progn
887          (define-key ispell-menu-map [ispell-region]
888            '(menu-item "Spell-Check Region" ispell-region
889                        :enable mark-active
890                        :help "Spell-check text in marked region"))
891        (define-key ispell-menu-map [ispell-message]        (define-key ispell-menu-map [ispell-message]
892          '("Check Message" . ispell-message))          '(menu-item "Spell-Check Message" ispell-message
893        (define-key ispell-menu-map [ispell-help]                      :help "Skip headers and included message text"))
894          ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ?        (define-key ispell-menu-map [ispell-buffer]
895          '("Help" . (lambda () (interactive) (describe-function 'ispell-help))))          '(menu-item "Spell-Check Buffer" ispell-buffer
896        (put 'ispell-region 'menu-enable 'mark-active)                      :help "Check spelling of selected buffer"))
897          ;;(put 'ispell-region 'menu-enable 'mark-active)
898        (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))        (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
899    
900  ;;; XEmacs versions 19 & 20  ;;; XEmacs versions 19 & 20
# Line 888  and added as a submenu of the \"Edit\" m Line 958  and added as a submenu of the \"Edit\" m
958    
959    
960  ;;; **********************************************************************  ;;; **********************************************************************
 ;;; The following are used by ispell, and should not be changed.  
 ;;; **********************************************************************  
961    
962    
963  ;;; This variable contains the current dictionary being used if the ispell  ;;; This variable contains the current dictionary being used if the ispell
# Line 934  Protects against bogus binding of `enabl Line 1002  Protects against bogus binding of `enabl
1002  (defvar ispell-process nil  (defvar ispell-process nil
1003    "The process object for Ispell.")    "The process object for Ispell.")
1004    
1005    (defvar ispell-async-processp (and (fboundp 'kill-process)
1006                                       (fboundp 'process-send-string)
1007                                       (fboundp 'accept-process-output)
1008                                       ;;(fboundp 'start-process)
1009                                       ;;(fboundp 'set-process-filter)
1010                                       ;;(fboundp 'process-kill-without-query)
1011                                       )
1012      "Non-nil means that the OS supports asynchronous processes.")
1013    
1014  (defvar ispell-pdict-modified-p nil  (defvar ispell-pdict-modified-p nil
1015    "Non-nil means personal dictionary has modifications to be saved.")    "Non-nil means personal dictionary has modifications to be saved.")
1016    
# Line 942  Protects against bogus binding of `enabl Line 1019  Protects against bogus binding of `enabl
1019  ;;; When numeric, contains cursor location in buffer, and cursor remains there.  ;;; When numeric, contains cursor location in buffer, and cursor remains there.
1020  (defvar ispell-quit nil)  (defvar ispell-quit nil)
1021    
1022    (defvar ispell-process-directory nil
1023      "The directory where `ispell-process' was started.")
1024    
1025  (defvar ispell-filter nil  (defvar ispell-filter nil
1026    "Output filter from piped calls to Ispell.")    "Output filter from piped calls to Ispell.")
1027    
1028  (defvar ispell-filter-continue nil  (defvar ispell-filter-continue nil
1029    "Control variable for Ispell filter function.")    "Control variable for Ispell filter function.")
1030    
1031  (defvar ispell-process-directory nil  (defvar ispell-output-buffer nil
1032    "The directory where `ispell-process' was started.")    "Buffer used for reading output of a synchronous Ispell subprocess.")
1033    
1034    (defvar ispell-session-buffer nil
1035      "Buffer used for passing input to a synchronous Ispell subprocess.")
1036    
1037    (defvar ispell-cmd-args nil
1038      "Command-line arguments to pass to a synchronous Ispell subprocess.")
1039    
1040  (defvar ispell-query-replace-marker (make-marker)  (defvar ispell-query-replace-marker (make-marker)
1041    "Marker for `query-replace' processing.")    "Marker for `query-replace' processing.")
# Line 999  The last occurring definition in the buf Line 1085  The last occurring definition in the buf
1085      (ispell-parsing-keyword        forward-line)      (ispell-parsing-keyword        forward-line)
1086      ("^---*BEGIN PGP [A-Z ]*--*" . "^---*END PGP [A-Z ]*--*")      ("^---*BEGIN PGP [A-Z ]*--*" . "^---*END PGP [A-Z ]*--*")
1087      ("^---* \\(Start of \\)?[Ff]orwarded [Mm]essage"   . "^---* End of [Ff]orwarded [Mm]essage")      ("^---* \\(Start of \\)?[Ff]orwarded [Mm]essage"   . "^---* End of [Ff]orwarded [Mm]essage")
1088      ;; matches e-mail addresses, file names, http addresses, etc.      ;; Matches e-mail addresses, file names, http addresses, etc.  The `-+'
1089      ("\\(/\\|\\(\\(\\w\\|-\\)+[.:@]\\)\\)\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+")      ;; pattern necessary for performance reasons when `-' part of word syntax.
1090        ("\\(-+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_]\\|~\\)+\\)+\\)")
1091      ;; This is a pretty complex regexp.  It can be simplified to the following:      ;; This is a pretty complex regexp.  It can be simplified to the following:
1092      ;; "\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+"      ;; "\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_]\\|~\\)+\\)+"
1093      ;; but some valid text will be skipped, e.g. "his/her".  This could be      ;; but some valid text will be skipped, e.g. "his/her".  This could be
1094      ;; fixed up (at the expense of a moderately more complex regexp)      ;; fixed up (at the expense of a moderately more complex regexp)
1095      ;; by not allowing "/" to be the character which triggers the      ;; by not allowing "/" to be the character which triggers the
1096      ;; identification of the computer name, e.g.:      ;; identification of the computer name, e.g.:
1097      ;; "\\(\\w\\|-\\)+[.:@]\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+"      ;; "\\(\\w\\|[-_]\\)+[.:@]\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_]\\|~\\)+\\)+"
1098      )      )
1099    "Alist expressing beginning and end of regions not to spell check.    "Alist expressing beginning and end of regions not to spell check.
1100  The alist key must be a regular expression.  The alist key must be a regular expression.
# Line 1048  Delete or add any regions you want to be Line 1135  Delete or add any regions you want to be
1135  for skipping in latex mode.")  for skipping in latex mode.")
1136    
1137    
 (defcustom ispell-skip-sgml 'use-mode-name  
   "*Indicates whether ispell should skip spell checking of SGML markup.  
 If t, always skip SGML markup; if nil, never skip; if non-t and non-nil,  
 guess whether SGML markup should be skipped according to the name of the  
 buffer's major mode."  
   :type '(choice (const :tag "always" t) (const :tag "never" nil)  
                  (const :tag "use-mode-name" use-mode-name))  
   :group 'ispell)  
   
1138  (defvar ispell-local-pdict ispell-personal-dictionary  (defvar ispell-local-pdict ispell-personal-dictionary
1139    "A buffer local variable containing the current personal dictionary.    "A buffer local variable containing the current personal dictionary.
1140  If non-nil, the value must be a string, which is a file name.  If non-nil, the value must be a string, which is a file name.
# Line 1095  You can set this variable in hooks in yo Line 1173  You can set this variable in hooks in yo
1173    
1174    
1175    
1176  (and (not version18p)  ;;;###autoload
1177       (not (boundp 'epoch::version))  (define-key esc-map "$" 'ispell-word)
      (defalias 'ispell 'ispell-buffer)  
      (defalias 'ispell-check-version 'check-ispell-version))  
1178    
1179    
1180  (if (not (fboundp 'buffer-substring-no-properties))  (defun ispell-accept-output (&optional timeout-secs timeout-msecs)
1181      (defun buffer-substring-no-properties (start end)    "Wait for output from ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS.
1182        (buffer-substring start end)))  If asynchronous subprocesses are not supported, call `ispell-filter' and
1183    pass it the output of the last ispell invocation."
1184      (if ispell-async-processp
1185          (accept-process-output ispell-process timeout-secs timeout-msecs)
1186        (if (null ispell-process)
1187            (error "No Ispell process to read output from!")
1188          (let ((buf ispell-output-buffer)
1189                ispell-output)
1190            (if (not (bufferp buf))
1191                (setq ispell-filter nil)
1192              (save-excursion
1193                (set-buffer buf)
1194                (setq ispell-output (buffer-substring-no-properties
1195                                     (point-min) (point-max))))
1196              (ispell-filter t ispell-output)
1197              (save-excursion
1198                (set-buffer buf)
1199                (erase-buffer)))))))
1200    
1201    
1202    (defun ispell-send-string (string)
1203      "Send the string STRING to the Ispell process."
1204      (if ispell-async-processp
1205          (process-send-string ispell-process string)
1206        ;; Asynchronous subprocesses aren't supported on this losing system.
1207        ;; We keep all the directives passed to Ispell during the entire
1208        ;; session in a buffer, and pass them anew each time we invoke
1209        ;; Ispell to process another chunk of text.  (Yes, I know this is a
1210        ;; terrible kludge, and it's a bit slow, but it does get the work done.)
1211        (let ((cmd (aref string 0))
1212              ;; The following commands are not passed to Ispell until
1213              ;; we have a *reall* reason to invoke it.
1214              (cmds-to-defer '(?* ?@ ?~ ?+ ?- ?! ?%))
1215              (default-major-mode 'fundamental-mode)
1216              (session-buf ispell-session-buffer)
1217              (output-buf ispell-output-buffer)
1218              (ispell-args ispell-cmd-args)
1219              (defdir ispell-process-directory)
1220              prev-pos)
1221          (save-excursion
1222            (set-buffer session-buf)
1223            (setq prev-pos (point))
1224            (setq default-directory defdir)
1225            (insert string)
1226            (if (not (memq cmd cmds-to-defer))
1227                (let (coding-system-for-read coding-system-for-write status)
1228                  (if (or xemacsp
1229                          (and (boundp 'enable-multibyte-characters)
1230                               enable-multibyte-characters))
1231                      (setq coding-system-for-read (ispell-get-coding-system)
1232                            coding-system-for-write (ispell-get-coding-system)))
1233                  (set-buffer output-buf)
1234                  (erase-buffer)
1235                  (set-buffer session-buf)
1236                  (setq status
1237                        (apply 'call-process-region (point-min) (point-max)
1238                               ispell-program-name nil
1239                               output-buf nil
1240                               "-a" "-m" ispell-args))
1241                  (set-buffer output-buf)
1242                  (goto-char (point-min))
1243                  (save-match-data
1244                    (if (not (looking-at "@(#) "))
1245                        (error "Ispell error: %s"
1246                               (buffer-substring-no-properties
1247                                (point) (progn (end-of-line) (point)))))
1248                    ;; If STRING is "^Z\n", we just started Ispell and need
1249                    ;; to retain its version ID line in the output buffer.
1250                    ;; Otherwise, remove the ID line, as it will confuse
1251                    ;; `ispell-filter'.
1252                    (or (string= string "\032\n")
1253                        (progn
1254                          (forward-line)
1255                          (delete-region (point-min) (point))))
1256                    ;; If STRING begins with ^ or any normal character, we need
1257                    ;; to remove the last line from the session buffer, since it
1258                    ;; was just spell-checked, and we don't want to check it again.
1259                    ;; The same goes for the # command, since Ispell already saved
1260                    ;; the personal dictionary.
1261                    (set-buffer session-buf)
1262                    (delete-region prev-pos (point))
1263                    ;; Ispell run synchronously saves the personal dictionary
1264                    ;; after each successful command.  So we can remove any
1265                    ;; lines in the session buffer that insert words into the
1266                    ;; dictionary.
1267                    (if (memq status '(0 nil))
1268                        (let ((more-lines t))
1269                          (goto-char (point-min))
1270                          (while more-lines
1271                            (if (looking-at "^\\*")
1272                                (let ((start (point)))
1273                                  (forward-line)
1274                                  (delete-region start (point)))
1275                              (setq more-lines (= 0 (forward-line))))))))))))))
1276    
1277    
 ;;;###autoload  
 (define-key esc-map "$" 'ispell-word)  
1278    
1279  ;;;###autoload  ;;;###autoload
1280  (defun ispell-word (&optional following quietly continue)  (defun ispell-word (&optional following quietly continue)
# Line 1156  quit          spell session exited." Line 1324  quit          spell session exited."
1324          (or quietly          (or quietly
1325              (message "Checking spelling of %s..."              (message "Checking spelling of %s..."
1326                       (funcall ispell-format-word word)))                       (funcall ispell-format-word word)))
1327          (process-send-string ispell-process "%\n") ;put in verbose mode          (ispell-send-string "%\n")      ; put in verbose mode
1328          (process-send-string ispell-process (concat "^" word "\n"))          (ispell-send-string (concat "^" word "\n"))
1329          ;; wait until ispell has processed word          ;; wait until ispell has processed word
1330          (while (progn          (while (progn
1331                   (accept-process-output ispell-process)                   (ispell-accept-output)
1332                   (not (string= "" (car ispell-filter)))))                   (not (string= "" (car ispell-filter)))))
1333          ;;(process-send-string ispell-process "!\n") ;back to terse mode.          ;;(ispell-send-string "!\n") ;back to terse mode.
1334          (setq ispell-filter (cdr ispell-filter)) ; remove extra \n          (setq ispell-filter (cdr ispell-filter)) ; remove extra \n
1335          (if (and ispell-filter (listp ispell-filter))          (if (and ispell-filter (listp ispell-filter))
1336              (if (> (length ispell-filter) 1)              (if (> (length ispell-filter) 1)
# Line 1296  If so, ask if it needs to be saved." Line 1464  If so, ask if it needs to be saved."
1464    (if (or ispell-pdict-modified-p force-save)    (if (or ispell-pdict-modified-p force-save)
1465        (if (or no-query (y-or-n-p "Personal dictionary modified.  Save? "))        (if (or no-query (y-or-n-p "Personal dictionary modified.  Save? "))
1466            (progn            (progn
1467              (process-send-string ispell-process "#\n") ; save dictionary              (ispell-send-string "#\n")  ; save dictionary
1468              (message "Personal dictionary saved."))))              (message "Personal dictionary saved."))))
1469    ;; unassert variable, even if not saved to avoid questioning.    ;; unassert variable, even if not saved to avoid questioning.
1470    (setq ispell-pdict-modified-p nil))    (setq ispell-pdict-modified-p nil))
# Line 1372  Global `ispell-quit' set to start locati Line 1540  Global `ispell-quit' set to start locati
1540      ;; ensure word is visible      ;; ensure word is visible
1541      (if (not (pos-visible-in-window-p end))      (if (not (pos-visible-in-window-p end))
1542          (sit-for 0))          (sit-for 0))
1543        
1544      ;; allow temporary split of dedicated windows...      ;; allow temporary split of dedicated windows...
1545      (if dedicated      (if dedicated
1546          (progn          (progn
# Line 1418  Global `ispell-quit' set to start locati Line 1586  Global `ispell-quit' set to start locati
1586                    (cond                    (cond
1587                     ((= char ? ) nil)    ; accept word this time only                     ((= char ? ) nil)    ; accept word this time only
1588                     ((= char ?i)         ; accept and insert word into pers dict                     ((= char ?i)         ; accept and insert word into pers dict
1589                      (process-send-string ispell-process (concat "*" word "\n"))                      (ispell-send-string (concat "*" word "\n"))
1590                      (setq ispell-pdict-modified-p '(t)) ; dictionary modified!                      (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1591                      nil)                      nil)
1592                     ((or (= char ?a) (= char ?A)) ; accept word without insert                     ((or (= char ?a) (= char ?A)) ; accept word without insert
1593                      (process-send-string ispell-process (concat "@" word "\n"))                      (ispell-send-string (concat "@" word "\n"))
1594                      (if (null ispell-pdict-modified-p)                      (if (null ispell-pdict-modified-p)
1595                          (setq ispell-pdict-modified-p                          (setq ispell-pdict-modified-p
1596                                (list ispell-pdict-modified-p)))                                (list ispell-pdict-modified-p)))
# Line 1518  Global `ispell-quit' set to start locati Line 1686  Global `ispell-quit' set to start locati
1686                                                            'block))                                                            'block))
1687                      t)                  ; reselect from new choices                      t)                  ; reselect from new choices
1688                     ((= char ?u)         ; insert lowercase into dictionary                     ((= char ?u)         ; insert lowercase into dictionary
1689                      (process-send-string ispell-process                      (ispell-send-string (concat "*" (downcase word) "\n"))
                                          (concat "*" (downcase word) "\n"))  
1690                      (setq ispell-pdict-modified-p '(t)) ; dictionary modified!                      (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
1691                      nil)                      nil)
1692                     ((= char ?m)         ; type in what to insert                     ((= char ?m)         ; type in what to insert
1693                      (process-send-string                      (ispell-send-string
1694                       ispell-process (concat "*" (read-string "Insert: " word)                       (concat "*" (read-string "Insert: " word) "\n"))
                                             "\n"))  
1695                      (setq ispell-pdict-modified-p '(t))                      (setq ispell-pdict-modified-p '(t))
1696                      (cons word nil))                      (cons word nil))
1697                     ((and (>= num 0) (< num count))                     ((and (>= num 0) (< num count))
# Line 1641  SPC:   Accept word this time. Line 1807  SPC:   Accept word this time.
1807    (if (equal ispell-help-in-bufferp 'electric)    (if (equal ispell-help-in-bufferp 'electric)
1808        (progn        (progn
1809          (require 'ehelp)          (require 'ehelp)
1810          (with-electric-help          (with-electric-help
1811           (function (lambda ()           (function (lambda ()
1812                       ;;This shouldn't be necessary: with-electric-help needs                       ;;This shouldn't be necessary: with-electric-help needs
1813                       ;; an optional argument telling it about the smallest                       ;; an optional argument telling it about the smallest
# Line 1859  The variable `ispell-highlight-face' sel Line 2025  The variable `ispell-highlight-face' sel
2025     (xemacsp     (xemacsp
2026      (ispell-highlight-spelling-error-xemacs start end highlight))      (ispell-highlight-spelling-error-xemacs start end highlight))
2027     ((and (not version18p)     ((and (not version18p)
2028           (featurep 'faces) window-system)           (featurep 'faces)
2029             (or (and (fboundp 'display-color-p) (display-color-p))
2030                 window-system))
2031      (ispell-highlight-spelling-error-overlay start end highlight))      (ispell-highlight-spelling-error-overlay start end highlight))
2032     (t (ispell-highlight-spelling-error-generic start end highlight refresh))))     (t (ispell-highlight-spelling-error-generic start end highlight refresh))))
2033    
# Line 1942  Optional third arg SHIFT is an offset to Line 2110  Optional third arg SHIFT is an offset to
2110                (nreverse miss-list) (nreverse guess-list)))))))                (nreverse miss-list) (nreverse guess-list)))))))
2111    
2112    
2113    (defun ispell-process-status ()
2114      "Return the status of the Ispell process.
2115    When asynchronous processes are not supported, `run' is always returned."
2116      (if ispell-async-processp
2117          (process-status ispell-process)
2118        (and ispell-process 'run)))
2119    
2120    
2121    (defun ispell-start-process ()
2122      "Start the ispell process, with support for no asynchronous processes.
2123    Keeps argument list for future ispell invocations for no async support."
2124      (let (args)
2125        ;; Local dictionary becomes the global dictionary in use.
2126        (if ispell-local-dictionary
2127            (setq ispell-dictionary ispell-local-dictionary))
2128        (setq args (ispell-get-ispell-args))
2129        (if ispell-dictionary               ; use specified dictionary
2130            (setq args
2131                  (append (list "-d" ispell-dictionary) args)))
2132        (if ispell-personal-dictionary      ; use specified pers dict
2133            (setq args
2134                  (append args
2135                          (list "-p"
2136                                (expand-file-name ispell-personal-dictionary)))))
2137        (setq args (append args ispell-extra-args))
2138    
2139        (if ispell-async-processp
2140            (let ((process-connection-type ispell-use-ptys-p))
2141              (apply 'start-process
2142                     "ispell" nil ispell-program-name
2143                     "-a"                   ; accept single input lines
2144                     "-m"                   ; make root/affix combos not in dict
2145                     args))
2146          (setq ispell-cmd-args args
2147                ispell-output-buffer (generate-new-buffer " *ispell-output*")
2148                ispell-session-buffer (generate-new-buffer " *ispell-session*"))
2149          (ispell-send-string "\032\n")     ; so Ispell prints version and exits
2150          t)))
2151    
2152    
2153    
2154  (defun ispell-init-process ()  (defun ispell-init-process ()
2155    "Check status of Ispell process and start if necessary."    "Check status of Ispell process and start if necessary."
2156    (if (and ispell-process    (if (and ispell-process
2157             (eq (process-status ispell-process) 'run)             (eq (ispell-process-status) 'run)
2158             ;; If we're using a personal dictionary, assure             ;; If we're using a personal dictionary, ensure
2159             ;; we're in the same default directory!             ;; we're in the same default directory!
2160             (or (not ispell-personal-dictionary)             (or (not ispell-personal-dictionary)
2161                 (equal ispell-process-directory default-directory)))                 (equal ispell-process-directory default-directory)))
# Line 1956  Optional third arg SHIFT is an offset to Line 2165  Optional third arg SHIFT is an offset to
2165      (message "Starting new Ispell process...")      (message "Starting new Ispell process...")
2166      (sit-for 0)      (sit-for 0)
2167      (check-ispell-version)      (check-ispell-version)
2168      (setq ispell-process      (setq ispell-process-directory default-directory
2169            (let ((process-connection-type ispell-use-ptys-p))            ispell-process (ispell-start-process)
             (apply 'start-process  
                    "ispell" nil ispell-program-name  
                    "-a"                 ; accept single input lines  
                    "-m"                 ; make root/affix combos not in dict  
                    (let (args)  
                      ;; Local dictionary becomes the global dictionary in use.  
                      (if ispell-local-dictionary  
                          (setq ispell-dictionary ispell-local-dictionary))  
                      (setq args (ispell-get-ispell-args))  
                      (if ispell-dictionary ; use specified dictionary  
                          (setq args  
                                (append (list "-d" ispell-dictionary) args)))  
                      (if ispell-personal-dictionary ; use specified pers dict  
                          (setq args  
                                (append args  
                                        (list "-p"  
                                              (expand-file-name  
                                               ispell-personal-dictionary)))))  
                      (setq args (append args ispell-extra-args))  
                      args)))  
2170            ispell-filter nil            ispell-filter nil
2171            ispell-filter-continue nil            ispell-filter-continue nil)
2172            ispell-process-directory default-directory)      (if ispell-async-processp
2173      (set-process-filter ispell-process 'ispell-filter)          (set-process-filter ispell-process 'ispell-filter))
2174      ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs      ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs
2175      (if (and (or xemacsp      (if (and (or xemacsp
2176                   (and (boundp 'enable-multibyte-characters)                   (and (boundp 'enable-multibyte-characters)
# Line 1991  Optional third arg SHIFT is an offset to Line 2180  Optional third arg SHIFT is an offset to
2180                                     (ispell-get-coding-system)))                                     (ispell-get-coding-system)))
2181      ;; Get version ID line      ;; Get version ID line
2182      (if (not version18p)      (if (not version18p)
2183          (accept-process-output ispell-process 3)          (ispell-accept-output 3)
2184        (accept-process-output ispell-process))        (ispell-accept-output))
2185      ;; get more output if filter empty?      ;; get more output if filter empty?
2186      (if (null ispell-filter) (accept-process-output ispell-process 3))      (if (null ispell-filter) (ispell-accept-output 3))
2187      (cond ((null ispell-filter)      (cond ((null ispell-filter)
2188             (error "%s did not output version line" ispell-program-name))             (error "%s did not output version line" ispell-program-name))
2189            ((and            ((and
# Line 2002  Optional third arg SHIFT is an offset to Line 2191  Optional third arg SHIFT is an offset to
2191              (if (string-match "warning: " (car ispell-filter))              (if (string-match "warning: " (car ispell-filter))
2192                  (progn                  (progn
2193                    (if (not version18p)                    (if (not version18p)
2194                        (accept-process-output ispell-process 3) ; was warn msg.                        (ispell-accept-output 3) ; was warn msg.
2195                      (accept-process-output ispell-process))                      (ispell-accept-output))
2196                    (stringp (car ispell-filter)))                    (stringp (car ispell-filter)))
2197                (null (cdr ispell-filter)))                (null (cdr ispell-filter)))
2198              (string-match "^@(#) " (car ispell-filter)))              (string-match "^@(#) " (car ispell-filter)))
# Line 2015  Optional third arg SHIFT is an offset to Line 2204  Optional third arg SHIFT is an offset to
2204             ;; But first wait to see if some more output is going to arrive.             ;; But first wait to see if some more output is going to arrive.
2205             ;; Otherwise we get cool errors like "Can't open ".             ;; Otherwise we get cool errors like "Can't open ".
2206             (sleep-for 1)             (sleep-for 1)
2207             (accept-process-output ispell-process 3)             (ispell-accept-output 3)
2208             (error "%s" (mapconcat 'identity ispell-filter "\n"))))             (error "%s" (mapconcat 'identity ispell-filter "\n"))))
2209      (setq ispell-filter nil)            ; Discard version ID line      (setq ispell-filter nil)            ; Discard version ID line
2210      (let ((extended-char-mode (ispell-get-extended-character-mode)))      (let ((extended-char-mode (ispell-get-extended-character-mode)))
2211        (if extended-char-mode            ; ~ extended character mode        (if extended-char-mode            ; ~ extended character mode
2212            (process-send-string ispell-process            (ispell-send-string (concat extended-char-mode "\n"))))
2213                                 (concat extended-char-mode "\n"))))      (if ispell-async-processp
2214      (process-kill-without-query ispell-process)))          (process-kill-without-query ispell-process))))
2215    
2216  ;;;###autoload  ;;;###autoload
2217  (defun ispell-kill-ispell (&optional no-error)  (defun ispell-kill-ispell (&optional no-error)
# Line 2030  Optional third arg SHIFT is an offset to Line 2219  Optional third arg SHIFT is an offset to
2219  With NO-ERROR, just return non-nil if there was no Ispell running."  With NO-ERROR, just return non-nil if there was no Ispell running."
2220    (interactive)    (interactive)
2221    (if (not (and ispell-process    (if (not (and ispell-process
2222                  (eq (process-status ispell-process) 'run)))                  (eq (ispell-process-status) 'run)))
2223        (or no-error        (or no-error
2224            (error "There is no ispell process running!"))            (error "There is no ispell process running!"))
2225      (process-send-eof ispell-process)      (if ispell-async-processp
2226      (if (eq (process-status ispell-process) 'run)          (progn
2227          (accept-process-output ispell-process 1))            (process-send-eof ispell-process)
2228      (if (eq (process-status ispell-process) 'run)            (if (eq (ispell-process-status) 'run)
2229          (kill-process ispell-process))                (ispell-accept-output 1))
2230      (while (not (or (eq (process-status ispell-process) 'exit)            (if (eq (ispell-process-status) 'run)
2231                      (eq (process-status ispell-process) 'signal)))                (kill-process ispell-process))
2232        (if version20p (sleep-for 0.25)            (while (not (or (eq (ispell-process-status) 'exit)
2233          (sleep-for 0 250)))                            (eq (ispell-process-status) 'signal)))
2234                (if (or xemacsp version20p) (sleep-for 0.25)
2235                  (sleep-for 0 250))))
2236          ;; synchronous processes
2237          (ispell-send-string "\n")         ; make sure side effects occurred.
2238          (kill-buffer ispell-output-buffer)
2239          (kill-buffer ispell-session-buffer)
2240          (setq ispell-output-buffer nil
2241                ispell-session-buffer nil))
2242      (setq ispell-process nil)      (setq ispell-process nil)
2243      (message "Ispell process killed")      (message "Ispell process killed")
2244      nil))      nil))
# Line 2210  Return nil if spell session is quit, Line 2407  Return nil if spell session is quit,
2407                                    "\\|" skip-regexp)))                                    "\\|" skip-regexp)))
2408      (if ispell-skip-tib      (if ispell-skip-tib
2409          (setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp)))          (setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp)))
2410      (if ispell-skip-sgml      (if ispell-skip-html
2411          (setq skip-regexp (concat "<author>" "\\|"          (setq skip-regexp (concat "<[cC][oO][dD][eE]\\>[^>]*>" "\\|"
2412                                    "<[cC][oO][dD][eE]>" "\\|"                                    "<[sS][cC][rR][iI][pP][tT]\\>[^>]*>" "\\|"
2413                                    "<[vV][eE][rR][bB]>" "\\|"                                    "<[aA][pP][pP][lL][eE][tT]\\>[^>]*>" "\\|"
2414                                    ;; "<[tT][tT]>" "\\|"                                    "<[vV][eE][rR][bB]\\>[^>]*>" "\\|"
2415                                      ;; "<[tT][tT]\\>[^>]*>" "\\|"
2416                                    "<[tT][tT]/" "\\|"                                    "<[tT][tT]/" "\\|"
                                   "</" "\\|"  
2417                                    "<" "\\|"                                    "<" "\\|"
2418                                    "&" "\\|"                                    "&" "\\|"
2419                                    skip-regexp)))                                    skip-regexp)))
# Line 2282  otherwise, the current line is skipped." Line 2479  otherwise, the current line is skipped."
2479        (search-forward comment-start ispell-region-end :end))        (search-forward comment-start ispell-region-end :end))
2480       ((and ispell-skip-tib (string-match ispell-tib-ref-beginning key))       ((and ispell-skip-tib (string-match ispell-tib-ref-beginning key))
2481        (re-search-forward ispell-tib-ref-end ispell-region-end t))        (re-search-forward ispell-tib-ref-end ispell-region-end t))
2482       ((and ispell-skip-sgml (string-match "<author>" key))       ((and ispell-skip-html (string-match "</" key))
       (search-forward-regexp ".$" ispell-region-end t))  
      ((and ispell-skip-sgml (string-match "</" key))  
2483        (search-forward ">" ispell-region-end t))        (search-forward ">" ispell-region-end t))
2484       ((and ispell-skip-sgml (string-match "<[cC][oO][dD][eE]>" key))         ((and ispell-skip-html (string-match "<[cC][oO][dD][eE]\\>[^>]*>" key))
2485        (search-forward-regexp "</[cC][oO][dD][eE]>" ispell-region-end t))        (search-forward-regexp "</[cC][oO][dD][eE]>" ispell-region-end t))
2486       ((and ispell-skip-sgml (string-match "<[vV][eE][rR][bB]>" key))         ((and ispell-skip-html
2487               (string-match "<[sS][cC][rR][iI][pP][tT]\\>[^>]*>" key))
2488          (search-forward-regexp "</[sS][cC][rR][iI][pP][tT]>" ispell-region-end t))
2489         ((and ispell-skip-html
2490               (string-match "<[aA][pP][pP][lL][eE][tT]\\>[^>]*>" key))
2491          (search-forward-regexp "</[aA][pP][pP][lL][eE][tT]>" ispell-region-end t))
2492         ((and ispell-skip-html (string-match "<[vV][eE][rR][bB]\\>[^>]*>" key))
2493        (search-forward-regexp "</[vV][eE][rR][bB]>" ispell-region-end t))        (search-forward-regexp "</[vV][eE][rR][bB]>" ispell-region-end t))
2494       ;;((and ispell-skip-sgml (string-match "<[tT][tT]>" key))         ;;((and ispell-skip-html (string-match "<[tT][tT]\\>[^>]*>" key))
2495       ;; (search-forward-regexp "</[tT][tT]>" ispell-region-end t))           ;; (search-forward-regexp "</[tT][tT]>" ispell-region-end t))
2496       ((and ispell-skip-sgml (string-match "<[tT][tT]/" key))         ((and ispell-skip-html (string-match "<[tT][tT]/" key))
2497        (search-forward "/" ispell-region-end t))              (search-forward "/" ispell-region-end t))
2498       ((and ispell-skip-sgml (string-match "<" key))       ((and ispell-skip-html (string-match "<" key))
2499        (search-forward-regexp "[/>]" ispell-region-end t))        (search-forward ">" ispell-region-end t))
2500       ((and ispell-skip-sgml (string-match "&" key))       ((and ispell-skip-html (string-match "&" key))
2501        (search-forward ";" ispell-region-end t))        (search-forward-regexp "[; \t\n]" ispell-region-end t))
2502       ;; markings from alist       ;; markings from alist
2503       (t       (t
2504        (while alist        (while alist
# Line 2335  otherwise, the current line is skipped." Line 2536  otherwise, the current line is skipped."
2536      (cond                               ; LOOK AT THIS LINE AND SKIP OR PROCESS      (cond                               ; LOOK AT THIS LINE AND SKIP OR PROCESS
2537       ((eolp)                            ; END OF LINE, just go to next line.       ((eolp)                            ; END OF LINE, just go to next line.
2538        (forward-line))        (forward-line))
2539       ;;((looking-at "[---#@*+!%~^]")    ; SKIP SPECIAL ISPELL CHARACTERS       ;;((looking-at "[-#@*+!%~^]")      ; SKIP SPECIAL ISPELL CHARACTERS
2540       ;; (forward-char 1))               ; not needed as quoted below.       ;; (forward-char 1))               ; not needed as quoted below.
2541       ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS       ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS
2542            (re-search-forward "[][()${}]" end t)) ; or MATH COMMANDS            (re-search-forward "[][()${}]" end t)) ; or MATH COMMANDS
# Line 2346  otherwise, the current line is skipped." Line 2547  otherwise, the current line is skipped."
2547      string))      string))
2548    
2549    
2550    ;;; Avoid error messages when compiling for these dynamic variables.
2551    (eval-when-compile
2552      (defvar start)
2553      (defvar end))
2554    
2555  (defun ispell-process-line (string shift)  (defun ispell-process-line (string shift)
2556    "Sends a LINE of text to ispell and processes the result.    "Sends a LINE of text to ispell and processes the result.
2557  This will modify the buffer for spelling errors.  This will modify the buffer for spelling errors.
# Line 2356  Returns the sum shift due to changes in Line 2562  Returns the sum shift due to changes in
2562      (if (not (numberp shift))      (if (not (numberp shift))
2563          (setq shift 0))          (setq shift 0))
2564      ;; send string to spell process and get input.      ;; send string to spell process and get input.
2565      (process-send-string ispell-process string)      (ispell-send-string string)
2566      (while (progn      (while (progn
2567               (accept-process-output ispell-process)               (ispell-accept-output)
2568               ;; Last item of output contains a blank line.               ;; Last item of output contains a blank line.
2569               (not (string= "" (car ispell-filter)))))               (not (string= "" (car ispell-filter)))))
2570      ;; parse all inputs from the stream one word at a time.      ;; parse all inputs from the stream one word at a time.
# Line 2386  Returns the sum shift due to changes in Line 2592  Returns the sum shift due to changes in
2592              (ispell-horiz-scroll)              (ispell-horiz-scroll)
2593              (goto-char word-start)              (goto-char word-start)
2594              (ispell-horiz-scroll)              (ispell-horiz-scroll)
   
2595              ;; Alignment cannot be tracked and this error will occur when              ;; Alignment cannot be tracked and this error will occur when
2596              ;; `query-replace' makes multiple corrections on the starting line.              ;; `query-replace' makes multiple corrections on the starting line.
2597              (if (/= (+ word-len (point))              (if (/= (+ word-len (point))
# Line 2426  Returns the sum shift due to changes in Line 2631  Returns the sum shift due to changes in
2631                    (set-marker line-end (point))                    (set-marker line-end (point))
2632                    (setq ispell-filter nil                    (setq ispell-filter nil
2633                          recheck-region t)))                          recheck-region t)))
2634                                          
2635              ;; insert correction if needed              ;; insert correction if needed
2636              (cond              (cond
2637               ((or (null replace)               ((or (null replace)
# Line 2458  Returns the sum shift due to changes in Line 2663  Returns the sum shift due to changes in
2663                      (let ((region-end (copy-marker ispell-region-end)))                      (let ((region-end (copy-marker ispell-region-end)))
2664                        (setq recheck-region ispell-filter                        (setq recheck-region ispell-filter
2665                              ispell-filter nil ; save filter                              ispell-filter nil ; save filter
2666                                shift 0     ; already accounted
2667                              shift (ispell-region                              shift (ispell-region
2668                                    word-start                                    word-start
2669                                    (+ word-start (length replace-word))                                    (+ word-start (length replace-word))
# Line 2655  Standard ispell choices are then availab Line 2861  Standard ispell choices are then availab
2861  (defun ispell-minor-mode (&optional arg)  (defun ispell-minor-mode (&optional arg)
2862    "Toggle Ispell minor mode.    "Toggle Ispell minor mode.
2863  With prefix arg, turn Ispell minor mode on iff arg is positive.  With prefix arg, turn Ispell minor mode on iff arg is positive.
2864    
2865  In Ispell minor mode, pressing SPC or RET  In Ispell minor mode, pressing SPC or RET
2866  warns you if the previous word is incorrectly spelled.  warns you if the previous word is incorrectly spelled.
2867    
# Line 2666  them into the running ispell process, ty Line 2872  them into the running ispell process, ty
2872          (not (or (and (null arg) ispell-minor-mode)          (not (or (and (null arg) ispell-minor-mode)
2873                   (<= (prefix-numeric-value arg) 0))))                   (<= (prefix-numeric-value arg) 0))))
2874    (force-mode-line-update))    (force-mode-line-update))
2875    
2876  (defun ispell-minor-check ()  (defun ispell-minor-check ()
2877    "Check previous word then continue with the normal binding of this key.    "Check previous word then continue with the normal binding of this key.
2878  Don't check previous word when character before point is a space or newline.  Don't check previous word when character before point is a space or newline.
# Line 2677  Don't read buffer-local settings or word Line 2883  Don't read buffer-local settings or word
2883          (last-char (char-after (1- (point)))))          (last-char (char-after (1- (point)))))
2884      (command-execute (key-binding (this-command-keys)))      (command-execute (key-binding (this-command-keys)))
2885      (if (not (or (eq last-char ?\ ) (eq last-char ?\n)      (if (not (or (eq last-char ?\ ) (eq last-char ?\n)
2886                   (and ispell-skip-sgml (eq last-char ?>))                   (and ispell-skip-html (eq last-char ?>))
2887                   (and ispell-skip-sgml (eq last-char ?\;))))                   (and ispell-skip-html (eq last-char ?\;))))
2888          (ispell-word nil t))))          (ispell-word nil t))))
2889    
2890    
# Line 2852  You can bind this to the key C-c i in GN Line 3058  You can bind this to the key C-c i in GN
3058  Overrides the default parsing mode.  Overrides the default parsing mode.
3059  Includes Latex/Nroff modes and extended character mode."  Includes Latex/Nroff modes and extended character mode."
3060    ;; (ispell-init-process) must already be called.    ;; (ispell-init-process) must already be called.
3061    (process-send-string ispell-process "!\n") ; Put process in terse mode.    (ispell-send-string "!\n")            ; Put process in terse mode.
3062    ;; We assume all major modes with "tex-mode" in them should use latex parsing    ;; We assume all major modes with "tex-mode" in them should use latex parsing
3063    ;; When exclusively checking comments, set to raw text mode (nroff).    ;; When exclusively checking comments, set to raw text mode (nroff).
3064    (if (and (not (eq 'exclusive ispell-check-comments))    (if (and (not (eq 'exclusive ispell-check-comments))
# Line 2861  Includes Latex/Nroff modes and extended Line 3067  Includes Latex/Nroff modes and extended
3067                                    (symbol-name major-mode)))                                    (symbol-name major-mode)))
3068                 (eq ispell-parser 'tex)))                 (eq ispell-parser 'tex)))
3069        (progn        (progn
3070          (process-send-string ispell-process "+\n") ; set ispell mode to tex          (ispell-send-string "+\n")      ; set ispell mode to tex
3071          (if (not (eq ispell-parser 'tex))          (if (not (eq ispell-parser 'tex))
3072              (set (make-local-variable 'ispell-parser) 'tex)))              (set (make-local-variable 'ispell-parser) 'tex)))
3073      (process-send-string ispell-process "-\n")) ; set mode to normal (nroff)      (ispell-send-string "-\n"))         ; set mode to normal (nroff)
3074    ;; If needed, test for SGML & HTML modes and set a buffer local nil/t value.    ;; If needed, test for SGML & HTML modes and set a buffer local nil/t value.
3075    (if (and ispell-skip-sgml (not (eq ispell-skip-sgml t)))    (if (and ispell-skip-html (not (eq ispell-skip-html t)))
3076        (set (make-local-variable 'ispell-skip-sgml)        (set (make-local-variable 'ispell-skip-html)
3077             (not (null (string-match "sgml\\|html"             (not (null (string-match "sgml\\|html"
3078                                      (downcase (symbol-name major-mode)))))))                                      (downcase (symbol-name major-mode)))))))
3079    ;; Set default extended character mode for given buffer, if any.    ;; Set default extended character mode for given buffer, if any.
3080    (let ((extended-char-mode (ispell-get-extended-character-mode)))    (let ((extended-char-mode (ispell-get-extended-character-mode)))
3081      (if extended-char-mode      (if extended-char-mode
3082          (process-send-string ispell-process (concat extended-char-mode "\n"))))          (ispell-send-string (concat extended-char-mode "\n"))))
3083    ;; Set buffer-local parsing mode and extended character mode, if specified.    ;; Set buffer-local parsing mode and extended character mode, if specified.
3084    (save-excursion    (save-excursion
3085      (goto-char (point-max))      (goto-char (point-max))
# Line 2888  Includes Latex/Nroff modes and extended Line 3094  Includes Latex/Nroff modes and extended
3094                                      (match-beginning 1) (match-end 1))))                                      (match-beginning 1) (match-end 1))))
3095              (cond ((and (string-match "latex-mode" string)              (cond ((and (string-match "latex-mode" string)
3096                          (not (eq 'exclusive ispell-check-comments)))                          (not (eq 'exclusive ispell-check-comments)))
3097                     (process-send-string ispell-process "+\n~tex\n"))                     (ispell-send-string "+\n~tex\n"))
3098                    ((string-match "nroff-mode" string)                    ((string-match "nroff-mode" string)
3099                     (process-send-string ispell-process "-\n~nroff\n"))                     (ispell-send-string "-\n~nroff\n"))
3100                    ((string-match "~" string) ; Set extended character mode.                    ((string-match "~" string) ; Set extended character mode.
3101                     (process-send-string ispell-process (concat string "\n")))                     (ispell-send-string (concat string "\n")))
3102                    (t (message "Invalid Ispell Parsing argument!")                    (t (message "Invalid Ispell Parsing argument!")
3103                       (sit-for 2))))))))                       (sit-for 2))))))))
3104    
# Line 2965  Both should not be used to define a buff Line 3171  Both should not be used to define a buff
3171            ;; Error handling needs to be added between ispell and emacs.            ;; Error handling needs to be added between ispell and emacs.
3172            (if (and (< 1 (length string))            (if (and (< 1 (length string))
3173                     (equal 0 (string-match ispell-casechars string)))                     (equal 0 (string-match ispell-casechars string)))
3174                (process-send-string ispell-process                (ispell-send-string (concat "@" string "\n"))))))))
                                    (concat "@" string "\n"))))))))  
3175    
3176    
3177  ;;; returns optionally adjusted region-end-point.  ;;; returns optionally adjusted region-end-point.
# Line 2978  Both should not be used to define a buff Line 3183  Both should not be used to define a buff
3183    (save-excursion    (save-excursion
3184      (goto-char (point-min))      (goto-char (point-min))
3185      (let ((old-case-fold-search case-fold-search)      (let ((old-case-fold-search case-fold-search)
3186            line-okay search done string)            line-okay search done found)
3187        (while (not done)        (while (not done)
3188          (setq case-fold-search nil          (setq case-fold-search nil
3189                search (search-forward ispell-words-keyword nil 'move)                search (search-forward ispell-words-keyword nil 'move)
3190                  found (or found search)
3191                line-okay (< (+ (length word) 1 ; 1 for space after word..                line-okay (< (+ (length word) 1 ; 1 for space after word..
3192                                (progn (end-of-line) (current-column)))                                (progn (end-of-line) (current-column)))
3193                             80)                             80)
# Line 2993  Both should not be used to define a buff Line 3199  Both should not be used to define a buff
3199                (if (null search)                (if (null search)
3200                    (progn                    (progn
3201                      (open-line 1)                      (open-line 1)
3202                      (setq string (concat comment-start " "                      (unless found (newline))
3203                                           ispell-words-keyword))                      (insert (concat comment-start " " ispell-words-keyword))
3204                      (insert string)                      (if (> (length comment-end) 0)
                     (if (and comment-end (not (equal "" comment-end)))  
3205                          (save-excursion                          (save-excursion
3206                            (open-line 1)                            (newline)
                           (forward-line 1)  
3207                            (insert comment-end)))))                            (insert comment-end)))))
3208                (insert (concat " " word))))))))                (insert (concat " " word))))))))
3209    
3210    (add-to-list 'debug-ignored-errors "^No word found to check!$")
3211    
3212  (provide 'ispell)  (provide 'ispell)
3213    

Legend:
Removed from v.1.137.4.1  
changed lines
  Added in v.1.137.4.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26