Mercurial > emacs
changeset 24701:04e6bb1f69e1
(ispell-local-dictionary-alist): New variable for
customizing local dictionaries not accessable by everyone.
(ispell-dictionary-alist): Loads `ispell-local-dictionary-alist'.
(ispell-required-version): Changed format `(major minor
revision)' to support general pattern matching.
(ispell-tex-skip-alists): AMS Tex block comment and `\author'
skip region commented out due to incorrect skip potential in std latex.
(ispell-word): Removed `when' macro. Fixed bug of not restoring
cursor point on small words for calls from `ispell-minor-mode'.
(check-ispell-version): Tests and accepts versions major.minor
and above, with adjustments for interactions in 3.1.0-3.1.11.
(ispell-get-line): No longer skips ispell process special characters.
(ispell-comments-and-strings): Removed `when' macro call.
(ispell-minor-check): Requires ispell-word to restore cursor point.
(ispell-buffer-local-parsing): Supports checking comments only.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sun, 09 May 1999 06:34:35 +0000 |
parents | 00ced60fa6df |
children | 95815bc1f83b |
files | lisp/textmodes/ispell.el |
diffstat | 1 files changed, 143 insertions(+), 87 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/textmodes/ispell.el Sun May 09 00:44:50 1999 +0000 +++ b/lisp/textmodes/ispell.el Sun May 09 06:34:35 1999 +0000 @@ -1,10 +1,10 @@ ;;; ispell.el --- Interface to International Ispell Version 3.1 -;; Copyright (C) 1994, 1995, 1997, 1998 Free Software Foundation, Inc. +;; Copyright (C) 1994, 1995, 1997, 1998, 1999 Free Software Foundation, Inc. ;; Authors : Ken Stevens <k.stevens@ieee.org> -;; Stevens Mod Date: Mon Nov 30 20:32:48 PST 1998 -;; Stevens Revision: 3.1 +;; Stevens Mod Date: Fri May 7 14:25:14 PDT 1999 +;; Stevens Revision: 3.2 ;; Status : Release with 3.1.12+ ispell. ;; Bug Reports : ispell-el-bugs@itcorp.com ;; Web Site : http://kdstevens.com/~stevens/ispell-page.html @@ -33,22 +33,24 @@ ;; INSTRUCTIONS -;; This code contains a section of user-settable variables that you should -;; inspect prior to installation. Look past the end of the history list. -;; Set them up for your locale and the preferences of the majority of the -;; users. Otherwise the users may need to set a number of variables +;; This code contains a section of user-settable variables that you +;; should inspect prior to installation. Look past the end of the history +;; list. Set them up for your locale and the preferences of the majority +;; of the users. Otherwise the users may need to set a number of variables ;; themselves. -;; You particularly may want to change the default dictionary for your +;; You particularly may want to change the default dictionary for your ;; country and language. +;; Most dictionary changes should be made in this file so all users can +;; enjoy them. Local or modified dictionaries are supported in your .emacs +;; file. Modify the variable `ispell-local-dictionary-alist' to include +;; these dictionaries, and they will be installed when ispell.el is loaded. ;; Depending on the mail system you use, you may want to include these: - ;; (add-hook 'news-inews-hook 'ispell-message) ;; (add-hook 'mail-send-hook 'ispell-message) ;; (add-hook 'mh-before-send-letter-hook 'ispell-message) - -;; Ispell has a TeX parser and a nroff parser (the default). +;; Ispell has a TeX parser and a nroff parser (the default). ;; The parsing is controlled by the variable ispell-parser. Currently ;; it is just a "toggle" between TeX and nroff, but if more parsers are ;; added it will be updated. See the variable description for more info. @@ -112,16 +114,41 @@ ;; `ispell-message' contains some custom skipping code for e-mail messages. ;; BUGS: -;; Accepting definitions in latex mode can mess up math mode skipping... +;; Accepting word definitions in latex mode can mess up math mode skipping. ;; On some versions of emacs, growing the minibuffer fails. -;; Autoloading ispell can result in problems if you need to use a local or -;; modified dictionary. Place the following in your .emacs file to -;; override the autoload definitions: -;; (setq ispell-dictionary-alist (cons '(dictionary ...) -;; ispell-dictionary-alist)) -;; (setq ispell-menu-map nil) -;; (setq ispell-dictionary-alist-override t) -;; (load-library "ispell") +;; see `ispell-help-in-bufferp'. + +;; HISTORY + +;; Modifications made in latest versions: + +;; Revision 3.2 1999/5/7 14:25:14 kss +;; Accept ispell versions 3.X.Y where X>=1 +;; fine tuned latex region skipping. Fixed bug in ispell-word that did not +;; point in right place on words < 2 chars. Simplified ispell-minor-mode. +;; Fixed bug in TeX parsing when math commands are in the comments. +;; Removed calls to `when' macro. + +;; Revision 3.1 1998/12/1 13:21:52 kss +;; Improved and fixed customize support. +;; Improved and fixed comments in variables and messages. +;; A coding system is now required for all languages. +;; casechars improved for castellano, castellano8, and norsk dictionaries. +;; Dictionary norsk7-tex removed. Dictionary polish added. +;; Dictionaries redefined at load-time to support dictionary changes. +;; Menu redefined at load time to support dictionary changes. +;; ispell-check-version added as an alias for `check-ispell-version'. +;; Spelling suggestions returned in order generated by ispell. +;; Small bug fixed in matching ispell error messages. +;; Robustness added to ensure `case-fold-search' doesn't get redefined. +;; Fixed bug that didn't respect case of word in `ispell-complete-word'. +;; Multibyte character coding support added for process interactions. +;; Ensure ispell process has terminated before starting new process. +;; This can otherwise confuse process filters and hang ispell. +;; Improved skipping support for sgml. +;; Fixed bug using ^M rather than \r in `ispell-minor-check'. +;; Improved message reference matching in `ispell-message'. +;; Fixed bug in returning to nroff mode from tex mode. ;;; Code: @@ -147,8 +174,7 @@ ;;; ********************************************************************** -;;; ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1 -;;; Code: +;;; ******* THIS FILE IS WRITTEN FOR ISPELL VERSION 3.1+ (defcustom ispell-highlight-p 'block "*Highlight spelling errors when non-nil. @@ -370,6 +396,31 @@ :type '(repeat string) :group 'ispell) + +;; Define definitions here only for personal dictionaries. +(defcustom ispell-local-dictionary-alist nil + "*Contains local or customized dictionary definitions. +See `ispell-dictionary-alist'." + :type '(repeat (list (choice :tag "Dictionary" + (string :tag "Dictionary name") + (const :tag "default" nil)) + (regexp :tag "Case characters") + (regexp :tag "Non case characters") + (regexp :tag "Other characters") + (boolean :tag "Many other characters") + (repeat :tag "Ispell command line args" + (string :tag "Arg")) + (choice :tag "Extended character mode" + (const "~tex") (const "~plaintex") + (const "~nroff") (const "~list") + (const "~latin1") (const "~latin3") + (const :tag "default" nil)) + (choice :tag "Character set" + (const iso-8859-1) + (const iso-8859-2)))) + :group 'ispell) + + ;;; split dictionary so line length is smaller in loaddefs.el ;;; First part of dictionary, shortened for loaddefs.el @@ -378,7 +429,7 @@ ispell-dictionary-alist-1 '((nil ; default (English.aff) "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1) - ("american" ; yankee English + ("american" ; Yankee English "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil iso-8859-1) ("british" ; British version "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "british") nil iso-8859-1) @@ -471,7 +522,7 @@ ;;;###autoload (setq ispell-dictionary-alist-6 - '(("russian" ; russian.aff (KOI8-R charset) + '(("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]" "[']" t ("-C" "-d" "russian") "~latin1" iso-8859-1) @@ -484,7 +535,8 @@ ;;;###autoload (defcustom ispell-dictionary-alist - (append ispell-dictionary-alist-1 ispell-dictionary-alist-2 + (append ispell-local-dictionary-alist ; dictionary customizations + ispell-dictionary-alist-1 ispell-dictionary-alist-2 ispell-dictionary-alist-3 ispell-dictionary-alist-4 ispell-dictionary-alist-5 ispell-dictionary-alist-6) "An alist of dictionaries and their associated parameters. @@ -552,14 +604,12 @@ (const iso-8859-2)))) :group 'ispell) -(defvar ispell-dictionary-alist-override nil) - ;;; update the dictionaries at load time -(unless ispell-dictionary-alist-override - (setq 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))) +(setq ispell-dictionary-alist + (append ispell-local-dictionary-alist ; dictionary customizations + ispell-dictionary-alist-1 ispell-dictionary-alist-2 + ispell-dictionary-alist-3 ispell-dictionary-alist-4 + ispell-dictionary-alist-5 ispell-dictionary-alist-6)) ;;; The preparation of the menu bar menu must be autoloaded ;;; because otherwise this file gets autoloaded every time Emacs starts @@ -696,7 +746,7 @@ ;;; 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) +(defconst ispell-required-version '(3 1 12) "Ispell versions with which this version of ispell.el is known to work.") (defvar ispell-offset -1 "Offset that maps protocol differences between ispell 3.1 versions.") @@ -810,7 +860,7 @@ ("\\(/\\|\\(\\(\\w\\|-\\)+[.:@]\\)\\)\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+") ;; This is a pretty complex regexp. It can be simplified to the following: ;; "\\(\\w\\|-\\)*\\([.:/@]+\\(\\w\\|-\\|~\\)+\\)+" - ;; but some valid text will be skipped, e.g. "his/herr". This could be + ;; but some valid text will be skipped, e.g. "his/her". This could be ;; fixed up (at the expense of a moderately more complex regexp) ;; by not allowing "/" to be the character which triggers the ;; identification of the computer name, e.g.: @@ -828,14 +878,14 @@ ;;;###autoload (defvar ispell-tex-skip-alists - '((("%\\[" . "%\\]") + '((;;("%\\[" . "%\\]") ; AMStex block comment... ;; All the standard LaTeX keywords from L. Lamport's guide: ;; \cite, \hspace, \hspace*, \hyphenation, \include, \includeonly, \input, ;; \label, \nocite, \rule (in ispell - rest included here) ("\\\\addcontentsline" ispell-tex-arg-end 2) ("\\\\add\\(tocontents\\|vspace\\)" ispell-tex-arg-end) ("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end) - ("\\\\author" ispell-tex-arg-end) + ;;("\\\\author" ispell-tex-arg-end) ("\\\\bibliographystyle" ispell-tex-arg-end) ("\\\\makebox" ispell-tex-arg-end 0) ;;("\\\\epsfig" ispell-tex-arg-end) @@ -950,7 +1000,8 @@ word (car word)) ;; now check spelling of word if it has 3 or more characters. - (when (> (length word) 2) + (cond + ((> (length word) 2) (or quietly (message "Checking spelling of %s..." (funcall ispell-format-word word))) @@ -1003,9 +1054,9 @@ (ispell-region start end))))) (if (get-buffer ispell-choices-buffer) (kill-buffer ispell-choices-buffer)))) - (goto-char cursor-location) ; return to original location (ispell-pdict-save ispell-silently-savep) - (if ispell-quit (setq ispell-quit nil)))))) + (if ispell-quit (setq ispell-quit nil)))) + (goto-char cursor-location)))) ; return to original location (defun ispell-get-word (following &optional extra-otherchars) @@ -1086,7 +1137,7 @@ (if (or ispell-pdict-modified-p force-save) (if (or no-query (y-or-n-p "Personal dictionary modified. Save? ")) (progn - (process-send-string ispell-process "#\n") + (process-send-string ispell-process "#\n") ; save dictionary (message "Personal dictionary saved.")))) ;; unassert variable, even if not saved to avoid questioning. (setq ispell-pdict-modified-p nil)) @@ -1321,7 +1372,7 @@ (ispell-highlight-spelling-error start end nil 'block)) t) ; reselect from new choices - ((= char ?u) + ((= char ?u) ; insert lowercase into dictionary (process-send-string ispell-process (concat "*" (downcase word) "\n")) (setq ispell-pdict-modified-p '(t)) ; dictionary modified! @@ -1675,7 +1726,7 @@ (save-excursion (let ((oldot (save-excursion (forward-line -1) (point))) (top (save-excursion (move-to-window-line height) (point)))) - ;; If line above old point (line starting at olddot) would be + ;; If line above old point (line starting at oldot) would be ;; hidden by new window, scroll it to just below new win ;; otherwise set top line of other win so it doesn't scroll. (if (< oldot top) (setq top oldot)) @@ -1778,18 +1829,25 @@ (setq case-fold-search t status (re-search-forward (concat "\\<\\(" - (regexp-quote (car ispell-required-version)) - "\\)\\([0-9]*\\)\\>") + (format "%d" (car ispell-required-version)) + "\\)\\.\\([0-9]*\\)\\.\\([0-9]*\\)\\>") nil t) case-fold-search case-fold-search-val) - (if (not status) - (error "%s version 3 release %s%s or greater is required" + (if (or (not status) ; major version mismatch + (< (car (read-from-string (buffer-substring-no-properties + (match-beginning 2) (match-end 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 ispell-required-version)) + (car (cdr (cdr ispell-required-version)))) ;; check that it is the correct version. - (if (< (car (read-from-string (buffer-substring-no-properties - (match-beginning 2) (match-end 2)))) - (car (cdr ispell-required-version))) + (if (and (= (car (read-from-string (buffer-substring-no-properties + (match-beginning 2)(match-end 2)))) + (car (cdr ispell-required-version))) + (< (car (read-from-string (buffer-substring-no-properties + (match-beginning 3)(match-end 3)))) + (car (cdr (cdr ispell-required-version))))) (setq ispell-offset 0))) (kill-buffer (current-buffer))) result)) @@ -1870,7 +1928,7 @@ (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 + (if extended-char-mode ; ~ extended character mode (process-send-string ispell-process (concat extended-char-mode "\n")))) (process-kill-without-query ispell-process))) @@ -2178,8 +2236,8 @@ (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS ((eolp) ; END OF LINE, just go to next line. (forward-line)) - ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS - (forward-char 1)) + ;;((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS + ;; (forward-char 1)) ; not needed as quoted below. ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS (re-search-forward "[][()${}]" end t)) ; or MATH COMMANDS (setq string (concat "^" (buffer-substring-no-properties start end) @@ -2327,14 +2385,14 @@ (setq done t) (setq state (parse-partial-sexp (point) (point-max) nil nil state 'syntax-table)) - (when (or (nth 3 state) (nth 4 state)) - (let ((start (point))) - (setq state (parse-partial-sexp start (point-max) - nil nil state 'syntax-table)) - (when (or (nth 3 state) (nth 4 state)) - (error "Unterminated string or comment")) - (save-excursion - (setq done (not (ispell-region start (point)))))))))) + (if (or (nth 3 state) (nth 4 state)) + (let ((start (point))) + (setq state (parse-partial-sexp start (point-max) + nil nil state 'syntax-table)) + (if (or (nth 3 state) (nth 4 state)) + (error "Unterminated string or comment")) + (save-excursion + (setq done (not (ispell-region start (point)))))))))) ;;;###autoload @@ -2493,15 +2551,11 @@ (let ((ispell-minor-mode nil) (ispell-check-only t) (last-char (char-after (1- (point))))) - (if (or (eq last-char ?\ ) (eq last-char ?\n) - (and ispell-skip-sgml (eq last-char ?>)) - (and ispell-skip-sgml (eq last-char ?\;))) - nil - (save-window-excursion - (save-restriction - (narrow-to-region (save-excursion (forward-line -1) (point)) (point)) - (ispell-word nil t)))) - (command-execute (key-binding (this-command-keys))))) + (command-execute (key-binding (this-command-keys))) + (if (not (or (eq last-char ?\ ) (eq last-char ?\n) + (and ispell-skip-sgml (eq last-char ?>)) + (and ispell-skip-sgml (eq last-char ?\;)))) + (ispell-word nil t)))) ;;; ********************************************************************** @@ -2519,7 +2573,7 @@ "^%!PS-Adobe-[123].0" ;; Matches uuencoded text "^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM" - ;; Matches shell files (esp. auto-decoding) + ;; Matches shell files (especially auto-decoding) "^#! /bin/[ck]?sh" ;; Matches context difference listing "\\(\\(^cd .*\n\\)?diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*" @@ -2676,9 +2730,12 @@ ;; (ispell-init-process) must already be called. (process-send-string ispell-process "!\n") ; Put process in terse mode. ;; We assume all major modes with "tex-mode" in them should use latex parsing - (if (or (and (eq ispell-parser 'use-mode-name) - (string-match "[Tt][Ee][Xx]-mode" (symbol-name major-mode))) - (eq ispell-parser 'tex)) + ;; When exclusively checking comments, set to raw text mode (nroff). + (if (and (not (eq 'exclusive ispell-check-comments)) + (or (and (eq ispell-parser 'use-mode-name) + (string-match "[Tt][Ee][Xx]-mode" + (symbol-name major-mode))) + (eq ispell-parser 'tex))) (progn (process-send-string ispell-process "+\n") ; set ispell mode to tex (if (not (eq ispell-parser 'tex)) @@ -2705,7 +2762,8 @@ ;; space separated definitions. (setq string (downcase (buffer-substring-no-properties (match-beginning 1) (match-end 1)))) - (cond ((string-match "latex-mode" string) + (cond ((and (string-match "latex-mode" string) + (not (eq 'exclusive ispell-check-comments))) (process-send-string ispell-process "+\n~tex\n")) ((string-match "nroff-mode" string) (process-send-string ispell-process "-\n~nroff\n")) @@ -2822,7 +2880,7 @@ (insert (concat " " word)))))))) -(defconst ispell-version "ispell.el 3.1 -- Mon Nov 30 20:32:48 PST 1998") +(defconst ispell-version "ispell.el 3.2 -- Fri May 7 14:25:14 PDT 1999") (provide 'ispell) @@ -2834,7 +2892,7 @@ ;;; eval: expression ;;; local-variable: value -;;; The following sets the buffer local dictionary to 'american' English +;;; The following sets the buffer local dictionary to `american' English ;;; and spell checks only comments. ;;; Local Variables: @@ -2852,15 +2910,13 @@ ;;; 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: Moellmann copyleft Dansk russian KOI charset minipage hspace mh -; LocalWords: unsplitable includeonly nocite epsfig displaymath eqnarray init -; LocalWords: settable autoload inews frag pdict alist Wildcards iconify arg -; LocalWords: tex alists minibuffer Autoloading setq changelog kss stevens reg -; LocalWords: Castellano framepop sgml modeline Wedler Dirk Froembgen fn Gerd -; LocalWords: pgp NZST Vignaux autoloaded loaddefs aff Francais Nederlands SPC -; LocalWords: popup nonmenu regexp herr num pers dict unhighlight ccept uit NB -; LocalWords: buf grep sync prev inc hilight olddot AIX ersion msg read's op -; LocalWords: bufs pt multibyte cmd Quinlan uuencoded esp unidiff eg sc -; LocalWords: VM lns HTML eval american IspellPersDict +; 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: AMStex hspace includeonly nocite epsfig displaymath eqnarray reg +; LocalWords: minipage modeline pers dict unhighlight buf grep sync prev inc +; LocalWords: fn hilight oldot NB AIX msg init read's bufs pt cmd Quinlan eg +; LocalWords: uuencoded unidiff sc nn VM SGML eval IspellPersDict unsplitable +; LocalWords: lns ;;; ispell.el ends here