annotate lisp/textmodes/flyspell.el @ 39465:6912cef77269

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