annotate lisp/textmodes/flyspell.el @ 34810:61d22833847a

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Thu, 21 Dec 2000 21:27:37 +0000
parents d16b29f737a7
children 6043184119bc
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
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
25 ;;; Commentary:
22611
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.
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
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.
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
32 ;;
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
33 ;; To enable Flyspell in text representing computer programs, type
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
34 ;; Meta-x flyspell-prog-mode.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
35 ;; In that mode only text inside comments are checked.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;;
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
37 ;; Note: consider setting the variable ispell-parser to `tex' to
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
38 ;; avoid TeX command checking; use `(setq ispell-parser 'tex)'.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;;
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; Some user variables control the behavior of flyspell. They are
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 ;; those defined under the `User variables' comment.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;; Code:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (require 'ispell)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
46 ;*---------------------------------------------------------------------*/
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
47 ;* Group ... */
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
48 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 (defgroup flyspell nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 "Spellchecking on the fly."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 :tag "FlySpell"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 :prefix "flyspell-"
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
53 :group 'processes)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
56 ;* User configuration ... */
22611
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 (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
59 "*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
60 Non-nil means use highlight, nil means use minibuffer messages."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
64 (defcustom flyspell-mark-duplications-flag t
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
65 "*Non-nil means Flyspell reports a repeated word as an error."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
69 (defcustom flyspell-sort-corrections nil
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 "*Non-nil means, sort the corrections alphabetically before popping them."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
74 (defcustom flyspell-duplicate-distance -1
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
75 "*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
76 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
77 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
78 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
79 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
80 -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
81 0 means do not search for duplicate unrecognized spellings."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 :type 'number)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (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
86 "*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
87 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 :type 'number)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (defcustom flyspell-persistent-highlight t
22946
cfde96067373 (flyspell-persistent-highlight): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 22891
diff changeset
91 "*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
92 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
93 is highlighted."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (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
98 "*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
99 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (defcustom flyspell-default-delayed-commands
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 '(self-insert-command
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 delete-backward-char
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
105 backward-or-forward-delete-char
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
106 delete-char
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
107 scrollbar-vertical-drag)
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
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
120 (defcustom flyspell-default-deplacement-commands
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
121 '(next-line
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
122 previous-line
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
123 scroll-up
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
124 scroll-down)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
125 "The standard list of deplacement commands for Flyspell.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
126 See `flyspell-deplacement-commands'."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
127 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
128 :type '(repeat (symbol)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
129
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
130 (defcustom flyspell-deplacement-commands nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
131 "List of commands that are \"deplacement\" for Flyspell mode.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
132 After these commands, Flyspell checking is performed only if the previous
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
133 command was not the very same command."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
134 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
135 :type '(repeat (symbol)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
136
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (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
138 "*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
139 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
142 (defcustom flyspell-incorrect-hook nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
143 "*List of functions to be called when incorrect words are encountered.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
144 Each function is given three arguments: the beginning and the end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
145 of the incorrect region. The third is either the symbol 'doublon' or the list
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
146 of possible corrections returned as returned by 'ispell-parse-output'.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
147
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
148 If any of the functions return non-Nil, the word is not highligted as
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
149 incorrect."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
150 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
151 :type 'hook)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
152
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
153 (defcustom flyspell-default-dictionary "american"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
154 "A string that is the name of the default dictionary.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
155 This is passed to the ispell-change-dictionary when flyspell is started.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
156 If the variables ispell-local-dictionary or ispell-dictionary are non nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
157 when flyspell is started, the value of that variables is used instead
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
158 of flyspell-default-dictionary to select the default dictionary."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
159 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
160 :type 'string)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
161
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
162 (defcustom flyspell-tex-command-regexp
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
163 "\\(\\(begin\\|end\\)[ \t]*{\\|\\(cite[a-z*]*\\|label\\|ref\\|eqref\\|usepackage\\|documentclass\\)[ \t]*\\(\\[[^]]*\\]\\)?{[^{}]*\\)"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
164 "A string that is the regular expression that matches TeX commands."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
165 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
166 :type 'string)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
167
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
168 (defcustom flyspell-check-tex-math-command nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
169 "*Non nils means check even inside TeX math environement. TeX math
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
170 environement are discovered byt eh TEXMATHP that is implemented inside
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
171 the eponyme emacs package. That package may be found at:
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
172 http://strw.leidenuniv.nl/~dominik/Tools"
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
176 (defcustom flyspell-dictionaries-that-consider-dash-as-word-delimiter
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
177 '("francais" "deutsch8" "norsk")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
178 "List of dictionary names that consider `-' as word delimiter."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
179 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
180 :type '(repeat (string)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
182 (defcustom flyspell-abbrev-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
183 t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
184 "*If true, add correction to abbreviation table."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 :group 'flyspell
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 :type 'boolean)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
188 (defcustom flyspell-use-global-abbrev-table-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
189 nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
190 "*If true, prefer global abbrev table to local abbrev table."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
191 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
192 :type 'boolean)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
193
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
194 ;;;###autoload
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
195 (defcustom flyspell-mode-line-string " Fly"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
196 "*String displayed on the modeline when flyspell is active.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
197 Set this to nil if you don't want a modeline indicator."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
198 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
199 :type 'string)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
200
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
201 (defcustom flyspell-large-region 1000
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
202 "*The threshold that determines if an region is small. The flyspell-region
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
203 is invoked, if the region is small, the word are checked one after the
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
204 other using regular flyspell check means. If the region is large, a new
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
205 ispell process is spawned to get speed."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
206 :group 'flyspell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
207 :type 'number)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
208
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 ;* Mode specific options */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 ;* Mode specific options enable users to disable flyspell on */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 ;* certain word depending of the emacs mode. For instance, when */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 ;* using flyspell with mail-mode add the following expression */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 ;* in your .emacs file: */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 ;* (add-hook 'mail-mode */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 ;* '(lambda () (setq flyspell-generic-check-word-p */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 ;* 'mail-mode-flyspell-verify))) */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (defvar flyspell-generic-check-word-p nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 "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
222 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
223 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
224 property of the major mode name.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (make-variable-buffer-local 'flyspell-generic-check-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
227 ;*--- mail mode -------------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
228 (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
229 (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (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
231 "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
232 (save-excursion
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
233 (not (or (re-search-forward mail-header-separator nil t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
234 (re-search-backward message-signature-separator nil t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
235 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
236 (beginning-of-line)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
237 (looking-at "[>}|]\\To:"))))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
239 ;*--- texinfo mode ----------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
240 (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (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
242 "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
243 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (forward-word -1)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (not (looking-at "@"))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
247 ;*--- tex mode --------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
248 (put 'tex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
249 (defun tex-mode-flyspell-verify ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
250 "This function is used for `flyspell-generic-check-word-p' in LaTeX mode."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
251 (and
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
252 (not (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
253 (re-search-backward "^[ \t]*%%%[ \t]+Local" (point-min) t)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
254 (not (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
255 (let ((this (point-marker))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
256 (e (progn (end-of-line) (point-marker))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
257 (beginning-of-line)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
258 (if (re-search-forward "\\\\\\(cite\\|label\\|ref\\){[^}]*}" e t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
259 (and (>= this (match-beginning 0))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
260 (<= this (match-end 0)) )))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
261
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
262 ;*--- sgml mode -------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
263 (put 'sgml-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
264 (put 'html-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
265
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
266 (defun sgml-mode-flyspell-verify ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
267 "This function is used for `flyspell-generic-check-word-p' in SGML mode."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
268 (not (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
269 (let ((this (point-marker))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
270 (s (progn (beginning-of-line) (point-marker)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
271 (e (progn (end-of-line) (point-marker))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
272 (or (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
273 (goto-char this)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
274 (and (re-search-forward "[^<]*>" e t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
275 (= (match-beginning 0) this)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
276 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
277 (goto-char this)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
278 (and (re-search-backward "<[^>]*" s t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
279 (= (match-end 0) this)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
280 (and (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
281 (goto-char this)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
282 (and (re-search-forward "[^&]*;" e t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
283 (= (match-beginning 0) this)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
284 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
285 (goto-char this)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
286 (and (re-search-backward "&[^;]*" s t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
287 (= (match-end 0) this)))))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
288
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
289 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
290 ;* Programming mode */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
291 ;*---------------------------------------------------------------------*/
33787
d16b29f737a7 (flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33426
diff changeset
292 (defvar flyspell-prog-text-faces
d16b29f737a7 (flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33426
diff changeset
293 '(font-lock-string-face font-lock-comment-face font-lock-doc-face)
d16b29f737a7 (flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33426
diff changeset
294 "Faces corresponding to text in programming-mode buffers.")
d16b29f737a7 (flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33426
diff changeset
295
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
296 (defun flyspell-generic-progmode-verify ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
297 "Used for `flyspell-generic-check-word-p' in programming modes."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
298 (let ((f (get-text-property (point) 'face)))
33787
d16b29f737a7 (flyspell-prog-text-faces): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33426
diff changeset
299 (memq f flyspell-prog-text-faces)))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
300
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
301 ;;;###autoload
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
302 (defun flyspell-prog-mode ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
303 "Turn on `flyspell-mode' for comments and strings."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
304 (interactive)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
305 (setq flyspell-generic-check-word-p 'flyspell-generic-progmode-verify)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
306 (flyspell-mode 1))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
307
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
309 ;* Overlay compatibility */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
311 (autoload 'make-overlay "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
312 (autoload 'overlayp "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
313 (autoload 'overlays-in "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
314 (autoload 'delete-overlay "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
315 (autoload 'overlays-at "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
316 (autoload 'overlay-put "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
317 (autoload 'overlay-get "overlay" "Overlay compatibility kit." t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
318 (autoload 'previous-overlay-change "overlay" "Overlay compatibility kit." t)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 ;* Which emacs are we currently running */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (defvar flyspell-emacs
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
325 ((string-match "XEmacs" emacs-version)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 'xemacs)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 'emacs))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
329 "The type of Emacs we are currently running.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330
23943
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
331 (defvar flyspell-use-local-map
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
332 (or (eq flyspell-emacs 'xemacs)
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
333 (not (string< emacs-version "20"))))
7555c77bc4f0 If local-maps work, don't put
Richard M. Stallman <rms@gnu.org>
parents: 23788
diff changeset
334
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 ;* The minor mode declaration. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (defvar flyspell-mode nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (make-variable-buffer-local 'flyspell-mode)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
341 (defvar flyspell-mouse-map
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
342 (let ((map (make-sparse-keymap)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
343 (cond
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
344 ((eq flyspell-emacs 'xemacs)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
345 (define-key map [(button2)]
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
346 #'flyspell-correct-word/mouse-keymap)
30470
6f18c5924d2e (flyspell-mouse-map): Use `map' instead
Gerd Moellmann <gerd@gnu.org>
parents: 30428
diff changeset
347 (define-key map "\M-\t" #'flyspell-auto-correct-word))
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
348 (flyspell-use-local-map
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
349 (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
350 (define-key map "\M-\t" #'flyspell-auto-correct-word)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
351 map))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
352
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
353 ;;;###autoload
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
354 (defvar flyspell-mode-map (make-sparse-keymap))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
355
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
356 ;; mouse, keyboard bindings and misc definition
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
357 (when (or (assoc 'flyspell-mode minor-mode-map-alist)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
358 (setq minor-mode-map-alist
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
359 (cons (cons 'flyspell-mode flyspell-mode-map)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
360 minor-mode-map-alist)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
361 (define-key flyspell-mode-map "\M-\t" 'flyspell-auto-correct-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
362 (define-key flyspell-mode-map [(mouse-2)]
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
363 (function flyspell-correct-word/local-keymap)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
364
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
365
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
366 ;; the name of the overlay property that defines the keymap
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
367 (defvar flyspell-overlay-keymap-property-name
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
368 (if (string-match "19.*XEmacs" emacs-version)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
369 'keymap
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
370 'local-map))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
371
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
372 ;; dash character machinery
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
373 (defvar flyspell-consider-dash-as-word-delimiter-flag nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
374 "*Non-nil means that the `-' char is considered as a word delimiter.")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
375 (make-variable-buffer-local 'flyspell-consider-dash-as-word-delimiter-flag)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
376 (defvar flyspell-dash-dictionary nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
377 (make-variable-buffer-local 'flyspell-dash-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
378 (defvar flyspell-dash-local-dictionary nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
379 (make-variable-buffer-local 'flyspell-dash-local-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
380
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
381 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
382 ;* Highlighting */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;*---------------------------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
384 (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
385 '((((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
386 (t (:bold t)))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
387 "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
388 :group 'flyspell)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
389
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
390 (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
391 '((((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
392 (t (:bold t)))
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
393 "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
394 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
395 :group 'flyspell)
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
396
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (defvar flyspell-overlay nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398
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 ;* flyspell-mode ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;;;###autoload
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (defun flyspell-mode (&optional arg)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 "Minor mode performing on-the-fly spelling checking.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 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
406 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
407 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
408 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
409
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 Bindings:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 \\[ispell-word]: correct words (using Ispell).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 \\[flyspell-auto-correct-word]: automatically correct word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 \\[flyspell-correct-word] (or mouse-2): popup correct words.
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 Hooks:
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
416 flyspell-mode-hook is run after flyspell is entered.
22611
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 Remark:
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 `flyspell-mode' uses `ispell-mode'. Thus all Ispell options are
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 valid. For instance, a personal dictionary can be used by
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 invoking `ispell-change-dictionary'.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 Consider using the `ispell-parser' to check your text. For instance
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
424 consider adding:
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
425 \(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 in your .emacs file.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 flyspell-region checks all words inside a region.
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 flyspell-buffer checks the whole buffer."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 (interactive "P")
23179
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
432 (let ((old-flyspell-mode flyspell-mode))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
433 ;; Mark the mode as on or off.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
434 (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
435 (<= (prefix-numeric-value arg) 0))))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
436 ;; Do the real work.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
437 (unless (eq flyspell-mode old-flyspell-mode)
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
438 (if flyspell-mode
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
439 (flyspell-mode-on)
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
440 (flyspell-mode-off))
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
441 ;; Force modeline redisplay.
72461ea3cfc8 (flyspell-mode): Do nothing if mode
Karl Heuer <kwzh@gnu.org>
parents: 22963
diff changeset
442 (set-buffer-modified-p (buffer-modified-p)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
443
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
444 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
445 ;* Autoloading */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
446 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
447 ;;;###autoload
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
448 (if (fboundp 'add-minor-mode)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
449 (add-minor-mode 'flyspell-mode
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
450 'flyspell-mode-line-string
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
451 flyspell-mode-map
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
452 nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
453 'flyspell-mode)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
454 (or (assoc 'flyspell-mode minor-mode-alist)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
455 (setq minor-mode-alist
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
456 (cons '(flyspell-mode flyspell-mode-line-string)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
457 minor-mode-alist)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
458
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
459 (or (assoc 'flyspell-mode minor-mode-map-alist)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
460 (setq minor-mode-map-alist
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
461 (cons (cons 'flyspell-mode flyspell-mode-map)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
462 minor-mode-map-alist))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
463
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
464
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
465 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
466 ;* flyspell-buffers ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
467 ;* ------------------------------------------------------------- */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
468 ;* For remembering buffers running flyspell */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
469 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
470 (defvar flyspell-buffers nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
471
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
472 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
473 ;* flyspell-minibuffer-p ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
474 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
475 (defun flyspell-minibuffer-p (buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
476 "Is BUFFER a minibuffer?"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
477 (let ((ws (get-buffer-window-list buffer t)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
478 (and (consp ws) (window-minibuffer-p (car ws)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
479
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
480 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
481 ;* flyspell-accept-buffer-local-defs ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
482 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
483 (defun flyspell-accept-buffer-local-defs ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
484 (ispell-accept-buffer-local-defs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
485 (if (not (and (eq flyspell-dash-dictionary ispell-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
486 (eq flyspell-dash-local-dictionary ispell-local-dictionary)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
487 ;; the dictionary as changed
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
488 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
489 (setq flyspell-dash-dictionary ispell-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
490 (setq flyspell-dash-local-dictionary ispell-local-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
491 (if (member (or ispell-local-dictionary ispell-dictionary)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
492 flyspell-dictionaries-that-consider-dash-as-word-delimiter)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
493 (setq flyspell-consider-dash-as-word-delimiter-flag t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
494 (setq flyspell-consider-dash-as-word-delimiter-flag nil)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
495
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
496 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 ;* flyspell-mode-on ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 ;*---------------------------------------------------------------------*/
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
499 (eval-when-compile (defvar flyspell-local-mouse-map))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
500
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (defun flyspell-mode-on ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
502 "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
503 (setq ispell-highlight-face 'flyspell-incorrect-face)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
504 ;; local dictionaries setup
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
505 (ispell-change-dictionary
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
506 (or ispell-local-dictionary ispell-dictionary flyspell-default-dictionary))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
507 ;; we have to force ispell to accept the local definition or
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
508 ;; otherwise it could be too late, the local dictionary may
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
509 ;; be forgotten!
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
510 (flyspell-accept-buffer-local-defs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
511 ;; we put the `flyspel-delayed' property on some commands
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (flyspell-delay-commands)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
513 ;; we put the `flyspel-deplacement' property on some commands
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
514 (flyspell-deplacement-commands)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 ;; 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
516 (make-local-hook 'post-command-hook)
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
517 (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
518 ;; 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
519 (make-local-hook 'pre-command-hook)
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
520 (add-hook 'pre-command-hook (function flyspell-pre-command-hook) t t)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
521 ;; we bound flyspell action to after-change hook
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
522 (make-local-variable 'after-change-functions)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
523 (setq after-change-functions
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
524 (cons 'flyspell-after-change-function after-change-functions))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
525 ;; 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
526 (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
527 (if mode-predicate
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
528 (setq flyspell-generic-check-word-p mode-predicate)))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
529 ;; work around the fact that the `local-map' text-property replaces the
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
530 ;; buffer's local map rather than shadowing it.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
531 (set (make-local-variable 'flyspell-mouse-map)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
532 (let ((map (copy-keymap flyspell-mouse-map)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
533 (set-keymap-parent map (current-local-map))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
534 map))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 ;; the welcome message
33426
62b21497a99f (flyspell-mode-on): Only output welcome message if interactive.
Miles Bader <miles@gnu.org>
parents: 33020
diff changeset
536 (if (and flyspell-issue-welcome-flag (interactive-p))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
537 (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
538 nil 'non-ascii)))
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
539 (message
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
540 (if binding
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
541 (format "Welcome to flyspell. Use %s or Mouse-2 to correct words."
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
542 (key-description binding))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
543 "Welcome to flyspell. Use Mouse-2 to correct words."))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
544
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
545 ;; 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
546 ;; misspelled word (unless they're overridden by
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
547 ;; `flyspell-mouse-map').
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
548 (set (make-local-variable 'flyspell-local-mouse-map)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
549 (let ((map (copy-keymap flyspell-mouse-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
550 (if (eq flyspell-emacs 'xemacs)
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
551 (set-keymap-parents (list (current-local-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
552 (set-keymap-parent map (current-local-map)))
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
553 map))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
554
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
555 ;; we end with the flyspell hooks
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556 (run-hooks 'flyspell-mode-hook))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 ;* flyspell-delay-commands ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
560 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
561 (defun flyspell-delay-commands ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
562 "Install the standard set of Flyspell delayed commands."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
563 (mapcar 'flyspell-delay-command flyspell-default-delayed-commands)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
564 (mapcar 'flyspell-delay-command flyspell-delayed-commands))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
565
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
566 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567 ;* flyspell-delay-command ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 (defun flyspell-delay-command (command)
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
570 "Set COMMAND to be delayed, for Flyspell.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
571 When flyspell `post-command-hook' is invoked because a delayed command
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 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
573 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
574 (interactive "SDelay Flyspell after Command: ")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
575 (put command 'flyspell-delayed t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
576
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
578 ;* flyspell-deplacement-commands ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
580 (defun flyspell-deplacement-commands ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
581 "Install the standard set of Flyspell deplacement commands."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
582 (mapcar 'flyspell-deplacement-command flyspell-default-deplacement-commands)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
583 (mapcar 'flyspell-deplacement-command flyspell-deplacement-commands))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
584
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
585 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
586 ;* flyspell-deplacement-command ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
587 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
588 (defun flyspell-deplacement-command (command)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
589 "Set COMMAND that implement cursor movements, for Flyspell.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
590 When flyspell `post-command-hook' is invoked because of a deplacement command
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
591 as been used the current word is checked only if the previous command was
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
592 not the very same deplacement command."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
593 (interactive "SDeplacement Flyspell after Command: ")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
594 (put command 'flyspell-deplacement t))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
595
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
596 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
597 ;* flyspell-word-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
598 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
599 (defvar flyspell-word-cache-start nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
600 (defvar flyspell-word-cache-end nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
601 (defvar flyspell-word-cache-word nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
602 (make-variable-buffer-local 'flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
603 (make-variable-buffer-local 'flyspell-word-cache-end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
604 (make-variable-buffer-local 'flyspell-word-cache-word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
605
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
606 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
607 ;* The flyspell pre-hook, store the current position. In the */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
608 ;* post command hook, we will check, if the word at this position */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
609 ;* has to be spell checked. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
610 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
611 (defvar flyspell-pre-buffer nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
612 (defvar flyspell-pre-point nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
613 (defvar flyspell-pre-column nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
614 (defvar flyspell-pre-pre-buffer nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
615 (defvar flyspell-pre-pre-point nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
616
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
617 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
618 ;* flyspell-previous-command ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
619 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
620 (defvar flyspell-previous-command nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
621 "The last interactive command checked by Flyspell.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
622
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
623 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
624 ;* flyspell-pre-command-hook ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
625 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
626 (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
627 "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
628 (interactive)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
629 (setq flyspell-pre-buffer (current-buffer))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
630 (setq flyspell-pre-point (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
631 (setq flyspell-pre-column (current-column)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 ;* flyspell-mode-off ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635 ;*---------------------------------------------------------------------*/
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
636 ;;;###autoload
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 (defun flyspell-mode-off ()
23234
b0e173658e2e (flyspell-mode-on): Make the
Karl Heuer <kwzh@gnu.org>
parents: 23233
diff changeset
638 "Turn Flyspell mode off."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 ;; we remove the hooks
22962
f4509374e88e (flyspell-command-hook): Option deleted.
Richard M. Stallman <rms@gnu.org>
parents: 22946
diff changeset
640 (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
641 (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
642 (setq after-change-functions (delq 'flyspell-after-change-function
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
643 after-change-functions))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;; we remove all the flyspell hilightings
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 (flyspell-delete-all-overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 ;; we have to erase pre cache variables
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (setq flyspell-pre-buffer nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (setq flyspell-pre-point nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
649 ;; we mark the mode as killed
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
650 (setq flyspell-mode nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
651
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
652 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
653 ;* flyspell-check-pre-word-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
654 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
655 (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
656 "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
657 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
658 before the current command."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
659 (cond
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
660 ((or (not (numberp flyspell-pre-point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
661 (not (bufferp flyspell-pre-buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
662 (not (buffer-live-p flyspell-pre-buffer)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 nil)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
664 ((and (eq flyspell-pre-pre-point flyspell-pre-point)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
665 (eq flyspell-pre-pre-buffer flyspell-pre-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
666 nil)
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
667 ((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
668 (eq (char-syntax (char-after flyspell-pre-point)) ?w))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (= flyspell-pre-point (point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
670 (= flyspell-pre-point (+ (point) 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 nil)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
672 ((and (symbolp this-command)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
673 (or (get this-command 'flyspell-delayed)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
674 (and (get this-command 'flyspell-deplacement)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
675 (eq flyspell-previous-command this-command)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
676 (or (= (current-column) 0)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
677 (= (current-column) flyspell-pre-column)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
678 (eq (char-syntax (char-after flyspell-pre-point)) ?w)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
679 nil)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 ((not (eq (current-buffer) flyspell-pre-buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 ((not (and (numberp flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 (numberp flyspell-word-cache-end)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (or (< flyspell-pre-point flyspell-word-cache-start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (> flyspell-pre-point flyspell-word-cache-end)))))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
688
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
689 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
690 ;* The flyspell after-change-hook, store the change position. In */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
691 ;* the post command hook, we will check, if the word at this */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
692 ;* position has to be spell checked. */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
693 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
694 (defvar flyspell-changes nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
695
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
696 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
697 ;* flyspell-after-change-function ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
698 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
699 (defun flyspell-after-change-function (start stop len)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
700 "Save the current buffer and point for Flyspell's post-command hook."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
701 (interactive)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
702 (setq flyspell-changes (cons (cons start stop) flyspell-changes)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
703
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
704 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
705 ;* flyspell-check-changed-word-p ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
706 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
707 (defun flyspell-check-changed-word-p (start stop)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
708 "Return t when the changed word has to be checked.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
709 The answer depends of several criteria.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
710 Mostly we check word delimiters."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
711 (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
712 ((and (eq (char-after start) ?\n) (> stop start))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
713 t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
714 ((not (numberp flyspell-pre-point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
715 t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
716 ((and (>= flyspell-pre-point start) (<= flyspell-pre-point stop))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
717 nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
718 ((let ((pos (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
719 (or (>= pos start) (<= pos stop) (= pos (1+ stop))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
720 nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
721 (t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
722 t)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
723
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
724 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
725 ;* flyspell-check-word-p ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
726 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
727 (defun flyspell-check-word-p ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
728 "Return t when the word at `point' has to be checked.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
729 The answer depends of several criteria.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
730 Mostly we check word delimiters."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
731 (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
732 ((<= (- (point-max) 1) (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
733 ;; the buffer is not filled enough
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
734 nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
735 ((and (and (> (current-column) 0)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
736 (not (eq (current-column) flyspell-pre-column)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
737 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
738 (backward-char 1)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
739 (and (looking-at (flyspell-get-not-casechars))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
740 (or flyspell-consider-dash-as-word-delimiter-flag
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
741 (not (looking-at "\\-"))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
742 ;; yes because we have reached or typed a word delimiter.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
743 t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
744 ((symbolp this-command)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
745 (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
746 ((get this-command 'flyspell-deplacement)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
747 (not (eq flyspell-previous-command this-command)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
748 ((get this-command 'flyspell-delayed)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
749 ;; the current command is not delayed, that
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
750 ;; is that we must check the word now
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
751 (if (fboundp 'about-xemacs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
752 (sit-for flyspell-delay nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
753 (sit-for flyspell-delay 0 nil)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
754 (t t)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
755 (t t)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
756
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
757 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
758 ;* flyspell-debug-signal-no-check ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
759 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
760 (defun flyspell-debug-signal-no-check (msg obj)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
761 (setq debug-on-error t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
762 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
763 (let ((buffer (get-buffer-create "*flyspell-debug*")))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
764 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
765 (erase-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
766 (insert "NO-CHECK:\n")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
767 (insert (format " %S : %S\n" msg obj)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
768
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
769 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
770 ;* flyspell-debug-signal-pre-word-checked ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
771 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
772 (defun flyspell-debug-signal-pre-word-checked ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
773 (setq debug-on-error t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
774 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
775 (let ((buffer (get-buffer-create "*flyspell-debug*")))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
776 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
777 (insert "PRE-WORD:\n")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
778 (insert (format " pre-point : %S\n" flyspell-pre-point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
779 (insert (format " pre-buffer : %S\n" flyspell-pre-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
780 (insert (format " cache-start: %S\n" flyspell-word-cache-start))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
781 (insert (format " cache-end : %S\n" flyspell-word-cache-end))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
782 (goto-char (point-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
783
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
784 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
785 ;* flyspell-debug-signal-word-checked ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
786 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
787 (defun flyspell-debug-signal-word-checked ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
788 (setq debug-on-error t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
789 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
790 (let ((oldbuf (current-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
791 (buffer (get-buffer-create "*flyspell-debug*"))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
792 (point (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
793 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
794 (insert "WORD:\n")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
795 (insert (format " this-cmd : %S\n" this-command))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
796 (insert (format " delayed : %S\n" (and (symbolp this-command)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
797 (get this-command 'flyspell-delayed))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
798 (insert (format " point : %S\n" point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
799 (insert (format " prev-char : [%c] %S\n"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
800 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
801 (set-buffer oldbuf)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
802 (let ((c (if (> (point) (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
803 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
804 (backward-char 1)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
805 (char-after (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
806 ? )))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
807 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
808 c))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
809 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
810 (set-buffer oldbuf)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
811 (let ((c (if (> (point) (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
812 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
813 (backward-char 1)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
814 (and (and (looking-at (flyspell-get-not-casechars)) 1)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
815 (and (or flyspell-consider-dash-as-word-delimiter-flag
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
816 (not (looking-at "\\-"))) 2))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
817 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
818 c))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
819 (insert (format " because : %S\n"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
820 (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
821 ((not (and (symbolp this-command)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
822 (get this-command 'flyspell-delayed)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
823 ;; the current command is not delayed, that
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
824 ;; is that we must check the word now
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
825 'not-delayed)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
826 ((progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
827 (set-buffer oldbuf)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
828 (let ((c (if (> (point) (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
829 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
830 (backward-char 1)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
831 (and (looking-at (flyspell-get-not-casechars))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
832 (or flyspell-consider-dash-as-word-delimiter-flag
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
833 (not (looking-at "\\-"))))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
834 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
835 c))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
836 ;; yes because we have reached or typed a word delimiter.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
837 'separator)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
838 ((not (integerp flyspell-delay))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
839 ;; yes because the user had set up a no-delay configuration.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
840 'no-delay)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
841 (t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
842 'sit-for))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
843 (goto-char (point-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
844
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
845 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
846 ;* flyspell-debug-signal-changed-checked ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
847 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
848 (defun flyspell-debug-signal-changed-checked ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
849 (setq debug-on-error t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
850 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
851 (let ((buffer (get-buffer-create "*flyspell-debug*"))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
852 (point (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
853 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
854 (insert "CHANGED WORD:\n")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
855 (insert (format " point : %S\n" point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
856 (goto-char (point-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
857
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 ;* flyspell-post-command-hook ... */
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
860 ;* ------------------------------------------------------------- */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
861 ;* It is possible that we check several words: */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
862 ;* 1- the current word is checked if the predicate */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
863 ;* FLYSPELL-CHECK-WORD-P is true */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
864 ;* 2- the word that used to be the current word before the */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
865 ;* THIS-COMMAND is checked if: */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
866 ;* a- the previous word is different from the current word */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
867 ;* b- the previous word as not just been checked by the */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
868 ;* previous FLYSPELL-POST-COMMAND-HOOK */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
869 ;* 3- the words changed by the THIS-COMMAND that are neither the */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
870 ;* previous word nor the current word */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (defun flyspell-post-command-hook ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
873 "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
874 (interactive)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
875 (let ((command this-command))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
876 (if (flyspell-check-pre-word-p)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
877 (save-excursion
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
878 '(flyspell-debug-signal-pre-word-checked)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
879 (set-buffer flyspell-pre-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
880 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
881 (goto-char flyspell-pre-point)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
882 (flyspell-word))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
883 (if (flyspell-check-word-p)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
884 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
885 '(flyspell-debug-signal-word-checked)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
886 (flyspell-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
887 ;; we remember which word we have just checked.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
888 ;; this will be used next time we will check a word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
889 ;; to compare the next current word with the word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
890 ;; that as been registered in the pre-command-hook
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
891 ;; that is these variables are used within the predicate
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
892 ;; FLYSPELL-CHECK-PRE-WORD-P
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
893 (setq flyspell-pre-pre-buffer (current-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
894 (setq flyspell-pre-pre-point (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
895 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
896 (setq flyspell-pre-pre-buffer nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
897 (setq flyspell-pre-pre-point nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
898 ;; when a word is not checked because of a delayed command
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
899 ;; we do not disable the ispell cache.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
900 (if (and (symbolp this-command) (get this-command 'flyspell-delayed))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
901 (setq flyspell-word-cache-end -1))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
902 (while (consp flyspell-changes)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
903 (let ((start (car (car flyspell-changes)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
904 (stop (cdr (car flyspell-changes))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
905 (if (flyspell-check-changed-word-p start stop)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
906 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
907 '(flyspell-debug-signal-changed-checked)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
908 (goto-char start)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
909 (flyspell-word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
910 (setq flyspell-changes (cdr flyspell-changes))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
911 (setq flyspell-previous-command command)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
912
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
913 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
914 ;* flyspell-notify-misspell ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
915 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
916 (defun flyspell-notify-misspell (start end word poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
917 (let ((replacements (if (stringp poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
918 poss
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
919 (if flyspell-sort-corrections
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
920 (sort (car (cdr (cdr poss))) 'string<)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
921 (car (cdr (cdr poss)))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
922 (message (format "mispelling `%s' %S" word replacements))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
923
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 ;* flyspell-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 (defun flyspell-word (&optional following)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 "Spell check a word."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (interactive (list current-prefix-arg))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 (if (interactive-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (setq following ispell-following-word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (save-excursion
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
933 ;; use the correct dictionary
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
934 (flyspell-accept-buffer-local-defs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
935 (let* ((cursor-location (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
936 (flyspell-word (flyspell-get-word following))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
937 start end poss word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
938 (if (or (eq flyspell-word nil)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939 (and (fboundp flyspell-generic-check-word-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (not (funcall flyspell-generic-check-word-p))))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
941 '()
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 (progn
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
943 ;; destructure return flyspell-word info list.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
944 (setq start (car (cdr flyspell-word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
945 end (car (cdr (cdr flyspell-word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
946 word (car flyspell-word))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
947 ;; before checking in the directory, we check for doublons.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
948 (cond
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
949 ((and (or (not (eq ispell-parser 'tex))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
950 (not (eq (char-after start) ?\\)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
951 flyspell-mark-duplications-flag
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (word-search-backward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
955 (- start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (+ 1 (- end start)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
957 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
958 ;; yes, this is a doublon
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
959 (flyspell-highlight-incorrect-region start end 'doublon))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
960 ((and (eq flyspell-word-cache-start start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
961 (eq flyspell-word-cache-end end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
962 (string-equal flyspell-word-cache-word word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
963 ;; this word had been already checked, we skip
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 ((and (eq ispell-parser 'tex)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
966 (flyspell-tex-command-p flyspell-word))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 ;; this is a correct word (because a tex command)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
970 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
971 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 ;; we setup the cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (setq flyspell-word-cache-start start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 (setq flyspell-word-cache-end end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (setq flyspell-word-cache-word word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 ;; now check spelling of word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 (process-send-string ispell-process "%\n")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 ;; put in verbose mode
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980 (process-send-string ispell-process
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (concat "^" word "\n"))
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
982 ;; 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
983 ;; 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
984 (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
985 (process-kill-without-query ispell-process))
22611
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 ;; (process-send-string ispell-process "!\n")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
991 ;; back to terse mode.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
992 (setq ispell-filter (cdr ispell-filter))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
993 (if (consp ispell-filter)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
994 (setq poss (ispell-parse-output (car ispell-filter))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
995 (cond ((eq poss t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
996 ;; correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
997 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
998 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
999 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1000 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1001 ((and (stringp poss) flyspell-highlight-flag)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1002 ;; correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1003 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1004 (if (> end start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1005 (flyspell-unhighlight-at (- end 1)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1006 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1007 ((null poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1008 (flyspell-unhighlight-at start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1009 (if (> end start)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1010 (flyspell-unhighlight-at (- end 1))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1011 ((or (and (< flyspell-duplicate-distance 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1012 (or (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1013 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1014 (word-search-backward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1015 (point-min)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1016 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1017 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1018 (goto-char end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1019 (word-search-forward word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1020 (point-max)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1021 t))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1022 (and (> flyspell-duplicate-distance 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1023 (or (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1024 (goto-char start)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1025 (word-search-backward
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1026 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1027 (- start
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1028 flyspell-duplicate-distance)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1029 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1030 (save-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1031 (goto-char end)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1032 (word-search-forward
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1033 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1034 (+ end
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1035 flyspell-duplicate-distance)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1036 t)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1037 (if flyspell-highlight-flag
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1038 (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
1039 (message (format "duplicate `%s'" word))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1040 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1041 ;; incorrect highlight the location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1042 (if flyspell-highlight-flag
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1043 (flyspell-highlight-incorrect-region start end poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1044 (flyspell-notify-misspell start end word poss))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1045 ;; return to original location
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1046 (goto-char cursor-location)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1047 (if ispell-quit (setq ispell-quit nil)))))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1048
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1049 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1050 ;* flyspell-tex-math-initialized ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1051 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1052 (defvar flyspell-tex-math-initialized nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1053
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1054 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1055 ;* flyspell-math-tex-command-p ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1056 ;* ------------------------------------------------------------- */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1057 ;* This function uses the texmathp package to check if (point) */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1058 ;* is within a tex command. In order to avoid using */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1059 ;* condition-case each time we use the variable */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1060 ;* flyspell-tex-math-initialized to make a special case the first */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1061 ;* time that function is called. */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1062 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1063 (defun flyspell-math-tex-command-p ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1064 (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1065 (flyspell-check-tex-math-command
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1066 nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1067 ((eq flyspell-tex-math-initialized t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1068 (texmathp))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1069 ((eq flyspell-tex-math-initialized 'error)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1070 nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1071 (t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1072 (setq flyspell-tex-math-initialized t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1073 (condition-case nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1074 (texmathp)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1075 (error (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1076 (setq flyspell-tex-math-initialized 'error)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1077 nil))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1078
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1079 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 ;* flyspell-tex-command-p ... */
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-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
1083 "Return t if WORD is a TeX command."
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1084 (or (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1085 (let ((b (car (cdr word))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1086 (and (re-search-backward "\\\\" (- (point) 100) t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1087 (or (= (match-end 0) b)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1088 (and (goto-char (match-end 0))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1089 (looking-at flyspell-tex-command-regexp)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1090 (>= (match-end 0) b))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1091 (flyspell-math-tex-command-p)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 ;* flyspell-casechars-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (defvar flyspell-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 (defvar flyspell-ispell-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 (make-variable-buffer-local 'flyspell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 (make-variable-buffer-local 'flyspell-ispell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 ;* flyspell-get-casechars ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 (defun flyspell-get-casechars ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 "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
1106 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
1107 this function changes the last char of the `ispell-casechars' string."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 (let ((ispell-casechars (ispell-get-casechars)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 (cond
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1110 ((eq ispell-parser 'tex)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 (setq flyspell-ispell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 (setq flyspell-casechars-cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (concat (substring ispell-casechars
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 0
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 (- (length ispell-casechars) 1))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1116 "]"))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 flyspell-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 (setq flyspell-ispell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (setq flyspell-casechars-cache ispell-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 flyspell-casechars-cache))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 ;* flyspell-get-not-casechars-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 (defvar flyspell-not-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 (defvar flyspell-ispell-not-casechars-cache nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 (make-variable-buffer-local 'flyspell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1132 ;* flyspell-get-not-casechars ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1134 (defun flyspell-get-not-casechars ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1135 "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
1136 (let ((ispell-not-casechars (ispell-get-not-casechars)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (cond
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1138 ((eq ispell-parser 'tex)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (setq flyspell-not-casechars-cache
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 (concat (substring ispell-not-casechars
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 0
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 (- (length ispell-not-casechars) 1))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1144 "]"))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 flyspell-not-casechars-cache)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 (t
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 (setq flyspell-ispell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 (setq flyspell-not-casechars-cache ispell-not-casechars)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 flyspell-not-casechars-cache))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 ;* flyspell-get-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (defun flyspell-get-word (following)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 "Return the word for spell-checking according to Ispell syntax.
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1156 If argument FOLLOWING is non-nil or if `ispell-following-word'
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 is non-nil when called interactively, then the following word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 \(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
1159 Optional second argument contains otherchars that can be included in word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1160 many times.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1161
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 Word syntax described by `ispell-dictionary-alist' (which see)."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1163 (let* ((flyspell-casechars (flyspell-get-casechars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1164 (flyspell-not-casechars (flyspell-get-not-casechars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1165 (ispell-otherchars (ispell-get-otherchars))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1166 (ispell-many-otherchars-p (ispell-get-many-otherchars-p))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1167 (word-regexp (if (string< "" ispell-otherchars)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1168 (concat flyspell-casechars
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1169 "+\\("
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1170 ispell-otherchars
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1171 "?"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1172 flyspell-casechars
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1173 "+\\)"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1174 (if ispell-many-otherchars-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1175 "*" "?"))
24943
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
1176 (concat flyspell-casechars "+")))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 did-it-once
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 start end word)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 ;; find the word
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1180 (if (not (looking-at flyspell-casechars))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 (if following
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 (re-search-forward flyspell-casechars (point-max) t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 (re-search-backward flyspell-casechars (point-min) t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 ;; move to front of word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (re-search-backward flyspell-not-casechars (point-min) 'start)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1186 (let ((pos nil))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1187 (if (string< "" ispell-otherchars)
24943
59585a4135a6 (flyspell-get-word): Add special handling for when ispell-otherchars is empty.
Richard M. Stallman <rms@gnu.org>
parents: 24458
diff changeset
1188 (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
1189 (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
1190 (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
1191 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
1192 (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
1193 (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
1194 (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
1195 (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
1196 (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
1197 (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
1198 (backward-char -1)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 ;; Now mark the word and save to string.
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1200 (if (eq (re-search-forward word-regexp (point-max) t) nil)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 nil
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1202 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1203 (setq start (match-beginning 0)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 end (point)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 word (buffer-substring start end))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 (list word start end)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1209 ;* flyspell-small-region ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1210 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1211 (defun flyspell-small-region (beg end)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1212 "Flyspell text between BEG and END."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1213 (save-excursion
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1214 (if (> beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1215 (let ((old beg))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1216 (setq beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1217 (setq end old)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1218 (goto-char beg)
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1219 (let ((count 0))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1220 (while (< (point) end)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1221 (if (= count 100)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1222 (progn
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1223 (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
1224 (* 100 (/ (float (- (point) beg)) (- end beg))))
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1225 (setq count 0))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1226 (setq count (+ 1 count)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1227 (flyspell-word)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1228 (sit-for 0)
22612
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1229 (let ((cur (point)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1230 (forward-word 1)
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1231 (if (and (< (point) end) (> (point) (+ cur 1)))
6def3da74c7c Delete defcustom definition.
Richard M. Stallman <rms@gnu.org>
parents: 22611
diff changeset
1232 (backward-char 1)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (backward-char 1)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1234 (message "Spell Checking completed.")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (flyspell-word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1236
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1237 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1238 ;* flyspell-external-ispell-process ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1239 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1240 (defvar flyspell-external-ispell-process '()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1241 "The external Flyspell ispell process")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1242
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1243 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1244 ;* flyspell-external-ispell-buffer ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1245 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1246 (defvar flyspell-external-ispell-buffer '())
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1247 (defvar flyspell-large-region-buffer '())
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1248 (defvar flyspell-large-region-beg (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1249 (defvar flyspell-large-region-end (point-max))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1250
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1251 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1252 ;* flyspell-external-point-words ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1253 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1254 (defun flyspell-external-point-words ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1255 (let ((buffer flyspell-external-ispell-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1256 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1257 (beginning-of-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1258 (let ((size (- flyspell-large-region-end flyspell-large-region-beg))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1259 (start flyspell-large-region-beg))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1260 ;; now we are done with ispell, we have to find the word in
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1261 ;; the initial buffer
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1262 (while (< (point) (- (point-max) 1))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1263 ;; we have to fetch the incorrect word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1264 (if (re-search-forward "\\([^\n]+\\)\n" (point-max) t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1265 (let ((word (match-string 1)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1266 (goto-char (match-end 0))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1267 (set-buffer flyspell-large-region-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1268 (goto-char flyspell-large-region-beg)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1269 (message "Spell Checking...%d%% [%s]"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1270 (* 100 (/ (float (- (point) start)) size))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1271 word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1272 (if (search-forward word flyspell-large-region-end t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1273 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1274 (setq flyspell-large-region-beg (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1275 (goto-char (- (point) 1))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1276 (flyspell-word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1277 (set-buffer buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1278 (goto-char (point-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1279 ;; we are done
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1280 (message "Spell Checking completed.")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1281 ;; ok, we are done with pointing out incorrect words, we just
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1282 ;; have to kill the temporary buffer
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1283 (kill-buffer flyspell-external-ispell-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1284 (setq flyspell-external-ispell-buffer nil)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1285
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1286 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1287 ;* flyspell-large-region ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1288 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1289 (defun flyspell-large-region (beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1290 (let* ((curbuf (current-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1291 (buffer (get-buffer-create "*flyspell-region*")))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1292 (setq flyspell-external-ispell-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1293 (setq flyspell-large-region-buffer curbuf)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1294 (setq flyspell-large-region-beg beg)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1295 (setq flyspell-large-region-end end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1296 (set-buffer buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1297 (erase-buffer)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1298 ;; this is done, we can start ckecking...
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1299 (message "Checking region...")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1300 (set-buffer curbuf)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1301 (let ((c (apply 'call-process-region beg
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1302 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1303 ispell-program-name
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1304 nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1305 buffer
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1306 nil
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1307 "-l"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1308 (let (args)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1309 ;; Local dictionary becomes the global dictionary in use.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1310 (if ispell-local-dictionary
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1311 (setq ispell-dictionary ispell-local-dictionary))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1312 (setq args (ispell-get-ispell-args))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1313 (if ispell-dictionary ; use specified dictionary
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1314 (setq args
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1315 (append (list "-d" ispell-dictionary) args)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1316 (if ispell-personal-dictionary ; use specified pers dict
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1317 (setq args
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1318 (append args
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1319 (list "-p"
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1320 (expand-file-name
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1321 ispell-personal-dictionary)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1322 (setq args (append args ispell-extra-args))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1323 args))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1324 (if (= c 0)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1325 (flyspell-external-point-words)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1326 (error "Can't check region...")))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1327
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1328 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1329 ;* flyspell-region ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1330 ;* ------------------------------------------------------------- */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1331 ;* Because `ispell -a' is too slow, it is not possible to use */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1332 ;* it on large region. Then, when ispell is invoked on a large */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1333 ;* text region, a new `ispell -l' process is spawned. The */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1334 ;* pointed out words are then searched in the region a checked with */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1335 ;* regular flyspell means. */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1336 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1337 (defun flyspell-region (beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1338 "Flyspell text between BEG and END."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1339 (interactive "r")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1340 (if (= beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1341 ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1342 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1343 (if (> beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1344 (let ((old beg))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1345 (setq beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1346 (setq end old)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1347 (if (> (- end beg) flyspell-large-region)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1348 (flyspell-large-region beg end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1349 (flyspell-small-region beg end)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1350
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1351 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1352 ;* flyspell-buffer ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1353 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1354 (defun flyspell-buffer ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1355 "Flyspell whole buffer."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1356 (interactive)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1357 (flyspell-region (point-min) (point-max)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1358
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1359 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1360 ;* old next error position ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1361 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1362 (defvar flyspell-old-buffer-error nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1363 (defvar flyspell-old-pos-error nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1364
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1365 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1366 ;* flyspell-goto-next-error ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1367 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1368 (defun flyspell-goto-next-error ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1369 "Go to the next previously detected error.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1370 In general FLYSPELL-GOTO-NEXT-ERROR must be used after
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1371 FLYSPELL-BUFFER."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1372 (interactive)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1373 (let ((pos (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1374 (max (point-max)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1375 (if (and (eq (current-buffer) flyspell-old-buffer-error)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1376 (eq pos flyspell-old-pos-error))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1377 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1378 (if (= flyspell-old-pos-error max)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1379 ;; goto beginning of buffer
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1380 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1381 (message "Restarting from beginning of buffer")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1382 (goto-char (point-min)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1383 (forward-word 1))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1384 (setq pos (point))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1385 ;; seek the next error
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1386 (while (and (< pos max)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1387 (let ((ovs (overlays-at pos))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1388 (r '()))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1389 (while (and (not r) (consp ovs))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1390 (if (flyspell-overlay-p (car ovs))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1391 (setq r t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1392 (setq ovs (cdr ovs))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1393 (not r)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1394 (setq pos (1+ pos)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1395 ;; save the current location for next invokation
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1396 (setq flyspell-old-pos-error pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1397 (setq flyspell-old-buffer-error (current-buffer))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1398 (goto-char pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1399 (if (= pos max)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1400 (message "No more miss-spelled word!"))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1401
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1402 ;*---------------------------------------------------------------------*/
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1403 ;* flyspell-overlay-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1404 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1405 (defun flyspell-overlay-p (o)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1406 "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
1407 (and (overlayp o) (overlay-get o 'flyspell-overlay)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1408
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1409 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1410 ;* flyspell-delete-all-overlays ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1411 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1412 ;* Remove all the overlays introduced by flyspell. */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1413 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1414 (defun flyspell-delete-all-overlays ()
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1415 "Delete all the overlays used by flyspell."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1416 (let ((l (overlays-in (point-min) (point-max))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1417 (while (consp l)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1418 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1419 (if (flyspell-overlay-p (car l))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1420 (delete-overlay (car l)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1421 (setq l (cdr l))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1422
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1423 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1424 ;* flyspell-unhighlight-at ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1425 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1426 (defun flyspell-unhighlight-at (pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1427 "Remove the flyspell overlay that are located at POS."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1428 (if flyspell-persistent-highlight
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1429 (let ((overlays (overlays-at pos)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1430 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1431 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1432 (delete-overlay (car overlays)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1433 (setq overlays (cdr overlays))))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1434 (if (flyspell-overlay-p flyspell-overlay)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1435 (delete-overlay flyspell-overlay))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1436
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1437 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1438 ;* flyspell-properties-at-p ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1439 ;* ------------------------------------------------------------- */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1440 ;* Is there an highlight properties at position pos? */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1441 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
1442 (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
1443 "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
1444 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
1445 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
1446 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
1447 (let ((prop (text-properties-at pos))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1448 (keep t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1449 (while (and keep (consp prop))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1450 (if (and (eq (car prop) 'local-map) (consp (cdr prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1451 (setq prop (cdr (cdr prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1452 (setq keep nil)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1453 (consp prop)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1454
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1455 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1456 ;* make-flyspell-overlay ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1457 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1458 (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
1459 "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
1460 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
1461 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
1462 for the overlay."
24076
6236e60302e2 (make-flyspell-overlay): fix front stickiness.
Richard M. Stallman <rms@gnu.org>
parents: 23943
diff changeset
1463 (let ((flyspell-overlay (make-overlay beg end nil t nil)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1464 (overlay-put flyspell-overlay 'face face)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1465 (overlay-put flyspell-overlay 'mouse-face mouse-face)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466 (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
1467 (if flyspell-use-local-map
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 (overlay-put flyspell-overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 flyspell-overlay-keymap-property-name
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1470 flyspell-local-mouse-map))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1471 flyspell-overlay))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 ;* flyspell-highlight-incorrect-region ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1476 (defun flyspell-highlight-incorrect-region (beg end poss)
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1477 "Set up an overlay on a misspelled word, in the buffer from BEG to END."
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1478 (unless (run-hook-with-args-until-success
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1479 'flyspell-incorrect-hook beg end poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1480 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1481 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1482 ;; we cleanup current overlay at the same position
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1483 (if (and (not flyspell-persistent-highlight)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1484 (overlayp flyspell-overlay))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1485 (delete-overlay flyspell-overlay)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1486 (let ((overlays (overlays-at beg)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1487 (while (consp overlays)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1488 (if (flyspell-overlay-p (car overlays))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1489 (delete-overlay (car overlays)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1490 (setq overlays (cdr overlays)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1491 ;; now we can use a new overlay
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1492 (setq flyspell-overlay
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1493 (make-flyspell-overlay beg end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1494 'flyspell-incorrect-face 'highlight))))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 ;* flyspell-highlight-duplicate-region ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499 (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
1500 "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
1501 (if (or flyspell-highlight-properties (not (flyspell-properties-at-p beg)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1502 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 ;; we cleanup current overlay at the same position
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 (if (and (not flyspell-persistent-highlight)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (overlayp flyspell-overlay))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (delete-overlay flyspell-overlay)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (let ((overlays (overlays-at beg)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 (delete-overlay (car overlays)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 (setq overlays (cdr overlays)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 ;; now we can use a new overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (setq flyspell-overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (make-flyspell-overlay beg end
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 'flyspell-duplicate-face 'highlight)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 ;* flyspell-auto-correct-cache ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 (defvar flyspell-auto-correct-pos nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 (defvar flyspell-auto-correct-region nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 (defvar flyspell-auto-correct-ring nil)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1523 (defvar flyspell-auto-correct-word nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1524 (make-variable-buffer-local 'flyspell-auto-correct-pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1525 (make-variable-buffer-local 'flyspell-auto-correct-region)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1526 (make-variable-buffer-local 'flyspell-auto-correct-ring)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1527 (make-variable-buffer-local 'flyspell-auto-correct-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1528
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1529 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1530 ;* flyspell-check-previous-highlighted-word ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1531 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1532 (defun flyspell-check-previous-highlighted-word (&optional arg)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1533 "Correct the closer mispelled word.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1534 This function scans a mis-spelled word before the cursor. If it finds one
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1535 it proposes replacement for that word. With prefix arg, count that many
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1536 misspelled words backwards."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1537 (interactive)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1538 (let ((pos1 (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1539 (pos (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1540 (arg (if (or (not (numberp arg)) (< arg 1)) 1 arg))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1541 ov ovs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1542 (if (catch 'exit
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1543 (while (and (setq pos (previous-overlay-change pos))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1544 (not (= pos pos1)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1545 (setq pos1 pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1546 (if (> pos (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1547 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1548 (setq ovs (overlays-at (1- pos)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1549 (while (consp ovs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1550 (setq ov (car ovs))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1551 (setq ovs (cdr ovs))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1552 (if (and (overlay-get ov 'flyspell-overlay)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1553 (= 0 (setq arg (1- arg))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1554 (throw 'exit t)))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1555 (save-excursion
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1556 (goto-char pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1557 (ispell-word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1558 (error "No word to correct before point."))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1559
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1560 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1561 ;* flyspell-display-next-corrections ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1562 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1563 (defun flyspell-display-next-corrections (corrections)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1564 (let ((string "Corrections:")
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1565 (l corrections)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1566 (pos '()))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1567 (while (< (length string) 80)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1568 (if (equal (car l) flyspell-auto-correct-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1569 (setq pos (cons (+ 1 (length string)) pos)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1570 (setq string (concat string " " (car l)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1571 (setq l (cdr l)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1572 (while (consp pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1573 (let ((num (car pos)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1574 (put-text-property num
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1575 (+ num (length flyspell-auto-correct-word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1576 'face
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1577 'flyspell-incorrect-face
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1578 string))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1579 (setq pos (cdr pos)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1580 (if (fboundp 'display-message)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1581 (display-message 'no-log string)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1582 (message string))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1583
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1584 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1585 ;* flyspell-abbrev-table ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1586 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1587 (defun flyspell-abbrev-table ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1588 (if flyspell-use-global-abbrev-table-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1589 global-abbrev-table
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1590 local-abbrev-table))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 ;* flyspell-auto-correct-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1595 (defun flyspell-auto-correct-word ()
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1596 "Correct the current word.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1597 This command proposes various successive corrections for the current word."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1598 (interactive)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1599 (let ((pos (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1600 (old-max (point-max)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1601 ;; use the correct dictionary
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1602 (flyspell-accept-buffer-local-defs)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1603 (if (and (eq flyspell-auto-correct-pos pos)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1604 (consp flyspell-auto-correct-region))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1605 ;; we have already been using the function at the same location
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1606 (let* ((start (car flyspell-auto-correct-region))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1607 (len (cdr flyspell-auto-correct-region)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1608 (delete-region start (+ start len))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1609 (setq flyspell-auto-correct-ring (cdr flyspell-auto-correct-ring))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1610 (let* ((word (car flyspell-auto-correct-ring))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1611 (len (length word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1612 (rplacd flyspell-auto-correct-region len)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1613 (goto-char start)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1614 (if flyspell-abbrev-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1615 (if (flyspell-already-abbrevp (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1616 flyspell-auto-correct-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1617 (flyspell-change-abbrev (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1618 flyspell-auto-correct-word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1619 word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1620 (define-abbrev (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1621 flyspell-auto-correct-word word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1622 (insert word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1623 (flyspell-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1624 (flyspell-display-next-corrections flyspell-auto-correct-ring))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1625 (flyspell-ajust-cursor-point pos (point) old-max)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1626 (setq flyspell-auto-correct-pos (point)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1627 ;; fetch the word to be checked
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1628 (let ((word (flyspell-get-word nil))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1629 start end poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1630 ;; destructure return word info list.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1631 (setq start (car (cdr word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1632 end (car (cdr (cdr word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1633 word (car word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1634 (setq flyspell-auto-correct-word word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1635 ;; now check spelling of word.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1636 (process-send-string ispell-process "%\n") ;put in verbose mode
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1637 (process-send-string ispell-process (concat "^" word "\n"))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1638 ;; wait until ispell has processed word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1639 (while (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1640 (accept-process-output ispell-process)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1641 (not (string= "" (car ispell-filter)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1642 (setq ispell-filter (cdr ispell-filter))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1643 (if (consp ispell-filter)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1644 (setq poss (ispell-parse-output (car ispell-filter))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1645 (cond ((or (eq poss t) (stringp poss))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1646 ;; don't correct word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1647 t)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1648 ((null poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1649 ;; ispell error
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1650 (error "Ispell: error in Ispell process"))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1651 (t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1652 ;; the word is incorrect, we have to propose a replacement
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1653 (let ((replacements (if flyspell-sort-corrections
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1654 (sort (car (cdr (cdr poss))) 'string<)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1655 (car (cdr (cdr poss))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1656 (setq flyspell-auto-correct-region nil)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1657 (if (consp replacements)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1658 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1659 (let ((replace (car replacements)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1660 (let ((new-word replace))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1661 (if (not (equal new-word (car poss)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1662 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1663 ;; the save the current replacements
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1664 (setq flyspell-auto-correct-region
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1665 (cons start (length new-word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1666 (let ((l replacements))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1667 (while (consp (cdr l))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1668 (setq l (cdr l)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1669 (rplacd l (cons (car poss) replacements)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1670 (setq flyspell-auto-correct-ring
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1671 replacements)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1672 (delete-region start end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1673 (insert new-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1674 (if flyspell-abbrev-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1675 (if (flyspell-already-abbrevp
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1676 (flyspell-abbrev-table) word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1677 (flyspell-change-abbrev
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1678 (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1679 word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1680 new-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1681 (define-abbrev (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1682 word new-word)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1683 (flyspell-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1684 (flyspell-display-next-corrections
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1685 (cons new-word flyspell-auto-correct-ring))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1686 (flyspell-ajust-cursor-point pos
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1687 (point)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1688 old-max))))))))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1689 (setq flyspell-auto-correct-pos (point))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1690 (ispell-pdict-save t)))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1693 ;* flyspell-correct-word ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1694 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1695 (defun flyspell-correct-word (event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1696 "Check spelling of word under or before the cursor.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1697 If the word is not found in dictionary, display possible corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1698 in a popup menu allowing you to choose one.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1699
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1700 Word syntax described by `ispell-dictionary-alist' (which see).
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1701
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1702 This will check or reload the dictionary. Use \\[ispell-change-dictionary]
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1703 or \\[ispell-region] to update the Ispell process."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1704 (interactive "e")
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1705 (if (eq flyspell-emacs 'xemacs)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1706 (flyspell-correct-word/mouse-keymap event)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1707 (flyspell-correct-word/local-keymap event)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1708
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1709 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1710 ;* flyspell-correct-word/local-keymap ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1711 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1712 (defun flyspell-correct-word/local-keymap (event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1713 "emacs 19.xx seems to be buggous. Overlay keymap does not seems
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1714 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
1715 defined for the overlay keymap, the current local map, is not
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1716 checked. The binding is resolved with the global map. The
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1717 consequence is that we can not use overlay map with flyspell."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1718 (interactive "e")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1719 (save-window-excursion
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1720 (let ((save (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1721 (mouse-set-point event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1722 ;; we look for a flyspell overlay here
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1723 (let ((overlays (overlays-at (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1724 (overlay nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1725 (while (consp overlays)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 (if (flyspell-overlay-p (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1727 (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 (setq overlay (car overlays))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1729 (setq overlays nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 (setq overlays (cdr overlays))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 ;; we return to the correct location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 (goto-char save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1733 ;; we check to see if button2 has been used overlay a
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1734 ;; flyspell overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1735 (if overlay
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 ;; yes, so we use the flyspell function
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 (flyspell-correct-word/mouse-keymap event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 ;; no so we have to use the non flyspell binding
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 (let ((flyspell-mode nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 (if (key-binding (this-command-keys))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 (command-execute (key-binding (this-command-keys))))))))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1744 ;* flyspell-correct-word/mouse-keymap ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 (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
1747 "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
1748 The word checked is the word at the mouse position."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 (interactive "e")
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 ;; use the correct dictionary
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1751 (flyspell-accept-buffer-local-defs)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 ;; 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
1753 (let ((save (point)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (mouse-set-point event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1755 (let ((cursor-location (point))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (word (flyspell-get-word nil))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 start end poss replace)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1758 ;; destructure return word info list.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 (setq start (car (cdr word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1760 end (car (cdr (cdr word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 word (car word))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 ;; now check spelling of word.
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (process-send-string ispell-process "%\n") ;put in verbose mode
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 (process-send-string ispell-process (concat "^" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 ;; wait until ispell has processed word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 (while (progn
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 (accept-process-output ispell-process)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 (not (string= "" (car ispell-filter)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (setq ispell-filter (cdr ispell-filter))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1770 (if (consp ispell-filter)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1771 (setq poss (ispell-parse-output (car ispell-filter))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1772 (cond ((or (eq poss t) (stringp poss))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1773 ;; don't correct word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1774 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1775 ((null poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 ;; ispell error
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 (error "Ispell: error in Ispell process"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 ((string-match "GNU" (emacs-version))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 ;; 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
1780 (setq replace (flyspell-emacs-popup event poss word))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 (cond ((eq replace 'ignore)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1782 (goto-char save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1783 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1784 ((eq replace 'save)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1785 (goto-char save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1786 (process-send-string ispell-process (concat "*" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1787 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1788 (setq ispell-pdict-modified-p '(t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 ((or (eq replace 'buffer) (eq replace 'session))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 (process-send-string ispell-process (concat "@" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (if (null ispell-pdict-modified-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (setq ispell-pdict-modified-p
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (list ispell-pdict-modified-p)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 (flyspell-unhighlight-at cursor-location)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1795 (goto-char save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 (if (eq replace 'buffer)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 (ispell-add-per-file-word-list word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 (replace
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1799 (let ((new-word (if (atom replace)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1800 replace
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1801 (car replace)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1802 (cursor-location (+ (- (length word) (- end start))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1803 cursor-location)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1804 (if (not (equal new-word (car poss)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1805 (let ((old-max (point-max)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1806 (delete-region start end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1807 (insert new-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1808 (if flyspell-abbrev-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1809 (define-abbrev (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1810 word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1811 new-word))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1812 (flyspell-ajust-cursor-point save
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1813 cursor-location
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1814 old-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1815 (t
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1816 (goto-char save)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1817 nil)))
27787
d40d47971e6b (flyspell-mouse-map): Change definition
Dave Love <fx@gnu.org>
parents: 24943
diff changeset
1818 ((eq flyspell-emacs 'xemacs)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (flyspell-xemacs-popup
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1820 event poss word cursor-location start end save)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1821 (goto-char save)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1822 (ispell-pdict-save t))))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 ;*---------------------------------------------------------------------*/
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 ;* flyspell-xemacs-correct ... */
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1827 (defun flyspell-xemacs-correct (replace poss word cursor-location start end save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 "The xemacs popup menu callback."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 (cond ((eq replace 'ignore)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 nil)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 ((eq replace 'save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 (process-send-string ispell-process (concat "*" word "\n"))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1833 (process-send-string ispell-process "#\n")
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1835 (setq ispell-pdict-modified-p '(t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 ((or (eq replace 'buffer) (eq replace 'session))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (process-send-string ispell-process (concat "@" word "\n"))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 (flyspell-unhighlight-at cursor-location)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (if (null ispell-pdict-modified-p)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 (setq ispell-pdict-modified-p
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 (list ispell-pdict-modified-p)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (if (eq replace 'buffer)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (ispell-add-per-file-word-list word)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 (replace
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1845 (let ((old-max (point-max))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1846 (new-word (if (atom replace)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1847 replace
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1848 (car replace)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1849 (cursor-location (+ (- (length word) (- end start))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1850 cursor-location)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1851 (if (not (equal new-word (car poss)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1852 (progn
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1853 (delete-region start end)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1854 (goto-char start)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1855 (insert new-word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1856 (if flyspell-abbrev-p
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1857 (define-abbrev (flyspell-abbrev-table)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1858 word
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1859 new-word))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1860 (flyspell-ajust-cursor-point save cursor-location old-max)))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1861
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1862 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1863 ;* flyspell-ajust-cursor-point ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1864 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1865 (defun flyspell-ajust-cursor-point (save cursor-location old-max)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1866 (if (>= save cursor-location)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1867 (let ((new-pos (+ save (- (point-max) old-max))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1868 (goto-char (cond
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1869 ((< new-pos (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1870 (point-min))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1871 ((> new-pos (point-max))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1872 (point-max))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1873 (t new-pos))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1874 (goto-char save)))
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1875
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1876 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
1877 ;* flyspell-emacs-popup ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 ;*---------------------------------------------------------------------*/
22844
1104a715c324 (flyspell-emacs-popup): Renamed from flyspell-gnuemacs-popup. Callers changed.
Richard M. Stallman <rms@gnu.org>
parents: 22648
diff changeset
1879 (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
1880 "The Emacs popup menu."
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1881 (if (not event)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1882 (let* ((mouse-pos (mouse-position))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1883 (mouse-pos (if (nth 1 mouse-pos)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1884 mouse-pos
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1885 (set-mouse-position (car mouse-pos)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1886 (/ (frame-width) 2) 2)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1887 (unfocus-frame)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1888 (mouse-position))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1889 (setq event (list (list (car (cdr mouse-pos))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1890 (1+ (cdr (cdr mouse-pos))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1891 (car mouse-pos)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1892 (let* ((corrects (if flyspell-sort-corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 (sort (car (cdr (cdr poss))) 'string<)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 (car (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 (cor-menu (if (consp corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 (mapcar (lambda (correct)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 (list correct correct))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 '()))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (affix (car (cdr (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 (base-menu (let ((save (if (consp affix)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 (list
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1903 (list (concat "Save affix: " (car affix))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1904 'save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1905 '("Accept (session)" accept)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1906 '("Accept (buffer)" buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1907 '(("Save word" save)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 ("Accept (session)" session)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 ("Accept (buffer)" buffer)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 (if (consp cor-menu)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1911 (append cor-menu (cons "" save))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 save)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 (menu (cons "flyspell correction menu" base-menu)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 (car (x-popup-menu event
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1915 (list (format "%s [%s]" word (or ispell-local-dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 ispell-dictionary))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 menu)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1918
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1919 ;*---------------------------------------------------------------------*/
22891
780c3ef895d7 (flyspell-duplicate-distance): Doc fix; change default to 10000.
Richard M. Stallman <rms@gnu.org>
parents: 22844
diff changeset
1920 ;* flyspell-xemacs-popup ... */
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921 ;*---------------------------------------------------------------------*/
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1922 (defun flyspell-xemacs-popup (event poss word cursor-location start end save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 "The xemacs popup menu."
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (let* ((corrects (if flyspell-sort-corrections
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 (sort (car (cdr (cdr poss))) 'string<)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 (car (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 (cor-menu (if (consp corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 (mapcar (lambda (correct)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 (vector correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 start
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1936 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1937 save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1938 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1939 corrects)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1940 '()))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (affix (car (cdr (cdr (cdr poss)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1942 (menu (let ((save (if (consp affix)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1943 (vector
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1944 (concat "Save affix: " (car affix))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1945 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 ''save
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 start
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1951 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1952 save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 t)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1954 (vector
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1955 "Save word"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1956 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1957 ''save
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 start
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1962 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1963 save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 (session (vector "Accept (session)"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 ''session
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 start
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1972 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1973 save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 t))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 (buffer (vector "Accept (buffer)"
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 (list 'flyspell-xemacs-correct
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 ''buffer
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 (list 'quote poss)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1979 word
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 cursor-location
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 start
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1982 end
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1983 save)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 t)))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1985 (if (consp cor-menu)
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (append cor-menu (list "-" save session buffer))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 (list save session buffer)))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 (popup-menu (cons (format "%s [%s]" word (or ispell-local-dictionary
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 ispell-dictionary))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 menu))))
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1992 ;*---------------------------------------------------------------------*/
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
1993 ;* Some example functions for real autocrrecting xb */
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1994 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1995 (defun flyspell-maybe-correct-transposition (beg end poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1996 "Apply 'transpose-chars' to all points in the region BEG to END and
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1997 return t if any those result in a possible replacement suggested by ispell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1998 in POSS. Otherwise the change is undone.
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
1999
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2000 This function is meant to be added to 'flyspell-incorrect-hook'."
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2001 (when (consp poss)
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2002 (catch 'done
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2003 (let ((str (buffer-substring beg end))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2004 (i 0) (len (- end beg)) tmp)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2005 (while (< (1+ i) len)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2006 (setq tmp (aref str i))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2007 (aset str i (aref str (1+ i)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2008 (aset str (1+ i) tmp)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2009 (when (member str (nth 2 poss))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2010 (save-excursion
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2011 (goto-char (+ beg i 1))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2012 (transpose-chars 1))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2013 (throw 'done t))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2014 (setq tmp (aref str i))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2015 (aset str i (aref str (1+ i)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2016 (aset str (1+ i) tmp)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2017 (setq i (1+ i))))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2018 nil)))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2019
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2020 (defun flyspell-maybe-correct-doubling (beg end poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2021 "For each doubled charachter in the region BEG to END, remove one and
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2022 return t if any those result in a possible replacement suggested by ispell
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2023 in POSS. Otherwise the change is undone.
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2024
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2025 This function is meant to be added to 'flyspell-incorrect-hook'."
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2026 (when (consp poss)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2027 (catch 'done
33020
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2028 (let ((str (buffer-substring beg end))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2029 (i 0) (len (- end beg)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2030 (while (< (1+ i) len)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2031 (when (and (= (aref str i) (aref str (1+ i)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2032 (member (concat (substring str 0 (1+ i))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2033 (substring str (+ i 2)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2034 (nth 2 poss)))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2035 (goto-char (+ beg i))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2036 (delete-char 1)
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2037 (throw 'done t))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2038 (setq i (1+ i))))
e21feeab77fb See ChangeLog
John Wiegley <johnw@newartisans.com>
parents: 30470
diff changeset
2039 nil)))
30428
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2040
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2041 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2042 ;* flyspell-already-abbrevp ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2043 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2044 (defun flyspell-already-abbrevp (table word)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2045 (let ((sym (abbrev-symbol word table)))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2046 (and sym (symbolp sym))))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2047
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2048 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2049 ;* flyspell-change-abbrev ... */
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2050 ;*---------------------------------------------------------------------*/
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2051 (defun flyspell-change-abbrev (table old new)
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2052 (set (abbrev-symbol old table) new))
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2053
b7b96f09059d Update to author's version 1.5d.
Gerd Moellmann <gerd@gnu.org>
parents: 27787
diff changeset
2054 (provide 'flyspell)
22611
38463342cd56 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2055 ;;; flyspell.el ends here