;;; ispell.el --- interface to International Ispell Versions 3.1 and 3.2
-;; Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 1997-2011 Free Software Foundation, Inc.
;; Author: Ken Stevens <k.stevens@ieee.org>
;; Maintainer: Ken Stevens <k.stevens@ieee.org>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;; Note: version numbers and time stamp are not updated
-;; when this file is edited for release with GNU emacs.
+;; when this file is edited for release with GNU Emacs.
;;; Commentary:
;; `m': Place entered value in personal dictionary, then recheck current word.
;; `C-l': redraws screen
;; `C-r': recursive edit
-;; `C-z': suspend emacs or iconify frame
+;; `C-z': suspend Emacs or iconify frame
;; Buffer-Local features:
;; There are a number of buffer-local features that can be used to customize
;; Need a way to select between different character mappings without separate
;; dictionary entries.
;; Multi-byte characters if not defined by current dictionary may result in the
-;; evil "misalignment error" in some versions of MULE emacs.
-;; On some versions of emacs, growing the minibuffer fails.
+;; evil "misalignment error" in some versions of MULE Emacs.
+;; On some versions of Emacs, growing the minibuffer fails.
;; see `ispell-help-in-bufferp'.
;; Recursive edits (?C-r or ?R) inside a keyboard text replacement check (?r)
;; can cause misalignment errors.
;; Added dictionary definition for Italian (William Deakin)
;; HTML region skipping greatly improved. (Chuck D. Phillips)
;; improved menus. Fixed regexp matching http/email addresses.
-;; one arg always for xemacs sleep-for (gunnar Evermann)
+;; one arg always for XEmacs sleep-for (gunnar Evermann)
;; support for synchronous processes (Eli Zaretskii)
;; Revision 3.3 1999/11/29 11:38:34 kss
;; Improved message reference matching in `ispell-message'.
;; Fixed bug in returning to nroff mode from tex mode.
+;;; Compatibility code for XEmacs and (not too) older emacsen:
+
+(eval-and-compile ;; Protect against declare-function undefined in XEmacs
+ (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
+(declare-function ispell-check-minver "ispell" (v1 v2))
+(declare-function ispell-looking-back "ispell"
+ (regexp &optional limit &rest ignored))
+
+(if (fboundp 'version<=)
+ (defalias 'ispell-check-minver 'version<=)
+ (defun ispell-check-minver (minver version)
+ "Check if string VERSION is at least string MINVER.
+Both must be in [0-9]+.[0-9]+... format. This is a fallback
+compatibility function in case `version<=' is not available."
+ (let ((pending t)
+ (return t)
+ start-ver start-mver)
+ ;; Loop until an absolute greater or smaller condition is reached
+ ;; or until no elements are left in any of version and minver. In
+ ;; this case version is exactly the minimal, so return OK.
+ (while pending
+ (let (ver mver)
+ (if (string-match "[0-9]+" version start-ver)
+ (setq start-ver (match-end 0)
+ ver (string-to-number (match-string 0 version))))
+ (if (string-match "[0-9]+" minver start-mver)
+ (setq start-mver (match-end 0)
+ mver (string-to-number (match-string 0 minver))))
+
+ (if (or ver mver)
+ (progn
+ (or ver (setq ver 0))
+ (or mver (setq mver 0))
+ ;; If none of below conditions match, this element is the
+ ;; same. Go checking next element.
+ (if (> ver mver)
+ (setq pending nil)
+ (if (< ver mver)
+ (setq pending nil
+ return nil))))
+ (setq pending nil))))
+ return)))
+
+;; XEmacs does not have looking-back
+(if (fboundp 'looking-back)
+ (defalias 'ispell-looking-back 'looking-back)
+ (defun ispell-looking-back (regexp &optional limit &rest ignored)
+ "Return non-nil if text before point matches regular expression REGEXP.
+Like `looking-at' except matches before point, and is slower.
+LIMIT if non-nil speeds up the search by specifying a minimum
+starting position, to avoid checking matches that would start
+before LIMIT.
+
+This is a stripped down compatibility function for use when
+full featured `looking-back' function is missing."
+ (save-excursion
+ (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t))))
;;; Code:
(defvar mail-yank-prefix)
-;;; Custom.el macros require recompiling this when they are not present.
-;;; Add in backward compatible custom support.
-(eval-when-compile
- (if (not (fboundp 'defcustom))
- (defmacro defcustom (symbol value doc &rest args)
- "Empty replacement for defcustom when not supplied."
- `(defvar ,symbol ,value ,doc))))
-
-(eval-when-compile
- (if (not (fboundp 'defgroup))
- (defmacro defgroup (&rest args)
- "Empty replacement for defgroup when not supplied.")))
-
(defgroup ispell nil
"User variables for Emacs ispell interface."
:group 'applications)
:version "22.1")
(defcustom ispell-highlight-face (if ispell-lazy-highlight 'isearch 'highlight)
- "*The face used for Ispell highlighting. For Emacses with overlays.
+ "*The face used for Ispell highlighting. For Emacsen with overlays.
Possible values are `highlight', `modeline', `secondary-selection',
`region', and `underline'.
This variable can be set by the user to whatever face they desire.
may produce undesired results."
:type '(choice (const exclusive) (const :tag "off" nil) (const :tag "on" t))
:group 'ispell)
-;;;###autoload(put 'ispell-check-comments 'safe-local-variable (lambda (a) (memq a '(nil t exclusive))))
+;;;###autoload
+(put 'ispell-check-comments 'safe-local-variable
+ (lambda (a) (memq a '(nil t exclusive))))
(defcustom ispell-query-replace-choices nil
"*Corrections made throughout region when non-nil.
:group 'ispell)
(defcustom ispell-program-name
- (or (locate-file "aspell" exec-path exec-suffixes 'file-executable-p)
+ (or (locate-file "aspell" exec-path exec-suffixes 'file-executable-p)
+ (locate-file "ispell" exec-path exec-suffixes 'file-executable-p)
+ (locate-file "hunspell" exec-path exec-suffixes 'file-executable-p)
"ispell")
"Program invoked by \\[ispell-word] and \\[ispell-region] commands."
:type 'string
:group 'ispell)
(defcustom ispell-alternate-dictionary
- (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2")
- ((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2")
- ((file-exists-p "/usr/dict/words") "/usr/dict/words")
- ((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words")
- ((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words")
- ((file-exists-p "/usr/share/lib/dict/words")
+ (cond ((file-readable-p "/usr/dict/web2") "/usr/dict/web2")
+ ((file-readable-p "/usr/share/dict/web2") "/usr/share/dict/web2")
+ ((file-readable-p "/usr/dict/words") "/usr/dict/words")
+ ((file-readable-p "/usr/lib/dict/words") "/usr/lib/dict/words")
+ ((file-readable-p "/usr/share/dict/words") "/usr/share/dict/words")
+ ((file-readable-p "/usr/share/lib/dict/words")
"/usr/share/lib/dict/words")
- ((file-exists-p "/sys/dict") "/sys/dict")
- (t "/usr/dict/words"))
- "*Alternate dictionary for spelling help."
+ ((file-readable-p "/sys/dict") "/sys/dict"))
+ "*Alternate plain word-list dictionary for spelling help."
:type '(choice file (const :tag "None" nil))
:group 'ispell)
-(defcustom ispell-complete-word-dict ispell-alternate-dictionary
- "*Dictionary used for word completion."
+(defcustom ispell-complete-word-dict nil
+ "*Plain word-list dictionary used for word completion if
+different from `ispell-alternate-dictionary'."
:type '(choice file (const :tag "None" nil))
:group 'ispell)
(if (memq system-type '(windows-nt ms-dos)) "-Ei" "-i")
"String of options to use when running the program in `ispell-grep-command'.
Should probably be \"-i\" or \"-e\".
-Some machines (like the NeXT) don't support \"-i\""
+Some machines (like the NeXT) don't support \"-i\"."
:type 'string
:group 'ispell)
;;;###autoload
(defcustom ispell-personal-dictionary nil
"*File name of your personal spelling dictionary, or nil.
-If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used,
-where DICTNAME is the name of your default dictionary."
+If nil, the default personal dictionary, (\"~/.ispell_DICTNAME\" for ispell or
+\"~/.aspell.LANG.pws\" for aspell) is used, where DICTNAME is the name of your
+default dictionary and LANG the two letter language code."
:type '(choice file
(const :tag "default" nil))
:group 'ispell)
The value must be a string dictionary name,
or nil, which means use the global setting in `ispell-dictionary'.
Dictionary names are defined in `ispell-local-dictionary-alist'
-and `ispell-dictionary-alist',
+and `ispell-dictionary-alist'.
Setting `ispell-local-dictionary' to a value has the same effect as
calling \\[ispell-change-dictionary] with that value. This variable
:type '(choice string
(const :tag "default" nil))
:group 'ispell)
-;;;###autoload(put 'ispell-local-dictionary 'safe-local-variable 'string-or-null-p)
+;;;###autoload
+(put 'ispell-local-dictionary 'safe-local-variable 'string-or-null-p)
(make-variable-buffer-local 'ispell-local-dictionary)
+(defcustom ispell-dictionary nil
+ "Default dictionary to use if `ispell-local-dictionary' is nil."
+ :type '(choice string
+ (const :tag "default" nil))
+ :group 'ispell)
+
(defcustom ispell-extra-args nil
"*If non-nil, a list of extra switches to pass to the Ispell program.
For example, (\"-W\" \"3\") to cause it to accept all 1-3 character
(make-variable-buffer-local 'ispell-skip-html)
-;;;###autoload
(defcustom ispell-local-dictionary-alist nil
"*List of local or customized dictionary definitions.
These can override the values in `ispell-dictionary-alist'.
:group 'ispell)
-;;; split dictionary so line length is smaller in loaddefs.el
-
-;;; First part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-1
- '((nil ; default (English.aff)
- "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
- ("american" ; Yankee English
- "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
- ("brasileiro" ; Brazilian mode
- "[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]"
- "[']" nil nil nil iso-8859-1)
- ("british" ; British version
- "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
- ("castellano" ; Spanish mode
- "[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]"
- "[-]" nil ("-B") "~tex" iso-8859-1)
- ("castellano8" ; 8 bit Spanish mode
- "[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]"
- "[-]" nil ("-B" "-d" "castellano") "~latin1" iso-8859-1)))
-
-
-;;; Second part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-2
- '(("czech"
- "[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]"
- "[^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]"
- "" nil ("-B") nil iso-8859-2)
- ("dansk" ; Dansk.aff
- "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]"
- "[']" nil ("-C") nil iso-8859-1)
- ("deutsch" ; Deutsch.aff
- "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" iso-8859-1)
- ("deutsch8"
- "[a-zA-Z\304\326\334\344\366\337\374]"
- "[^a-zA-Z\304\326\334\344\366\337\374]"
- "[']" t ("-C" "-d" "deutsch") "~latin1" iso-8859-1)
- ("english" ; make English explicitly selectable
- "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)))
-
-
-;;; Third part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-3
- '(("esperanto"
- "[A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
- "[^A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
- "[-']" t ("-C") "~latin3" iso-8859-3)
- ("esperanto-tex"
- "[A-Za-z^\\]" "[^A-Za-z^\\]"
- "[-'`\"]" t ("-C" "-d" "esperanto") "~tex" iso-8859-3)
- ("francais7"
- "[A-Za-z]" "[^A-Za-z]" "[`'^-]" t nil nil iso-8859-1)
- ("francais" ; Francais.aff
- "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
- "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
- "[-'.@]" t nil "~list" iso-8859-1)
- ("francais-tex" ; Francais.aff
- "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
- "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
- "[-'^`\".@]" t nil "~tex" iso-8859-1)))
-
-
-;;; Fourth part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-4
- '(("german" ; german.aff
- "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" iso-8859-1)
- ("german8" ; german.aff
- "[a-zA-Z\304\326\334\344\366\337\374]"
- "[^a-zA-Z\304\326\334\344\366\337\374]"
- "[']" t ("-C" "-d" "german") "~latin1" iso-8859-1)
- ("italiano" ; Italian.aff
- "[A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
- "[^A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
- "[-.]" nil ("-B" "-d" "italian") "~tex" iso-8859-1)
- ("nederlands" ; Nederlands.aff
- "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
- "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
- "[']" t ("-C") nil iso-8859-1)
- ("nederlands8" ; Dutch8.aff
- "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
- "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
- "[']" t ("-C") nil iso-8859-1)))
-
-
-;;; Fifth part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-5
- '(("norsk" ; 8 bit Norwegian mode
- "[A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
- "[^A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
- "[\"]" nil nil "~list" iso-8859-1)
- ("norsk7-tex" ; 7 bit Norwegian TeX mode
- "[A-Za-z{}\\'^`]" "[^A-Za-z{}\\'^`]"
- "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1)
- ("polish" ; Polish mode
- "[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]"
- "[.]" nil nil nil iso-8859-2)
- ("portugues" ; Portuguese mode
- "[a-zA-Z\301\302\311\323\340\341\342\351\352\355\363\343\372]"
- "[^a-zA-Z\301\302\311\323\340\341\342\351\352\355\363\343\372]"
- "[']" t ("-C") "~latin1" iso-8859-1)))
-
-
-;;; Sixth part of dictionary, shortened for loaddefs.el
-;;;###autoload
-(setq
- ispell-dictionary-alist-6
- ;; include Russian iso coding system too?
- ;; "[']" t ("-d" "russian") "~latin1" iso-8859-1
- '(("russian" ; Russian.aff (KOI8-R charset)
- "[\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]"
- "[^\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]"
- "" nil nil nil koi8-r)
- ("russianw" ; russianw.aff (CP1251 charset)
- "[\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]"
- "[^\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]"
- "" nil nil nil windows-1251)
- ("slovak" ; Slovakian
- "[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]"
- "[^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]"
- "" nil ("-B") nil iso-8859-2)
- ("slovenian" ; Slovenian
- "[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]"
- "[^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]"
- "" nil ("-B" "-d" "slovenian") nil iso-8859-2)
- ("svenska" ; Swedish mode
- "[A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
- "[^A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
- "[']" nil ("-C") "~list" iso-8859-1)))
-
-
-;;;###autoload
-(defvar ispell-dictionary-alist
- (append ispell-dictionary-alist-1 ispell-dictionary-alist-2
- ispell-dictionary-alist-3 ispell-dictionary-alist-4
- ispell-dictionary-alist-5 ispell-dictionary-alist-6)
+(defvar ispell-dictionary-base-alist
+ '((nil
+ ;; The default dictionary. It may be English.aff, or any other
+ ;; dictionary depending on locale and such things. We should probably
+ ;; ask ispell what dictionary it's using, but until we do that, let's
+ ;; just use an approximate regexp.
+ "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-B") nil iso-8859-1)
+ ("american" ; Yankee English
+ "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
+ ("brasileiro" ; Brazilian mode
+ "[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]"
+ "[']" nil nil nil iso-8859-1)
+ ("british" ; British version
+ "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
+ ("castellano" ; Spanish mode
+ "[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]"
+ "[-]" nil ("-B") "~tex" iso-8859-1)
+ ("castellano8" ; 8 bit Spanish mode
+ "[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]"
+ "[-]" nil ("-B" "-d" "castellano") "~latin1" iso-8859-1)
+ ("czech"
+ "[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]"
+ "[^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]"
+ "" nil ("-B") nil iso-8859-2)
+ ("dansk" ; Dansk.aff
+ "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]"
+ "[']" nil ("-C") nil iso-8859-1)
+ ("deutsch" ; Deutsch.aff
+ "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" iso-8859-1)
+ ("deutsch8"
+ "[a-zA-Z\304\326\334\344\366\337\374]"
+ "[^a-zA-Z\304\326\334\344\366\337\374]"
+ "[']" t ("-C" "-d" "deutsch") "~latin1" iso-8859-1)
+ ("english" ; make English explicitly selectable
+ "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1)
+ ("esperanto"
+ "[A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
+ "[^A-Za-z\246\254\266\274\306\330\335\336\346\370\375\376]"
+ "[-']" t ("-C") "~latin3" iso-8859-3)
+ ("esperanto-tex"
+ "[A-Za-z^\\]" "[^A-Za-z^\\]"
+ "[-'`\"]" t ("-C" "-d" "esperanto") "~tex" iso-8859-3)
+ ("finnish"
+ "[A-Za-z\345\344\366\305\304\326]"
+ "[^A-Za-z\345\344\366\305\304\326]"
+ "[:]" nil ("-C") "~list" iso-8859-1)
+ ("francais7"
+ "[A-Za-z]" "[^A-Za-z]" "[`'^-]" t nil nil iso-8859-1)
+ ("francais" ; Francais.aff
+ "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
+ "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]"
+ "[-'.@]" t nil "~list" iso-8859-1)
+ ("francais-tex" ; Francais.aff
+ "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
+ "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]"
+ "[-'^`\".@]" t nil "~tex" iso-8859-1)
+ ("german" ; german.aff
+ "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex" iso-8859-1)
+ ("german8" ; german.aff
+ "[a-zA-Z\304\326\334\344\366\337\374]"
+ "[^a-zA-Z\304\326\334\344\366\337\374]"
+ "[']" t ("-C" "-d" "german") "~latin1" iso-8859-1)
+ ("italiano" ; Italian.aff
+ "[A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
+ "[^A-Z\300\301\310\311\314\315\322\323\331\332a-z\340\341\350\351\354\355\363\371\372]"
+ "[-.]" nil ("-B" "-d" "italian") "~tex" iso-8859-1)
+ ("nederlands" ; Nederlands.aff
+ "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
+ "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
+ "[']" t ("-C") nil iso-8859-1)
+ ("nederlands8" ; Dutch8.aff
+ "[A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
+ "[^A-Za-z\300\301\302\303\304\305\307\310\311\312\313\314\315\316\317\322\323\324\325\326\331\332\333\334\340\341\342\343\344\345\347\350\351\352\353\354\355\356\357\361\362\363\364\365\366\371\372\373\374]"
+ "[']" t ("-C") nil iso-8859-1)
+ ("norsk" ; 8 bit Norwegian mode
+ "[A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
+ "[^A-Za-z\305\306\307\310\311\322\324\330\345\346\347\350\351\362\364\370]"
+ "[\"]" nil nil "~list" iso-8859-1)
+ ("norsk7-tex" ; 7 bit Norwegian TeX mode
+ "[A-Za-z{}\\'^`]" "[^A-Za-z{}\\'^`]"
+ "[\"]" nil ("-d" "norsk") "~plaintex" iso-8859-1)
+ ("polish" ; Polish mode
+ "[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]"
+ "[.]" nil nil nil iso-8859-2)
+ ("portugues" ; Portuguese mode
+ "[a-zA-Z\301\302\307\311\323\340\341\342\351\352\355\363\343\347\372]"
+ "[^a-zA-Z\301\302\307\311\323\340\341\342\351\352\355\363\343\347\372]"
+ "[']" t ("-C") "~latin1" iso-8859-1)
+ ("russian" ; Russian.aff (KOI8-R charset)
+ "[\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]"
+ "[^\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]"
+ "" nil nil nil koi8-r)
+ ("russianw" ; russianw.aff (CP1251 charset)
+ "[\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]"
+ "[^\300\301\302\303\304\305\250\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\334\333\332\335\336\337\340\341\342\343\344\345\270\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\374\373\372\375\376\377]"
+ "" nil nil nil windows-1251)
+ ("slovak" ; Slovakian
+ "[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]"
+ "[^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]"
+ "" nil ("-B") nil iso-8859-2)
+ ("slovenian" ; Slovenian
+ "[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]"
+ "[^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]"
+ "" nil ("-B" "-d" "slovenian") nil iso-8859-2)
+ ("svenska" ; Swedish mode
+ "[A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
+ "[^A-Za-z\345\344\366\351\340\374\350\346\370\347\305\304\326\311\300\334\310\306\330\307]"
+ "[']" nil ("-C") "~list" iso-8859-1))
+ "Base value for `ispell-dictionary-alist'.")
+
+(defvar ispell-dictionary-alist nil
"An alist of dictionaries and their associated parameters.
Each element of this list is also a list:
in English. This has the same effect as the command-line `-T' option.
The buffer Major Mode controls Ispell's parsing in tex or nroff mode,
but the dictionary can control the extended character mode.
-Both defaults can be overruled in a buffer-local fashion. See
+Both defaults can be overruled in a buffer-local fashion. See
`ispell-parsing-keyword' for details on this.
CHARACTER-SET used for languages with multibyte characters.
contain the same character set as casechars and otherchars in the
LANGUAGE.aff file \(e.g., english.aff\).")
-(defvar ispell-really-aspell nil) ; Non-nil if aspell extensions should be used
-
-(defvar ispell-aspell-supports-utf8 nil
- "Non-nil means to try to automatically find aspell dictionaries.
-This is set to t in `ispell-check-version' for aspell >= 0.60.
+(defvar ispell-really-aspell nil) ; Non-nil if we can use aspell extensions.
+(defvar ispell-really-hunspell nil) ; Non-nil if we can use hunspell extensions.
+(defvar ispell-encoding8-command nil
+ "Command line option prefix to select UTF-8 if supported, nil otherwise.
+If UTF-8 if supported by spellchecker and is selectable from the command line
+this variable will contain \"--encoding=\" for aspell and \"-i \" for hunspell,
+so UTF-8 or other mime charsets can be selected. That will be set for hunspell
+>=1.1.6 or aspell >= 0.60 in `ispell-check-version'.
+For aspell non-nil means to try to automatically find aspell dictionaries.
Earlier aspell versions do not consistently support UTF-8. Handling
this would require some extra guessing in `ispell-aspell-find-dictionary'.")
+(defvar ispell-aspell-supports-utf8 nil
+ "Non nil if aspell has consistent command line UTF-8 support. Obsolete.
+ispell.el and flyspell.el will use for this purpose the more generic
+variable `ispell-encoding8-command' for both aspell and hunspell. Is left
+here just for backwards compatibility.")
+
+(make-obsolete-variable 'ispell-aspell-supports-utf8
+ 'ispell-encoding8-command "23.1")
;;; **********************************************************************
-;;; The version must be 3.1 or greater for this version of ispell.el
-;;; There is an incompatibility between version 3.1.12 and lower versions.
+;; The version must be 3.1 or greater for this version of ispell.el
+;; There is an incompatibility between version 3.1.12 and lower versions.
(defconst ispell-required-version '(3 1 12)
"Ispell versions with which this version of ispell.el is known to work.")
(defvar ispell-offset -1
;; all versions, since versions earlier than 3.0.09 didn't identify
;; themselves on startup.
(interactive "p")
- (let ((case-fold-search-val case-fold-search)
- ;; avoid bugs when syntax of `.' changes in various default modes
- (default-major-mode 'fundamental-mode)
- (default-directory (or (and (boundp 'temporary-file-directory)
+ (let ((default-directory (or (and (boundp 'temporary-file-directory)
temporary-file-directory)
default-directory))
- result status)
- (save-excursion
- (let ((buf (get-buffer " *ispell-tmp*")))
- (if buf (kill-buffer buf)))
- (set-buffer (get-buffer-create " *ispell-tmp*"))
- (erase-buffer)
+ result status ispell-program-version)
+
+ (with-temp-buffer
(setq status (ispell-call-process
ispell-program-name nil t nil
;; aspell doesn't accept the -vv switch.
(message "%s" result))
;; return library directory.
(if (re-search-forward "LIBDIR = \\\"\\([^ \t\n]*\\)\\\"" nil t)
- (setq result (buffer-substring (match-beginning 1) (match-end 1)))))
+ (setq result (match-string 1))))
(goto-char (point-min))
(if (not (memq status '(0 nil)))
(error "%s exited with %s %s" ispell-program-name
(if (stringp status) "signal" "code") status))
- (setq case-fold-search t
- status (re-search-forward
- (concat "\\<\\("
- (format "%d" (car ispell-required-version))
- "\\)\\.\\([0-9]*\\)\\.\\([0-9]*\\)\\>")
- nil t)
- case-fold-search case-fold-search-val)
- (if (or (not status) ; major version mismatch
- (< (car (read-from-string (match-string-no-properties 2)))
- (car (cdr ispell-required-version)))) ; minor version mismatch
- (error "%s version 3 release %d.%d.%d or greater is required"
- ispell-program-name (car ispell-required-version)
- (car (cdr ispell-required-version))
- (car (cdr (cdr ispell-required-version))))
- ;; check that it is the correct version.
- (if (and (= (car (read-from-string (match-string-no-properties 2)))
- (car (cdr ispell-required-version)))
- (< (car (read-from-string (match-string-no-properties 3)))
- (car (cdr (cdr ispell-required-version)))))
- (setq ispell-offset 0))
- ;; Check to see if it's really aspell.
- (goto-char (point-min))
- (let (case-fold-search)
- (setq ispell-really-aspell
- (and (search-forward-regexp
- "(but really Aspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t)
- (progn
- (setq ispell-aspell-supports-utf8
- (not (version< (match-string 1) "0.60")))
- t)))))
- (kill-buffer (current-buffer)))
+
+ ;; Get relevant version strings. Only xx.yy.... format works well
+ (let (case-fold-search)
+ (setq ispell-program-version
+ (and (search-forward-regexp "\\([0-9]+\\.[0-9\\.]+\\)" nil t)
+ (match-string 1)))
+
+ ;; Make sure these variables are (re-)initialized to the default value
+ (setq ispell-really-aspell nil
+ ispell-aspell-supports-utf8 nil
+ ispell-really-hunspell nil
+ ispell-encoding8-command nil)
+
+ (goto-char (point-min))
+ (or (setq ispell-really-aspell
+ (and (search-forward-regexp
+ "(but really Aspell \\([0-9]+\\.[0-9\\.-]+\\)?)" nil t)
+ (match-string 1)))
+ (setq ispell-really-hunspell
+ (and (search-forward-regexp
+ "(but really Hunspell \\([0-9]+\\.[0-9\\.-]+\\)?)"
+ nil t)
+ (match-string 1)))))
+
+ (let ((aspell-minver "0.50")
+ (aspell8-minver "0.60")
+ (ispell0-minver "3.1.0")
+ (ispell-minver "3.1.12")
+ (hunspell8-minver "1.1.6"))
+
+ (if (ispell-check-minver ispell0-minver ispell-program-version)
+ (or (ispell-check-minver ispell-minver ispell-program-version)
+ (setq ispell-offset 0))
+ (error "%s release %s or greater is required"
+ ispell-program-name
+ ispell-minver))
+
+ (cond
+ (ispell-really-aspell
+ (if (ispell-check-minver aspell-minver ispell-really-aspell)
+ (if (ispell-check-minver aspell8-minver ispell-really-aspell)
+ (progn
+ (setq ispell-aspell-supports-utf8 t)
+ (setq ispell-encoding8-command "--encoding=")))
+ (setq ispell-really-aspell nil)))
+ (ispell-really-hunspell
+ (if (ispell-check-minver hunspell8-minver ispell-really-hunspell)
+ (setq ispell-encoding8-command "-i ")
+ (setq ispell-really-hunspell nil))))))
result))
(defun ispell-call-process (&rest args)
-;;; The preparation of the menu bar menu must be autoloaded
-;;; because otherwise this file gets autoloaded every time Emacs starts
-;;; so that it can set up the menus and determine keyboard equivalents.
-
+;; The preparation of the menu bar menu must be autoloaded
+;; because otherwise this file gets autoloaded every time Emacs starts
+;; so that it can set up the menus and determine keyboard equivalents.
;;;###autoload
(defvar ispell-menu-map nil "Key map for ispell menu.")
If nil when package is loaded, a standard menu will be set,
and added as a submenu of the \"Edit\" menu.")
-;;; Break out XEmacs menu and split into several calls to avoid having
-;;; long lines in loaddefs.el. Detect need off following constant.
+;; Break out XEmacs menu and split into several calls to avoid having
+;; long lines in loaddefs.el. Detect need off following constant.
;;; Set up dictionary
;;;###autoload
;; Make ispell.el work better with aspell.
-(defvar ispell-have-aspell-dictionaries nil
- "Non-nil if we have queried Aspell for dictionaries at least once.")
-
-(defun ispell-maybe-find-aspell-dictionaries ()
- "Find Aspell's dictionaries, unless already done."
- (when (and (not ispell-have-aspell-dictionaries)
- (condition-case ()
- (progn (ispell-check-version) t)
- (error nil))
- ispell-really-aspell
- ispell-aspell-supports-utf8)
- (ispell-find-aspell-dictionaries)))
+(defvar ispell-aspell-dictionary-alist nil
+ "An alist of parsed aspell dicts and associated parameters.
+Internal use.")
(defun ispell-find-aspell-dictionaries ()
"Find Aspell's dictionaries, and record in `ispell-dictionary-alist'."
- (unless ispell-really-aspell
- (error "This function only works with aspell"))
+ (unless (and ispell-really-aspell ispell-encoding8-command)
+ (error "This function only works with aspell >= 0.60"))
(let* ((dictionaries
(split-string
(with-temp-buffer
(dolist (dict ispell-dictionary-alist)
(unless (assoc (car dict) found)
(setq found (nconc found (list dict)))))
- (setq ispell-dictionary-alist found)
+ (setq ispell-aspell-dictionary-alist found)
;; Add a default entry
- (let* ((english-dict (assoc "en" ispell-dictionary-alist))
- (default-dict
- (cons nil (or (cdr english-dict)
- (cdr (car ispell-dictionary-alist-1))))))
- (push default-dict ispell-dictionary-alist))
- (setq ispell-have-aspell-dictionaries t)))
+ (let ((default-dict
+ '(nil "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-B") nil utf-8)))
+ (push default-dict ispell-aspell-dictionary-alist))))
(defvar ispell-aspell-data-dir nil
"Data directory of Aspell.")
(car (split-string (buffer-string)))))
(defun ispell-aspell-find-dictionary (dict-name)
- ;; This returns nil if the data file does not exist.
- ;; Can someone please explain the return value format when the
- ;; file does exist -- rms?
- (let* ((lang ;; Strip out region, variant, etc.
- (and (string-match "^[[:alpha:]]+" dict-name)
- (match-string 0 dict-name)))
+ "For aspell dictionary DICT-NAME, return a list of parameters if an
+ associated data file is found or nil otherwise. List format is
+ that of `ispell-dictionary-base-alist' elements."
+ ;; Make sure `ispell-aspell-data-dir' is defined
+ (or ispell-aspell-data-dir
+ (setq ispell-aspell-data-dir
+ (ispell-get-aspell-config-value "data-dir")))
+ ;; Try finding associated datafile
+ (let* ((datafile1
+ (concat ispell-aspell-data-dir "/"
+ ;; Strip out variant, country code, etc.
+ (and (string-match "^[[:alpha:]]+" dict-name)
+ (match-string 0 dict-name)) ".dat"))
+ (datafile2
+ (concat ispell-aspell-data-dir "/"
+ ;; Strip out anything but xx_YY.
+ (and (string-match "^[[:alpha:]_]+" dict-name)
+ (match-string 0 dict-name)) ".dat"))
(data-file
- (concat (or ispell-aspell-data-dir
- (setq ispell-aspell-data-dir
- (ispell-get-aspell-config-value "data-dir")))
- "/" lang ".dat"))
+ (if (file-readable-p datafile1)
+ datafile1
+ (if (file-readable-p datafile2)
+ datafile2)))
otherchars)
- (condition-case ()
+
+ (if data-file
(with-temp-buffer
(insert-file-contents data-file)
;; There is zero or one line with special characters declarations.
"[^[:alpha:]]"
(regexp-opt otherchars)
t ; We can't tell, so set this to t
- (list "-d" dict-name "--encoding=utf-8")
+ (list "-d" dict-name)
nil ; aspell doesn't support this
;; Here we specify the encoding to use while communicating with
;; aspell. This doesn't apply to command line arguments, so
;; just don't pass words to spellcheck as arguments...
- 'utf-8))
- (file-error
- nil))))
+ 'utf-8)))))
(defun ispell-aspell-add-aliases (alist)
"Find aspell's dictionary aliases and add them to dictionary ALIST.
Return the new dictionary alist."
- (let ((aliases (file-expand-wildcards
+ (let ((aliases
+ (file-expand-wildcards
(concat (or ispell-aspell-dict-dir
(setq ispell-aspell-dict-dir
(ispell-get-aspell-config-value "dict-dir")))
(push (cons aliasname (cdr realdict)) alist))))))
alist))
+;; Set params according to the selected spellchecker
+
+(defvar ispell-last-program-name nil
+ "Last value of `ispell-program-name'. Internal use.")
+
+(defvar ispell-initialize-spellchecker-hook nil
+ "Normal hook run on spellchecker initialization.
+This hook is run when a spellchecker is used for the first
+time, before `ispell-dictionary-alist' is set. It is intended for
+sysadmins to override entries in `ispell-dictionary-base-alist'
+by putting those overrides in `ispell-base-dicts-override-alist', which is
+a dynamically scoped var with same format as `ispell-dictionary-alist'.
+This alist will not override the auto-detected values (e.g. if a recent
+aspell is used along with Emacs).")
+
+(defun ispell-set-spellchecker-params ()
+ "Initialize some spellchecker parameters when changed or first used."
+ (unless (eq ispell-last-program-name ispell-program-name)
+ (setq ispell-last-program-name ispell-program-name)
+ (ispell-kill-ispell t)
+ (if (and (condition-case ()
+ (progn
+ (setq ispell-library-directory (ispell-check-version))
+ t)
+ (error nil))
+ ispell-really-aspell
+ ispell-encoding8-command
+ ;; XEmacs does not like [:alpha:] regexps.
+ (string-match "^[[:alpha:]]+$" "abcde"))
+ (unless ispell-aspell-dictionary-alist
+ (ispell-find-aspell-dictionaries)))
+
+ ;; Substitute ispell-dictionary-alist with the list of dictionaries
+ ;; corresponding to the given spellchecker. If a recent aspell, use
+ ;; the list of really installed dictionaries and add to it elements
+ ;; of the original list that are not present there. Allow distro info.
+ (let ((found-dicts-alist
+ (if (and ispell-really-aspell
+ ispell-encoding8-command)
+ ispell-aspell-dictionary-alist
+ nil))
+ ispell-base-dicts-override-alist ; Override only base-dicts-alist
+ all-dicts-alist)
+
+ (run-hooks 'ispell-initialize-spellchecker-hook)
+
+ ;; Add dicts to ``ispell-dictionary-alist'' unless already present.
+ (dolist (dict (append found-dicts-alist
+ ispell-base-dicts-override-alist
+ ispell-dictionary-base-alist))
+ (unless (assoc (car dict) all-dicts-alist)
+ (add-to-list 'all-dicts-alist dict)))
+ (setq ispell-dictionary-alist all-dicts-alist))))
+
+
(defun ispell-valid-dictionary-list ()
- "Returns a list of valid dictionaries.
+ "Return a list of valid dictionaries.
The variable `ispell-library-directory' defines the library location."
- ;; If Ispell is really Aspell, query it for the dictionary list.
- (ispell-maybe-find-aspell-dictionaries)
+ ;; Initialize variables and dictionaries alists for desired spellchecker.
+ ;; Make sure ispell.el is loaded to avoid some autoload loops in XEmacs
+ ;; (and may be others)
+ (if (featurep 'ispell)
+ (ispell-set-spellchecker-params))
+
(let ((dicts (append ispell-local-dictionary-alist ispell-dictionary-alist))
(dict-list (cons "default" nil))
- name load-dict)
+ name dict-bname)
(dolist (dict dicts)
(setq name (car dict)
- load-dict (car (cdr (member "-d" (nth 5 dict)))))
+ dict-bname (or (car (cdr (member "-d" (nth 5 dict))))
+ name))
;; Include if the dictionary is in the library, or dir not defined.
(if (and
name
- ;; include all dictionaries if lib directory not known.
;; For Aspell, we already know which dictionaries exist.
(or ispell-really-aspell
+ ;; Include all dictionaries if lib directory not known.
+ ;; Same for Hunspell, where ispell-library-directory is nil.
(not ispell-library-directory)
(file-exists-p (concat ispell-library-directory
- "/" name ".hash"))
- (file-exists-p (concat ispell-library-directory "/" name ".has"))
- (and load-dict
- (or (file-exists-p (concat ispell-library-directory
- "/" load-dict ".hash"))
- (file-exists-p (concat ispell-library-directory
- "/" load-dict ".has"))))))
- (setq dict-list (cons name dict-list))))
+ "/" dict-bname ".hash"))
+ (file-exists-p (concat ispell-library-directory
+ "/" dict-bname ".has"))))
+ (push name dict-list)))
dict-list))
;;; define commands in menu in opposite order you want them to appear.
(progn
(setq ispell-menu-map (make-sparse-keymap "Spell"))
(define-key ispell-menu-map [ispell-change-dictionary]
- '(menu-item "Change Dictionary..." ispell-change-dictionary
- :help "Supply explicit dictionary file name"))
+ `(menu-item ,(purecopy "Change Dictionary...") ispell-change-dictionary
+ :help ,(purecopy "Supply explicit dictionary file name")))
(define-key ispell-menu-map [ispell-kill-ispell]
- '(menu-item "Kill Process" ispell-kill-ispell
+ `(menu-item ,(purecopy "Kill Process") ispell-kill-ispell
:enable (and (boundp 'ispell-process) ispell-process
(eq (ispell-process-status) 'run))
- :help "Terminate Ispell subprocess"))
+ :help ,(purecopy "Terminate Ispell subprocess")))
(define-key ispell-menu-map [ispell-pdict-save]
- '(menu-item "Save Dictionary"
+ `(menu-item ,(purecopy "Save Dictionary")
(lambda () (interactive) (ispell-pdict-save t t))
- :help "Save personal dictionary"))
+ :help ,(purecopy "Save personal dictionary")))
(define-key ispell-menu-map [ispell-customize]
- '(menu-item "Customize..."
+ `(menu-item ,(purecopy "Customize...")
(lambda () (interactive) (customize-group 'ispell))
- :help "Customize spell checking options"))
+ :help ,(purecopy "Customize spell checking options")))
(define-key ispell-menu-map [ispell-help]
;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ?
- '(menu-item "Help"
+ `(menu-item ,(purecopy "Help")
(lambda () (interactive) (describe-function 'ispell-help))
- :help "Show standard Ispell keybindings and commands"))
+ :help ,(purecopy "Show standard Ispell keybindings and commands")))
(define-key ispell-menu-map [flyspell-mode]
- '(menu-item "Automatic spell checking (Flyspell)"
+ `(menu-item ,(purecopy "Automatic spell checking (Flyspell)")
flyspell-mode
- :help "Check spelling while you edit the text"
+ :help ,(purecopy "Check spelling while you edit the text")
:button (:toggle . (bound-and-true-p flyspell-mode))))
(define-key ispell-menu-map [ispell-complete-word]
- '(menu-item "Complete Word" ispell-complete-word
- :help "Complete word at cursor using dictionary"))
+ `(menu-item ,(purecopy "Complete Word") ispell-complete-word
+ :help ,(purecopy "Complete word at cursor using dictionary")))
(define-key ispell-menu-map [ispell-complete-word-interior-frag]
- '(menu-item "Complete Word Fragment" ispell-complete-word-interior-frag
- :help "Complete word fragment at cursor"))))
+ `(menu-item ,(purecopy "Complete Word Fragment")
+ ispell-complete-word-interior-frag
+ :help ,(purecopy "Complete word fragment at cursor")))))
;;;###autoload
(if ispell-menu-map-needed
(progn
(define-key ispell-menu-map [ispell-continue]
- '(menu-item "Continue Spell-Checking" ispell-continue
+ `(menu-item ,(purecopy "Continue Spell-Checking") ispell-continue
:enable (and (boundp 'ispell-region-end)
(marker-position ispell-region-end)
(equal (marker-buffer ispell-region-end)
(current-buffer)))
- :help "Continue spell checking last region"))
+ :help ,(purecopy "Continue spell checking last region")))
(define-key ispell-menu-map [ispell-word]
- '(menu-item "Spell-Check Word" ispell-word
- :help "Spell-check word at cursor"))
+ `(menu-item ,(purecopy "Spell-Check Word") ispell-word
+ :help ,(purecopy "Spell-check word at cursor")))
(define-key ispell-menu-map [ispell-comments-and-strings]
- '(menu-item "Spell-Check Comments" ispell-comments-and-strings
- :help "Spell-check only comments and strings"))))
+ `(menu-item ,(purecopy "Spell-Check Comments")
+ ispell-comments-and-strings
+ :help ,(purecopy "Spell-check only comments and strings")))))
;;;###autoload
(if ispell-menu-map-needed
(progn
(define-key ispell-menu-map [ispell-region]
- '(menu-item "Spell-Check Region" ispell-region
+ `(menu-item ,(purecopy "Spell-Check Region") ispell-region
:enable mark-active
- :help "Spell-check text in marked region"))
+ :help ,(purecopy "Spell-check text in marked region")))
(define-key ispell-menu-map [ispell-message]
- '(menu-item "Spell-Check Message" ispell-message
+ `(menu-item ,(purecopy "Spell-Check Message") ispell-message
:visible (eq major-mode 'mail-mode)
- :help "Skip headers and included message text"))
+ :help ,(purecopy "Skip headers and included message text")))
(define-key ispell-menu-map [ispell-buffer]
- '(menu-item "Spell-Check Buffer" ispell-buffer
- :help "Check spelling of selected buffer"))
+ `(menu-item ,(purecopy "Spell-Check Buffer") ispell-buffer
+ :help ,(purecopy "Check spelling of selected buffer")))
;;(put 'ispell-region 'menu-enable 'mark-active)
(fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
(delete-menu-item '("Edit" "Spell")) ; in case already defined
(add-menu '("Edit") "Spell" ispell-menu-xemacs))))))
-;;; Allow incrementing characters as integers in XEmacs 20
-(if (and (featurep 'xemacs)
- (fboundp 'int-char))
- (fset 'ispell-int-char 'int-char)
- ;; Emacs and XEmacs 19 or earlier
- (fset 'ispell-int-char 'identity))
+(defalias 'ispell-int-char
+ ;; Allow incrementing characters as integers in XEmacs 20
+ (if (and (featurep 'xemacs)
+ (fboundp 'int-char))
+ 'int-char
+ ;; Emacs and XEmacs 19 or earlier
+ 'identity))
;;; **********************************************************************
-
-;;; This variable contains the current dictionary being used if the ispell
-;;; process is running.
(defvar ispell-current-dictionary nil
"The name of the current dictionary, or nil for the default.
This is passed to the ispell process using the `-d' switch and is
"The name of the current personal dictionary, or nil for the default.
This is passed to the ispell process using the `-p' switch.")
-(defvar ispell-dictionary nil
- "Default dictionary to use if `ispell-local-dictionary' is nil.")
-
(defun ispell-decode-string (str)
"Decodes multibyte character strings.
Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
+ ;; FIXME: enable-multibyte-characters is read-only, so bogus bindings are
+ ;; really nasty (they signal an error in Emacs): Who does that? --Stef
(if (and (or (featurep 'xemacs)
(and (boundp 'enable-multibyte-characters)
enable-multibyte-characters))
(decode-coding-string str (ispell-get-coding-system))
str))
-(put 'ispell-unified-chars-table 'char-table-extra-slots 0)
-
-;; Char-table that maps an Unicode character (charset:
-;; latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-34ff) to
-;; a string in which all equivalent characters are listed.
-
-(defconst ispell-unified-chars-table
- (let ((table (make-char-table 'ispell-unified-chars-table)))
- (map-char-table
- #'(lambda (c v)
- (if (and v (/= c v))
- (let ((unified (or (aref table v) (string v))))
- (aset table v (concat unified (string c))))))
- ucs-mule-8859-to-mule-unicode)
- table))
-
-;; Return a string decoded from Nth element of the current dictionary
-;; while splicing equivalent characters into the string. This splicing
-;; is done only if the string is a regular expression of the form
-;; "[...]" because, otherwise, splicing will result in incorrect
-;; regular expression matching.
-
+;; Return a string decoded from Nth element of the current dictionary.
(defun ispell-get-decoded-string (n)
+ "Get the decoded string in slot N of the descriptor of the current dict."
(let* ((slot (or
(assoc ispell-current-dictionary ispell-local-dictionary-alist)
- (assoc ispell-current-dictionary ispell-dictionary-alist)))
+ (assoc ispell-current-dictionary ispell-dictionary-alist)
+ (error "No match for the current dictionary")))
(str (nth n slot)))
(when (and (> (length str) 0)
(not (multibyte-string-p str)))
(setq str (ispell-decode-string str))
- (if (and (= (aref str 0) ?\[)
- (eq (string-match "\\]" str) (1- (length str))))
- (setq str
- (string-as-multibyte
- (mapconcat
- #'(lambda (c)
- (let ((unichar (aref ucs-mule-8859-to-mule-unicode c)))
- (if unichar
- (aref ispell-unified-chars-table unichar)
- (string c))))
- str ""))))
- (setcar (nthcdr n slot) str))
+ (or (multibyte-string-p str)
+ (setq str (string-to-multibyte str))))
str))
(defun ispell-get-casechars ()
;;;###autoload
(defvar ispell-skip-region-alist
- '((ispell-words-keyword forward-line)
+ `((ispell-words-keyword forward-line)
(ispell-dictionary-keyword forward-line)
(ispell-pdict-keyword forward-line)
(ispell-parsing-keyword forward-line)
- ("^---*BEGIN PGP [A-Z ]*--*" . "^---*END PGP [A-Z ]*--*")
+ (,(purecopy "^---*BEGIN PGP [A-Z ]*--*")
+ . ,(purecopy "^---*END PGP [A-Z ]*--*"))
;; assume multiline uuencoded file? "\nM.*$"?
- ("^begin [0-9][0-9][0-9] [^ \t]+$" . "\nend\n")
- ("^%!PS-Adobe-[123].0" . "\n%%EOF\n")
- ("^---* \\(Start of \\)?[Ff]orwarded [Mm]essage"
- . "^---* End of [Ff]orwarded [Mm]essage")
+ (,(purecopy "^begin [0-9][0-9][0-9] [^ \t]+$") . ,(purecopy "\nend\n"))
+ (,(purecopy "^%!PS-Adobe-[123].0") . ,(purecopy "\n%%EOF\n"))
+ (,(purecopy "^---* \\(Start of \\)?[Ff]orwarded [Mm]essage")
+ . ,(purecopy "^---* End of [Ff]orwarded [Mm]essage"))
;; Matches e-mail addresses, file names, http addresses, etc. The
;; `-+' `_+' patterns are necessary for performance reasons when
;; `-' or `_' part of word syntax.
- ("\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")
+ (,(purecopy "\\(--+\\|_+\\|\\(/\\w\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)"))
;; above checks /.\w sequences
;;("\\(--+\\|\\(/\\|\\(\\(\\w\\|[-_]\\)+[.:@]\\)\\)\\(\\w\\|[-_]\\)*\\([.:/@]+\\(\\w\\|[-_~=?&]\\)+\\)+\\)")
;; This is a pretty complex regexp. It can be simplified to the following:
;;;###autoload
(defvar ispell-tex-skip-alists
+ (purecopy
'((;;("%\\[" . "%\\]") ; AMStex block comment...
;; All the standard LaTeX keywords from L. Lamport's guide:
;; \cite, \hspace, \hspace*, \hyphenation, \include, \includeonly, \input,
("\\(figure\\|table\\)\\*?" ispell-tex-arg-end 0)
("list" ispell-tex-arg-end 2)
("program" . "\\\\end[ \t\n]*{[ \t\n]*program[ \t\n]*}")
- ("verbatim\\*?" . "\\\\end[ \t\n]*{[ \t\n]*verbatim\\*?[ \t\n]*}")))
+ ("verbatim\\*?" . "\\\\end[ \t\n]*{[ \t\n]*verbatim\\*?[ \t\n]*}"))))
"*Lists of regions to be skipped in TeX mode.
First list is used raw.
Second list has key placed inside \\begin{}.
;;;###autoload
-(defvar ispell-html-skip-alists
+(defconst ispell-html-skip-alists
'(("<[cC][oO][dD][eE]\\>[^>]*>" "</[cC][oO][dD][eE]*>")
("<[sS][cC][rR][iI][pP][tT]\\>[^>]*>" "</[sS][cC][rR][iI][pP][tT]>")
("<[aA][pP][pP][lL][eE][tT]\\>[^>]*>" "</[aA][pP][pP][lL][eE][tT]>")
("<[^ \t\n>]" ">")
("&[^ \t\n;]" "[; \t\n]"))
"*Lists of start and end keys to skip in HTML buffers.
-Same format as `ispell-skip-region-alist'
+Same format as `ispell-skip-region-alist'.
Note - substrings of other matches must come last
(e.g. \"<[tT][tT]/\" and \"<[^ \\t\\n>]\").")
(put 'ispell-html-skip-alists 'risky-local-variable t)
ispell-output)
(if (not (bufferp buf))
(setq ispell-filter nil)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(setq ispell-output (buffer-substring-no-properties
(point-min) (point-max))))
(ispell-filter t ispell-output)
- (save-excursion
- (set-buffer buf)
+ (with-current-buffer buf
(erase-buffer)))))))
(defun ispell-send-replacement (misspelled replacement)
"Notify aspell that MISSPELLED should be spelled REPLACEMENT.
-This allows it to improve the suggestion list based on actual mispellings."
+This allows it to improve the suggestion list based on actual misspellings."
(and ispell-really-aspell
(ispell-send-string (concat "$$ra " misspelled "," replacement "\n"))))
;; The following commands are not passed to Ispell until
;; we have a *real* reason to invoke it.
(cmds-to-defer '(?* ?@ ?~ ?+ ?- ?! ?%))
- (default-major-mode 'fundamental-mode)
(session-buf ispell-session-buffer)
(output-buf ispell-output-buffer)
(ispell-args ispell-cmd-args)
(defdir ispell-process-directory)
prev-pos)
- (save-excursion
- (set-buffer session-buf)
+ (with-current-buffer session-buf
(setq prev-pos (point))
(setq default-directory defdir)
(insert string)
(point-min) (point-max)
ispell-program-name nil
output-buf nil
- "-a" "-m" ispell-args))
+ "-a"
+ ;; hunspell -m option means something different
+ (if ispell-really-hunspell "" "-m")
+ ispell-args))
(set-buffer output-buf)
(goto-char (point-min))
(save-match-data
(setq more-lines (= 0 (forward-line))))))))))))))
-;; Insert WORD while translating Latin characters to the equivalent
-;; characters that is supported by buffer-file-coding-system.
-
+;; Insert WORD while possibly translating characters by
+;; translation-table-for-input.
(defun ispell-insert-word (word)
(let ((pos (point)))
(insert word)
- (if (char-table-p translation-table-for-input)
- (translate-region pos (point) translation-table-for-input))))
+ ;; Avoid "obsolete" warnings for translation-table-for-input.
+ (with-no-warnings
+ (if (char-table-p translation-table-for-input)
+ (translate-region pos (point) translation-table-for-input)))))
;;;###autoload
-(defun ispell-word (&optional following quietly continue)
+(defun ispell-word (&optional following quietly continue region)
"Check spelling of word under or before the cursor.
If the word is not found in dictionary, display possible corrections
in a window allowing you to choose one.
With a prefix argument (or if CONTINUE is non-nil),
resume interrupted spell-checking of a buffer or region.
+Interactively, in Transient Mark mode when the mark is active, call
+`ispell-region' to check the active region for spelling errors.
+
Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'.
\"word\" word corrected from word list.
\(\"word\" arg\) word is hand entered.
quit spell session exited."
-
- (interactive (list ispell-following-word ispell-quietly current-prefix-arg))
- (if continue
- (ispell-continue)
- (ispell-maybe-find-aspell-dictionaries)
+ (interactive (list ispell-following-word ispell-quietly current-prefix-arg t))
+ (cond
+ ((and region (use-region-p))
+ (ispell-region (region-beginning) (region-end)))
+ (continue (ispell-continue))
+ (t
+ (ispell-set-spellchecker-params) ; Initialize variables and dicts alists
(ispell-accept-buffer-local-defs) ; use the correct dictionary
(let ((cursor-location (point)) ; retain cursor location
(word (ispell-get-word following))
(or quietly
(message "%s is correct"
(funcall ispell-format-word-function word)))
- (and (fboundp 'extent-at)
+ (and (featurep 'xemacs)
(extent-at start)
(and (fboundp 'delete-extent)
(delete-extent (extent-at start)))))
(message "%s is correct because of root %s"
(funcall ispell-format-word-function word)
(funcall ispell-format-word-function poss)))
- (and (fboundp 'extent-at)
+ (and (featurep 'xemacs)
(extent-at start)
(and (fboundp 'delete-extent)
(delete-extent (extent-at start)))))
;; NB: Cancels ispell-quit incorrectly if called from ispell-region
(if ispell-quit (setq ispell-quit nil replace 'quit))
(goto-char cursor-location) ; return to original location
- replace)))
+ replace))))
(defun ispell-get-word (following &optional extra-otherchars)
Word syntax is controlled by the definition of the chosen dictionary,
which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'."
+ (ispell-set-spellchecker-params) ; Initialize variables and dicts alists
(let* ((ispell-casechars (ispell-get-casechars))
(ispell-not-casechars (ispell-get-not-casechars))
(ispell-otherchars (ispell-get-otherchars))
Automatic query-replace when second element is `query-replace'.
Highlights the word, which is assumed to run from START to END.
Global `ispell-pdict-modified-p' becomes a list where the only value
-indicates whether the dictionary has been modified when option `a' or `i' is
-used.
+indicates whether the dictionary has been modified when option `a'
+or `i' is used.
Global `ispell-quit' set to start location to continue spell session."
(let ((count ?0)
(line ispell-choices-win-default-height)
char num result textwin dedicated-win)
;; setup the *Choices* buffer with valid data.
- (save-excursion
- (set-buffer (get-buffer-create ispell-choices-buffer))
+ (with-current-buffer (get-buffer-create ispell-choices-buffer)
(setq mode-line-format
- (concat "-- %b -- word: " word
- " -- dict: " (or ispell-current-dictionary "default")
- " -- prog: " (file-name-nondirectory ispell-program-name)))
+ (concat
+ "-- %b -- word: " word
+ " -- dict: " (or ispell-current-dictionary "default")
+ " -- prog: " (file-name-nondirectory ispell-program-name)))
;; XEmacs: no need for horizontal scrollbar in choices window
(with-no-warnings
(and (fboundp 'set-specifier)
(setq line (1+ line))))
(insert (car guess) " ")
(setq guess (cdr guess)))
- (insert "\nUse option `i' to accept this spelling and put it in your private dictionary.")
+ (insert "\nUse option `i' to accept this spelling and put it in your private dictionary.\n")
(setq line (+ line (if choices 3 2)))))
(while (and choices
(< (if (> (+ 7 (current-column) (length (car choices))
(let (message-log-max)
(message (concat "C-h or ? for more options; SPC to leave "
"unchanged, Character to replace word")))
- (let ((inhibit-quit t))
- (setq char (if (fboundp 'read-char-exclusive)
- (read-char-exclusive)
- (read-char))
- skipped 0)
- (if (or quit-flag (= char ?\C-g)) ; C-g is like typing X
- (setq char ?X
- quit-flag nil)))
+ (let ((inhibit-quit t)
+ (input-valid t))
+ (setq char nil skipped 0)
+ ;; If the user types C-g, or generates some other
+ ;; non-character event (such as a frame switch
+ ;; event), stop ispell. As a special exception,
+ ;; ignore mouse events occurring in the same frame.
+ (while (and input-valid (not (characterp char)))
+ (setq char (read-key))
+ (setq input-valid
+ (or (characterp char)
+ (and (mouse-event-p char)
+ (eq (selected-frame)
+ (window-frame
+ (posn-window (event-start char))))))))
+ (when (or quit-flag (not input-valid) (= char ?\C-g))
+ (setq char ?X quit-flag nil)))
;; Adjust num to array offset skipping command characters.
(let ((com-chars command-characters))
(while com-chars
word)))
(if new-word
(progn
- (save-excursion
- (set-buffer (get-buffer-create
- ispell-choices-buffer))
+ (with-current-buffer (get-buffer-create
+ ispell-choices-buffer)
(erase-buffer)
(setq count ?0
skipped 0
- mode-line-format
+ mode-line-format ;; setup the *Choices* buffer with valid data.
(concat "-- %b -- word: " new-word
- " -- dict: "
- ispell-alternate-dictionary)
+ " -- word-list: "
+ (or ispell-complete-word-dict
+ ispell-alternate-dictionary))
miss (lookup-words new-word)
choices miss
line ispell-choices-win-default-height)
(defun ispell-show-choices (line end)
- "Shows the choices in another buffer or frame."
+ "Show the choices in another buffer or frame."
(if (and ispell-use-framepop-p (fboundp 'framepop-display-buffer))
(progn
(framepop-display-buffer (get-buffer ispell-choices-buffer))
-;;; (get-buffer-window ispell-choices-buffer t)
+ ;; (get-buffer-window ispell-choices-buffer t)
(select-window (previous-window))) ; *Choices* window
;; standard selection by splitting a small buffer out of this window.
(let ((choices-window (get-buffer-window ispell-choices-buffer)))
`a': Accept word for this session.
`A': Accept word and place in `buffer-local dictionary'.
`r': Replace word with typed-in value. Rechecked.
-`R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
+`R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
`?': Show these commands.
`x': Exit spelling buffer. Move cursor to original point.
`X': Exit spelling buffer. Leaves cursor at the current point, and permits
`a': Accept word for this session.
`A': Accept word and place in `buffer-local dictionary'.
`r': Replace word with typed-in value. Rechecked.
-`R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
+`R': Replace word with typed-in value. Query-replaced in buffer. Rechecked.
`?': Show these commands.
`x': Exit spelling buffer. Move cursor to original point.
`X': Exit spelling buffer. Leaves cursor at the current point, and permits
search for the words (usually egrep).
Optional second argument contains the dictionary to use; the default is
-`ispell-alternate-dictionary'."
+`ispell-alternate-dictionary', overriden by `ispell-complete-word-dict'
+if defined."
;; We don't use the filter for this function, rather the result is written
;; into a buffer. Hence there is no need to save the filter values.
(if (null lookup-dict)
- (setq lookup-dict ispell-alternate-dictionary))
+ (setq lookup-dict (or ispell-complete-word-dict
+ ispell-alternate-dictionary)))
+
+ (if lookup-dict
+ (unless (file-readable-p lookup-dict)
+ (error "lookup-words error: Unreadable or missing plain word-list %s."
+ lookup-dict))
+ (error (concat "lookup-words error: No plain word-list found at system"
+ "default locations. "
+ "Customize `ispell-alternate-dictionary' to set yours.")))
(let* ((process-connection-type ispell-use-ptys-p)
(wild-p (string-match "\\*" word))
(look-p (and ispell-look-p ; Only use look for an exact match.
(or ispell-have-new-look (not wild-p))))
- (ispell-grep-buffer (get-buffer-create "*Ispell-Temp*")) ; result buf
(prog (if look-p ispell-look-command ispell-grep-command))
(args (if look-p ispell-look-options ispell-grep-options))
status results loc)
- (unwind-protect
- (save-window-excursion
- (message "Starting \"%s\" process..." (file-name-nondirectory prog))
- (set-buffer ispell-grep-buffer)
- (if look-p
- nil
- ;; convert * to .*
- (insert "^" word "$")
- (while (search-backward "*" nil t) (insert "."))
- (setq word (buffer-string))
- (erase-buffer))
- (setq status (apply 'ispell-call-process prog nil t nil
- (nconc (if (and args (> (length args) 0))
- (list args)
- (if look-p nil
- (list "-e")))
- (list word)
- (if lookup-dict (list lookup-dict)))))
- ;; grep returns status 1 and no output when word not found, which
- ;; is a perfectly normal thing.
- (if (stringp status)
- (setq results (cons (format "error: %s exited with signal %s"
- (file-name-nondirectory prog) status)
- results))
- ;; else collect words into `results' in FIFO order
- (goto-char (point-max))
- ;; assure we've ended with \n
- (or (bobp) (= (preceding-char) ?\n) (insert ?\n))
- (while (not (bobp))
- (setq loc (point))
- (forward-line -1)
- (setq results (cons (buffer-substring-no-properties (point)
- (1- loc))
- results)))))
- ;; protected
- (kill-buffer ispell-grep-buffer)
- (if (and results (string-match ".+: " (car results)))
- (error "%s error: %s" ispell-grep-command (car results))))
+ (with-temp-buffer
+ (message "Starting \"%s\" process..." (file-name-nondirectory prog))
+ (if look-p
+ nil
+ ;; Convert * to .*
+ (insert "^" word "$")
+ (while (search-backward "*" nil t) (insert "."))
+ (setq word (buffer-string))
+ (erase-buffer))
+ (setq status (apply 'ispell-call-process prog nil t nil
+ (nconc (if (and args (> (length args) 0))
+ (list args)
+ (if look-p nil
+ (list "-e")))
+ (list word)
+ (if lookup-dict (list lookup-dict)))))
+ ;; `grep' returns status 1 and no output when word not found, which
+ ;; is a perfectly normal thing.
+ (if (stringp status)
+ (error "error: %s exited with signal %s"
+ (file-name-nondirectory prog) status)
+ ;; Else collect words into `results' in FIFO order.
+ (goto-char (point-max))
+ ;; Assure we've ended with \n.
+ (or (bobp) (= (preceding-char) ?\n) (insert ?\n))
+ (while (not (bobp))
+ (setq loc (point))
+ (forward-line -1)
+ (push (buffer-substring-no-properties (point)
+ (1- loc))
+ results))))
+ (if (and results (string-match ".+: " (car results)))
+ (error "%s error: %s" ispell-grep-command (car results)))
results))
-;;; "ispell-filter" is a list of output lines from the generating function.
-;;; Each full line (ending with \n) is a separate item on the list.
-;;; "output" can contain multiple lines, part of a line, or both.
-;;; "start" and "end" are used to keep bounds on lines when "output" contains
-;;; multiple lines.
-;;; "ispell-filter-continue" is true when we have received only part of a
-;;; line as output from a generating function ("output" did not end with \n)
-;;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
-;;; This is the case when a process dies or fails. The default behavior
-;;; in this case treats the next input received as fresh input.
+;; "ispell-filter" is a list of output lines from the generating function.
+;; Each full line (ending with \n) is a separate item on the list.
+;; "output" can contain multiple lines, part of a line, or both.
+;; "start" and "end" are used to keep bounds on lines when "output" contains
+;; multiple lines.
+;; "ispell-filter-continue" is true when we have received only part of a
+;; line as output from a generating function ("output" did not end with \n)
+;; THIS FUNCTION WILL FAIL IF THE PROCESS OUTPUT DOESN'T END WITH \n!
+;; This is the case when a process dies or fails. The default behavior
+;; in this case treats the next input received as fresh input.
(defun ispell-filter (process output)
"Output filter function for ispell, grep, and look."
(setq count (string-to-number output) ; get number of misses.
output (substring output (1+ (string-match " " output 1)))))
(setq offset (string-to-number output))
- (if (eq type ?#) ; No miss or guess list.
- (setq output nil)
- (setq output (substring output (1+ (string-match " " output 1)))))
+ (setq output (if (eq type ?#) ; No miss or guess list.
+ nil
+ (substring output (1+ (string-match " " output 1)))))
(while output
(let ((end (string-match ", \\|\\($\\)" output))) ; end of miss/guess.
(setq cur-count (1+ cur-count))
(if (> cur-count count)
- (setq guess-list (cons (substring output 0 end) guess-list))
- (setq miss-list (cons (substring output 0 end) miss-list)))
- (if (match-end 1) ; True only when at end of line.
- (setq output nil) ; no more misses or guesses
- (setq output (substring output (+ end 2))))))
+ (push (substring output 0 end) guess-list)
+ (push (substring output 0 end) miss-list))
+ (setq output (if (match-end 1) ; True only when at end of line.
+ nil ; No more misses or guesses.
+ (substring output (+ end 2))))))
;; return results. Accept word if it was already accepted.
;; adjust offset.
(if (member original-word accept-list)
(defun ispell-start-process ()
"Start the ispell process, with support for no asynchronous processes.
Keeps argument list for future ispell invocations for no async support."
- (let ((default-directory default-directory)
- args)
- (unless (and (file-directory-p default-directory)
- (file-readable-p default-directory))
- ;; Defend against bad `default-directory'.
- (setq default-directory (expand-file-name "~/")))
- ;; Local dictionary becomes the global dictionary in use.
- (setq ispell-current-dictionary
- (or ispell-local-dictionary ispell-dictionary))
- (setq ispell-current-personal-dictionary
- (or ispell-local-pdict ispell-personal-dictionary))
- (setq args (ispell-get-ispell-args))
- (if (and ispell-current-dictionary ; use specified dictionary
- (not (member "-d" args))) ; only define if not overridden
- (setq args
- (append (list "-d" ispell-current-dictionary) args)))
- (if ispell-current-personal-dictionary ; use specified pers dict
- (setq args
- (append args
- (list "-p"
- (expand-file-name ispell-current-personal-dictionary)))))
- (setq args (append args ispell-extra-args))
+ ;; Local dictionary becomes the global dictionary in use.
+ (setq ispell-current-dictionary
+ (or ispell-local-dictionary ispell-dictionary))
+ (setq ispell-current-personal-dictionary
+ (or ispell-local-pdict ispell-personal-dictionary))
+ (let* ((default-directory
+ (if (and (file-directory-p default-directory)
+ (file-readable-p default-directory))
+ default-directory
+ ;; Defend against bad `default-directory'.
+ (expand-file-name "~/")))
+ (orig-args (ispell-get-ispell-args))
+ (args
+ (append
+ (if (and ispell-current-dictionary ; Not for default dict (nil)
+ (not (member "-d" orig-args))) ; Only define if not overridden.
+ (list "-d" ispell-current-dictionary))
+ orig-args
+ (if ispell-current-personal-dictionary ; Use specified pers dict.
+ (list "-p"
+ (expand-file-name ispell-current-personal-dictionary)))
+ ;; If we are using recent aspell or hunspell, make sure we use the
+ ;; right encoding for communication. ispell or older aspell/hunspell
+ ;; does not support this.
+ (if ispell-encoding8-command
+ (list
+ (concat ispell-encoding8-command
+ (symbol-name (ispell-get-coding-system)))))
+ ispell-extra-args)))
;; Initially we don't know any buffer's local words.
(setq ispell-buffer-local-name nil)
(let ((process-connection-type ispell-use-ptys-p))
(apply 'start-process
"ispell" nil ispell-program-name
- "-a" ; accept single input lines
- "-m" ; make root/affix combos not in dict
+ "-a" ; Accept single input lines.
+ ;; Make root/affix combos not in dict.
+ ;; hunspell -m option means different.
+ (if ispell-really-hunspell "" "-m")
args))
(setq ispell-cmd-args args
ispell-output-buffer (generate-new-buffer " *ispell-output*")
t)))
-
(defun ispell-init-process ()
"Check status of Ispell process and start if necessary."
- (if (and ispell-process
- (eq (ispell-process-status) 'run)
- ;; If we're using a personal dictionary, ensure
- ;; we're in the same default directory!
- (or (not ispell-personal-dictionary)
- (equal ispell-process-directory default-directory)))
- (setq ispell-filter nil ispell-filter-continue nil)
- ;; may need to restart to select new personal dictionary.
- (ispell-kill-ispell t)
- (message "Starting new Ispell process [%s] ..."
- (or ispell-local-dictionary ispell-dictionary "default"))
- (sit-for 0)
- (setq ispell-library-directory (ispell-check-version)
- ispell-process-directory default-directory
- ispell-process (ispell-start-process)
- ispell-filter nil
- ispell-filter-continue nil)
- (if ispell-async-processp
- (set-process-filter ispell-process 'ispell-filter))
- ;; protect against bogus binding of `enable-multibyte-characters' in XEmacs
- (if (and (or (featurep 'xemacs)
- (and (boundp 'enable-multibyte-characters)
- enable-multibyte-characters))
- (fboundp 'set-process-coding-system))
- (set-process-coding-system ispell-process (ispell-get-coding-system)
- (ispell-get-coding-system)))
- ;; Get version ID line
- (ispell-accept-output 3)
- ;; get more output if filter empty?
- (if (null ispell-filter) (ispell-accept-output 3))
- (cond ((null ispell-filter)
- (error "%s did not output version line" ispell-program-name))
- ((and
- (stringp (car ispell-filter))
- (if (string-match "warning: " (car ispell-filter))
- (progn
- (ispell-accept-output 3) ; was warn msg.
- (stringp (car ispell-filter)))
- (null (cdr ispell-filter)))
- (string-match "^@(#) " (car ispell-filter)))
- ;; got the version line as expected (we already know it's the right
- ;; version, so don't bother checking again.)
- nil)
- (t
- ;; Otherwise, it must be an error message. Show the user.
- ;; But first wait to see if some more output is going to arrive.
- ;; Otherwise we get cool errors like "Can't open ".
- (sleep-for 1)
- (ispell-accept-output 3)
- (error "%s" (mapconcat 'identity ispell-filter "\n"))))
- (setq ispell-filter nil) ; Discard version ID line
- (let ((extended-char-mode (ispell-get-extended-character-mode)))
- (if extended-char-mode ; ~ extended character mode
- (ispell-send-string (concat extended-char-mode "\n"))))
- (if ispell-async-processp
- (set-process-query-on-exit-flag ispell-process nil))))
+ (let* (;; Basename of dictionary used by the spell-checker
+ (dict-bname (or (car (cdr (member "-d" (ispell-get-ispell-args))))
+ ispell-current-dictionary))
+ ;; Use "~/" as default-directory unless using Ispell with per-dir
+ ;; personal dictionaries and not in a minibuffer under XEmacs
+ (default-directory
+ (if (or ispell-really-aspell
+ ispell-really-hunspell
+ ;; Protect against bad default-directory
+ (not (and (file-directory-p default-directory)
+ (file-readable-p default-directory)))
+ ;; Ispell and per-dir personal dicts available
+ (not (or (file-readable-p (concat default-directory
+ ".ispell_words"))
+ (file-readable-p (concat default-directory
+ ".ispell_"
+ (or dict-bname
+ "default")))))
+ ;; Ispell, in a minibuffer, and XEmacs
+ (and (window-minibuffer-p)
+ (not (fboundp 'minibuffer-selected-window))))
+ (expand-file-name "~/")
+ (expand-file-name default-directory))))
+ ;; Check if process needs restart
+ (if (and ispell-process
+ (eq (ispell-process-status) 'run)
+ ;; Unless we are using an explicit personal dictionary, ensure
+ ;; we're in the same default directory! Restart check for
+ ;; personal dictionary is done in
+ ;; `ispell-internal-change-dictionary', called from
+ ;; `ispell-buffer-local-dict'
+ (or (or ispell-local-pdict ispell-personal-dictionary)
+ (equal ispell-process-directory default-directory)))
+ (setq ispell-filter nil ispell-filter-continue nil)
+ ;; may need to restart to select new personal dictionary.
+ (ispell-kill-ispell t)
+ (message "Starting new Ispell process [%s] ..."
+ (or ispell-local-dictionary ispell-dictionary "default"))
+ (sit-for 0)
+ (setq ispell-library-directory (ispell-check-version)
+ ispell-process (ispell-start-process)
+ ispell-filter nil
+ ispell-filter-continue nil
+ ispell-process-directory default-directory)
+
+ (unless (equal ispell-process-directory (expand-file-name "~/"))
+ ;; At this point, `ispell-process-directory' will be "~/" unless using
+ ;; Ispell with directory-specific dicts and not in XEmacs minibuffer.
+ ;; If not, kill ispell process when killing buffer. It may be in a
+ ;; removable device that would otherwise become un-mountable.
+ (with-current-buffer
+ (if (and (window-minibuffer-p) ;; In minibuffer
+ (fboundp 'minibuffer-selected-window)) ;; Not XEmacs.
+ ;; In this case kill ispell only when parent buffer is killed
+ ;; to avoid over and over ispell kill.
+ (window-buffer (minibuffer-selected-window))
+ (current-buffer))
+ ;; 'local does not automatically make hook buffer-local in XEmacs.
+ (if (featurep 'xemacs)
+ (make-local-hook 'kill-buffer-hook))
+ (add-hook 'kill-buffer-hook
+ (lambda () (ispell-kill-ispell t)) nil 'local)))
+
+ (if ispell-async-processp
+ (set-process-filter ispell-process 'ispell-filter))
+ ;; Protect against XEmacs bogus binding of `enable-multibyte-characters'.
+ (if (and (or (featurep 'xemacs)
+ (and (boundp 'enable-multibyte-characters)
+ enable-multibyte-characters))
+ (fboundp 'set-process-coding-system))
+ (set-process-coding-system ispell-process (ispell-get-coding-system)
+ (ispell-get-coding-system)))
+ ;; Get version ID line
+ (ispell-accept-output 3)
+ ;; get more output if filter empty?
+ (if (null ispell-filter) (ispell-accept-output 3))
+ (cond ((null ispell-filter)
+ (error "%s did not output version line" ispell-program-name))
+ ((and
+ (stringp (car ispell-filter))
+ (if (string-match "warning: " (car ispell-filter))
+ (progn
+ (ispell-accept-output 3) ; was warn msg.
+ (stringp (car ispell-filter)))
+ (null (cdr ispell-filter)))
+ (string-match "^@(#) " (car ispell-filter)))
+ ;; got the version line as expected (we already know it's the right
+ ;; version, so don't bother checking again.)
+ nil)
+ (t
+ ;; Otherwise, it must be an error message. Show the user.
+ ;; But first wait to see if some more output is going to arrive.
+ ;; Otherwise we get cool errors like "Can't open ".
+ (sleep-for 1)
+ (ispell-accept-output 3)
+ (error "%s" (mapconcat 'identity ispell-filter "\n"))))
+ (setq ispell-filter nil) ; Discard version ID line
+ (let ((extended-char-mode (ispell-get-extended-character-mode)))
+ (if extended-char-mode ; ~ extended character mode
+ (ispell-send-string (concat extended-char-mode "\n"))))
+ (if ispell-async-processp
+ (if (featurep 'emacs)
+ (set-process-query-on-exit-flag ispell-process nil)
+ (if (fboundp 'set-process-query-on-exit-flag)
+ (set-process-query-on-exit-flag ispell-process nil)
+ (process-kill-without-query ispell-process)))))))
;;;###autoload
(defun ispell-kill-ispell (&optional no-error)
(message "Ispell process killed")
nil))
-
;;; ispell-change-dictionary is set in some people's hooks. Maybe this should
;;; call ispell-init-process rather than wait for a spell checking command?
(mapcar 'list (ispell-valid-dictionary-list)))
nil t)
current-prefix-arg))
- (ispell-maybe-find-aspell-dictionaries)
+ (ispell-set-spellchecker-params) ; Initilize variables and dicts alists
(unless arg (ispell-buffer-local-dict 'no-reload))
(if (equal dict "default") (setq dict nil))
;; This relies on completing-read's bug of returning "" for no match
(setq ispell-current-dictionary dict
ispell-current-personal-dictionary pdict))))
-;;; Spelling of comments are checked when ispell-check-comments is non-nil.
+;; Avoid error messages when compiling for these dynamic variables.
+(defvar ispell-start)
+(defvar ispell-end)
+
+;; Spelling of comments are checked when ispell-check-comments is non-nil.
;;;###autoload
(defun ispell-region (reg-start reg-end &optional recheckp shift)
Return nil if spell session is quit,
otherwise returns shift offset amount for last line processed."
(interactive "r") ; Don't flag errors on read-only bufs.
- (ispell-maybe-find-aspell-dictionaries)
+ (ispell-set-spellchecker-params) ; Initialize variables and dicts alists
(if (not recheckp)
(ispell-accept-buffer-local-defs)) ; set up dictionary, local words, etc.
(let ((skip-region-start (make-marker))
(rstart (make-marker)))
(unwind-protect
(save-excursion
- (message "Spell checking %s using %s with %s dictionary..."
+ (message "Spell-checking %s using %s with %s dictionary..."
(if (and (= reg-start (point-min)) (= reg-end (point-max)))
(buffer-name) "region")
(file-name-nondirectory ispell-program-name)
(message "searching for regions to skip"))
(if (re-search-forward (ispell-begin-skip-region-regexp) reg-end t)
(progn
- (setq key (buffer-substring-no-properties
- (match-beginning 0) (match-end 0)))
+ (setq key (match-string-no-properties 0))
(set-marker skip-region-start (- (point) (length key)))
(goto-char reg-start)))
(let (message-log-max)
- (message "Continuing spelling check using %s with %s dictionary..."
- (file-name-nondirectory ispell-program-name)
- (or ispell-current-dictionary "default")))
+ (message
+ "Continuing spelling check using %s with %s dictionary..."
+ (file-name-nondirectory ispell-program-name)
+ (or ispell-current-dictionary "default")))
(set-marker rstart reg-start)
(set-marker ispell-region-end reg-end)
(while (and (not ispell-quit)
(if (marker-position skip-region-start)
(min skip-region-start ispell-region-end)
(marker-position ispell-region-end))))
- (let* ((start (point))
- (end (save-excursion (end-of-line) (min (point) reg-end)))
- (string (ispell-get-line start end in-comment)))
+ (let* ((ispell-start (point))
+ (ispell-end (min (point-at-eol) reg-end))
+ (string (ispell-get-line
+ ispell-start ispell-end in-comment)))
(if in-comment ; account for comment chars added
- (setq start (- start (length in-comment))
+ (setq ispell-start (- ispell-start (length in-comment))
in-comment nil))
- (setq end (point)) ; "end" tracks region retrieved.
+ (setq ispell-end (point)) ; "end" tracks region retrieved.
(if string ; there is something to spell check!
;; (special start end)
(setq shift (ispell-process-line string
(and recheckp shift))))
- (goto-char end)))))
+ (goto-char ispell-end)))))
(if ispell-quit
nil
(or shift 0)))
(if (not recheckp) (set-marker ispell-region-end nil))
;; Only save if successful exit.
(ispell-pdict-save ispell-silently-savep)
- (message "Spell-checking using %s with %s dictionary done"
+ (message "Spell-checking %s using %s with %s dictionary...done"
+ (if (and (= reg-start (point-min)) (= reg-end (point-max)))
+ (buffer-name) "region")
(file-name-nondirectory ispell-program-name)
(or ispell-current-dictionary "default"))))))
(defun ispell-begin-skip-region-regexp ()
- "Returns a regexp of the search keys for region skipping.
+ "Return a regexp of the search keys for region skipping.
Includes `ispell-skip-region-alist' plus tex, tib, html, and comment keys.
Must call after `ispell-buffer-local-parsing' due to dependence on mode."
- ;; start with regions generic to all buffers
- (let ((skip-regexp (ispell-begin-skip-region ispell-skip-region-alist)))
- ;; Comments
- (if (and (null ispell-check-comments) comment-start)
- (setq skip-regexp (concat (regexp-quote comment-start) "\\|"
- skip-regexp)))
- (if (and (eq 'exclusive ispell-check-comments) comment-start)
- ;; search from end of current comment to start of next comment.
- (setq skip-regexp (concat (if (string= "" comment-end) "^"
- (regexp-quote comment-end))
- "\\|" skip-regexp)))
- ;; tib
- (if ispell-skip-tib
- (setq skip-regexp (concat ispell-tib-ref-beginning "\\|" skip-regexp)))
- ;; html stuff
- (if ispell-skip-html
- (setq skip-regexp (concat
- (ispell-begin-skip-region ispell-html-skip-alists)
- "\\|"
- skip-regexp)))
- ;; tex
- (if (eq ispell-parser 'tex)
- (setq skip-regexp (concat (ispell-begin-tex-skip-regexp) "\\|"
- skip-regexp)))
- ;; messages
- (if (and ispell-checking-message
- (not (eq t ispell-checking-message)))
- (setq skip-regexp (concat
- (mapconcat (lambda (lst) (car lst))
- ispell-checking-message
- "\\|")
- "\\|"
- skip-regexp)))
-
- ;; return new regexp
- skip-regexp))
+ (mapconcat
+ 'identity
+ (delq nil
+ (list
+ ;; messages
+ (if (and ispell-checking-message
+ (not (eq t ispell-checking-message)))
+ (mapconcat #'car ispell-checking-message "\\|"))
+ ;; tex
+ (if (eq ispell-parser 'tex)
+ (ispell-begin-tex-skip-regexp))
+ ;; html stuff
+ (if ispell-skip-html
+ (ispell-begin-skip-region ispell-html-skip-alists))
+ ;; tib
+ (if ispell-skip-tib ispell-tib-ref-beginning)
+ ;; Comments
+ (if (and (eq 'exclusive ispell-check-comments) comment-start)
+ ;; search from end of current comment to start of next comment.
+ (if (string= "" comment-end) "^" (regexp-quote comment-end)))
+ (if (and (null ispell-check-comments) comment-start)
+ (regexp-quote comment-start))
+ (ispell-begin-skip-region ispell-skip-region-alist)))
+ "\\|"))
(defun ispell-begin-skip-region (skip-alist)
(defun ispell-skip-region-list ()
- "Returns a list describing key and body regions to skip for this buffer.
+ "Return a list describing key and body regions to skip for this buffer.
Includes regions defined by `ispell-skip-region-alist', tex mode,
`ispell-html-skip-alists', and `ispell-checking-message'.
Manual checking must include comments and tib references.
(defun ispell-ignore-fcc (start end)
- "Deletes the Fcc: message header when large attachments are included.
+ "Delete the Fcc: message header when large attachments are included.
Return value `nil' if file with large attachments are saved.
This can be used to avoid multiple questions for multiple large attachments.
Returns point to starting location afterwards."
(defun ispell-skip-region (key)
- "Skips across KEY and then to end of region.
+ "Skip across KEY and then to end of region.
Key lookup determines region to skip.
Point is placed at end of skipped region."
;; move over key to begin checking.
(sit-for 2)))))
-;;; Grab the next line of data.
-;;; Returns a string with the line data
(defun ispell-get-line (start end in-comment)
+ "Grab the next line of data.
+Returns a string with the line data."
(let ((ispell-casechars (ispell-get-casechars))
string)
(cond ; LOOK AT THIS LINE AND SKIP OR PROCESS
(point) (+ (point) len))
coding)))))
-;;; Avoid error messages when compiling for these dynamic variables.
-(defvar start)
-(defvar end)
-
(defun ispell-process-line (string shift)
- "Sends STRING, a line of text, to ispell and processes the result.
+ "Send STRING, a line of text, to ispell and processes the result.
This will modify the buffer for spelling errors.
-Requires variables START and END to be defined in its lexical scope.
+Requires variables ISPELL-START and ISPELL-END to be defined in its
+dynamic scope.
Returns the sum SHIFT due to changes in word replacements."
- ;;(declare special start end)
+ ;;(declare special ispell-start ispell-end)
(let (poss accept-list)
(if (not (numberp shift))
(setq shift 0))
;; Markers can move with highlighting! This destroys
;; end of region markers line-end and ispell-region-end
(let ((word-start
- (copy-marker (+ start ispell-offset (car (cdr poss)))))
+ (copy-marker (+ ispell-start ispell-offset (car (cdr poss)))))
(word-len (length (car poss)))
- (line-end (copy-marker end))
- (line-start (copy-marker start))
+ (line-end (copy-marker ispell-end))
+ (line-start (copy-marker ispell-start))
recheck-region replace)
(goto-char word-start)
;; Adjust the horizontal scroll & point
;; (length (car poss)))))
))
(if (not ispell-quit)
+ ;; FIXME: remove redundancy with identical code above.
(let (message-log-max)
- (message "Continuing spelling check using %s with %s dictionary..."
- (file-name-nondirectory ispell-program-name)
- (or ispell-current-dictionary "default"))))
+ (message
+ "Continuing spelling check using %s with %s dictionary..."
+ (file-name-nondirectory ispell-program-name)
+ (or ispell-current-dictionary "default"))))
(sit-for 0)
- (setq start (marker-position line-start)
- end (marker-position line-end))
+ (setq ispell-start (marker-position line-start)
+ ispell-end (marker-position line-end))
;; Adjust markers when end of region lost from highlighting.
- (if (and (not recheck-region) (< end (+ word-start word-len)))
- (setq end (+ word-start word-len)))
+ (if (and (not recheck-region)
+ (< ispell-end (+ word-start word-len)))
+ (setq ispell-end (+ word-start word-len)))
(if (= word-start ispell-region-end)
(set-marker ispell-region-end (+ word-start word-len)))
;; going out of scope - unneeded
;;; Horizontal scrolling
(defun ispell-horiz-scroll ()
- "Places point within the horizontal visibility of its window area."
+ "Place point within the horizontal visibility of its window area."
(if truncate-lines ; display truncating lines?
;; See if display needs to be scrolled.
(let ((column (- (current-column) (max (window-hscroll) 1))))
;;; Interactive word completion.
-;;; Forces "previous-word" processing. Do we want to make this selectable?
+;; Forces "previous-word" processing. Do we want to make this selectable?
;;;###autoload
(defun ispell-complete-word (&optional interior-frag)
(lookup-words (concat (and interior-frag "*") word
(if (or interior-frag (null ispell-look-p))
"*"))
- ispell-complete-word-dict)))
+ (or ispell-complete-word-dict
+ ispell-alternate-dictionary))))
(cond ((eq possibilities t)
(message "No word to complete"))
((null possibilities)
;;; Ispell Minor Mode
;;; **********************************************************************
-(defvar ispell-minor-mode nil
- "Non-nil if Ispell minor mode is enabled.")
-;; Variable indicating that ispell minor mode is active.
-(make-variable-buffer-local 'ispell-minor-mode)
-
-(or (assq 'ispell-minor-mode minor-mode-alist)
- (setq minor-mode-alist
- (cons '(ispell-minor-mode " Spell") minor-mode-alist)))
-
(defvar ispell-minor-keymap
(let ((map (make-sparse-keymap)))
(define-key map " " 'ispell-minor-check)
map)
"Keymap used for Ispell minor mode.")
-(or (not (boundp 'minor-mode-map-alist))
- (assoc 'ispell-minor-mode minor-mode-map-alist)
- (setq minor-mode-map-alist
- (cons (cons 'ispell-minor-mode ispell-minor-keymap)
- minor-mode-map-alist)))
-
;;;###autoload
-(defun ispell-minor-mode (&optional arg)
+(define-minor-mode ispell-minor-mode
"Toggle Ispell minor mode.
With prefix argument ARG, turn Ispell minor mode on if ARG is positive,
otherwise turn it off.
All the buffer-local variables and dictionaries are ignored -- to read
them into the running ispell process, type \\[ispell-word] SPC."
- (interactive "P")
- (setq ispell-minor-mode
- (not (or (and (null arg) ispell-minor-mode)
- (<= (prefix-numeric-value arg) 0))))
- (force-mode-line-update))
+ nil " Spell" ispell-minor-keymap)
(defun ispell-minor-check ()
"Check previous word then continue with the normal binding of this key.
;; Matches context difference listing
"\\(\\(^cd .*\n\\)?diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*"
;; Matches unidiff difference listing
- "\\(diff -u .*\\)?\n--- .*\n\\+\\+\\+ .*\n@@ [-+][0-9]+,[0-9]+ [-+][0-9]+,[0-9]+ @@\n"
+ "\\(diff -u .*\\)?\n--- .*\n\\+\\+\\+ .*\n@@ [-+][0-9]+,[0-9]+ [-+][0-9]+,[0-9]+ @@"
;; Matches reporter.el bug report
"^current state:\n==============\n"
;; Matches commonly used "cut" boundaries
(defun ispell-mime-skip-part (boundary)
- "Moves point across header, or entire MIME part if message is encoded.
+ "Move point across header, or entire MIME part if message is encoded.
All specified types except `7bit' `8bit' and `quoted-printable' are considered
encoded and therefore skipped. See rfc 1521, 2183, ...
If no boundary is given, then entire message is skipped.
(goto-char (point-min))
(let* (boundary mimep
(ispell-skip-region-alist-save ispell-skip-region-alist)
- ;; Nil when message came from outside (eg calling emacs as editor)
+ ;; Nil when message came from outside (eg calling Emacs as editor)
;; Non-nil marker of end of headers.
(internal-messagep
(re-search-forward
(cite-regexp ;Prefix of quoted text
(cond
((functionp 'sc-cite-regexp) ; sc 3.0
- (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
- (with-no-warnings
- (ispell-non-empty-string sc-reference-tag-string))))
+ (with-no-warnings
+ (concat "\\(" (sc-cite-regexp) "\\)" "\\|"
+ (ispell-non-empty-string sc-reference-tag-string))))
((boundp 'sc-cite-regexp) ; sc 2.3
(concat "\\(" sc-cite-regexp "\\)" "\\|"
(with-no-warnings
(goto-char (point-min))
;; Select type or skip checking if this is a non-multipart message
;; Point moved to end of buffer if region is encoded.
- (if (and mimep (not boundary))
- (let (skip-regexp) ; protect from `ispell-mime-skip-part'
+ (when (and mimep (not boundary))
(goto-char (point-min))
(re-search-forward "Content-[^ \t]*:" end-of-headers t)
(forward-line -1) ; following fn starts one line above
(ispell-mime-skip-part nil)
;; if message-text-end region, limit may be less than point.
(if (> (point) limit)
- (set-marker limit (point)))))
+ (set-marker limit (point))))
(goto-char (max end-of-headers (point)))
(forward-line 1)
(setq case-fold-search old-case-fold-search)
(goto-char (point-max))
;; Uses last occurrence of ispell-parsing-keyword
(if (search-backward ispell-parsing-keyword nil t)
- (let ((end (save-excursion (end-of-line) (point)))
+ (let ((end (point-at-eol))
string)
(search-forward ispell-parsing-keyword)
(while (re-search-forward " *\\([^ \"]+\\)" end t)
(sit-for 2))))))))
-;;; Can kill the current ispell process
+;; Can kill the current ispell process
(defun ispell-buffer-local-dict (&optional no-reload)
"Initializes local dictionary and local personal dictionary.
(if (search-backward ispell-dictionary-keyword nil t)
(progn
(search-forward ispell-dictionary-keyword)
- (setq end (save-excursion (end-of-line) (point)))
+ (setq end (point-at-eol))
(if (re-search-forward " *\\([^ \"]+\\)" end t)
(setq ispell-local-dictionary
(match-string-no-properties 1))))))
(if (search-backward ispell-pdict-keyword nil t)
(progn
(search-forward ispell-pdict-keyword)
- (setq end (save-excursion (end-of-line) (point)))
+ (setq end (point-at-eol))
(if (re-search-forward " *\\([^ \"]+\\)" end t)
(setq ispell-local-pdict
(match-string-no-properties 1)))))))
(defun ispell-buffer-local-words ()
- "Loads the buffer-local dictionary in the current buffer."
+ "Load the buffer-local dictionary in the current buffer."
;; If there's an existing ispell process that's wrong for this use,
;; kill it.
(if (and ispell-buffer-local-name
(while (search-forward ispell-words-keyword nil t)
(or ispell-buffer-local-name
(setq ispell-buffer-local-name (buffer-name)))
- (let ((end (save-excursion (end-of-line) (point)))
+ (let ((end (point-at-eol))
(ispell-casechars (ispell-get-casechars))
string)
;; buffer-local words separated by a space, and can contain
(while (re-search-forward " *\\([^ ]+\\)" end t)
(setq string (match-string-no-properties 1))
;; This can fail when string contains a word with invalid chars.
- ;; Error handling needs to be added between ispell and emacs.
+ ;; Error handling needs to be added between ispell and Emacs.
(if (and (< 1 (length string))
(equal 0 (string-match ispell-casechars string)))
(ispell-send-string (concat "@" string "\n"))))))))
;;; returns optionally adjusted region-end-point.
+;; If comment-padright is defined, newcomment must be loaded.
+(declare-function comment-add "newcomment" (arg))
+
(defun ispell-add-per-file-word-list (word)
"Add WORD to the per-file word list."
(or ispell-buffer-local-name
(setq ispell-buffer-local-name (buffer-name)))
(save-excursion
(goto-char (point-min))
- (let ((old-case-fold-search case-fold-search)
- line-okay search done found)
+ (let (line-okay search done found)
(while (not done)
- (setq case-fold-search nil
- search (search-forward ispell-words-keyword nil 'move)
+ (let ((case-fold-search nil))
+ (setq search (search-forward ispell-words-keyword nil 'move)
found (or found search)
line-okay (< (+ (length word) 1 ; 1 for space after word..
(progn (end-of-line) (current-column)))
- 80)
- case-fold-search old-case-fold-search)
+ fill-column)))
(if (or (and search line-okay)
(null search))
(progn
(progn
(open-line 1)
(unless found (newline))
- (insert (concat comment-start " " ispell-words-keyword))
- (if (> (length comment-end) 0)
+ (insert (if comment-start
+ (concat
+ (if (fboundp 'comment-padright)
+ ;; Try and use the proper comment marker,
+ ;; e.g. ";;" rather than ";".
+ (comment-padright comment-start
+ (comment-add nil))
+ comment-start)
+ " ")
+ "")
+ ispell-words-keyword)
+ (if (and comment-end (> (length comment-end) 0))
(save-excursion
(newline)
(insert comment-end)))))
\f
;;; LOCAL VARIABLES AND BUFFER-LOCAL VALUE EXAMPLES.
-;;; Local Variable options:
-;;; mode: name(-mode)
-;;; eval: expression
-;;; local-variable: value
+;; Local Variable options:
+;; mode: name(-mode)
+;; eval: expression
+;; local-variable: value
-;;; The following sets the buffer local dictionary to `american' English
-;;; and spell checks only comments.
+;; The following sets the buffer local dictionary to `american' English
+;; and spell checks only comments.
-;;; Local Variables:
-;;; mode: emacs-lisp
-;;; comment-column: 40
-;;; ispell-check-comments: exclusive
-;;; ispell-local-dictionary: "american"
-;;; End:
+;; Local Variables:
+;; mode: emacs-lisp
+;; comment-column: 40
+;; ispell-check-comments: exclusive
+;; ispell-local-dictionary: "american"
+;; End:
;;; MORE EXAMPLES OF ISPELL BUFFER-LOCAL VALUES
-;;; The following places this file in nroff parsing and extended char modes.
-;;; Local IspellParsing: nroff-mode ~nroff
-;;; Change IspellPersDict to IspellPersDict: to enable the following line.
-;;; Local IspellPersDict ~/.ispell_lisp
-;;; The following were automatically generated by ispell using the 'A' command:
+;; The following places this file in nroff parsing and extended char modes.
+;; Local IspellParsing: nroff-mode ~nroff
+;; Change IspellPersDict to IspellPersDict: to enable the following line.
+;; Local IspellPersDict ~/.ispell_lisp
+;; The following were automatically generated by ispell using the 'A' command:
; LocalWords: settable alist inews mh frag pdict Wildcards iconify arg tex kss
; LocalWords: alists minibuffer bufferp autoload loaddefs aff Dansk KOI SPC op
; LocalWords: Francais Nederlands charset autoloaded popup nonmenu regexp num
; LocalWords: uuencoded unidiff sc nn VM SGML eval IspellPersDict unsplitable
; LocalWords: lns XEmacs HTML casechars Multibyte
-;;; arch-tag: 4941b9f9-3b7c-4a76-a4ed-5fa8b6010ef5
;;; ispell.el ends here