aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-06-26 01:27:40 +0000
committerRichard M. Stallman1998-06-26 01:27:40 +0000
commit1d8a80f0bdf75ef9665fcf8cd409db17d7ee9ad5 (patch)
tree5b380b6ff15776ae9a5ab33e2baaeec1d7907dbe
parent60371a2e3d30618c3f65a5d1c83a9e4c99ee95a2 (diff)
downloademacs-1d8a80f0bdf75ef9665fcf8cd409db17d7ee9ad5.tar.gz
emacs-1d8a80f0bdf75ef9665fcf8cd409db17d7ee9ad5.zip
Delete defcustom definition.
(flyspell-auto-correct-binding): Fix custom type. (mail-mode-flyspell-verify): Check for `Subject:'. (flyspell-mouse-map): Use cond, not if. (flyspell-region): Update message only every 100 actions.
-rw-r--r--lisp/textmodes/flyspell.el175
1 files changed, 31 insertions, 144 deletions
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 29c7a8089dd..950d688791b 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -3,10 +3,7 @@
3;; Copyright (C) 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1998 Free Software Foundation, Inc.
4 4
5;; Author: Manuel Serrano <Manuel.Serrano@unice.fr> 5;; Author: Manuel Serrano <Manuel.Serrano@unice.fr>
6;; version 1.2h 6;; Keywords: convenience
7;; new version may be found at:
8;;
9;; http://kaolin.unice.fr/~serrano
10 7
11;;; This file is part of GNU Emacs. 8;;; This file is part of GNU Emacs.
12 9
@@ -28,12 +25,7 @@
28;;; commentary: 25;;; commentary:
29;; 26;;
30;; Flyspell is a minor Emacs mode performing on-the-fly spelling 27;; Flyspell is a minor Emacs mode performing on-the-fly spelling
31;; checking. It requires `font-lock' and `ispell'. It has been 28;; checking.
32;; tested on gnu-emacs 19.29, 19.34 and Xemacs 19.15.
33;;
34;; To install it, copy the flyspell.el file in your Emacs path and
35;; add to your .emacs file:
36;; `(autoload 'flyspell-mode "flyspell" "On-the-fly Ispell." t)'
37;; 29;;
38;; To enter the flyspell minor mode, Meta-x flyspell-mode. 30;; To enter the flyspell minor mode, Meta-x flyspell-mode.
39;; 31;;
@@ -44,130 +36,14 @@
44;; Some user variables control the behavior of flyspell. They are 36;; Some user variables control the behavior of flyspell. They are
45;; those defined under the `User variables' comment. 37;; those defined under the `User variables' comment.
46;; 38;;
47;; Note: as suggested by Yaron M. Minsky, if you use flyspell when 39;; Note: as suggested by Yaron M. Minsky, if you use flyspell when
48;; sending mails, you should add the following: 40;; sending mails, you should add the following:
49;; (add-hook 'mail-send-hook 'flyspell-mode-off) 41;; (add-hook 'mail-send-hook 'flyspell-mode-off)
50;; -------------------------------------------------------------
51;; Release 1.2h:
52;; - Fix a bug on mouse-2 (yank-at-click) for gnu-emacs.
53;; Release 1.2g:
54;; - Support for flyspell-generic-check-word-p (has suggested
55;; by Eric M. Ludlam).
56;; - Compliance to emacs-lisp comments.
57;; Release 1.2f:
58;; - Improved TeX handling.
59;; - Improved word fetch implementation.
60;; - flyspell-sort-corrections was not used inside
61;; flyspell-auto-correct-word. The consequence was that auto
62;; corrections where not sorted even if the variable was set
63;; to non-nil.
64;; - Support for flyspell-multi-language-p variable. Setting
65;; this variable to nil will prevent flyspell to spawn a new
66;; Ispell process per buffer.
67;; Release 1.2e:
68;; - Fix two popup bugs on Xemacs. If no replacement words are
69;; proposed only the save option is available. Corrected words
70;; were not inserted at the correct position in the buffer.
71;; - Addition of flyspell-region and flyspell-buffer.
72;; Release 1.2d:
73;; - Make-face-... expressions are now enclosed in
74;; condition-case expressions.
75;; - Fix bugs when flyspell-auto-correct-binding is set to nil
76;; (thanks to Eli Tziperman).
77;; Release 1.2c:
78;; - Fix the overlay keymap problem for Emacs (it was correctly
79;; working with Xemacs).
80;; - Thanks to Didier Remy, flyspell now uses a cache in order
81;; to improve efficiency and make uses of a pre-command-hook
82;; in order to check a word when living it.
83;; - Remaned flyspell-ignore-command into
84;; flyspell-delay-command.
85;; - Add the flyspell-issue-welcome (as suggested by Joshua
86;; Guttman).
87;; - Ispell process are now killed when the buffer they are
88;; running in is deleted (thanks to Jeff Miller and Roland
89;; Rosenfled).
90;; - When used on a B&W terminal flyspell used boldness instead
91;; of color for incorrect words.
92;; Release 1.2:
93;; - Breaks (space or newline) inside incorrect words are now
94;; better handled.
95;; - Flyspell sorts the proposed replacement words (thanks to
96;; Carsten Dominik). See new variable
97;; `flyspell-sort-corrections'.
98;; - The mouse binding to correct mispelled word is now mouse-2
99;; on an highlighted region. This enhancement (as well as a
100;; lot of code cleaning) has been acheived by Carsten Dominik.
101;; - flyspell-mode arg is now optional.
102;; - flyspell bindings are better displayed.
103;; - flyspell nows is able to handle concurent and different
104;; dictionaries (that each buffer running flyspell uses its
105;; own (buffer local) Ispell process).
106;; - default value for flyspell-highlight-property has been
107;; turned to t.
108;; - flyspell popup menus now support session and buffer
109;; dictionaries.
110;; - corrected words are now correctly unhighlighted (no
111;; highlighted characters left).
112;; Note: I think emacs-19.34 has a bug on the overlay event
113;; handling. When an overlay (or a text property) has uses a
114;; local-map, if this map does not include a key binding,
115;; instead of looking at the enclosing local-map emacs-19.34
116;; uses the global-map. I have not tested this with emacs-20.
117;; I have checked with Xemacs that does contain this error.
118;; Release 1.1:
119;; - Add an automatic replacement for incorrect word.
120;; Release 1.0:
121;; - Add popup menu for fast correction.
122;; Release 0.9:
123;; - Add an Ispell bug workaround. Now, in french mode, word
124;; starting by the '-' character does not, any longer, make
125;; Ispell to fall in infinite loops.
126;; Release 0.8:
127;; - Better Xemacs support
128;; Release 0.7:
129;; - Rather than hard-coding the ignored commend I now uses a
130;; property field to check if a command is ignored. The
131;; advantage is that user may now add its own ignored
132;; commands.
133;; Release 0.6:
134;; - Fix flyspell mode name (in modeline bar) bug.
135;; - Fix the bug on flyspell quitting. Overlays are now really
136;; removed.
137;; Release 0.5:
138;; - Persistent hilightings.
139;; - Refresh of the modeline on flyspell ending
140;; - Do not hilight text with properties (e.g. font lock text)
141 42
142;;; Code: 43;;; Code:
143(require 'font-lock) 44(require 'font-lock)
144(require 'ispell) 45(require 'ispell)
145 46
146;*---------------------------------------------------------------------*/
147;* defcustom stuff. This ensure that we have the correct custom */
148;* library. */
149;*---------------------------------------------------------------------*/
150(eval-and-compile
151 (condition-case () (require 'custom) (error nil))
152 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
153 ;; We have got what we need
154 (if (not (string-match "XEmacs" emacs-version))
155 ;; suppress warnings
156 (progn
157 ;; This is part of bytecomp.el in 19.35:
158 (put 'custom-declare-variable 'byte-hunk-handler
159 'byte-compile-file-form-custom-declare-variable)
160 (defun byte-compile-file-form-custom-declare-variable (form)
161 (if (memq 'free-vars byte-compile-warnings)
162 (setq byte-compile-bound-variables
163 (cons (nth 1 (nth 1 form))
164 byte-compile-bound-variables)))
165 form)))
166 ;; We have the old custom-library, hack around it!
167 (defmacro defgroup (&rest args) nil)
168 (defmacro defcustom (var value doc &rest args)
169 (` (defvar (, var) (, value) (, doc))))))
170
171(defgroup flyspell nil 47(defgroup flyspell nil
172 "Spellchecking on the fly." 48 "Spellchecking on the fly."
173 :tag "FlySpell" 49 :tag "FlySpell"
@@ -212,7 +88,7 @@
212 "*Non-nil means that its value (a binding) will bound to the flyspell 88 "*Non-nil means that its value (a binding) will bound to the flyspell
213auto-correct." 89auto-correct."
214 :group 'flyspell 90 :group 'flyspell
215 :type '(choice (const nil string))) 91 :type '(choice (const nil) string))
216 92
217(defcustom flyspell-command-hook t 93(defcustom flyspell-command-hook t
218 "*Non-nil means that `post-command-hook' is used to check 94 "*Non-nil means that `post-command-hook' is used to check
@@ -302,11 +178,14 @@ Returns t to continue checking, nil otherwise.")
302(defun mail-mode-flyspell-verify () 178(defun mail-mode-flyspell-verify ()
303 "Return t if we want flyspell to check the word under point." 179 "Return t if we want flyspell to check the word under point."
304 (save-excursion 180 (save-excursion
305 (not (or (re-search-forward mail-header-separator nil t) 181 (or (progn
306 (re-search-backward message-signature-separator nil t) 182 (beginning-of-line)
307 (progn 183 (looking-at "Subject:"))
308 (beginning-of-line) 184 (not (or (re-search-forward mail-header-separator nil t)
309 (looking-at "[>}|]")))))) 185 (re-search-backward message-signature-separator nil t)
186 (progn
187 (beginning-of-line)
188 (looking-at "[>}|]")))))))
310 189
311(defun texinfo-mode-flyspell-verify () 190(defun texinfo-mode-flyspell-verify ()
312 "Return t if we want flyspell to check the word under point." 191 "Return t if we want flyspell to check the word under point."
@@ -402,11 +281,13 @@ to be a symbol."
402 (define-key flyspell-mode-map flyspell-auto-correct-binding 281 (define-key flyspell-mode-map flyspell-auto-correct-binding
403 (function flyspell-auto-correct-word))) 282 (function flyspell-auto-correct-word)))
404;; mouse bindings 283;; mouse bindings
405(if (eq flyspell-emacs 'xemacs) 284(cond
406 (define-key flyspell-mouse-map [(button2)] 285 ((eq flyspell-emacs 'xemacs)
407 (function flyspell-correct-word/mouse-keymap)) 286 (define-key flyspell-mouse-map [(button2)]
287 (function flyspell-correct-word/mouse-keymap)))
288 (t
408 (define-key flyspell-mode-map [(mouse-2)] 289 (define-key flyspell-mode-map [(mouse-2)]
409 (function flyspell-correct-word/local-keymap))) 290 (function flyspell-correct-word/local-keymap))))
410 291
411;; the name of the overlay property that defines the keymap 292;; the name of the overlay property that defines the keymap
412(defvar flyspell-overlay-keymap-property-name 293(defvar flyspell-overlay-keymap-property-name
@@ -941,13 +822,19 @@ Word syntax described by `ispell-dictionary-alist' (which see)."
941 (interactive "r") 822 (interactive "r")
942 (save-excursion 823 (save-excursion
943 (goto-char beg) 824 (goto-char beg)
944 (while (< (point) end) 825 (let ((count 0))
945 (message "Spell Checking...%d%%" (* 100 (/ (float (point)) (- end beg)))) 826 (while (< (point) end)
946 (flyspell-word) 827 (if (= count 100)
947 (let ((cur (point))) 828 (progn
948 (forward-word 1) 829 (message "Spell Checking...%d%%"
949 (if (and (< (point) end) (> (point) (+ cur 1))) 830 (* 100 (/ (float (point)) (- end beg))))
950 (backward-char 1)))) 831 (setq count 0))
832 (setq count (+ 1 count)))
833 (flyspell-word)
834 (let ((cur (point)))
835 (forward-word 1)
836 (if (and (< (point) end) (> (point) (+ cur 1)))
837 (backward-char 1)))))
951 (backward-char 1) 838 (backward-char 1)
952 (message "Spell Checking...done") 839 (message "Spell Checking...done")
953 (flyspell-word))) 840 (flyspell-word)))