annotate lisp/textmodes/flyspell.el @ 29190:f0d6f1a9c9ae

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Thu, 25 May 2000 15:47:07 +0000
parents d40d47971e6b
children b7b96f09059d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; flyspell.el --- On-the-fly spell checker
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
3 ;; Copyright (C) 1998, 2000 Free Software Foundation, Inc.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Manuel Serrano <Manuel.Serrano@unice.fr>
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
6 ;; Keywords: convenience
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;;; This file is part of GNU Emacs.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; commentary:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; Flyspell is a minor Emacs mode performing on-the-fly spelling
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
28 ;; checking.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;;
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
30 ;; To enable Flyspell minor mode, type Meta-x flyspell-mode.
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
31 ;; This applies only to the current buffer.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;;
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
33 ;; Note: consider setting the variable ispell-parser to `tex' to
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
34 ;; avoid TeX command checking; use `(setq ispell-parser 'tex)'
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; _before_ entering flyspell.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; Some user variables control the behavior of flyspell. They are
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; those defined under the `User variables' comment.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
40 ;; Note: as suggested by Yaron M. Minsky, if you use flyspell when
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; sending mails, you should add the following:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; (add-hook 'mail-send-hook 'flyspell-mode-off)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;;; Code:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (require 'ispell)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
47 ;*---------------------------------------------------------------------*/
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
48 ;* Group ... */
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
49 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (defgroup flyspell nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 "Spellchecking on the fly."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 :tag "FlySpell"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 :prefix "flyspell-"
22648
3b7f1e026beb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 22612
diff changeset
54 :group 'processes
3b7f1e026beb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 22612
diff changeset
55 :version "20.3")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;* User variables ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (defcustom flyspell-highlight-flag t
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
61 "*How Flyspell should indicate misspelled words.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
62 Non-nil means use highlight, nil means use minibuffer messages."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
66 (defcustom flyspell-mark-duplications-flag t
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
67 "*Non-nil means Flyspell reports a repeated word as an error."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (defcustom flyspell-sort-corrections t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 "*Non-nil means, sort the corrections alphabetically before popping them."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
76 (defcustom flyspell-duplicate-distance 10000
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
77 "*The maximum distance for finding duplicates of unrecognized words.
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
78 This applies to the feature that when a word is not found in the dictionary,
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
79 if the same spelling occurs elsewhere in the buffer,
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
80 Flyspell uses a different face (`flyspell-duplicate-face') to highlight it.
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
81 This variable specifies how far to search to find such a duplicate.
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
82 -1 means no limit (search the whole buffer).
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
83 0 means do not search for duplicate unrecognized spellings."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 :type 'number)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (defcustom flyspell-delay 3
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
88 "*The number of seconds to wait before checking, after a \"delayed\" command."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 :type 'number)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (defcustom flyspell-persistent-highlight t
22946
cfde96067373 (flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22891
diff changeset
93 "*Non-nil means misspelled words remain highlighted until corrected.
cfde96067373 (flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22891
diff changeset
94 If this variable is nil, only the most recently detected misspelled word
cfde96067373 (flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22891
diff changeset
95 is highlighted."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (defcustom flyspell-highlight-properties t
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
100 "*Non-nil means highlight incorrect words even if a property exists for this word."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (defcustom flyspell-default-delayed-commands
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 '(self-insert-command
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 delete-backward-char
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 delete-char)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
108 "The standard list of delayed commands for Flyspell.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
109 See `flyspell-delayed-commands'."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 :type '(repeat (symbol)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
113 (defcustom flyspell-delayed-commands nil
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
114 "List of commands that are \"delayed\" for Flyspell mode.
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
115 After these commands, Flyspell checking is delayed for a short time,
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
116 whose length is specified by `flyspell-delay'."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 :type '(repeat (symbol)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (defcustom flyspell-issue-welcome-flag t
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
121 "*Non-nil means that Flyspell should display a welcome message when started."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (defcustom flyspell-consider-dash-as-word-delimiter-flag nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 "*Non-nil means that the `-' char is considered as a word delimiter."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (defcustom flyspell-incorrect-hook nil
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
131 "*List of functions to be called when incorrect words are encountered.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
132 Each function is given two arguments: the beginning and the end
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
133 of the incorrect region."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 :group 'flyspell)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135
23179
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
136 (defcustom flyspell-multi-language-p nil
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
137 "*Non-nil means that Flyspell can be used with multiple languages.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
138 This mode works by starting a separate Ispell process for each buffer,
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
139 so that each buffer can use its own language."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 ;* Mode specific options */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;* Mode specific options enable users to disable flyspell on */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;* certain word depending of the emacs mode. For instance, when */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 ;* using flyspell with mail-mode add the following expression */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 ;* in your .emacs file: */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 ;* (add-hook 'mail-mode */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 ;* '(lambda () (setq flyspell-generic-check-word-p */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152 ;* 'mail-mode-flyspell-verify))) */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 (defvar flyspell-generic-check-word-p nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 "Function providing per-mode customization over which words are flyspelled.
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
156 Returns t to continue checking, nil otherwise.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
157 Flyspell mode sets this variable to whatever is the `flyspell-mode-predicate'
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
158 property of the major mode name.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (make-variable-buffer-local 'flyspell-generic-check-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
161 (put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
162 (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (defun mail-mode-flyspell-verify ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
164 "This function is used for `flyspell-generic-check-word-p' in Mail mode."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (save-excursion
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
166 (or (progn
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
167 (beginning-of-line)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
168 (looking-at "Subject:"))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
169 (not (or (re-search-forward mail-header-separator nil t)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
170 (re-search-backward message-signature-separator nil t)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
171 (progn
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
172 (beginning-of-line)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
173 (looking-at "[>}|]")))))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
175 (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (defun texinfo-mode-flyspell-verify ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
177 "This function is used for `flyspell-generic-check-word-p' in Texinfo mode."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 (forward-word -1)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (not (looking-at "@"))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 ;* Overlay compatibility */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (autoload 'make-overlay "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (autoload 'move-overlay "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (autoload 'overlayp "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (autoload 'overlay-properties "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (autoload 'overlays-in "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 (autoload 'delete-overlay "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 (autoload 'overlays-at "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 (autoload 'overlay-put "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 (autoload 'overlay-get "overlay" "" t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 ;* Which emacs are we currently running */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 (defvar flyspell-emacs
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ((string-match "XEmacs" emacs-version)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 'xemacs)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 'emacs))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
204 "The type of Emacs we are currently running.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
206 (defvar flyspell-use-local-map
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
207 (or (eq flyspell-emacs 'xemacs)
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
208 (not (string< emacs-version "20"))))
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
209
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ;* The minor mode declaration. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 (defvar flyspell-mode nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 (make-variable-buffer-local 'flyspell-mode)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
216 (defvar flyspell-mouse-map
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
217 (let ((map (make-sparse-keymap)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
218 (cond
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
219 ((eq flyspell-emacs 'xemacs)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
220 (define-key map [(button2)]
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
221 #'flyspell-correct-word/mouse-keymap)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
222 (define-key flyspell-mouse-map "\M-\t" #'flyspell-auto-correct-word))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
223 (flyspell-use-local-map
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
224 (define-key map [(mouse-2)] #'flyspell-correct-word/mouse-keymap)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
225 (define-key map "\M-\t" #'flyspell-auto-correct-word)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
226 map))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (defvar flyspell-mode-map (make-sparse-keymap))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (or (assoc 'flyspell-mode minor-mode-alist)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
230 (setq minor-mode-alist
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
231 (cons '(flyspell-mode " Fly") minor-mode-alist)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
233 ;; mouse or local-map bindings
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
234 (when (or (assoc 'flyspell-mode minor-mode-map-alist)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
235 (setq minor-mode-map-alist
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
236 (cons (cons 'flyspell-mode flyspell-mode-map)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
237 minor-mode-map-alist)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
238 (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
239 (define-key flyspell-mode-map [(mouse-2)]
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
240 (function flyspell-correct-word/local-keymap)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 ;; the name of the overlay property that defines the keymap
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (defvar flyspell-overlay-keymap-property-name
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (if (string-match "19.*XEmacs" emacs-version)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 'keymap
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 'local-map))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
247
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 ;* Highlighting */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 ;*---------------------------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
251 (defface flyspell-incorrect-face
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
252 '((((class color)) (:foreground "OrangeRed" :bold t :underline t))
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
253 (t (:bold t)))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
254 "Face used for marking a misspelled word in Flyspell."
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
255 :group 'flyspell)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
256
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
257 (defface flyspell-duplicate-face
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
258 '((((class color)) (:foreground "Gold3" :bold t :underline t))
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
259 (t (:bold t)))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
260 "Face used for marking a misspelled word that appears twice in the buffer.
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
261 See also `flyspell-duplicate-distance'."
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
262 :group 'flyspell)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
263
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (defvar flyspell-overlay nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 ;* flyspell-mode ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 ;;;###autoload
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (defun flyspell-mode (&optional arg)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 "Minor mode performing on-the-fly spelling checking.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 Ispell is automatically spawned on background for each entered words.
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
273 The default flyspell behavior is to highlight incorrect words.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
274 With no argument, this command toggles Flyspell mode.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
275 With a prefix argument ARG, turn Flyspell minor mode on iff ARG is positive.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 Bindings:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 \\[ispell-word]: correct words (using Ispell).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 \\[flyspell-auto-correct-word]: automatically correct word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 \\[flyspell-correct-word] (or mouse-2): popup correct words.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 Hooks:
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
283 flyspell-mode-hook is run after flyspell is entered.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 Remark:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 valid. For instance, a personal dictionary can be used by
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 invoking `ispell-change-dictionary'.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 Consider using the `ispell-parser' to check your text. For instance
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 consider adding:
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
292 \(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 in your .emacs file.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 flyspell-region checks all words inside a region.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 flyspell-buffer checks the whole buffer."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (interactive "P")
23179
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
299 (let ((old-flyspell-mode flyspell-mode))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
300 ;; Mark the mode as on or off.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
301 (setq flyspell-mode (not (or (and (null arg) flyspell-mode)
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
302 (<= (prefix-numeric-value arg) 0))))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
303 ;; Do the real work.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
304 (unless (eq flyspell-mode old-flyspell-mode)
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
305 (if flyspell-mode
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
306 (flyspell-mode-on)
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
307 (flyspell-mode-off))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
308 ;; Force modeline redisplay.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
309 (set-buffer-modified-p (buffer-modified-p)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 ;* flyspell-mode-on ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 ;*---------------------------------------------------------------------*/
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
314 (eval-when-compile (defvar flyspell-local-mouse-map))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
315
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 (defun flyspell-mode-on ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
317 "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (setq ispell-highlight-face 'flyspell-incorrect-face)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 ;; ispell initialization
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (if flyspell-multi-language-p
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 (make-variable-buffer-local 'ispell-dictionary)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (make-variable-buffer-local 'ispell-process)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (make-variable-buffer-local 'ispell-filter)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 (make-variable-buffer-local 'ispell-filter-continue)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (make-variable-buffer-local 'ispell-process-directory)
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
327 (make-variable-buffer-local 'ispell-parser)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
328 (put 'ispell-dictionary 'permanent-local t)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
329 (put 'ispell-process 'permanent-local t)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
330 (put 'ispell-filter 'permanent-local t)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
331 (put 'ispell-filter-continue 'permanent-local t)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
332 (put 'ispell-process-directory 'permanent-local t)
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
333 (put 'ispell-parser 'permanent-local t)))
23788
764497f1c6a0 (flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents: 23234
diff changeset
334 ;; We put the `flyspell-delayed' property on some commands.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (flyspell-delay-commands)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;; we bound flyspell action to post-command hook
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
337 (make-local-hook 'post-command-hook)
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
338 (add-hook 'post-command-hook (function flyspell-post-command-hook) t t)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 ;; we bound flyspell action to pre-command hook
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
340 (make-local-hook 'pre-command-hook)
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
341 (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
342
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
343 ;; Set flyspell-generic-check-word-p based on the major mode.
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
344 (let ((mode-predicate (get major-mode 'flyspell-mode-predicate)))
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
345 (if mode-predicate
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
346 (setq flyspell-generic-check-word-p mode-predicate)))
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
347
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
348 ;; the welcome message
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
349 (if flyspell-issue-welcome-flag
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
350 (let ((binding (where-is-internal 'flyspell-auto-correct-word
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
351 nil 'non-ascii)))
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
352 (message
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
353 (if binding
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
354 (format "Welcome to flyspell. Use %s or Mouse-2 to correct words."
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
355 (key-description binding))
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
356 "Welcome to flyspell. Use Mouse-2 to correct words."))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
357 ;; we have to kill the flyspell process when the buffer is deleted.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
358 ;; (thanks to Jeff Miller and Roland Rosenfeld who sent me this
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
359 ;; improvement).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
360 (add-hook 'kill-buffer-hook
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
361 (lambda ()
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
362 (if (and flyspell-multi-language-p ispell-process)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
363 (ispell-kill-ispell t))))
24458
1544b0109c3b (flyspell-mode-on): Use
Karl Heuer <kwzh@gnu.org>
parents: 24076
diff changeset
364 (make-local-hook 'change-major-mode-hook)
1544b0109c3b (flyspell-mode-on): Use
Karl Heuer <kwzh@gnu.org>
parents: 24076
diff changeset
365 (add-hook 'change-major-mode-hook 'flyspell-mode-off)
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
366 ;; Use this so that we can still get major mode bindings at a
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
367 ;; misspelled word (unless they're overridden by
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
368 ;; `flyspell-mouse-map').
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
369 (set (make-local-variable 'flyspell-local-mouse-map)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
370 (let ((map (copy-keymap flyspell-mouse-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
371 (if (eq flyspell-emacs 'xemacs)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
372 (set-keymap-parents (list (current-local-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
373 (set-keymap-parent map (current-local-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
374 map))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
375 ;; we end with the flyspell hooks
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
376 (run-hooks 'flyspell-mode-hook))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
377
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
378 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 ;* flyspell-delay-commands ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 (defun flyspell-delay-commands ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
382 "Install the standard set of Flyspell delayed commands."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 (mapcar 'flyspell-delay-command flyspell-default-delayed-commands)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (mapcar 'flyspell-delay-command flyspell-delayed-commands))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 ;* flyspell-delay-command ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (defun flyspell-delay-command (command)
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
390 "Set COMMAND to be delayed, for Flyspell.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 When flyspell `post-command-hook' is invoked because a delayed command
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 as been used the current word is not immediatly checked.
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
393 It will be checked only after `flyspell-delay' seconds."
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
394 (interactive "SDelay Flyspell after Command: ")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (put command 'flyspell-delayed t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 ;* flyspell-ignore-commands ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (defun flyspell-ignore-commands ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
401 "This is an obsolete function, use `flyspell-delay-commands' instead."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 (flyspell-delay-commands))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 ;* flyspell-ignore-command ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (defun flyspell-ignore-command (command)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
408 "This is an obsolete function, use `flyspell-delay-command' instead.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 COMMAND is the name of the command to be delayed."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 (flyspell-delay-command command))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 (make-obsolete 'flyspell-ignore-commands 'flyspell-delay-commands)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (make-obsolete 'flyspell-ignore-command 'flyspell-delay-command)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ;* flyspell-word-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 (defvar flyspell-word-cache-start nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (defvar flyspell-word-cache-end nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 (defvar flyspell-word-cache-word nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (make-variable-buffer-local 'flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 (make-variable-buffer-local 'flyspell-word-cache-end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 (make-variable-buffer-local 'flyspell-word-cache-word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 ;* The flyspell pre-hook, store the current position. In the */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 ;* post command hook, we will check, if the word at this position */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 ;* has to be spell checked. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (defvar flyspell-pre-buffer nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (defvar flyspell-pre-point nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
433 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 ;* flyspell-pre-command-hook ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
436 (defun flyspell-pre-command-hook ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
437 "Save the current buffer and point for Flyspell's post-command hook."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 (interactive)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439 (setq flyspell-pre-buffer (current-buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
440 (setq flyspell-pre-point (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
441
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
442 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443 ;* flyspell-mode-off ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;*---------------------------------------------------------------------*/
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
445 ;;;###autoload
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
446 (defun flyspell-mode-off ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
447 "Turn Flyspell mode off."
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
448 ;; If we have an Ispell process for each buffer,
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
449 ;; kill the one for this buffer.
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
450 (if flyspell-multi-language-p
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
451 (ispell-kill-ispell t))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
452 ;; we remove the hooks
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
453 (remove-hook 'post-command-hook (function flyspell-post-command-hook) t)
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
454 (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
455 ;; we remove all the flyspell hilightings
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
456 (flyspell-delete-all-overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
457 ;; we have to erase pre cache variables
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
458 (setq flyspell-pre-buffer nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
459 (setq flyspell-pre-point nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
460 ;; we mark the mode as killed
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
461 (setq flyspell-mode nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
462
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
463 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
464 ;* flyspell-check-word-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
465 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
466 (defun flyspell-check-word-p ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
467 "Return t when the word at `point' has to be checked.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
468 The answer depends of several criteria.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
469 Mostly we check word delimiters."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
470 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
471 ((<= (- (point-max) 1) (point-min))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
472 ;; the buffer is not filled enough
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
473 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474 ((not (and (symbolp this-command) (get this-command 'flyspell-delayed)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 ;; the current command is not delayed, that
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 ;; is that we must check the word now
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 ((and (> (point) (point-min))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (backward-char 1)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (and (looking-at (flyspell-get-not-casechars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 (or flyspell-consider-dash-as-word-delimiter-flag
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (not (looking-at "\\-"))))))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
484 ;; yes because we have reached or typed a word delimiter.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 ((not (integerp flyspell-delay))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
487 ;; yes because the user had set up a no-delay configuration.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 t)
23788
764497f1c6a0 (flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents: 23234
diff changeset
489 (executing-kbd-macro
764497f1c6a0 (flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents: 23234
diff changeset
490 ;; Don't delay inside a keyboard macro.
764497f1c6a0 (flyspell-check-word-p): Don't delay inside a kbd macro.
Richard M. Stallman <rms@gnu.org>
parents: 23234
diff changeset
491 t)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493 (if (fboundp 'about-xemacs)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (sit-for flyspell-delay nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (sit-for flyspell-delay 0 nil)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 ;* flyspell-check-pre-word-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (defun flyspell-check-pre-word-p ()
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
501 "Return non-nil if we should to check the word before point.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
502 More precisely, it applies to the word that was before point
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
503 before the current command."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 ((or (not (numberp flyspell-pre-point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (not (bufferp flyspell-pre-buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (not (buffer-live-p flyspell-pre-buffer)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 nil)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
509 ((or (and (= flyspell-pre-point (- (point) 1))
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
510 (eq (char-syntax (char-after flyspell-pre-point)) ?w))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (= flyspell-pre-point (point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (= flyspell-pre-point (+ (point) 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 ((not (eq (current-buffer) flyspell-pre-buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 ((not (and (numberp flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 (numberp flyspell-word-cache-end)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 (or (< flyspell-pre-point flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (> flyspell-pre-point flyspell-word-cache-end)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 ;* flyspell-post-command-hook ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 (defun flyspell-post-command-hook ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 "The `post-command-hook' used by flyspell to check a word in-the-fly."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (interactive)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (if (flyspell-check-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (flyspell-word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (if (flyspell-check-pre-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (set-buffer flyspell-pre-buffer)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (goto-char flyspell-pre-point)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (flyspell-word)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 ;* flyspell-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 (defun flyspell-word (&optional following)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 "Spell check a word."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (interactive (list current-prefix-arg))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (if (interactive-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545 (setq following ispell-following-word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (ispell-accept-buffer-local-defs) ; use the correct dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 (let ((cursor-location (point)) ; retain cursor location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
549 (word (flyspell-get-word following))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
550 start end poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
551 (if (or (eq word nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
552 (and (fboundp flyspell-generic-check-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
553 (not (funcall flyspell-generic-check-word-p))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
554 t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 ;; destructure return word info list.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 (setq start (car (cdr word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 end (car (cdr (cdr word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 word (car word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 ;; before checking in the directory, we check for doublons.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (cond
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
562 ((and flyspell-mark-duplications-flag
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565 (word-search-backward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 (- start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 (+ 1 (- end start)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 ;; yes, this is a doublon
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (flyspell-highlight-incorrect-region start end))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 ((and (eq flyspell-word-cache-start start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (eq flyspell-word-cache-end end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (string-equal flyspell-word-cache-word word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
574 ;; this word had been already checked, we skip
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576 ((and (eq ispell-parser 'tex)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (flyspell-tex-command-p word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 ;; this is a correct word (because a tex command)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
583 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584 ;; we setup the cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 (setq flyspell-word-cache-start start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
586 (setq flyspell-word-cache-end end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 (setq flyspell-word-cache-word word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
588 ;; now check spelling of word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
589 (process-send-string ispell-process "%\n")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
590 ;; put in verbose mode
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
591 (process-send-string ispell-process
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
592 (concat "^" word "\n"))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
593 ;; we mark the ispell process so it can be killed
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
594 ;; when emacs is exited without query
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
595 (if (fboundp 'process-kill-without-query)
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
596 (process-kill-without-query ispell-process))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 ;; wait until ispell has processed word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 (while (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (accept-process-output ispell-process)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (not (string= "" (car ispell-filter)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 ;; (process-send-string ispell-process "!\n")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 ;; back to terse mode.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (setq ispell-filter (cdr ispell-filter))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (if (listp ispell-filter)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605 (setq poss (ispell-parse-output (car ispell-filter))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 (cond ((eq poss t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ;; correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
611 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
612 ((and (stringp poss) flyspell-highlight-flag)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
613 ;; correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
614 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
615 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
616 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
617 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
618 ((null poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
619 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
620 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
621 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622 (message "Error in ispell process"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 ((or (and (< flyspell-duplicate-distance 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 (or (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (word-search-backward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
627 (point-min)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
628 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
630 (goto-char end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
631 (word-search-forward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632 (point-max)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 t))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (and (> flyspell-duplicate-distance 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 (or (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (word-search-backward
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 (- start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 flyspell-duplicate-distance)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
641 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (goto-char end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 (word-search-forward
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 (+ end
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 flyspell-duplicate-distance)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 t)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 (if flyspell-highlight-flag
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (flyspell-highlight-duplicate-region start end)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
651 (message (format "duplicate `%s'" word))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 ;; incorrect highlight the location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 (if flyspell-highlight-flag
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (flyspell-highlight-incorrect-region start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
656 (message (format "mispelling `%s'" word)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
657 (goto-char cursor-location) ; return to original location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
658 (if ispell-quit (setq ispell-quit nil)))))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 ;* flyspell-tex-command-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (defun flyspell-tex-command-p (word)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
664 "Return t if WORD is a TeX command."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (eq (aref word 0) ?\\))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 ;* flyspell-casechars-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (defvar flyspell-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 (defvar flyspell-ispell-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 (make-variable-buffer-local 'flyspell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (make-variable-buffer-local 'flyspell-ispell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 ;* flyspell-get-casechars ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (defun flyspell-get-casechars ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 "This function builds a string that is the regexp of word chars.
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
680 In order to avoid one useless string construction,
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
681 this function changes the last char of the `ispell-casechars' string."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (let ((ispell-casechars (ispell-get-casechars)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ((eq ispell-casechars flyspell-ispell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 flyspell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 ((not (eq ispell-parser 'tex))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (setq flyspell-ispell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (setq flyspell-casechars-cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (concat (substring ispell-casechars
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 0
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 (- (length ispell-casechars) 1))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 "{}]"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 flyspell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (setq flyspell-ispell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 (setq flyspell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 flyspell-casechars-cache))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 ;* flyspell-get-not-casechars-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (defvar flyspell-not-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 (defvar flyspell-ispell-not-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (make-variable-buffer-local 'flyspell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 ;* flyspell-get-not-casechars ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
709 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 (defun flyspell-get-not-casechars ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
711 "This function builds a string that is the regexp of non-word chars."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
712 (let ((ispell-not-casechars (ispell-get-not-casechars)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
713 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
714 ((eq ispell-not-casechars flyspell-ispell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
715 flyspell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 ((not (eq ispell-parser 'tex))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 (setq flyspell-not-casechars-cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (concat (substring ispell-not-casechars
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 0
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 (- (length ispell-not-casechars) 1))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 "{}]"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 flyspell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (setq flyspell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 flyspell-not-casechars-cache))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 ;* flyspell-get-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 (defun flyspell-get-word (following)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 "Return the word for spell-checking according to Ispell syntax.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 If optional argument FOLLOWING is non-nil or if `ispell-following-word'
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 is non-nil when called interactively, then the following word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 \(rather than preceding\) is checked when the cursor is not over a word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 Optional second argument contains otherchars that can be included in word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 many times.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 Word syntax described by `ispell-dictionary-alist' (which see)."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 (let* ((flyspell-casechars (flyspell-get-casechars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 (flyspell-not-casechars (flyspell-get-not-casechars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (ispell-otherchars (ispell-get-otherchars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (ispell-many-otherchars-p (ispell-get-many-otherchars-p))
24943
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
745 (word-regexp (if (not (string= "" ispell-otherchars))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
746 (concat
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
747 flyspell-casechars
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
748 "+\\("
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
749 ispell-otherchars
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
750 "?"
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
751 flyspell-casechars
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
752 "+\\)"
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
753 (if ispell-many-otherchars-p
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
754 "*" "?"))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
755 (concat flyspell-casechars "+")))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 (tex-prelude "[\\\\{]")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757 (tex-regexp (if (eq ispell-parser 'tex)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (concat tex-prelude "?" word-regexp "}?")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 word-regexp))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 did-it-once
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 start end word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 ;; find the word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (if (not (or (looking-at flyspell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (and (eq ispell-parser 'tex)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (looking-at tex-prelude))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 (if following
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (re-search-forward flyspell-casechars (point-max) t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (re-search-backward flyspell-casechars (point-min) t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 ;; move to front of word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (re-search-backward flyspell-not-casechars (point-min) 'start)
24943
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
772 (if (not (string= "" ispell-otherchars))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
773 (let ((pos nil))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
774 (while (and (looking-at ispell-otherchars)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
775 (not (bobp))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
776 (or (not did-it-once)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
777 ispell-many-otherchars-p)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
778 (not (eq pos (point))))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
779 (setq pos (point))
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
780 (setq did-it-once t)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
781 (backward-char 1)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
782 (if (looking-at flyspell-casechars)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
783 (re-search-backward flyspell-not-casechars (point-min) 'move)
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
784 (backward-char -1)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 ;; Now mark the word and save to string.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 (if (eq (re-search-forward tex-regexp (point-max) t) nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
787 nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (setq start (match-beginning 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 end (point)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 word (buffer-substring start end))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (list word start end)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 ;* flyspell-region ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (defun flyspell-region (beg end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 "Flyspell text between BEG and END."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (interactive "r")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 (save-excursion
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
801 (if (> beg end)
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
802 (let ((old beg))
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
803 (setq beg end)
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
804 (setq end old)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 (goto-char beg)
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
806 (let ((count 0))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
807 (while (< (point) end)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
808 (if (= count 100)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
809 (progn
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
810 (message "Spell Checking...%d%%"
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
811 (* 100 (/ (float (- (point) beg)) (- end beg))))
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
812 (setq count 0))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
813 (setq count (+ 1 count)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
814 (flyspell-word)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
815 (let ((cur (point)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
816 (forward-word 1)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
817 (if (and (< (point) end) (> (point) (+ cur 1)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
818 (backward-char 1)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (backward-char 1)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (message "Spell Checking...done")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
821 (flyspell-word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 ;* flyspell-buffer ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (defun flyspell-buffer ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827 "Flyspell whole buffer."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (interactive)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 (flyspell-region (point-min) (point-max)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 ;* flyspell-overlay-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (defun flyspell-overlay-p (o)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 "A predicate that return true iff O is an overlay used by flyspell."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 (and (overlayp o) (overlay-get o 'flyspell-overlay)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
838 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
839 ;* flyspell-delete-all-overlays ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
840 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
841 ;* Remove all the overlays introduced by flyspell. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
842 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
843 (defun flyspell-delete-all-overlays ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
844 "Delete all the overlays used by flyspell."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
845 (let ((l (overlays-in (point-min) (point-max))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
846 (while (consp l)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
847 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
848 (if (flyspell-overlay-p (car l))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
849 (delete-overlay (car l)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
850 (setq l (cdr l))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
851
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
852 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
853 ;* flyspell-unhighlight-at ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
854 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (defun flyspell-unhighlight-at (pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 "Remove the flyspell overlay that are located at POS."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 (if flyspell-persistent-highlight
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 (let ((overlays (overlays-at pos)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (delete-overlay (car overlays)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (setq overlays (cdr overlays))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (delete-overlay flyspell-overlay)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 ;* flyspell-properties-at-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 ;* Is there an highlight properties at position pos? */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
870 (defun flyspell-properties-at-p (pos)
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
871 "Return t if there is a text property at POS, not counting `local-map'.
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
872 If variable `flyspell-highlight-properties' is set to nil,
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
873 text with properties are not checked. This function is used to discover
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
874 if the character at POS has any other property."
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
875 (let ((prop (text-properties-at pos))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
876 (keep t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (while (and keep (consp prop))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
878 (if (and (eq (car prop) 'local-map) (consp (cdr prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
879 (setq prop (cdr (cdr prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
880 (setq keep nil)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
881 (consp prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 ;* make-flyspell-overlay ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (defun make-flyspell-overlay (beg end face mouse-face)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
887 "Allocate an overlay to highlight an incorrect word.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
888 BEG and END specify the range in the buffer of that word.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
889 FACE and MOUSE-FACE specify the `face' and `mouse-face' properties
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
890 for the overlay."
24076
6236e60302e2 (make-flyspell-overlay): fix front stickiness.
Richard M. Stallman <rms@gnu.org>
parents: 23943
diff changeset
891 (let ((flyspell-overlay (make-overlay beg end nil t nil)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (overlay-put flyspell-overlay 'face face)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (overlay-put flyspell-overlay 'mouse-face mouse-face)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
894 (overlay-put flyspell-overlay 'flyspell-overlay t)
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
895 (if flyspell-use-local-map
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (overlay-put flyspell-overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 flyspell-overlay-keymap-property-name
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
898 flyspell-local-mouse-map))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
900 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 ;* flyspell-highlight-incorrect-region ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 (defun flyspell-highlight-incorrect-region (beg end)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
904 "Set up an overlay on a misspelled word, in the buffer from BEG to END."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 (run-hook-with-args 'flyspell-incorrect-hook beg end)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
906 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 ;; we cleanup current overlay at the same position
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 (if (and (not flyspell-persistent-highlight)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (overlayp flyspell-overlay))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (delete-overlay flyspell-overlay)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (let ((overlays (overlays-at beg)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (delete-overlay (car overlays)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 (setq overlays (cdr overlays)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 ;; now we can use a new overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (setq flyspell-overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (make-flyspell-overlay beg end
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
920 'flyspell-incorrect-face 'highlight)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
922 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923 ;* flyspell-highlight-duplicate-region ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 (defun flyspell-highlight-duplicate-region (beg end)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
926 "Set up an overlay on a duplicated word, in the buffer from BEG to END."
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
927 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 ;; we cleanup current overlay at the same position
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (if (and (not flyspell-persistent-highlight)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (overlayp flyspell-overlay))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (delete-overlay flyspell-overlay)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 (let ((overlays (overlays-at beg)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (delete-overlay (car overlays)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (setq overlays (cdr overlays)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 ;; now we can use a new overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (setq flyspell-overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (make-flyspell-overlay beg end
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 'flyspell-duplicate-face 'highlight)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
943 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 ;* flyspell-auto-correct-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (defvar flyspell-auto-correct-pos nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 (defvar flyspell-auto-correct-region nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (defvar flyspell-auto-correct-ring nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 ;* flyspell-auto-correct-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (defun flyspell-auto-correct-word (pos)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
954 "Correct the word at POS.
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
955 This command proposes various successive corrections for the word at POS.
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
956 The variable `flyspell-auto-correct-binding' specifies the key to bind
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
957 to this command."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 (interactive "d")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
959 ;; use the correct dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 (ispell-accept-buffer-local-defs)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 (if (eq flyspell-auto-correct-pos pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 ;; we have already been using the function at the same location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 (let ((start (car flyspell-auto-correct-region))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (len (cdr flyspell-auto-correct-region)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 (delete-region start (+ start len))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (setq flyspell-auto-correct-ring (cdr flyspell-auto-correct-ring))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (let* ((word (car flyspell-auto-correct-ring))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 (len (length word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 (rplacd flyspell-auto-correct-region len)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (insert word))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (setq flyspell-auto-correct-pos (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 ;; retain cursor location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (let ((cursor-location pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 (word (flyspell-get-word nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 start end poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 ;; destructure return word info list.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 (setq start (car (cdr word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 end (car (cdr (cdr word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 word (car word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ;; now check spelling of word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
984 (process-send-string ispell-process "%\n") ;put in verbose mode
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
985 (process-send-string ispell-process (concat "^" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
986 ;; wait until ispell has processed word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
987 (while (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
988 (accept-process-output ispell-process)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
989 (not (string= "" (car ispell-filter)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
990 (setq ispell-filter (cdr ispell-filter))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 (if (listp ispell-filter)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 (setq poss (ispell-parse-output (car ispell-filter))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993 (cond ((or (eq poss t) (stringp poss))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 ;; don't correct word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 ((null poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 ;; ispell error
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (error "Ispell: error in Ispell process"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 ;; the word is incorrect, we have to propose a replacement
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 (let ((replacements (if flyspell-sort-corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 (sort (car (cdr (cdr poss))) 'string<)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 (car (cdr (cdr poss))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (if (consp replacements)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 (let ((replace (car replacements)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 (setq word replace)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (setq cursor-location (+ (- (length word) (- end start))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 cursor-location))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1010 (if (not (equal word (car poss)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 ;; the save the current replacements
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 (setq flyspell-auto-correct-pos cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 (setq flyspell-auto-correct-region
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 (cons start (length word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 (let ((l replacements))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (while (consp (cdr l))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (setq l (cdr l)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 (rplacd l (cons (car poss) replacements)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 (setq flyspell-auto-correct-ring
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 (cdr replacements))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (delete-region start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (insert word)))))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 ;; return to original location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 (goto-char cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 (ispell-pdict-save t))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 ;* flyspell-correct-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 (defun flyspell-correct-word (event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 "Check spelling of word under or before the cursor.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 If the word is not found in dictionary, display possible corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 in a popup menu allowing you to choose one.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 Word syntax described by `ispell-dictionary-alist' (which see).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 This will check or reload the dictionary. Use \\[ispell-change-dictionary]
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1039 or \\[ispell-region] to update the Ispell process."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 (interactive "e")
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
1041 (if flyspell-use-local-map
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (flyspell-correct-word/mouse-keymap event)
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
1043 (flyspell-correct-word/local-keymap event)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1044
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1045 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1046 ;* flyspell-correct-word/local-keymap ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048 (defun flyspell-correct-word/local-keymap (event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 "emacs 19.xx seems to be buggous. Overlay keymap does not seems
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1050 to work correctly with local map. That is, if a key is not
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1051 defined for the overlay keymap, the current local map, is not
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1052 checked. The binding is resolved with the global map. The
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1053 consequence is that we can not use overlay map with flyspell."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1054 (interactive "e")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (save-window-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 (let ((save (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 (mouse-set-point event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 ;; we look for a flyspell overlay here
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 (let ((overlays (overlays-at (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 (overlay nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 (setq overlay (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 (setq overlays nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 (setq overlays (cdr overlays))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 ;; we return to the correct location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 (goto-char save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 ;; we check to see if button2 has been used overlay a
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 ;; flyspell overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 (if overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 ;; yes, so we use the flyspell function
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 (flyspell-correct-word/mouse-keymap event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 ;; no so we have to use the non flyspell binding
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 (let ((flyspell-mode nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 (if (key-binding (this-command-keys))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 (command-execute (key-binding (this-command-keys))))))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 ;* flyspell-correct-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 (defun flyspell-correct-word/mouse-keymap (event)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1083 "Pop up a menu of possible corrections for a misspelled word.
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1084 The word checked is the word at the mouse position."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 (interactive "e")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086 ;; use the correct dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 (ispell-accept-buffer-local-defs)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 ;; retain cursor location (I don't know why but save-excursion here fails).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1089 (let ((save (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1090 (mouse-set-point event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 (let ((cursor-location (point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 (word (flyspell-get-word nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 start end poss replace)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 ;; destructure return word info list.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 (setq start (car (cdr word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 end (car (cdr (cdr word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 word (car word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 ;; now check spelling of word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 (process-send-string ispell-process "%\n") ;put in verbose mode
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 (process-send-string ispell-process (concat "^" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ;; wait until ispell has processed word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 (while (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 (accept-process-output ispell-process)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 (not (string= "" (car ispell-filter)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 (setq ispell-filter (cdr ispell-filter))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 (if (listp ispell-filter)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 (setq poss (ispell-parse-output (car ispell-filter))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 (cond ((or (eq poss t) (stringp poss))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 ;; don't correct word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 ((null poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 ;; ispell error
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (error "Ispell: error in Ispell process"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 ((string-match "GNU" (emacs-version))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 ;; the word is incorrect, we have to propose a replacement
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1116 (setq replace (flyspell-emacs-popup event poss word))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 (cond ((eq replace 'ignore)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 ((eq replace 'save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (process-send-string ispell-process (concat "*" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 (setq ispell-pdict-modified-p '(t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 ((or (eq replace 'buffer) (eq replace 'session))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 (process-send-string ispell-process (concat "@" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 (if (null ispell-pdict-modified-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 (setq ispell-pdict-modified-p
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 (list ispell-pdict-modified-p)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 (if (eq replace 'buffer)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 (ispell-add-per-file-word-list word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 (replace
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 (setq word (if (atom replace) replace (car replace))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 cursor-location (+ (- (length word) (- end start))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 cursor-location))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 (if (not (equal word (car poss)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1136 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (delete-region start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 (insert word))))))
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
1139 ((eq flyspell-emacs 'xemacs)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (flyspell-xemacs-popup
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 event poss word cursor-location start end)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (ispell-pdict-save t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (if (< save (point-max))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (goto-char save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 (goto-char (point-max)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 ;* flyspell-xemacs-correct ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 (defun flyspell-xemacs-correct (replace poss word cursor-location start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 "The xemacs popup menu callback."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (cond ((eq replace 'ignore)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 ((eq replace 'save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (process-send-string ispell-process (concat "*" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 (setq ispell-pdict-modified-p '(t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 ((or (eq replace 'buffer) (eq replace 'session))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 (process-send-string ispell-process (concat "@" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161 (if (null ispell-pdict-modified-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (setq ispell-pdict-modified-p
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 (list ispell-pdict-modified-p)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (if (eq replace 'buffer)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 (ispell-add-per-file-word-list word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (replace
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1167 (setq word (if (atom replace) replace (car replace))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1168 cursor-location (+ (- (length word) (- end start))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1169 cursor-location))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1170 (if (not (equal word (car poss)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1171 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1172 (delete-region start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 (insert word))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
1177 ;* flyspell-emacs-popup ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 ;*---------------------------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1179 (defun flyspell-emacs-popup (event poss word)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1180 "The Emacs popup menu."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 (if (not event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (let* ((mouse-pos (mouse-position))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (mouse-pos (if (nth 1 mouse-pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 mouse-pos
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (set-mouse-position (car mouse-pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (/ (frame-width) 2) 2)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (unfocus-frame)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1188 (mouse-position))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1189 (setq event (list (list (car (cdr mouse-pos))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1190 (1+ (cdr (cdr mouse-pos))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1191 (car mouse-pos)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (let* ((corrects (if flyspell-sort-corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (sort (car (cdr (cdr poss))) 'string<)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 (car (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 (cor-menu (if (consp corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 (mapcar (lambda (correct)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197 (list correct correct))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 '()))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 (affix (car (cdr (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 (base-menu (let ((save (if (consp affix)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 (list
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 (list (concat "Save affix: " (car affix))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 'save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 '("Accept (session)" accept)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 '("Accept (buffer)" buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 '(("Save word" save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 ("Accept (session)" session)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 ("Accept (buffer)" buffer)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 (if (consp cor-menu)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1211 (append cor-menu (cons "" save))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 save)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (menu (cons "flyspell correction menu" base-menu)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1214 (car (x-popup-menu event
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1215 (list (format "%s [%s]" word (or ispell-local-dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1216 ispell-dictionary))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1217 menu)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1219 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
1220 ;* flyspell-xemacs-popup ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1221 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 (defun flyspell-xemacs-popup (event poss word cursor-location start end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1223 "The xemacs popup menu."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1224 (let* ((corrects (if flyspell-sort-corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1225 (sort (car (cdr (cdr poss))) 'string<)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1226 (car (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1227 (cor-menu (if (consp corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1228 (mapcar (lambda (correct)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1229 (vector correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236 end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1238 corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1239 '()))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1240 (affix (car (cdr (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1241 (menu (let ((save (if (consp affix)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1242 (vector
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1243 (concat "Save affix: " (car affix))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1244 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1245 ''save
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1246 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1247 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1248 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1249 start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1250 end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1251 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1252 (vector
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1253 "Save word"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1254 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1255 ''save
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1256 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1257 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1258 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1259 start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1260 end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1261 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1262 (session (vector "Accept (session)"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1263 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1264 ''session
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1265 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1266 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1267 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1268 start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1269 end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1270 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1271 (buffer (vector "Accept (buffer)"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1272 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1273 ''buffer
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1274 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1275 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1276 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1277 start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1278 end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1279 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1280 (if (consp cor-menu)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1281 (append cor-menu (list "-" save session buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1282 (list save session buffer)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1283 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1284 ispell-dictionary))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1285 menu))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1286
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1287 (provide 'flyspell)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1288
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1289 ;;; flyspell.el ends here