diff options
| author | Stefan Monnier | 2005-11-16 17:00:29 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-11-16 17:00:29 +0000 |
| commit | 042c6fb7c7072eb01c17e04668e2c5f5f66e5887 (patch) | |
| tree | d83e0df9e5c12bfa9d608dab724da69c50feb5e5 | |
| parent | 9f7b984baef1351ccd203ddfcad11fa574931a1c (diff) | |
| download | emacs-042c6fb7c7072eb01c17e04668e2c5f5f66e5887.tar.gz emacs-042c6fb7c7072eb01c17e04668e2c5f5f66e5887.zip | |
Fix commenting convention. Remove unnecessary leading * in custom docstrings.
(flyspell-emacs): Remove unused var.
(flyspell-accept-buffer-local-defs): Use save-current-buffer.
(flyspell-debug-signal-no-check, flyspell-debug-signal-changed-checked)
(flyspell-debug-signal-pre-word-checked, flyspell-post-command-hook)
(flyspell-debug-signal-word-checked): Use with-current-buffer.
(make-flyspell-overlay): Don't locally reuse a global name.
(flyspell-highlight-incorrect-region)
(flyspell-highlight-duplicate-region): Use flyspell-unhighlight-at.
(flyspell-check-previous-highlighted-word): Use flyspell-overlay-p.
(flyspell-notify-misspell): Remove unused args `start' and `end'.
(flyspell-word): Adjust call accordingly. Use ispell-send-string.
Wrap calls to accept-process-output inside with-local-quit since it's
often called from a post-command-hook.
(flyspell-correct-word, flyspell-auto-correct-word): Use ispell-send-string.
(flyspell-xemacs-popup): Remove unused arg `event'. Update call.
| -rw-r--r-- | lisp/ChangeLog | 21 | ||||
| -rw-r--r-- | lisp/textmodes/flyspell.el | 763 |
2 files changed, 381 insertions, 403 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 018fd0b4664..119f6848294 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,24 @@ | |||
| 1 | 2005-11-16 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2005-11-16 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * textmodes/flyspell.el (flyspell-delete-region-overlays): Use | 3 | * textmodes/flyspell.el: Fix commenting convention. |
| 4 | remove-overlays. | 4 | Remove unnecessary leading * in custom docstrings. |
| 5 | (flyspell-emacs): Remove unused var. | ||
| 6 | (flyspell-delete-region-overlays): Use remove-overlays. | ||
| 7 | (flyspell-accept-buffer-local-defs): Use save-current-buffer. | ||
| 8 | (flyspell-debug-signal-no-check, flyspell-debug-signal-changed-checked) | ||
| 9 | (flyspell-debug-signal-pre-word-checked, flyspell-post-command-hook) | ||
| 10 | (flyspell-debug-signal-word-checked): Use with-current-buffer. | ||
| 11 | (make-flyspell-overlay): Don't locally reuse a global name. | ||
| 12 | (flyspell-highlight-incorrect-region) | ||
| 13 | (flyspell-highlight-duplicate-region): Use flyspell-unhighlight-at. | ||
| 14 | (flyspell-check-previous-highlighted-word): Use flyspell-overlay-p. | ||
| 15 | (flyspell-notify-misspell): Remove unused args `start' and `end'. | ||
| 16 | (flyspell-word): Adjust call accordingly. Use ispell-send-string. | ||
| 17 | Wrap calls to accept-process-output inside with-local-quit since it's | ||
| 18 | often called from a post-command-hook. | ||
| 19 | (flyspell-correct-word, flyspell-auto-correct-word): | ||
| 20 | Use ispell-send-string. | ||
| 21 | (flyspell-xemacs-popup): Remove unused arg `event'. Update call. | ||
| 5 | 22 | ||
| 6 | * calendar/diary-lib.el (diary-list-entries): Also hide the | 23 | * calendar/diary-lib.el (diary-list-entries): Also hide the |
| 7 | terminating newline. | 24 | terminating newline. |
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 33e66978cb5..dd718e21ed9 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -46,9 +46,9 @@ | |||
| 46 | 46 | ||
| 47 | (require 'ispell) | 47 | (require 'ispell) |
| 48 | 48 | ||
| 49 | ;*---------------------------------------------------------------------*/ | 49 | ;;*---------------------------------------------------------------------*/ |
| 50 | ;* Group ... */ | 50 | ;;* Group ... */ |
| 51 | ;*---------------------------------------------------------------------*/ | 51 | ;;*---------------------------------------------------------------------*/ |
| 52 | (defgroup flyspell nil | 52 | (defgroup flyspell nil |
| 53 | "Spell checking on the fly." | 53 | "Spell checking on the fly." |
| 54 | :tag "FlySpell" | 54 | :tag "FlySpell" |
| @@ -56,41 +56,30 @@ | |||
| 56 | :group 'ispell | 56 | :group 'ispell |
| 57 | :group 'processes) | 57 | :group 'processes) |
| 58 | 58 | ||
| 59 | ;*---------------------------------------------------------------------*/ | 59 | ;;*---------------------------------------------------------------------*/ |
| 60 | ;* Which emacs are we currently running */ | 60 | ;;* User configuration ... */ |
| 61 | ;*---------------------------------------------------------------------*/ | 61 | ;;*---------------------------------------------------------------------*/ |
| 62 | (defvar flyspell-emacs | ||
| 63 | (cond | ||
| 64 | ((string-match "XEmacs" emacs-version) | ||
| 65 | 'xemacs) | ||
| 66 | (t | ||
| 67 | 'emacs)) | ||
| 68 | "The type of Emacs we are currently running.") | ||
| 69 | |||
| 70 | ;*---------------------------------------------------------------------*/ | ||
| 71 | ;* User configuration ... */ | ||
| 72 | ;*---------------------------------------------------------------------*/ | ||
| 73 | (defcustom flyspell-highlight-flag t | 62 | (defcustom flyspell-highlight-flag t |
| 74 | "*How Flyspell should indicate misspelled words. | 63 | "How Flyspell should indicate misspelled words. |
| 75 | Non-nil means use highlight, nil means use minibuffer messages." | 64 | Non-nil means use highlight, nil means use minibuffer messages." |
| 76 | :group 'flyspell | 65 | :group 'flyspell |
| 77 | :type 'boolean) | 66 | :type 'boolean) |
| 78 | 67 | ||
| 79 | (defcustom flyspell-mark-duplications-flag t | 68 | (defcustom flyspell-mark-duplications-flag t |
| 80 | "*Non-nil means Flyspell reports a repeated word as an error. | 69 | "Non-nil means Flyspell reports a repeated word as an error. |
| 81 | Detection of repeated words is not implemented in | 70 | Detection of repeated words is not implemented in |
| 82 | \"large\" regions; see `flyspell-large-region'." | 71 | \"large\" regions; see `flyspell-large-region'." |
| 83 | :group 'flyspell | 72 | :group 'flyspell |
| 84 | :type 'boolean) | 73 | :type 'boolean) |
| 85 | 74 | ||
| 86 | (defcustom flyspell-sort-corrections nil | 75 | (defcustom flyspell-sort-corrections nil |
| 87 | "*Non-nil means, sort the corrections alphabetically before popping them." | 76 | "Non-nil means, sort the corrections alphabetically before popping them." |
| 88 | :group 'flyspell | 77 | :group 'flyspell |
| 89 | :version "21.1" | 78 | :version "21.1" |
| 90 | :type 'boolean) | 79 | :type 'boolean) |
| 91 | 80 | ||
| 92 | (defcustom flyspell-duplicate-distance -1 | 81 | (defcustom flyspell-duplicate-distance -1 |
| 93 | "*The maximum distance for finding duplicates of unrecognized words. | 82 | "The maximum distance for finding duplicates of unrecognized words. |
| 94 | This applies to the feature that when a word is not found in the dictionary, | 83 | This applies to the feature that when a word is not found in the dictionary, |
| 95 | if the same spelling occurs elsewhere in the buffer, | 84 | if the same spelling occurs elsewhere in the buffer, |
| 96 | Flyspell uses a different face (`flyspell-duplicate') to highlight it. | 85 | Flyspell uses a different face (`flyspell-duplicate') to highlight it. |
| @@ -102,19 +91,19 @@ This variable specifies how far to search to find such a duplicate. | |||
| 102 | :type 'number) | 91 | :type 'number) |
| 103 | 92 | ||
| 104 | (defcustom flyspell-delay 3 | 93 | (defcustom flyspell-delay 3 |
| 105 | "*The number of seconds to wait before checking, after a \"delayed\" command." | 94 | "The number of seconds to wait before checking, after a \"delayed\" command." |
| 106 | :group 'flyspell | 95 | :group 'flyspell |
| 107 | :type 'number) | 96 | :type 'number) |
| 108 | 97 | ||
| 109 | (defcustom flyspell-persistent-highlight t | 98 | (defcustom flyspell-persistent-highlight t |
| 110 | "*Non-nil means misspelled words remain highlighted until corrected. | 99 | "Non-nil means misspelled words remain highlighted until corrected. |
| 111 | If this variable is nil, only the most recently detected misspelled word | 100 | If this variable is nil, only the most recently detected misspelled word |
| 112 | is highlighted." | 101 | is highlighted." |
| 113 | :group 'flyspell | 102 | :group 'flyspell |
| 114 | :type 'boolean) | 103 | :type 'boolean) |
| 115 | 104 | ||
| 116 | (defcustom flyspell-highlight-properties t | 105 | (defcustom flyspell-highlight-properties t |
| 117 | "*Non-nil means highlight incorrect words even if a property exists for this word." | 106 | "Non-nil means highlight incorrect words even if a property exists for this word." |
| 118 | :group 'flyspell | 107 | :group 'flyspell |
| 119 | :type 'boolean) | 108 | :type 'boolean) |
| 120 | 109 | ||
| @@ -158,17 +147,17 @@ command was not the very same command." | |||
| 158 | :type '(repeat (symbol))) | 147 | :type '(repeat (symbol))) |
| 159 | 148 | ||
| 160 | (defcustom flyspell-issue-welcome-flag t | 149 | (defcustom flyspell-issue-welcome-flag t |
| 161 | "*Non-nil means that Flyspell should display a welcome message when started." | 150 | "Non-nil means that Flyspell should display a welcome message when started." |
| 162 | :group 'flyspell | 151 | :group 'flyspell |
| 163 | :type 'boolean) | 152 | :type 'boolean) |
| 164 | 153 | ||
| 165 | (defcustom flyspell-issue-message-flag t | 154 | (defcustom flyspell-issue-message-flag t |
| 166 | "*Non-nil means that Flyspell emits messages when checking words." | 155 | "Non-nil means that Flyspell emits messages when checking words." |
| 167 | :group 'flyspell | 156 | :group 'flyspell |
| 168 | :type 'boolean) | 157 | :type 'boolean) |
| 169 | 158 | ||
| 170 | (defcustom flyspell-incorrect-hook nil | 159 | (defcustom flyspell-incorrect-hook nil |
| 171 | "*List of functions to be called when incorrect words are encountered. | 160 | "List of functions to be called when incorrect words are encountered. |
| 172 | Each function is given three arguments. The first two | 161 | Each function is given three arguments. The first two |
| 173 | arguments are the beginning and the end of the incorrect region. | 162 | arguments are the beginning and the end of the incorrect region. |
| 174 | The third is either the symbol `doublon' or the list | 163 | The third is either the symbol `doublon' or the list |
| @@ -200,7 +189,7 @@ Ispell's ultimate default dictionary." | |||
| 200 | :type 'string) | 189 | :type 'string) |
| 201 | 190 | ||
| 202 | (defcustom flyspell-check-tex-math-command nil | 191 | (defcustom flyspell-check-tex-math-command nil |
| 203 | "*Non nil means check even inside TeX math environment. | 192 | "Non nil means check even inside TeX math environment. |
| 204 | TeX math environments are discovered by the TEXMATHP that implemented | 193 | TeX math environments are discovered by the TEXMATHP that implemented |
| 205 | inside the texmathp.el Emacs package. That package may be found at: | 194 | inside the texmathp.el Emacs package. That package may be found at: |
| 206 | http://strw.leidenuniv.nl/~dominik/Tools" | 195 | http://strw.leidenuniv.nl/~dominik/Tools" |
| @@ -216,26 +205,26 @@ http://strw.leidenuniv.nl/~dominik/Tools" | |||
| 216 | 205 | ||
| 217 | (defcustom flyspell-abbrev-p | 206 | (defcustom flyspell-abbrev-p |
| 218 | nil | 207 | nil |
| 219 | "*If non-nil, add correction to abbreviation table." | 208 | "If non-nil, add correction to abbreviation table." |
| 220 | :group 'flyspell | 209 | :group 'flyspell |
| 221 | :version "21.1" | 210 | :version "21.1" |
| 222 | :type 'boolean) | 211 | :type 'boolean) |
| 223 | 212 | ||
| 224 | (defcustom flyspell-use-global-abbrev-table-p | 213 | (defcustom flyspell-use-global-abbrev-table-p |
| 225 | nil | 214 | nil |
| 226 | "*If non-nil, prefer global abbrev table to local abbrev table." | 215 | "If non-nil, prefer global abbrev table to local abbrev table." |
| 227 | :group 'flyspell | 216 | :group 'flyspell |
| 228 | :version "21.1" | 217 | :version "21.1" |
| 229 | :type 'boolean) | 218 | :type 'boolean) |
| 230 | 219 | ||
| 231 | (defcustom flyspell-mode-line-string " Fly" | 220 | (defcustom flyspell-mode-line-string " Fly" |
| 232 | "*String displayed on the modeline when flyspell is active. | 221 | "String displayed on the modeline when flyspell is active. |
| 233 | Set this to nil if you don't want a modeline indicator." | 222 | Set this to nil if you don't want a modeline indicator." |
| 234 | :group 'flyspell | 223 | :group 'flyspell |
| 235 | :type '(choice string (const :tag "None" nil))) | 224 | :type '(choice string (const :tag "None" nil))) |
| 236 | 225 | ||
| 237 | (defcustom flyspell-large-region 1000 | 226 | (defcustom flyspell-large-region 1000 |
| 238 | "*The threshold that determines if a region is small. | 227 | "The threshold that determines if a region is small. |
| 239 | If the region is smaller than this number of characters, | 228 | If the region is smaller than this number of characters, |
| 240 | `flyspell-region' checks the words sequentially using regular | 229 | `flyspell-region' checks the words sequentially using regular |
| 241 | flyspell methods. Else, if the region is large, a new Ispell process is | 230 | flyspell methods. Else, if the region is large, a new Ispell process is |
| @@ -250,7 +239,7 @@ If `flyspell-large-region' is nil, all regions are treated as small." | |||
| 250 | :type '(choice number (const :tag "All small" nil))) | 239 | :type '(choice number (const :tag "All small" nil))) |
| 251 | 240 | ||
| 252 | (defcustom flyspell-insert-function (function insert) | 241 | (defcustom flyspell-insert-function (function insert) |
| 253 | "*Function for inserting word by flyspell upon correction." | 242 | "Function for inserting word by flyspell upon correction." |
| 254 | :group 'flyspell | 243 | :group 'flyspell |
| 255 | :type 'function) | 244 | :type 'function) |
| 256 | 245 | ||
| @@ -265,7 +254,7 @@ If `flyspell-large-region' is nil, all regions are treated as small." | |||
| 265 | :type '(choice string (const nil))) | 254 | :type '(choice string (const nil))) |
| 266 | 255 | ||
| 267 | (defcustom flyspell-use-meta-tab t | 256 | (defcustom flyspell-use-meta-tab t |
| 268 | "*Non-nil means that flyspell uses META-TAB to correct word." | 257 | "Non-nil means that flyspell uses M-TAB to correct word." |
| 269 | :group 'flyspell | 258 | :group 'flyspell |
| 270 | :type 'boolean) | 259 | :type 'boolean) |
| 271 | 260 | ||
| @@ -274,17 +263,17 @@ If `flyspell-large-region' is nil, all regions are treated as small." | |||
| 274 | "The key binding for flyspell auto correction." | 263 | "The key binding for flyspell auto correction." |
| 275 | :group 'flyspell) | 264 | :group 'flyspell) |
| 276 | 265 | ||
| 277 | ;*---------------------------------------------------------------------*/ | 266 | ;;*---------------------------------------------------------------------*/ |
| 278 | ;* Mode specific options */ | 267 | ;;* Mode specific options */ |
| 279 | ;* ------------------------------------------------------------- */ | 268 | ;;* ------------------------------------------------------------- */ |
| 280 | ;* Mode specific options enable users to disable flyspell on */ | 269 | ;;* Mode specific options enable users to disable flyspell on */ |
| 281 | ;* certain word depending of the emacs mode. For instance, when */ | 270 | ;;* certain word depending of the emacs mode. For instance, when */ |
| 282 | ;* using flyspell with mail-mode add the following expression */ | 271 | ;;* using flyspell with mail-mode add the following expression */ |
| 283 | ;* in your .emacs file: */ | 272 | ;;* in your .emacs file: */ |
| 284 | ;* (add-hook 'mail-mode */ | 273 | ;;* (add-hook 'mail-mode */ |
| 285 | ;* '(lambda () (setq flyspell-generic-check-word-p */ | 274 | ;;* '(lambda () (setq flyspell-generic-check-word-p */ |
| 286 | ;* 'mail-mode-flyspell-verify))) */ | 275 | ;;* 'mail-mode-flyspell-verify))) */ |
| 287 | ;*---------------------------------------------------------------------*/ | 276 | ;;*---------------------------------------------------------------------*/ |
| 288 | (defvar flyspell-generic-check-word-p nil | 277 | (defvar flyspell-generic-check-word-p nil |
| 289 | "Function providing per-mode customization over which words are flyspelled. | 278 | "Function providing per-mode customization over which words are flyspelled. |
| 290 | Returns t to continue checking, nil otherwise. | 279 | Returns t to continue checking, nil otherwise. |
| @@ -292,7 +281,7 @@ Flyspell mode sets this variable to whatever is the `flyspell-mode-predicate' | |||
| 292 | property of the major mode name.") | 281 | property of the major mode name.") |
| 293 | (make-variable-buffer-local 'flyspell-generic-check-word-p) | 282 | (make-variable-buffer-local 'flyspell-generic-check-word-p) |
| 294 | 283 | ||
| 295 | ;*--- mail mode -------------------------------------------------------*/ | 284 | ;;*--- mail mode -------------------------------------------------------*/ |
| 296 | (put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) | 285 | (put 'mail-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) |
| 297 | (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) | 286 | (put 'message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) |
| 298 | (defun mail-mode-flyspell-verify () | 287 | (defun mail-mode-flyspell-verify () |
| @@ -321,7 +310,7 @@ property of the major mode name.") | |||
| 321 | (beginning-of-line) | 310 | (beginning-of-line) |
| 322 | (not (looking-at "[>}|]\\|To:"))))))) | 311 | (not (looking-at "[>}|]\\|To:"))))))) |
| 323 | 312 | ||
| 324 | ;*--- texinfo mode ----------------------------------------------------*/ | 313 | ;;*--- texinfo mode ----------------------------------------------------*/ |
| 325 | (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify) | 314 | (put 'texinfo-mode 'flyspell-mode-predicate 'texinfo-mode-flyspell-verify) |
| 326 | (defun texinfo-mode-flyspell-verify () | 315 | (defun texinfo-mode-flyspell-verify () |
| 327 | "This function is used for `flyspell-generic-check-word-p' in Texinfo mode." | 316 | "This function is used for `flyspell-generic-check-word-p' in Texinfo mode." |
| @@ -329,7 +318,7 @@ property of the major mode name.") | |||
| 329 | (forward-word -1) | 318 | (forward-word -1) |
| 330 | (not (looking-at "@")))) | 319 | (not (looking-at "@")))) |
| 331 | 320 | ||
| 332 | ;*--- tex mode --------------------------------------------------------*/ | 321 | ;;*--- tex mode --------------------------------------------------------*/ |
| 333 | (put 'tex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify) | 322 | (put 'tex-mode 'flyspell-mode-predicate 'tex-mode-flyspell-verify) |
| 334 | (defun tex-mode-flyspell-verify () | 323 | (defun tex-mode-flyspell-verify () |
| 335 | "This function is used for `flyspell-generic-check-word-p' in LaTeX mode." | 324 | "This function is used for `flyspell-generic-check-word-p' in LaTeX mode." |
| @@ -344,7 +333,7 @@ property of the major mode name.") | |||
| 344 | (and (>= this (match-beginning 0)) | 333 | (and (>= this (match-beginning 0)) |
| 345 | (<= this (match-end 0)) ))))))) | 334 | (<= this (match-end 0)) ))))))) |
| 346 | 335 | ||
| 347 | ;*--- sgml mode -------------------------------------------------------*/ | 336 | ;;*--- sgml mode -------------------------------------------------------*/ |
| 348 | (put 'sgml-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) | 337 | (put 'sgml-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) |
| 349 | (put 'html-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) | 338 | (put 'html-mode 'flyspell-mode-predicate 'sgml-mode-flyspell-verify) |
| 350 | 339 | ||
| @@ -371,9 +360,9 @@ property of the major mode name.") | |||
| 371 | (and (re-search-backward "&[^;]*" s t) | 360 | (and (re-search-backward "&[^;]*" s t) |
| 372 | (= (match-end 0) this))))))))) | 361 | (= (match-end 0) this))))))))) |
| 373 | 362 | ||
| 374 | ;*---------------------------------------------------------------------*/ | 363 | ;;*---------------------------------------------------------------------*/ |
| 375 | ;* Programming mode */ | 364 | ;;* Programming mode */ |
| 376 | ;*---------------------------------------------------------------------*/ | 365 | ;;*---------------------------------------------------------------------*/ |
| 377 | (defvar flyspell-prog-text-faces | 366 | (defvar flyspell-prog-text-faces |
| 378 | '(font-lock-string-face font-lock-comment-face font-lock-doc-face) | 367 | '(font-lock-string-face font-lock-comment-face font-lock-doc-face) |
| 379 | "Faces corresponding to text in programming-mode buffers.") | 368 | "Faces corresponding to text in programming-mode buffers.") |
| @@ -391,9 +380,9 @@ property of the major mode name.") | |||
| 391 | (flyspell-mode 1) | 380 | (flyspell-mode 1) |
| 392 | (run-hooks 'flyspell-prog-mode-hook)) | 381 | (run-hooks 'flyspell-prog-mode-hook)) |
| 393 | 382 | ||
| 394 | ;*---------------------------------------------------------------------*/ | 383 | ;;*---------------------------------------------------------------------*/ |
| 395 | ;* Overlay compatibility */ | 384 | ;;* Overlay compatibility */ |
| 396 | ;*---------------------------------------------------------------------*/ | 385 | ;;*---------------------------------------------------------------------*/ |
| 397 | (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) | 386 | (autoload 'make-overlay "overlay" "Overlay compatibility kit." t) |
| 398 | (autoload 'overlayp "overlay" "Overlay compatibility kit." t) | 387 | (autoload 'overlayp "overlay" "Overlay compatibility kit." t) |
| 399 | (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) | 388 | (autoload 'overlays-in "overlay" "Overlay compatibility kit." t) |
| @@ -403,9 +392,9 @@ property of the major mode name.") | |||
| 403 | (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) | 392 | (autoload 'overlay-get "overlay" "Overlay compatibility kit." t) |
| 404 | (autoload 'previous-overlay-change "overlay" "Overlay compatibility kit." t) | 393 | (autoload 'previous-overlay-change "overlay" "Overlay compatibility kit." t) |
| 405 | 394 | ||
| 406 | ;*---------------------------------------------------------------------*/ | 395 | ;;*---------------------------------------------------------------------*/ |
| 407 | ;* The minor mode declaration. */ | 396 | ;;* The minor mode declaration. */ |
| 408 | ;*---------------------------------------------------------------------*/ | 397 | ;;*---------------------------------------------------------------------*/ |
| 409 | (defvar flyspell-mouse-map | 398 | (defvar flyspell-mouse-map |
| 410 | (let ((map (make-sparse-keymap))) | 399 | (let ((map (make-sparse-keymap))) |
| 411 | (define-key map (if (featurep 'xemacs) [button2] [down-mouse-2]) | 400 | (define-key map (if (featurep 'xemacs) [button2] [down-mouse-2]) |
| @@ -432,9 +421,9 @@ property of the major mode name.") | |||
| 432 | (defvar flyspell-dash-local-dictionary nil) | 421 | (defvar flyspell-dash-local-dictionary nil) |
| 433 | (make-variable-buffer-local 'flyspell-dash-local-dictionary) | 422 | (make-variable-buffer-local 'flyspell-dash-local-dictionary) |
| 434 | 423 | ||
| 435 | ;*---------------------------------------------------------------------*/ | 424 | ;;*---------------------------------------------------------------------*/ |
| 436 | ;* Highlighting */ | 425 | ;;* Highlighting */ |
| 437 | ;*---------------------------------------------------------------------*/ | 426 | ;;*---------------------------------------------------------------------*/ |
| 438 | (defface flyspell-incorrect | 427 | (defface flyspell-incorrect |
| 439 | '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) | 428 | '((((class color)) (:foreground "OrangeRed" :bold t :underline t)) |
| 440 | (t (:bold t))) | 429 | (t (:bold t))) |
| @@ -454,9 +443,9 @@ See also `flyspell-duplicate-distance'." | |||
| 454 | 443 | ||
| 455 | (defvar flyspell-overlay nil) | 444 | (defvar flyspell-overlay nil) |
| 456 | 445 | ||
| 457 | ;*---------------------------------------------------------------------*/ | 446 | ;;*---------------------------------------------------------------------*/ |
| 458 | ;* flyspell-mode ... */ | 447 | ;;* flyspell-mode ... */ |
| 459 | ;*---------------------------------------------------------------------*/ | 448 | ;;*---------------------------------------------------------------------*/ |
| 460 | ;;;###autoload(defvar flyspell-mode nil) | 449 | ;;;###autoload(defvar flyspell-mode nil) |
| 461 | ;;;###autoload | 450 | ;;;###autoload |
| 462 | (define-minor-mode flyspell-mode | 451 | (define-minor-mode flyspell-mode |
| @@ -494,32 +483,31 @@ in your .emacs file. | |||
| 494 | (flyspell-mode-on) | 483 | (flyspell-mode-on) |
| 495 | (flyspell-mode-off))) | 484 | (flyspell-mode-off))) |
| 496 | 485 | ||
| 497 | ;*---------------------------------------------------------------------*/ | 486 | ;;*---------------------------------------------------------------------*/ |
| 498 | ;* flyspell-buffers ... */ | 487 | ;;* flyspell-buffers ... */ |
| 499 | ;* ------------------------------------------------------------- */ | 488 | ;;* ------------------------------------------------------------- */ |
| 500 | ;* For remembering buffers running flyspell */ | 489 | ;;* For remembering buffers running flyspell */ |
| 501 | ;*---------------------------------------------------------------------*/ | 490 | ;;*---------------------------------------------------------------------*/ |
| 502 | (defvar flyspell-buffers nil) | 491 | (defvar flyspell-buffers nil) |
| 503 | 492 | ||
| 504 | ;*---------------------------------------------------------------------*/ | 493 | ;;*---------------------------------------------------------------------*/ |
| 505 | ;* flyspell-minibuffer-p ... */ | 494 | ;;* flyspell-minibuffer-p ... */ |
| 506 | ;*---------------------------------------------------------------------*/ | 495 | ;;*---------------------------------------------------------------------*/ |
| 507 | (defun flyspell-minibuffer-p (buffer) | 496 | (defun flyspell-minibuffer-p (buffer) |
| 508 | "Is BUFFER a minibuffer?" | 497 | "Is BUFFER a minibuffer?" |
| 509 | (let ((ws (get-buffer-window-list buffer t))) | 498 | (let ((ws (get-buffer-window-list buffer t))) |
| 510 | (and (consp ws) (window-minibuffer-p (car ws))))) | 499 | (and (consp ws) (window-minibuffer-p (car ws))))) |
| 511 | 500 | ||
| 512 | ;*---------------------------------------------------------------------*/ | 501 | ;;*---------------------------------------------------------------------*/ |
| 513 | ;* flyspell-accept-buffer-local-defs ... */ | 502 | ;;* flyspell-accept-buffer-local-defs ... */ |
| 514 | ;*---------------------------------------------------------------------*/ | 503 | ;;*---------------------------------------------------------------------*/ |
| 515 | (defun flyspell-accept-buffer-local-defs () | 504 | (defun flyspell-accept-buffer-local-defs () |
| 516 | ;; strange problem. If buffer in current window has font-lock turned on, | 505 | ;; strange problem. If buffer in current window has font-lock turned on, |
| 517 | ;; but SET-BUFFER was called to point to an invisible buffer, this ispell | 506 | ;; but SET-BUFFER was called to point to an invisible buffer, this ispell |
| 518 | ;; call will reset the buffer to the buffer in the current window. However, | 507 | ;; call will reset the buffer to the buffer in the current window. However, |
| 519 | ;; it only happens at startup (fix by Albert L. Ting). | 508 | ;; it only happens at startup (fix by Albert L. Ting). |
| 520 | (let ((buf (current-buffer))) | 509 | (save-current-buffer |
| 521 | (ispell-accept-buffer-local-defs) | 510 | (ispell-accept-buffer-local-defs)) |
| 522 | (set-buffer buf)) | ||
| 523 | (if (not (and (eq flyspell-dash-dictionary ispell-dictionary) | 511 | (if (not (and (eq flyspell-dash-dictionary ispell-dictionary) |
| 524 | (eq flyspell-dash-local-dictionary ispell-local-dictionary))) | 512 | (eq flyspell-dash-local-dictionary ispell-local-dictionary))) |
| 525 | ;; The dictionary has changed | 513 | ;; The dictionary has changed |
| @@ -531,9 +519,9 @@ in your .emacs file. | |||
| 531 | (setq flyspell-consider-dash-as-word-delimiter-flag t) | 519 | (setq flyspell-consider-dash-as-word-delimiter-flag t) |
| 532 | (setq flyspell-consider-dash-as-word-delimiter-flag nil))))) | 520 | (setq flyspell-consider-dash-as-word-delimiter-flag nil))))) |
| 533 | 521 | ||
| 534 | ;*---------------------------------------------------------------------*/ | 522 | ;;*---------------------------------------------------------------------*/ |
| 535 | ;* flyspell-mode-on ... */ | 523 | ;;* flyspell-mode-on ... */ |
| 536 | ;*---------------------------------------------------------------------*/ | 524 | ;;*---------------------------------------------------------------------*/ |
| 537 | (defun flyspell-mode-on () | 525 | (defun flyspell-mode-on () |
| 538 | "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." | 526 | "Turn Flyspell mode on. Do not use this; use `flyspell-mode' instead." |
| 539 | (ispell-maybe-find-aspell-dictionaries) | 527 | (ispell-maybe-find-aspell-dictionaries) |
| @@ -576,17 +564,17 @@ in your .emacs file. | |||
| 576 | ;; we end with the flyspell hooks | 564 | ;; we end with the flyspell hooks |
| 577 | (run-hooks 'flyspell-mode-hook)) | 565 | (run-hooks 'flyspell-mode-hook)) |
| 578 | 566 | ||
| 579 | ;*---------------------------------------------------------------------*/ | 567 | ;;*---------------------------------------------------------------------*/ |
| 580 | ;* flyspell-delay-commands ... */ | 568 | ;;* flyspell-delay-commands ... */ |
| 581 | ;*---------------------------------------------------------------------*/ | 569 | ;;*---------------------------------------------------------------------*/ |
| 582 | (defun flyspell-delay-commands () | 570 | (defun flyspell-delay-commands () |
| 583 | "Install the standard set of Flyspell delayed commands." | 571 | "Install the standard set of Flyspell delayed commands." |
| 584 | (mapcar 'flyspell-delay-command flyspell-default-delayed-commands) | 572 | (mapcar 'flyspell-delay-command flyspell-default-delayed-commands) |
| 585 | (mapcar 'flyspell-delay-command flyspell-delayed-commands)) | 573 | (mapcar 'flyspell-delay-command flyspell-delayed-commands)) |
| 586 | 574 | ||
| 587 | ;*---------------------------------------------------------------------*/ | 575 | ;;*---------------------------------------------------------------------*/ |
| 588 | ;* flyspell-delay-command ... */ | 576 | ;;* flyspell-delay-command ... */ |
| 589 | ;*---------------------------------------------------------------------*/ | 577 | ;;*---------------------------------------------------------------------*/ |
| 590 | (defun flyspell-delay-command (command) | 578 | (defun flyspell-delay-command (command) |
| 591 | "Set COMMAND to be delayed, for Flyspell. | 579 | "Set COMMAND to be delayed, for Flyspell. |
| 592 | When flyspell `post-command-hook' is invoked because a delayed command | 580 | When flyspell `post-command-hook' is invoked because a delayed command |
| @@ -595,17 +583,17 @@ It will be checked only after `flyspell-delay' seconds." | |||
| 595 | (interactive "SDelay Flyspell after Command: ") | 583 | (interactive "SDelay Flyspell after Command: ") |
| 596 | (put command 'flyspell-delayed t)) | 584 | (put command 'flyspell-delayed t)) |
| 597 | 585 | ||
| 598 | ;*---------------------------------------------------------------------*/ | 586 | ;;*---------------------------------------------------------------------*/ |
| 599 | ;* flyspell-deplacement-commands ... */ | 587 | ;;* flyspell-deplacement-commands ... */ |
| 600 | ;*---------------------------------------------------------------------*/ | 588 | ;;*---------------------------------------------------------------------*/ |
| 601 | (defun flyspell-deplacement-commands () | 589 | (defun flyspell-deplacement-commands () |
| 602 | "Install the standard set of Flyspell deplacement commands." | 590 | "Install the standard set of Flyspell deplacement commands." |
| 603 | (mapcar 'flyspell-deplacement-command flyspell-default-deplacement-commands) | 591 | (mapcar 'flyspell-deplacement-command flyspell-default-deplacement-commands) |
| 604 | (mapcar 'flyspell-deplacement-command flyspell-deplacement-commands)) | 592 | (mapcar 'flyspell-deplacement-command flyspell-deplacement-commands)) |
| 605 | 593 | ||
| 606 | ;*---------------------------------------------------------------------*/ | 594 | ;;*---------------------------------------------------------------------*/ |
| 607 | ;* flyspell-deplacement-command ... */ | 595 | ;;* flyspell-deplacement-command ... */ |
| 608 | ;*---------------------------------------------------------------------*/ | 596 | ;;*---------------------------------------------------------------------*/ |
| 609 | (defun flyspell-deplacement-command (command) | 597 | (defun flyspell-deplacement-command (command) |
| 610 | "Set COMMAND that implement cursor movements, for Flyspell. | 598 | "Set COMMAND that implement cursor movements, for Flyspell. |
| 611 | When flyspell `post-command-hook' is invoked because of a deplacement command | 599 | When flyspell `post-command-hook' is invoked because of a deplacement command |
| @@ -614,9 +602,9 @@ not the very same deplacement command." | |||
| 614 | (interactive "SDeplacement Flyspell after Command: ") | 602 | (interactive "SDeplacement Flyspell after Command: ") |
| 615 | (put command 'flyspell-deplacement t)) | 603 | (put command 'flyspell-deplacement t)) |
| 616 | 604 | ||
| 617 | ;*---------------------------------------------------------------------*/ | 605 | ;;*---------------------------------------------------------------------*/ |
| 618 | ;* flyspell-word-cache ... */ | 606 | ;;* flyspell-word-cache ... */ |
| 619 | ;*---------------------------------------------------------------------*/ | 607 | ;;*---------------------------------------------------------------------*/ |
| 620 | (defvar flyspell-word-cache-start nil) | 608 | (defvar flyspell-word-cache-start nil) |
| 621 | (defvar flyspell-word-cache-end nil) | 609 | (defvar flyspell-word-cache-end nil) |
| 622 | (defvar flyspell-word-cache-word nil) | 610 | (defvar flyspell-word-cache-word nil) |
| @@ -626,26 +614,26 @@ not the very same deplacement command." | |||
| 626 | (make-variable-buffer-local 'flyspell-word-cache-word) | 614 | (make-variable-buffer-local 'flyspell-word-cache-word) |
| 627 | (make-variable-buffer-local 'flyspell-word-cache-result) | 615 | (make-variable-buffer-local 'flyspell-word-cache-result) |
| 628 | 616 | ||
| 629 | ;*---------------------------------------------------------------------*/ | 617 | ;;*---------------------------------------------------------------------*/ |
| 630 | ;* The flyspell pre-hook, store the current position. In the */ | 618 | ;;* The flyspell pre-hook, store the current position. In the */ |
| 631 | ;* post command hook, we will check, if the word at this position */ | 619 | ;;* post command hook, we will check, if the word at this position */ |
| 632 | ;* has to be spell checked. */ | 620 | ;;* has to be spell checked. */ |
| 633 | ;*---------------------------------------------------------------------*/ | 621 | ;;*---------------------------------------------------------------------*/ |
| 634 | (defvar flyspell-pre-buffer nil) | 622 | (defvar flyspell-pre-buffer nil) |
| 635 | (defvar flyspell-pre-point nil) | 623 | (defvar flyspell-pre-point nil) |
| 636 | (defvar flyspell-pre-column nil) | 624 | (defvar flyspell-pre-column nil) |
| 637 | (defvar flyspell-pre-pre-buffer nil) | 625 | (defvar flyspell-pre-pre-buffer nil) |
| 638 | (defvar flyspell-pre-pre-point nil) | 626 | (defvar flyspell-pre-pre-point nil) |
| 639 | 627 | ||
| 640 | ;*---------------------------------------------------------------------*/ | 628 | ;;*---------------------------------------------------------------------*/ |
| 641 | ;* flyspell-previous-command ... */ | 629 | ;;* flyspell-previous-command ... */ |
| 642 | ;*---------------------------------------------------------------------*/ | 630 | ;;*---------------------------------------------------------------------*/ |
| 643 | (defvar flyspell-previous-command nil | 631 | (defvar flyspell-previous-command nil |
| 644 | "The last interactive command checked by Flyspell.") | 632 | "The last interactive command checked by Flyspell.") |
| 645 | 633 | ||
| 646 | ;*---------------------------------------------------------------------*/ | 634 | ;;*---------------------------------------------------------------------*/ |
| 647 | ;* flyspell-pre-command-hook ... */ | 635 | ;;* flyspell-pre-command-hook ... */ |
| 648 | ;*---------------------------------------------------------------------*/ | 636 | ;;*---------------------------------------------------------------------*/ |
| 649 | (defun flyspell-pre-command-hook () | 637 | (defun flyspell-pre-command-hook () |
| 650 | "Save the current buffer and point for Flyspell's post-command hook." | 638 | "Save the current buffer and point for Flyspell's post-command hook." |
| 651 | (interactive) | 639 | (interactive) |
| @@ -653,9 +641,9 @@ not the very same deplacement command." | |||
| 653 | (setq flyspell-pre-point (point)) | 641 | (setq flyspell-pre-point (point)) |
| 654 | (setq flyspell-pre-column (current-column))) | 642 | (setq flyspell-pre-column (current-column))) |
| 655 | 643 | ||
| 656 | ;*---------------------------------------------------------------------*/ | 644 | ;;*---------------------------------------------------------------------*/ |
| 657 | ;* flyspell-mode-off ... */ | 645 | ;;* flyspell-mode-off ... */ |
| 658 | ;*---------------------------------------------------------------------*/ | 646 | ;;*---------------------------------------------------------------------*/ |
| 659 | ;;;###autoload | 647 | ;;;###autoload |
| 660 | (defun flyspell-mode-off () | 648 | (defun flyspell-mode-off () |
| 661 | "Turn Flyspell mode off." | 649 | "Turn Flyspell mode off." |
| @@ -672,9 +660,9 @@ not the very same deplacement command." | |||
| 672 | ;; we mark the mode as killed | 660 | ;; we mark the mode as killed |
| 673 | (setq flyspell-mode nil)) | 661 | (setq flyspell-mode nil)) |
| 674 | 662 | ||
| 675 | ;*---------------------------------------------------------------------*/ | 663 | ;;*---------------------------------------------------------------------*/ |
| 676 | ;* flyspell-check-pre-word-p ... */ | 664 | ;;* flyspell-check-pre-word-p ... */ |
| 677 | ;*---------------------------------------------------------------------*/ | 665 | ;;*---------------------------------------------------------------------*/ |
| 678 | (defun flyspell-check-pre-word-p () | 666 | (defun flyspell-check-pre-word-p () |
| 679 | "Return non-nil if we should check the word before point. | 667 | "Return non-nil if we should check the word before point. |
| 680 | More precisely, it applies to the word that was before point | 668 | More precisely, it applies to the word that was before point |
| @@ -710,24 +698,24 @@ before the current command." | |||
| 710 | (or (< flyspell-pre-point flyspell-word-cache-start) | 698 | (or (< flyspell-pre-point flyspell-word-cache-start) |
| 711 | (> flyspell-pre-point flyspell-word-cache-end))))) | 699 | (> flyspell-pre-point flyspell-word-cache-end))))) |
| 712 | 700 | ||
| 713 | ;*---------------------------------------------------------------------*/ | 701 | ;;*---------------------------------------------------------------------*/ |
| 714 | ;* The flyspell after-change-hook, store the change position. In */ | 702 | ;;* The flyspell after-change-hook, store the change position. In */ |
| 715 | ;* the post command hook, we will check, if the word at this */ | 703 | ;;* the post command hook, we will check, if the word at this */ |
| 716 | ;* position has to be spell checked. */ | 704 | ;;* position has to be spell checked. */ |
| 717 | ;*---------------------------------------------------------------------*/ | 705 | ;;*---------------------------------------------------------------------*/ |
| 718 | (defvar flyspell-changes nil) | 706 | (defvar flyspell-changes nil) |
| 719 | 707 | ||
| 720 | ;*---------------------------------------------------------------------*/ | 708 | ;;*---------------------------------------------------------------------*/ |
| 721 | ;* flyspell-after-change-function ... */ | 709 | ;;* flyspell-after-change-function ... */ |
| 722 | ;*---------------------------------------------------------------------*/ | 710 | ;;*---------------------------------------------------------------------*/ |
| 723 | (defun flyspell-after-change-function (start stop len) | 711 | (defun flyspell-after-change-function (start stop len) |
| 724 | "Save the current buffer and point for Flyspell's post-command hook." | 712 | "Save the current buffer and point for Flyspell's post-command hook." |
| 725 | (interactive) | 713 | (interactive) |
| 726 | (setq flyspell-changes (cons (cons start stop) flyspell-changes))) | 714 | (setq flyspell-changes (cons (cons start stop) flyspell-changes))) |
| 727 | 715 | ||
| 728 | ;*---------------------------------------------------------------------*/ | 716 | ;;*---------------------------------------------------------------------*/ |
| 729 | ;* flyspell-check-changed-word-p ... */ | 717 | ;;* flyspell-check-changed-word-p ... */ |
| 730 | ;*---------------------------------------------------------------------*/ | 718 | ;;*---------------------------------------------------------------------*/ |
| 731 | (defun flyspell-check-changed-word-p (start stop) | 719 | (defun flyspell-check-changed-word-p (start stop) |
| 732 | "Return t when the changed word has to be checked. | 720 | "Return t when the changed word has to be checked. |
| 733 | The answer depends of several criteria. | 721 | The answer depends of several criteria. |
| @@ -745,9 +733,9 @@ Mostly we check word delimiters." | |||
| 745 | (t | 733 | (t |
| 746 | t))) | 734 | t))) |
| 747 | 735 | ||
| 748 | ;*---------------------------------------------------------------------*/ | 736 | ;;*---------------------------------------------------------------------*/ |
| 749 | ;* flyspell-check-word-p ... */ | 737 | ;;* flyspell-check-word-p ... */ |
| 750 | ;*---------------------------------------------------------------------*/ | 738 | ;;*---------------------------------------------------------------------*/ |
| 751 | (defun flyspell-check-word-p () | 739 | (defun flyspell-check-word-p () |
| 752 | "Return t when the word at `point' has to be checked. | 740 | "Return t when the word at `point' has to be checked. |
| 753 | The answer depends of several criteria. | 741 | The answer depends of several criteria. |
| @@ -777,67 +765,57 @@ Mostly we check word delimiters." | |||
| 777 | (t t))) | 765 | (t t))) |
| 778 | (t t))) | 766 | (t t))) |
| 779 | 767 | ||
| 780 | ;*---------------------------------------------------------------------*/ | 768 | ;;*---------------------------------------------------------------------*/ |
| 781 | ;* flyspell-debug-signal-no-check ... */ | 769 | ;;* flyspell-debug-signal-no-check ... */ |
| 782 | ;*---------------------------------------------------------------------*/ | 770 | ;;*---------------------------------------------------------------------*/ |
| 783 | (defun flyspell-debug-signal-no-check (msg obj) | 771 | (defun flyspell-debug-signal-no-check (msg obj) |
| 784 | (setq debug-on-error t) | 772 | (setq debug-on-error t) |
| 785 | (save-excursion | 773 | (with-current-buffer (get-buffer-create "*flyspell-debug*") |
| 786 | (let ((buffer (get-buffer-create "*flyspell-debug*"))) | 774 | (erase-buffer) |
| 787 | (set-buffer buffer) | 775 | (insert "NO-CHECK:\n") |
| 788 | (erase-buffer) | 776 | (insert (format " %S : %S\n" msg obj)))) |
| 789 | (insert "NO-CHECK:\n") | 777 | |
| 790 | (insert (format " %S : %S\n" msg obj))))) | 778 | ;;*---------------------------------------------------------------------*/ |
| 791 | 779 | ;;* flyspell-debug-signal-pre-word-checked ... */ | |
| 792 | ;*---------------------------------------------------------------------*/ | 780 | ;;*---------------------------------------------------------------------*/ |
| 793 | ;* flyspell-debug-signal-pre-word-checked ... */ | ||
| 794 | ;*---------------------------------------------------------------------*/ | ||
| 795 | (defun flyspell-debug-signal-pre-word-checked () | 781 | (defun flyspell-debug-signal-pre-word-checked () |
| 796 | (setq debug-on-error t) | 782 | (setq debug-on-error t) |
| 797 | (save-excursion | 783 | (with-current-buffer (get-buffer-create "*flyspell-debug*") |
| 798 | (let ((buffer (get-buffer-create "*flyspell-debug*"))) | 784 | (insert "PRE-WORD:\n") |
| 799 | (set-buffer buffer) | 785 | (insert (format " pre-point : %S\n" flyspell-pre-point)) |
| 800 | (insert "PRE-WORD:\n") | 786 | (insert (format " pre-buffer : %S\n" flyspell-pre-buffer)) |
| 801 | (insert (format " pre-point : %S\n" flyspell-pre-point)) | 787 | (insert (format " cache-start: %S\n" flyspell-word-cache-start)) |
| 802 | (insert (format " pre-buffer : %S\n" flyspell-pre-buffer)) | 788 | (insert (format " cache-end : %S\n" flyspell-word-cache-end)) |
| 803 | (insert (format " cache-start: %S\n" flyspell-word-cache-start)) | 789 | (goto-char (point-max)))) |
| 804 | (insert (format " cache-end : %S\n" flyspell-word-cache-end)) | 790 | |
| 805 | (goto-char (point-max))))) | 791 | ;;*---------------------------------------------------------------------*/ |
| 806 | 792 | ;;* flyspell-debug-signal-word-checked ... */ | |
| 807 | ;*---------------------------------------------------------------------*/ | 793 | ;;*---------------------------------------------------------------------*/ |
| 808 | ;* flyspell-debug-signal-word-checked ... */ | ||
| 809 | ;*---------------------------------------------------------------------*/ | ||
| 810 | (defun flyspell-debug-signal-word-checked () | 794 | (defun flyspell-debug-signal-word-checked () |
| 811 | (setq debug-on-error t) | 795 | (setq debug-on-error t) |
| 812 | (save-excursion | 796 | (let ((oldbuf (current-buffer)) |
| 813 | (let ((oldbuf (current-buffer)) | 797 | (point (point))) |
| 814 | (buffer (get-buffer-create "*flyspell-debug*")) | 798 | (with-current-buffer (get-buffer-create "*flyspell-debug*") |
| 815 | (point (point))) | ||
| 816 | (set-buffer buffer) | ||
| 817 | (insert "WORD:\n") | 799 | (insert "WORD:\n") |
| 818 | (insert (format " this-cmd : %S\n" this-command)) | 800 | (insert (format " this-cmd : %S\n" this-command)) |
| 819 | (insert (format " delayed : %S\n" (and (symbolp this-command) | 801 | (insert (format " delayed : %S\n" (and (symbolp this-command) |
| 820 | (get this-command 'flyspell-delayed)))) | 802 | (get this-command 'flyspell-delayed)))) |
| 821 | (insert (format " point : %S\n" point)) | 803 | (insert (format " point : %S\n" point)) |
| 822 | (insert (format " prev-char : [%c] %S\n" | 804 | (insert (format " prev-char : [%c] %S\n" |
| 823 | (progn | 805 | (with-current-buffer oldbuf |
| 824 | (set-buffer oldbuf) | ||
| 825 | (let ((c (if (> (point) (point-min)) | 806 | (let ((c (if (> (point) (point-min)) |
| 826 | (save-excursion | 807 | (save-excursion |
| 827 | (backward-char 1) | 808 | (backward-char 1) |
| 828 | (char-after (point))) | 809 | (char-after (point))) |
| 829 | ? ))) | 810 | ? ))) |
| 830 | (set-buffer buffer) | ||
| 831 | c)) | 811 | c)) |
| 832 | (progn | 812 | (with-current-buffer oldbuf |
| 833 | (set-buffer oldbuf) | ||
| 834 | (let ((c (if (> (point) (point-min)) | 813 | (let ((c (if (> (point) (point-min)) |
| 835 | (save-excursion | 814 | (save-excursion |
| 836 | (backward-char 1) | 815 | (backward-char 1) |
| 837 | (and (and (looking-at (flyspell-get-not-casechars)) 1) | 816 | (and (and (looking-at (flyspell-get-not-casechars)) 1) |
| 838 | (and (or flyspell-consider-dash-as-word-delimiter-flag | 817 | (and (or flyspell-consider-dash-as-word-delimiter-flag |
| 839 | (not (looking-at "\\-"))) 2)))))) | 818 | (not (looking-at "\\-"))) 2)))))) |
| 840 | (set-buffer buffer) | ||
| 841 | c)))) | 819 | c)))) |
| 842 | (insert (format " because : %S\n" | 820 | (insert (format " because : %S\n" |
| 843 | (cond | 821 | (cond |
| @@ -846,15 +824,13 @@ Mostly we check word delimiters." | |||
| 846 | ;; the current command is not delayed, that | 824 | ;; the current command is not delayed, that |
| 847 | ;; is that we must check the word now | 825 | ;; is that we must check the word now |
| 848 | 'not-delayed) | 826 | 'not-delayed) |
| 849 | ((progn | 827 | ((with-current-buffer oldbuf |
| 850 | (set-buffer oldbuf) | ||
| 851 | (let ((c (if (> (point) (point-min)) | 828 | (let ((c (if (> (point) (point-min)) |
| 852 | (save-excursion | 829 | (save-excursion |
| 853 | (backward-char 1) | 830 | (backward-char 1) |
| 854 | (and (looking-at (flyspell-get-not-casechars)) | 831 | (and (looking-at (flyspell-get-not-casechars)) |
| 855 | (or flyspell-consider-dash-as-word-delimiter-flag | 832 | (or flyspell-consider-dash-as-word-delimiter-flag |
| 856 | (not (looking-at "\\-")))))))) | 833 | (not (looking-at "\\-")))))))) |
| 857 | (set-buffer buffer) | ||
| 858 | c)) | 834 | c)) |
| 859 | ;; yes because we have reached or typed a word delimiter. | 835 | ;; yes because we have reached or typed a word delimiter. |
| 860 | 'separator) | 836 | 'separator) |
| @@ -865,33 +841,31 @@ Mostly we check word delimiters." | |||
| 865 | 'sit-for)))) | 841 | 'sit-for)))) |
| 866 | (goto-char (point-max))))) | 842 | (goto-char (point-max))))) |
| 867 | 843 | ||
| 868 | ;*---------------------------------------------------------------------*/ | 844 | ;;*---------------------------------------------------------------------*/ |
| 869 | ;* flyspell-debug-signal-changed-checked ... */ | 845 | ;;* flyspell-debug-signal-changed-checked ... */ |
| 870 | ;*---------------------------------------------------------------------*/ | 846 | ;;*---------------------------------------------------------------------*/ |
| 871 | (defun flyspell-debug-signal-changed-checked () | 847 | (defun flyspell-debug-signal-changed-checked () |
| 872 | (setq debug-on-error t) | 848 | (setq debug-on-error t) |
| 873 | (save-excursion | 849 | (let ((point (point))) |
| 874 | (let ((buffer (get-buffer-create "*flyspell-debug*")) | 850 | (with-current-buffer (get-buffer-create "*flyspell-debug*") |
| 875 | (point (point))) | ||
| 876 | (set-buffer buffer) | ||
| 877 | (insert "CHANGED WORD:\n") | 851 | (insert "CHANGED WORD:\n") |
| 878 | (insert (format " point : %S\n" point)) | 852 | (insert (format " point : %S\n" point)) |
| 879 | (goto-char (point-max))))) | 853 | (goto-char (point-max))))) |
| 880 | 854 | ||
| 881 | ;*---------------------------------------------------------------------*/ | 855 | ;;*---------------------------------------------------------------------*/ |
| 882 | ;* flyspell-post-command-hook ... */ | 856 | ;;* flyspell-post-command-hook ... */ |
| 883 | ;* ------------------------------------------------------------- */ | 857 | ;;* ------------------------------------------------------------- */ |
| 884 | ;* It is possible that we check several words: */ | 858 | ;;* It is possible that we check several words: */ |
| 885 | ;* 1- the current word is checked if the predicate */ | 859 | ;;* 1- the current word is checked if the predicate */ |
| 886 | ;* FLYSPELL-CHECK-WORD-P is true */ | 860 | ;;* FLYSPELL-CHECK-WORD-P is true */ |
| 887 | ;* 2- the word that used to be the current word before the */ | 861 | ;;* 2- the word that used to be the current word before the */ |
| 888 | ;* THIS-COMMAND is checked if: */ | 862 | ;;* THIS-COMMAND is checked if: */ |
| 889 | ;* a- the previous word is different from the current word */ | 863 | ;;* a- the previous word is different from the current word */ |
| 890 | ;* b- the previous word as not just been checked by the */ | 864 | ;;* b- the previous word as not just been checked by the */ |
| 891 | ;* previous FLYSPELL-POST-COMMAND-HOOK */ | 865 | ;;* previous FLYSPELL-POST-COMMAND-HOOK */ |
| 892 | ;* 3- the words changed by the THIS-COMMAND that are neither the */ | 866 | ;;* 3- the words changed by the THIS-COMMAND that are neither the */ |
| 893 | ;* previous word nor the current word */ | 867 | ;;* previous word nor the current word */ |
| 894 | ;*---------------------------------------------------------------------*/ | 868 | ;;*---------------------------------------------------------------------*/ |
| 895 | (defun flyspell-post-command-hook () | 869 | (defun flyspell-post-command-hook () |
| 896 | "The `post-command-hook' used by flyspell to check a word in-the-fly." | 870 | "The `post-command-hook' used by flyspell to check a word in-the-fly." |
| 897 | (interactive) | 871 | (interactive) |
| @@ -899,9 +873,8 @@ Mostly we check word delimiters." | |||
| 899 | ;; Prevent anything we do from affecting the mark. | 873 | ;; Prevent anything we do from affecting the mark. |
| 900 | deactivate-mark) | 874 | deactivate-mark) |
| 901 | (if (flyspell-check-pre-word-p) | 875 | (if (flyspell-check-pre-word-p) |
| 902 | (save-excursion | 876 | (with-current-buffer flyspell-pre-buffer |
| 903 | '(flyspell-debug-signal-pre-word-checked) | 877 | '(flyspell-debug-signal-pre-word-checked) |
| 904 | (set-buffer flyspell-pre-buffer) | ||
| 905 | (save-excursion | 878 | (save-excursion |
| 906 | (goto-char flyspell-pre-point) | 879 | (goto-char flyspell-pre-point) |
| 907 | (flyspell-word)))) | 880 | (flyspell-word)))) |
| @@ -937,10 +910,10 @@ Mostly we check word delimiters." | |||
| 937 | (setq flyspell-changes (cdr flyspell-changes)))) | 910 | (setq flyspell-changes (cdr flyspell-changes)))) |
| 938 | (setq flyspell-previous-command command))) | 911 | (setq flyspell-previous-command command))) |
| 939 | 912 | ||
| 940 | ;*---------------------------------------------------------------------*/ | 913 | ;;*---------------------------------------------------------------------*/ |
| 941 | ;* flyspell-notify-misspell ... */ | 914 | ;;* flyspell-notify-misspell ... */ |
| 942 | ;*---------------------------------------------------------------------*/ | 915 | ;;*---------------------------------------------------------------------*/ |
| 943 | (defun flyspell-notify-misspell (start end word poss) | 916 | (defun flyspell-notify-misspell (word poss) |
| 944 | (let ((replacements (if (stringp poss) | 917 | (let ((replacements (if (stringp poss) |
| 945 | poss | 918 | poss |
| 946 | (if flyspell-sort-corrections | 919 | (if flyspell-sort-corrections |
| @@ -949,9 +922,9 @@ Mostly we check word delimiters." | |||
| 949 | (if flyspell-issue-message-flag | 922 | (if flyspell-issue-message-flag |
| 950 | (message "misspelling `%s' %S" word replacements)))) | 923 | (message "misspelling `%s' %S" word replacements)))) |
| 951 | 924 | ||
| 952 | ;*---------------------------------------------------------------------*/ | 925 | ;;*---------------------------------------------------------------------*/ |
| 953 | ;* flyspell-word-search-backward ... */ | 926 | ;;* flyspell-word-search-backward ... */ |
| 954 | ;*---------------------------------------------------------------------*/ | 927 | ;;*---------------------------------------------------------------------*/ |
| 955 | (defun flyspell-word-search-backward (word bound) | 928 | (defun flyspell-word-search-backward (word bound) |
| 956 | (save-excursion | 929 | (save-excursion |
| 957 | (let ((r '()) | 930 | (let ((r '()) |
| @@ -963,9 +936,9 @@ Mostly we check word delimiters." | |||
| 963 | (goto-char p)))) | 936 | (goto-char p)))) |
| 964 | r))) | 937 | r))) |
| 965 | 938 | ||
| 966 | ;*---------------------------------------------------------------------*/ | 939 | ;;*---------------------------------------------------------------------*/ |
| 967 | ;* flyspell-word-search-forward ... */ | 940 | ;;* flyspell-word-search-forward ... */ |
| 968 | ;*---------------------------------------------------------------------*/ | 941 | ;;*---------------------------------------------------------------------*/ |
| 969 | (defun flyspell-word-search-forward (word bound) | 942 | (defun flyspell-word-search-forward (word bound) |
| 970 | (save-excursion | 943 | (save-excursion |
| 971 | (let ((r '()) | 944 | (let ((r '()) |
| @@ -977,9 +950,9 @@ Mostly we check word delimiters." | |||
| 977 | (goto-char (1+ p))))) | 950 | (goto-char (1+ p))))) |
| 978 | r))) | 951 | r))) |
| 979 | 952 | ||
| 980 | ;*---------------------------------------------------------------------*/ | 953 | ;;*---------------------------------------------------------------------*/ |
| 981 | ;* flyspell-word ... */ | 954 | ;;* flyspell-word ... */ |
| 982 | ;*---------------------------------------------------------------------*/ | 955 | ;;*---------------------------------------------------------------------*/ |
| 983 | (defun flyspell-word (&optional following) | 956 | (defun flyspell-word (&optional following) |
| 984 | "Spell check a word." | 957 | "Spell check a word." |
| 985 | (interactive (list ispell-following-word)) | 958 | (interactive (list ispell-following-word)) |
| @@ -987,8 +960,8 @@ Mostly we check word delimiters." | |||
| 987 | ;; use the correct dictionary | 960 | ;; use the correct dictionary |
| 988 | (flyspell-accept-buffer-local-defs) | 961 | (flyspell-accept-buffer-local-defs) |
| 989 | (let* ((cursor-location (point)) | 962 | (let* ((cursor-location (point)) |
| 990 | (flyspell-word (flyspell-get-word following)) | 963 | (flyspell-word (flyspell-get-word following)) |
| 991 | start end poss word) | 964 | start end poss word) |
| 992 | (if (or (eq flyspell-word nil) | 965 | (if (or (eq flyspell-word nil) |
| 993 | (and (fboundp flyspell-generic-check-word-p) | 966 | (and (fboundp flyspell-generic-check-word-p) |
| 994 | (not (funcall flyspell-generic-check-word-p)))) | 967 | (not (funcall flyspell-generic-check-word-p)))) |
| @@ -1031,18 +1004,20 @@ Mostly we check word delimiters." | |||
| 1031 | (setq flyspell-word-cache-end end) | 1004 | (setq flyspell-word-cache-end end) |
| 1032 | (setq flyspell-word-cache-word word) | 1005 | (setq flyspell-word-cache-word word) |
| 1033 | ;; now check spelling of word. | 1006 | ;; now check spelling of word. |
| 1034 | (process-send-string ispell-process "%\n") | 1007 | (ispell-send-string "%\n") |
| 1035 | ;; put in verbose mode | 1008 | ;; put in verbose mode |
| 1036 | (process-send-string ispell-process | 1009 | (ispell-send-string (concat "^" word "\n")) |
| 1037 | (concat "^" word "\n")) | ||
| 1038 | ;; we mark the ispell process so it can be killed | 1010 | ;; we mark the ispell process so it can be killed |
| 1039 | ;; when emacs is exited without query | 1011 | ;; when emacs is exited without query |
| 1040 | (set-process-query-on-exit-flag ispell-process nil) | 1012 | (set-process-query-on-exit-flag ispell-process nil) |
| 1041 | ;; wait until ispell has processed word | 1013 | ;; Wait until ispell has processed word. Since this code is often |
| 1042 | (while (progn | 1014 | ;; executed rom post-command-hook but the ispell process may not |
| 1043 | (accept-process-output ispell-process) | 1015 | ;; be responsive, it's important to make sure we re-enable C-g. |
| 1044 | (not (string= "" (car ispell-filter))))) | 1016 | (with-local-quit |
| 1045 | ;; (process-send-string ispell-process "!\n") | 1017 | (while (progn |
| 1018 | (accept-process-output ispell-process) | ||
| 1019 | (not (string= "" (car ispell-filter)))))) | ||
| 1020 | ;; (ispell-send-string "!\n") | ||
| 1046 | ;; back to terse mode. | 1021 | ;; back to terse mode. |
| 1047 | (setq ispell-filter (cdr ispell-filter)) | 1022 | (setq ispell-filter (cdr ispell-filter)) |
| 1048 | (if (consp ispell-filter) | 1023 | (if (consp ispell-filter) |
| @@ -1105,27 +1080,27 @@ Mostly we check word delimiters." | |||
| 1105 | (if flyspell-highlight-flag | 1080 | (if flyspell-highlight-flag |
| 1106 | (flyspell-highlight-incorrect-region | 1081 | (flyspell-highlight-incorrect-region |
| 1107 | start end poss) | 1082 | start end poss) |
| 1108 | (flyspell-notify-misspell start end word poss)) | 1083 | (flyspell-notify-misspell word poss)) |
| 1109 | nil)))) | 1084 | nil)))) |
| 1110 | ;; return to original location | 1085 | ;; return to original location |
| 1111 | (goto-char cursor-location) | 1086 | (goto-char cursor-location) |
| 1112 | (if ispell-quit (setq ispell-quit nil)) | 1087 | (if ispell-quit (setq ispell-quit nil)) |
| 1113 | res)))))))) | 1088 | res)))))))) |
| 1114 | 1089 | ||
| 1115 | ;*---------------------------------------------------------------------*/ | 1090 | ;;*---------------------------------------------------------------------*/ |
| 1116 | ;* flyspell-tex-math-initialized ... */ | 1091 | ;;* flyspell-tex-math-initialized ... */ |
| 1117 | ;*---------------------------------------------------------------------*/ | 1092 | ;;*---------------------------------------------------------------------*/ |
| 1118 | (defvar flyspell-tex-math-initialized nil) | 1093 | (defvar flyspell-tex-math-initialized nil) |
| 1119 | 1094 | ||
| 1120 | ;*---------------------------------------------------------------------*/ | 1095 | ;;*---------------------------------------------------------------------*/ |
| 1121 | ;* flyspell-math-tex-command-p ... */ | 1096 | ;;* flyspell-math-tex-command-p ... */ |
| 1122 | ;* ------------------------------------------------------------- */ | 1097 | ;;* ------------------------------------------------------------- */ |
| 1123 | ;* This function uses the texmathp package to check if (point) */ | 1098 | ;;* This function uses the texmathp package to check if (point) */ |
| 1124 | ;* is within a tex command. In order to avoid using */ | 1099 | ;;* is within a tex command. In order to avoid using */ |
| 1125 | ;* condition-case each time we use the variable */ | 1100 | ;;* condition-case each time we use the variable */ |
| 1126 | ;* flyspell-tex-math-initialized to make a special case the first */ | 1101 | ;;* flyspell-tex-math-initialized to make a special case the first */ |
| 1127 | ;* time that function is called. */ | 1102 | ;;* time that function is called. */ |
| 1128 | ;*---------------------------------------------------------------------*/ | 1103 | ;;*---------------------------------------------------------------------*/ |
| 1129 | (defun flyspell-math-tex-command-p () | 1104 | (defun flyspell-math-tex-command-p () |
| 1130 | (when (fboundp 'texmathp) | 1105 | (when (fboundp 'texmathp) |
| 1131 | (cond | 1106 | (cond |
| @@ -1143,9 +1118,9 @@ Mostly we check word delimiters." | |||
| 1143 | (setq flyspell-tex-math-initialized 'error) | 1118 | (setq flyspell-tex-math-initialized 'error) |
| 1144 | nil))))))) | 1119 | nil))))))) |
| 1145 | 1120 | ||
| 1146 | ;*---------------------------------------------------------------------*/ | 1121 | ;;*---------------------------------------------------------------------*/ |
| 1147 | ;* flyspell-tex-command-p ... */ | 1122 | ;;* flyspell-tex-command-p ... */ |
| 1148 | ;*---------------------------------------------------------------------*/ | 1123 | ;;*---------------------------------------------------------------------*/ |
| 1149 | (defun flyspell-tex-command-p (word) | 1124 | (defun flyspell-tex-command-p (word) |
| 1150 | "Return t if WORD is a TeX command." | 1125 | "Return t if WORD is a TeX command." |
| 1151 | (or (save-excursion | 1126 | (or (save-excursion |
| @@ -1157,17 +1132,17 @@ Mostly we check word delimiters." | |||
| 1157 | (>= (match-end 0) b)))))) | 1132 | (>= (match-end 0) b)))))) |
| 1158 | (flyspell-math-tex-command-p))) | 1133 | (flyspell-math-tex-command-p))) |
| 1159 | 1134 | ||
| 1160 | ;*---------------------------------------------------------------------*/ | 1135 | ;;*---------------------------------------------------------------------*/ |
| 1161 | ;* flyspell-casechars-cache ... */ | 1136 | ;;* flyspell-casechars-cache ... */ |
| 1162 | ;*---------------------------------------------------------------------*/ | 1137 | ;;*---------------------------------------------------------------------*/ |
| 1163 | (defvar flyspell-casechars-cache nil) | 1138 | (defvar flyspell-casechars-cache nil) |
| 1164 | (defvar flyspell-ispell-casechars-cache nil) | 1139 | (defvar flyspell-ispell-casechars-cache nil) |
| 1165 | (make-variable-buffer-local 'flyspell-casechars-cache) | 1140 | (make-variable-buffer-local 'flyspell-casechars-cache) |
| 1166 | (make-variable-buffer-local 'flyspell-ispell-casechars-cache) | 1141 | (make-variable-buffer-local 'flyspell-ispell-casechars-cache) |
| 1167 | 1142 | ||
| 1168 | ;*---------------------------------------------------------------------*/ | 1143 | ;;*---------------------------------------------------------------------*/ |
| 1169 | ;* flyspell-get-casechars ... */ | 1144 | ;;* flyspell-get-casechars ... */ |
| 1170 | ;*---------------------------------------------------------------------*/ | 1145 | ;;*---------------------------------------------------------------------*/ |
| 1171 | (defun flyspell-get-casechars () | 1146 | (defun flyspell-get-casechars () |
| 1172 | "This function builds a string that is the regexp of word chars. | 1147 | "This function builds a string that is the regexp of word chars. |
| 1173 | In order to avoid one useless string construction, | 1148 | In order to avoid one useless string construction, |
| @@ -1187,17 +1162,17 @@ this function changes the last char of the `ispell-casechars' string." | |||
| 1187 | (setq flyspell-casechars-cache ispell-casechars) | 1162 | (setq flyspell-casechars-cache ispell-casechars) |
| 1188 | flyspell-casechars-cache)))) | 1163 | flyspell-casechars-cache)))) |
| 1189 | 1164 | ||
| 1190 | ;*---------------------------------------------------------------------*/ | 1165 | ;;*---------------------------------------------------------------------*/ |
| 1191 | ;* flyspell-get-not-casechars-cache ... */ | 1166 | ;;* flyspell-get-not-casechars-cache ... */ |
| 1192 | ;*---------------------------------------------------------------------*/ | 1167 | ;;*---------------------------------------------------------------------*/ |
| 1193 | (defvar flyspell-not-casechars-cache nil) | 1168 | (defvar flyspell-not-casechars-cache nil) |
| 1194 | (defvar flyspell-ispell-not-casechars-cache nil) | 1169 | (defvar flyspell-ispell-not-casechars-cache nil) |
| 1195 | (make-variable-buffer-local 'flyspell-not-casechars-cache) | 1170 | (make-variable-buffer-local 'flyspell-not-casechars-cache) |
| 1196 | (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache) | 1171 | (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache) |
| 1197 | 1172 | ||
| 1198 | ;*---------------------------------------------------------------------*/ | 1173 | ;;*---------------------------------------------------------------------*/ |
| 1199 | ;* flyspell-get-not-casechars ... */ | 1174 | ;;* flyspell-get-not-casechars ... */ |
| 1200 | ;*---------------------------------------------------------------------*/ | 1175 | ;;*---------------------------------------------------------------------*/ |
| 1201 | (defun flyspell-get-not-casechars () | 1176 | (defun flyspell-get-not-casechars () |
| 1202 | "This function builds a string that is the regexp of non-word chars." | 1177 | "This function builds a string that is the regexp of non-word chars." |
| 1203 | (let ((ispell-not-casechars (ispell-get-not-casechars))) | 1178 | (let ((ispell-not-casechars (ispell-get-not-casechars))) |
| @@ -1215,9 +1190,9 @@ this function changes the last char of the `ispell-casechars' string." | |||
| 1215 | (setq flyspell-not-casechars-cache ispell-not-casechars) | 1190 | (setq flyspell-not-casechars-cache ispell-not-casechars) |
| 1216 | flyspell-not-casechars-cache)))) | 1191 | flyspell-not-casechars-cache)))) |
| 1217 | 1192 | ||
| 1218 | ;*---------------------------------------------------------------------*/ | 1193 | ;;*---------------------------------------------------------------------*/ |
| 1219 | ;* flyspell-get-word ... */ | 1194 | ;;* flyspell-get-word ... */ |
| 1220 | ;*---------------------------------------------------------------------*/ | 1195 | ;;*---------------------------------------------------------------------*/ |
| 1221 | (defun flyspell-get-word (following &optional extra-otherchars) | 1196 | (defun flyspell-get-word (following &optional extra-otherchars) |
| 1222 | "Return the word for spell-checking according to Ispell syntax. | 1197 | "Return the word for spell-checking according to Ispell syntax. |
| 1223 | If optional argument FOLLOWING is non-nil or if `flyspell-following-word' | 1198 | If optional argument FOLLOWING is non-nil or if `flyspell-following-word' |
| @@ -1278,9 +1253,9 @@ Word syntax described by `flyspell-dictionary-alist' (which see)." | |||
| 1278 | word (buffer-substring-no-properties start end)) | 1253 | word (buffer-substring-no-properties start end)) |
| 1279 | (list word start end))))) | 1254 | (list word start end))))) |
| 1280 | 1255 | ||
| 1281 | ;*---------------------------------------------------------------------*/ | 1256 | ;;*---------------------------------------------------------------------*/ |
| 1282 | ;* flyspell-small-region ... */ | 1257 | ;;* flyspell-small-region ... */ |
| 1283 | ;*---------------------------------------------------------------------*/ | 1258 | ;;*---------------------------------------------------------------------*/ |
| 1284 | (defun flyspell-small-region (beg end) | 1259 | (defun flyspell-small-region (beg end) |
| 1285 | "Flyspell text between BEG and END." | 1260 | "Flyspell text between BEG and END." |
| 1286 | (save-excursion | 1261 | (save-excursion |
| @@ -1307,23 +1282,23 @@ Word syntax described by `flyspell-dictionary-alist' (which see)." | |||
| 1307 | (if flyspell-issue-message-flag (message "Spell Checking completed.")) | 1282 | (if flyspell-issue-message-flag (message "Spell Checking completed.")) |
| 1308 | (flyspell-word))) | 1283 | (flyspell-word))) |
| 1309 | 1284 | ||
| 1310 | ;*---------------------------------------------------------------------*/ | 1285 | ;;*---------------------------------------------------------------------*/ |
| 1311 | ;* flyspell-external-ispell-process ... */ | 1286 | ;;* flyspell-external-ispell-process ... */ |
| 1312 | ;*---------------------------------------------------------------------*/ | 1287 | ;;*---------------------------------------------------------------------*/ |
| 1313 | (defvar flyspell-external-ispell-process '() | 1288 | (defvar flyspell-external-ispell-process '() |
| 1314 | "The external Flyspell Ispell process.") | 1289 | "The external Flyspell Ispell process.") |
| 1315 | 1290 | ||
| 1316 | ;*---------------------------------------------------------------------*/ | 1291 | ;;*---------------------------------------------------------------------*/ |
| 1317 | ;* flyspell-external-ispell-buffer ... */ | 1292 | ;;* flyspell-external-ispell-buffer ... */ |
| 1318 | ;*---------------------------------------------------------------------*/ | 1293 | ;;*---------------------------------------------------------------------*/ |
| 1319 | (defvar flyspell-external-ispell-buffer '()) | 1294 | (defvar flyspell-external-ispell-buffer '()) |
| 1320 | (defvar flyspell-large-region-buffer '()) | 1295 | (defvar flyspell-large-region-buffer '()) |
| 1321 | (defvar flyspell-large-region-beg (point-min)) | 1296 | (defvar flyspell-large-region-beg (point-min)) |
| 1322 | (defvar flyspell-large-region-end (point-max)) | 1297 | (defvar flyspell-large-region-end (point-max)) |
| 1323 | 1298 | ||
| 1324 | ;*---------------------------------------------------------------------*/ | 1299 | ;;*---------------------------------------------------------------------*/ |
| 1325 | ;* flyspell-external-point-words ... */ | 1300 | ;;* flyspell-external-point-words ... */ |
| 1326 | ;*---------------------------------------------------------------------*/ | 1301 | ;;*---------------------------------------------------------------------*/ |
| 1327 | (defun flyspell-external-point-words () | 1302 | (defun flyspell-external-point-words () |
| 1328 | "Mark words from a buffer listing incorrect words in order of appearance. | 1303 | "Mark words from a buffer listing incorrect words in order of appearance. |
| 1329 | The list of incorrect words should be in `flyspell-external-ispell-buffer'. | 1304 | The list of incorrect words should be in `flyspell-external-ispell-buffer'. |
| @@ -1374,12 +1349,12 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1374 | (kill-buffer flyspell-external-ispell-buffer) | 1349 | (kill-buffer flyspell-external-ispell-buffer) |
| 1375 | (setq flyspell-external-ispell-buffer nil)) | 1350 | (setq flyspell-external-ispell-buffer nil)) |
| 1376 | 1351 | ||
| 1377 | ;*---------------------------------------------------------------------*/ | 1352 | ;;*---------------------------------------------------------------------*/ |
| 1378 | ;* flyspell-process-localwords ... */ | 1353 | ;;* flyspell-process-localwords ... */ |
| 1379 | ;* ------------------------------------------------------------- */ | 1354 | ;;* ------------------------------------------------------------- */ |
| 1380 | ;* This function is used to prevent marking of words explicitly */ | 1355 | ;;* This function is used to prevent marking of words explicitly */ |
| 1381 | ;* declared correct. */ | 1356 | ;;* declared correct. */ |
| 1382 | ;*---------------------------------------------------------------------*/ | 1357 | ;;*---------------------------------------------------------------------*/ |
| 1383 | (defun flyspell-process-localwords (misspellings-buffer) | 1358 | (defun flyspell-process-localwords (misspellings-buffer) |
| 1384 | (let (localwords | 1359 | (let (localwords |
| 1385 | (ispell-casechars (ispell-get-casechars))) | 1360 | (ispell-casechars (ispell-get-casechars))) |
| @@ -1412,9 +1387,9 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1412 | (while (re-search-forward regexp nil t) | 1387 | (while (re-search-forward regexp nil t) |
| 1413 | (delete-region (match-beginning 0) (match-end 0))))))))) | 1388 | (delete-region (match-beginning 0) (match-end 0))))))))) |
| 1414 | 1389 | ||
| 1415 | ;*---------------------------------------------------------------------*/ | 1390 | ;;*---------------------------------------------------------------------*/ |
| 1416 | ;* flyspell-large-region ... */ | 1391 | ;;* flyspell-large-region ... */ |
| 1417 | ;*---------------------------------------------------------------------*/ | 1392 | ;;*---------------------------------------------------------------------*/ |
| 1418 | (defun flyspell-large-region (beg end) | 1393 | (defun flyspell-large-region (beg end) |
| 1419 | (let* ((curbuf (current-buffer)) | 1394 | (let* ((curbuf (current-buffer)) |
| 1420 | (buffer (get-buffer-create "*flyspell-region*"))) | 1395 | (buffer (get-buffer-create "*flyspell-region*"))) |
| @@ -1462,15 +1437,15 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1462 | (flyspell-external-point-words)) | 1437 | (flyspell-external-point-words)) |
| 1463 | (error "Can't check region..."))))) | 1438 | (error "Can't check region..."))))) |
| 1464 | 1439 | ||
| 1465 | ;*---------------------------------------------------------------------*/ | 1440 | ;;*---------------------------------------------------------------------*/ |
| 1466 | ;* flyspell-region ... */ | 1441 | ;;* flyspell-region ... */ |
| 1467 | ;* ------------------------------------------------------------- */ | 1442 | ;;* ------------------------------------------------------------- */ |
| 1468 | ;* Because `ispell -a' is too slow, it is not possible to use */ | 1443 | ;;* Because `ispell -a' is too slow, it is not possible to use */ |
| 1469 | ;* it on large region. Then, when ispell is invoked on a large */ | 1444 | ;;* it on large region. Then, when ispell is invoked on a large */ |
| 1470 | ;* text region, a new `ispell -l' process is spawned. The */ | 1445 | ;;* text region, a new `ispell -l' process is spawned. The */ |
| 1471 | ;* pointed out words are then searched in the region a checked with */ | 1446 | ;;* pointed out words are then searched in the region a checked with */ |
| 1472 | ;* regular flyspell means. */ | 1447 | ;;* regular flyspell means. */ |
| 1473 | ;*---------------------------------------------------------------------*/ | 1448 | ;;*---------------------------------------------------------------------*/ |
| 1474 | ;;;###autoload | 1449 | ;;;###autoload |
| 1475 | (defun flyspell-region (beg end) | 1450 | (defun flyspell-region (beg end) |
| 1476 | "Flyspell text between BEG and END." | 1451 | "Flyspell text between BEG and END." |
| @@ -1486,24 +1461,24 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1486 | (flyspell-large-region beg end) | 1461 | (flyspell-large-region beg end) |
| 1487 | (flyspell-small-region beg end))))) | 1462 | (flyspell-small-region beg end))))) |
| 1488 | 1463 | ||
| 1489 | ;*---------------------------------------------------------------------*/ | 1464 | ;;*---------------------------------------------------------------------*/ |
| 1490 | ;* flyspell-buffer ... */ | 1465 | ;;* flyspell-buffer ... */ |
| 1491 | ;*---------------------------------------------------------------------*/ | 1466 | ;;*---------------------------------------------------------------------*/ |
| 1492 | ;;;###autoload | 1467 | ;;;###autoload |
| 1493 | (defun flyspell-buffer () | 1468 | (defun flyspell-buffer () |
| 1494 | "Flyspell whole buffer." | 1469 | "Flyspell whole buffer." |
| 1495 | (interactive) | 1470 | (interactive) |
| 1496 | (flyspell-region (point-min) (point-max))) | 1471 | (flyspell-region (point-min) (point-max))) |
| 1497 | 1472 | ||
| 1498 | ;*---------------------------------------------------------------------*/ | 1473 | ;;*---------------------------------------------------------------------*/ |
| 1499 | ;* old next error position ... */ | 1474 | ;;* old next error position ... */ |
| 1500 | ;*---------------------------------------------------------------------*/ | 1475 | ;;*---------------------------------------------------------------------*/ |
| 1501 | (defvar flyspell-old-buffer-error nil) | 1476 | (defvar flyspell-old-buffer-error nil) |
| 1502 | (defvar flyspell-old-pos-error nil) | 1477 | (defvar flyspell-old-pos-error nil) |
| 1503 | 1478 | ||
| 1504 | ;*---------------------------------------------------------------------*/ | 1479 | ;;*---------------------------------------------------------------------*/ |
| 1505 | ;* flyspell-goto-next-error ... */ | 1480 | ;;* flyspell-goto-next-error ... */ |
| 1506 | ;*---------------------------------------------------------------------*/ | 1481 | ;;*---------------------------------------------------------------------*/ |
| 1507 | (defun flyspell-goto-next-error () | 1482 | (defun flyspell-goto-next-error () |
| 1508 | "Go to the next previously detected error. | 1483 | "Go to the next previously detected error. |
| 1509 | In general FLYSPELL-GOTO-NEXT-ERROR must be used after | 1484 | In general FLYSPELL-GOTO-NEXT-ERROR must be used after |
| @@ -1538,18 +1513,18 @@ FLYSPELL-BUFFER." | |||
| 1538 | (if (= pos max) | 1513 | (if (= pos max) |
| 1539 | (message "No more miss-spelled word!")))) | 1514 | (message "No more miss-spelled word!")))) |
| 1540 | 1515 | ||
| 1541 | ;*---------------------------------------------------------------------*/ | 1516 | ;;*---------------------------------------------------------------------*/ |
| 1542 | ;* flyspell-overlay-p ... */ | 1517 | ;;* flyspell-overlay-p ... */ |
| 1543 | ;*---------------------------------------------------------------------*/ | 1518 | ;;*---------------------------------------------------------------------*/ |
| 1544 | (defun flyspell-overlay-p (o) | 1519 | (defun flyspell-overlay-p (o) |
| 1545 | "A predicate that return true iff O is an overlay used by flyspell." | 1520 | "A predicate that return true iff O is an overlay used by flyspell." |
| 1546 | (and (overlayp o) (overlay-get o 'flyspell-overlay))) | 1521 | (and (overlayp o) (overlay-get o 'flyspell-overlay))) |
| 1547 | 1522 | ||
| 1548 | ;*---------------------------------------------------------------------*/ | 1523 | ;;*---------------------------------------------------------------------*/ |
| 1549 | ;* flyspell-delete-region-overlays, flyspell-delete-all-overlays */ | 1524 | ;;* flyspell-delete-region-overlays, flyspell-delete-all-overlays */ |
| 1550 | ;* ------------------------------------------------------------- */ | 1525 | ;;* ------------------------------------------------------------- */ |
| 1551 | ;* Remove overlays introduced by flyspell. */ | 1526 | ;;* Remove overlays introduced by flyspell. */ |
| 1552 | ;*---------------------------------------------------------------------*/ | 1527 | ;;*---------------------------------------------------------------------*/ |
| 1553 | (defun flyspell-delete-region-overlays (beg end) | 1528 | (defun flyspell-delete-region-overlays (beg end) |
| 1554 | "Delete overlays used by flyspell in a given region." | 1529 | "Delete overlays used by flyspell in a given region." |
| 1555 | (remove-overlays beg end 'flyspell-overlay t)) | 1530 | (remove-overlays beg end 'flyspell-overlay t)) |
| @@ -1559,9 +1534,9 @@ FLYSPELL-BUFFER." | |||
| 1559 | "Delete all the overlays used by flyspell." | 1534 | "Delete all the overlays used by flyspell." |
| 1560 | (flyspell-delete-region-overlays (point-min) (point-max))) | 1535 | (flyspell-delete-region-overlays (point-min) (point-max))) |
| 1561 | 1536 | ||
| 1562 | ;*---------------------------------------------------------------------*/ | 1537 | ;;*---------------------------------------------------------------------*/ |
| 1563 | ;* flyspell-unhighlight-at ... */ | 1538 | ;;* flyspell-unhighlight-at ... */ |
| 1564 | ;*---------------------------------------------------------------------*/ | 1539 | ;;*---------------------------------------------------------------------*/ |
| 1565 | (defun flyspell-unhighlight-at (pos) | 1540 | (defun flyspell-unhighlight-at (pos) |
| 1566 | "Remove the flyspell overlay that are located at POS." | 1541 | "Remove the flyspell overlay that are located at POS." |
| 1567 | (if flyspell-persistent-highlight | 1542 | (if flyspell-persistent-highlight |
| @@ -1571,13 +1546,13 @@ FLYSPELL-BUFFER." | |||
| 1571 | (delete-overlay (car overlays))) | 1546 | (delete-overlay (car overlays))) |
| 1572 | (setq overlays (cdr overlays)))) | 1547 | (setq overlays (cdr overlays)))) |
| 1573 | (if (flyspell-overlay-p flyspell-overlay) | 1548 | (if (flyspell-overlay-p flyspell-overlay) |
| 1574 | (delete-overlay flyspell-overlay)))) | 1549 | (delete-overlay flyspell-overlay)))) |
| 1575 | 1550 | ||
| 1576 | ;*---------------------------------------------------------------------*/ | 1551 | ;;*---------------------------------------------------------------------*/ |
| 1577 | ;* flyspell-properties-at-p ... */ | 1552 | ;;* flyspell-properties-at-p ... */ |
| 1578 | ;* ------------------------------------------------------------- */ | 1553 | ;;* ------------------------------------------------------------- */ |
| 1579 | ;* Is there an highlight properties at position pos? */ | 1554 | ;;* Is there an highlight properties at position pos? */ |
| 1580 | ;*---------------------------------------------------------------------*/ | 1555 | ;;*---------------------------------------------------------------------*/ |
| 1581 | (defun flyspell-properties-at-p (pos) | 1556 | (defun flyspell-properties-at-p (pos) |
| 1582 | "Return t if there is a text property at POS, not counting `local-map'. | 1557 | "Return t if there is a text property at POS, not counting `local-map'. |
| 1583 | If variable `flyspell-highlight-properties' is set to nil, | 1558 | If variable `flyspell-highlight-properties' is set to nil, |
| @@ -1591,33 +1566,33 @@ if the character at POS has any other property." | |||
| 1591 | (setq keep nil))) | 1566 | (setq keep nil))) |
| 1592 | (consp prop))) | 1567 | (consp prop))) |
| 1593 | 1568 | ||
| 1594 | ;*---------------------------------------------------------------------*/ | 1569 | ;;*---------------------------------------------------------------------*/ |
| 1595 | ;* make-flyspell-overlay ... */ | 1570 | ;;* make-flyspell-overlay ... */ |
| 1596 | ;*---------------------------------------------------------------------*/ | 1571 | ;;*---------------------------------------------------------------------*/ |
| 1597 | (defun make-flyspell-overlay (beg end face mouse-face) | 1572 | (defun make-flyspell-overlay (beg end face mouse-face) |
| 1598 | "Allocate an overlay to highlight an incorrect word. | 1573 | "Allocate an overlay to highlight an incorrect word. |
| 1599 | BEG and END specify the range in the buffer of that word. | 1574 | BEG and END specify the range in the buffer of that word. |
| 1600 | FACE and MOUSE-FACE specify the `face' and `mouse-face' properties | 1575 | FACE and MOUSE-FACE specify the `face' and `mouse-face' properties |
| 1601 | for the overlay." | 1576 | for the overlay." |
| 1602 | (let ((flyspell-overlay (make-overlay beg end nil t nil))) | 1577 | (let ((overlay (make-overlay beg end nil t nil))) |
| 1603 | (overlay-put flyspell-overlay 'face face) | 1578 | (overlay-put overlay 'face face) |
| 1604 | (overlay-put flyspell-overlay 'mouse-face mouse-face) | 1579 | (overlay-put overlay 'mouse-face mouse-face) |
| 1605 | (overlay-put flyspell-overlay 'flyspell-overlay t) | 1580 | (overlay-put overlay 'flyspell-overlay t) |
| 1606 | (overlay-put flyspell-overlay 'evaporate t) | 1581 | (overlay-put overlay 'evaporate t) |
| 1607 | (overlay-put flyspell-overlay 'help-echo "mouse-2: correct word at point") | 1582 | (overlay-put overlay 'help-echo "mouse-2: correct word at point") |
| 1608 | (overlay-put flyspell-overlay 'keymap flyspell-mouse-map) | 1583 | (overlay-put overlay 'keymap flyspell-mouse-map) |
| 1609 | (when (eq face 'flyspell-incorrect) | 1584 | (when (eq face 'flyspell-incorrect) |
| 1610 | (and (stringp flyspell-before-incorrect-word-string) | 1585 | (and (stringp flyspell-before-incorrect-word-string) |
| 1611 | (overlay-put flyspell-overlay 'before-string | 1586 | (overlay-put overlay 'before-string |
| 1612 | flyspell-before-incorrect-word-string)) | 1587 | flyspell-before-incorrect-word-string)) |
| 1613 | (and (stringp flyspell-after-incorrect-word-string) | 1588 | (and (stringp flyspell-after-incorrect-word-string) |
| 1614 | (overlay-put flyspell-overlay 'after-string | 1589 | (overlay-put overlay 'after-string |
| 1615 | flyspell-after-incorrect-word-string))) | 1590 | flyspell-after-incorrect-word-string))) |
| 1616 | flyspell-overlay)) | 1591 | overlay)) |
| 1617 | 1592 | ||
| 1618 | ;*---------------------------------------------------------------------*/ | 1593 | ;;*---------------------------------------------------------------------*/ |
| 1619 | ;* flyspell-highlight-incorrect-region ... */ | 1594 | ;;* flyspell-highlight-incorrect-region ... */ |
| 1620 | ;*---------------------------------------------------------------------*/ | 1595 | ;;*---------------------------------------------------------------------*/ |
| 1621 | (defun flyspell-highlight-incorrect-region (beg end poss) | 1596 | (defun flyspell-highlight-incorrect-region (beg end poss) |
| 1622 | "Set up an overlay on a misspelled word, in the buffer from BEG to END. | 1597 | "Set up an overlay on a misspelled word, in the buffer from BEG to END. |
| 1623 | POSS is usually a list of possible spelling/correction lists, | 1598 | POSS is usually a list of possible spelling/correction lists, |
| @@ -1639,22 +1614,15 @@ is itself incorrect, but suspiciously repeated." | |||
| 1639 | (delete-overlay (car os))) | 1614 | (delete-overlay (car os))) |
| 1640 | (setq os (cdr os))))) | 1615 | (setq os (cdr os))))) |
| 1641 | ;; we cleanup current overlay at the same position | 1616 | ;; we cleanup current overlay at the same position |
| 1642 | (if (and (not flyspell-persistent-highlight) | 1617 | (flyspell-unhighlight-at beg) |
| 1643 | (overlayp flyspell-overlay)) | ||
| 1644 | (delete-overlay flyspell-overlay) | ||
| 1645 | (let ((os (overlays-at beg))) | ||
| 1646 | (while (consp os) | ||
| 1647 | (if (flyspell-overlay-p (car os)) | ||
| 1648 | (delete-overlay (car os))) | ||
| 1649 | (setq os (cdr os))))) | ||
| 1650 | ;; now we can use a new overlay | 1618 | ;; now we can use a new overlay |
| 1651 | (setq flyspell-overlay | 1619 | (setq flyspell-overlay |
| 1652 | (make-flyspell-overlay | 1620 | (make-flyspell-overlay |
| 1653 | beg end 'flyspell-incorrect 'highlight))))))) | 1621 | beg end 'flyspell-incorrect 'highlight))))))) |
| 1654 | 1622 | ||
| 1655 | ;*---------------------------------------------------------------------*/ | 1623 | ;;*---------------------------------------------------------------------*/ |
| 1656 | ;* flyspell-highlight-duplicate-region ... */ | 1624 | ;;* flyspell-highlight-duplicate-region ... */ |
| 1657 | ;*---------------------------------------------------------------------*/ | 1625 | ;;*---------------------------------------------------------------------*/ |
| 1658 | (defun flyspell-highlight-duplicate-region (beg end poss) | 1626 | (defun flyspell-highlight-duplicate-region (beg end poss) |
| 1659 | "Set up an overlay on a duplicate misspelled word, in the buffer from BEG to END. | 1627 | "Set up an overlay on a duplicate misspelled word, in the buffer from BEG to END. |
| 1660 | POSS is a list of possible spelling/correction lists, | 1628 | POSS is a list of possible spelling/correction lists, |
| @@ -1666,23 +1634,16 @@ as returned by `ispell-parse-output'." | |||
| 1666 | (not (flyspell-properties-at-p beg))) | 1634 | (not (flyspell-properties-at-p beg))) |
| 1667 | (progn | 1635 | (progn |
| 1668 | ;; we cleanup current overlay at the same position | 1636 | ;; we cleanup current overlay at the same position |
| 1669 | (if (and (not flyspell-persistent-highlight) | 1637 | (flyspell-unhighlight-at beg) |
| 1670 | (overlayp flyspell-overlay)) | ||
| 1671 | (delete-overlay flyspell-overlay) | ||
| 1672 | (let ((overlays (overlays-at beg))) | ||
| 1673 | (while (consp overlays) | ||
| 1674 | (if (flyspell-overlay-p (car overlays)) | ||
| 1675 | (delete-overlay (car overlays))) | ||
| 1676 | (setq overlays (cdr overlays))))) | ||
| 1677 | ;; now we can use a new overlay | 1638 | ;; now we can use a new overlay |
| 1678 | (setq flyspell-overlay | 1639 | (setq flyspell-overlay |
| 1679 | (make-flyspell-overlay beg end | 1640 | (make-flyspell-overlay beg end |
| 1680 | 'flyspell-duplicate | 1641 | 'flyspell-duplicate |
| 1681 | 'highlight))))))) | 1642 | 'highlight))))))) |
| 1682 | 1643 | ||
| 1683 | ;*---------------------------------------------------------------------*/ | 1644 | ;;*---------------------------------------------------------------------*/ |
| 1684 | ;* flyspell-auto-correct-cache ... */ | 1645 | ;;* flyspell-auto-correct-cache ... */ |
| 1685 | ;*---------------------------------------------------------------------*/ | 1646 | ;;*---------------------------------------------------------------------*/ |
| 1686 | (defvar flyspell-auto-correct-pos nil) | 1647 | (defvar flyspell-auto-correct-pos nil) |
| 1687 | (defvar flyspell-auto-correct-region nil) | 1648 | (defvar flyspell-auto-correct-region nil) |
| 1688 | (defvar flyspell-auto-correct-ring nil) | 1649 | (defvar flyspell-auto-correct-ring nil) |
| @@ -1692,9 +1653,9 @@ as returned by `ispell-parse-output'." | |||
| 1692 | (make-variable-buffer-local 'flyspell-auto-correct-ring) | 1653 | (make-variable-buffer-local 'flyspell-auto-correct-ring) |
| 1693 | (make-variable-buffer-local 'flyspell-auto-correct-word) | 1654 | (make-variable-buffer-local 'flyspell-auto-correct-word) |
| 1694 | 1655 | ||
| 1695 | ;*---------------------------------------------------------------------*/ | 1656 | ;;*---------------------------------------------------------------------*/ |
| 1696 | ;* flyspell-check-previous-highlighted-word ... */ | 1657 | ;;* flyspell-check-previous-highlighted-word ... */ |
| 1697 | ;*---------------------------------------------------------------------*/ | 1658 | ;;*---------------------------------------------------------------------*/ |
| 1698 | (defun flyspell-check-previous-highlighted-word (&optional arg) | 1659 | (defun flyspell-check-previous-highlighted-word (&optional arg) |
| 1699 | "Correct the closer misspelled word. | 1660 | "Correct the closer misspelled word. |
| 1700 | This function scans a mis-spelled word before the cursor. If it finds one | 1661 | This function scans a mis-spelled word before the cursor. If it finds one |
| @@ -1715,7 +1676,7 @@ misspelled words backwards." | |||
| 1715 | (while (consp ovs) | 1676 | (while (consp ovs) |
| 1716 | (setq ov (car ovs)) | 1677 | (setq ov (car ovs)) |
| 1717 | (setq ovs (cdr ovs)) | 1678 | (setq ovs (cdr ovs)) |
| 1718 | (if (and (overlay-get ov 'flyspell-overlay) | 1679 | (if (and (flyspell-overlay-p ov) |
| 1719 | (= 0 (setq arg (1- arg)))) | 1680 | (= 0 (setq arg (1- arg)))) |
| 1720 | (throw 'exit t))))))) | 1681 | (throw 'exit t))))))) |
| 1721 | (save-excursion | 1682 | (save-excursion |
| @@ -1723,9 +1684,9 @@ misspelled words backwards." | |||
| 1723 | (ispell-word)) | 1684 | (ispell-word)) |
| 1724 | (error "No word to correct before point")))) | 1685 | (error "No word to correct before point")))) |
| 1725 | 1686 | ||
| 1726 | ;*---------------------------------------------------------------------*/ | 1687 | ;;*---------------------------------------------------------------------*/ |
| 1727 | ;* flyspell-display-next-corrections ... */ | 1688 | ;;* flyspell-display-next-corrections ... */ |
| 1728 | ;*---------------------------------------------------------------------*/ | 1689 | ;;*---------------------------------------------------------------------*/ |
| 1729 | (defun flyspell-display-next-corrections (corrections) | 1690 | (defun flyspell-display-next-corrections (corrections) |
| 1730 | (let ((string "Corrections:") | 1691 | (let ((string "Corrections:") |
| 1731 | (l corrections) | 1692 | (l corrections) |
| @@ -1746,25 +1707,25 @@ misspelled words backwards." | |||
| 1746 | (display-message 'no-log string) | 1707 | (display-message 'no-log string) |
| 1747 | (message "%s" string)))) | 1708 | (message "%s" string)))) |
| 1748 | 1709 | ||
| 1749 | ;*---------------------------------------------------------------------*/ | 1710 | ;;*---------------------------------------------------------------------*/ |
| 1750 | ;* flyspell-abbrev-table ... */ | 1711 | ;;* flyspell-abbrev-table ... */ |
| 1751 | ;*---------------------------------------------------------------------*/ | 1712 | ;;*---------------------------------------------------------------------*/ |
| 1752 | (defun flyspell-abbrev-table () | 1713 | (defun flyspell-abbrev-table () |
| 1753 | (if flyspell-use-global-abbrev-table-p | 1714 | (if flyspell-use-global-abbrev-table-p |
| 1754 | global-abbrev-table | 1715 | global-abbrev-table |
| 1755 | (or local-abbrev-table global-abbrev-table))) | 1716 | (or local-abbrev-table global-abbrev-table))) |
| 1756 | 1717 | ||
| 1757 | ;*---------------------------------------------------------------------*/ | 1718 | ;;*---------------------------------------------------------------------*/ |
| 1758 | ;* flyspell-define-abbrev ... */ | 1719 | ;;* flyspell-define-abbrev ... */ |
| 1759 | ;*---------------------------------------------------------------------*/ | 1720 | ;;*---------------------------------------------------------------------*/ |
| 1760 | (defun flyspell-define-abbrev (name expansion) | 1721 | (defun flyspell-define-abbrev (name expansion) |
| 1761 | (let ((table (flyspell-abbrev-table))) | 1722 | (let ((table (flyspell-abbrev-table))) |
| 1762 | (when table | 1723 | (when table |
| 1763 | (define-abbrev table name expansion)))) | 1724 | (define-abbrev table name expansion)))) |
| 1764 | 1725 | ||
| 1765 | ;*---------------------------------------------------------------------*/ | 1726 | ;;*---------------------------------------------------------------------*/ |
| 1766 | ;* flyspell-auto-correct-word ... */ | 1727 | ;;* flyspell-auto-correct-word ... */ |
| 1767 | ;*---------------------------------------------------------------------*/ | 1728 | ;;*---------------------------------------------------------------------*/ |
| 1768 | (defun flyspell-auto-correct-word () | 1729 | (defun flyspell-auto-correct-word () |
| 1769 | "Correct the current word. | 1730 | "Correct the current word. |
| 1770 | This command proposes various successive corrections for the current word." | 1731 | This command proposes various successive corrections for the current word." |
| @@ -1806,12 +1767,12 @@ This command proposes various successive corrections for the current word." | |||
| 1806 | poss) | 1767 | poss) |
| 1807 | (setq flyspell-auto-correct-word word) | 1768 | (setq flyspell-auto-correct-word word) |
| 1808 | ;; now check spelling of word. | 1769 | ;; now check spelling of word. |
| 1809 | (process-send-string ispell-process "%\n") ;put in verbose mode | 1770 | (ispell-send-string "%\n") ;put in verbose mode |
| 1810 | (process-send-string ispell-process (concat "^" word "\n")) | 1771 | (ispell-send-string (concat "^" word "\n")) |
| 1811 | ;; wait until ispell has processed word | 1772 | ;; wait until ispell has processed word. |
| 1812 | (while (progn | 1773 | (while (progn |
| 1813 | (accept-process-output ispell-process) | 1774 | (accept-process-output ispell-process) |
| 1814 | (not (string= "" (car ispell-filter))))) | 1775 | (not (string= "" (car ispell-filter))))) |
| 1815 | (setq ispell-filter (cdr ispell-filter)) | 1776 | (setq ispell-filter (cdr ispell-filter)) |
| 1816 | (if (consp ispell-filter) | 1777 | (if (consp ispell-filter) |
| 1817 | (setq poss (ispell-parse-output (car ispell-filter)))) | 1778 | (setq poss (ispell-parse-output (car ispell-filter)))) |
| @@ -1864,15 +1825,15 @@ This command proposes various successive corrections for the current word." | |||
| 1864 | (setq flyspell-auto-correct-pos (point)) | 1825 | (setq flyspell-auto-correct-pos (point)) |
| 1865 | (ispell-pdict-save t))))))) | 1826 | (ispell-pdict-save t))))))) |
| 1866 | 1827 | ||
| 1867 | ;*---------------------------------------------------------------------*/ | 1828 | ;;*---------------------------------------------------------------------*/ |
| 1868 | ;* flyspell-auto-correct-previous-pos ... */ | 1829 | ;;* flyspell-auto-correct-previous-pos ... */ |
| 1869 | ;*---------------------------------------------------------------------*/ | 1830 | ;;*---------------------------------------------------------------------*/ |
| 1870 | (defvar flyspell-auto-correct-previous-pos nil | 1831 | (defvar flyspell-auto-correct-previous-pos nil |
| 1871 | "Holds the start of the first incorrect word before point.") | 1832 | "Holds the start of the first incorrect word before point.") |
| 1872 | 1833 | ||
| 1873 | ;*---------------------------------------------------------------------*/ | 1834 | ;;*---------------------------------------------------------------------*/ |
| 1874 | ;* flyspell-auto-correct-previous-hook ... */ | 1835 | ;;* flyspell-auto-correct-previous-hook ... */ |
| 1875 | ;*---------------------------------------------------------------------*/ | 1836 | ;;*---------------------------------------------------------------------*/ |
| 1876 | (defun flyspell-auto-correct-previous-hook () | 1837 | (defun flyspell-auto-correct-previous-hook () |
| 1877 | "Hook to track successive calls to `flyspell-auto-correct-previous-word'. | 1838 | "Hook to track successive calls to `flyspell-auto-correct-previous-word'. |
| 1878 | Sets `flyspell-auto-correct-previous-pos' to nil" | 1839 | Sets `flyspell-auto-correct-previous-pos' to nil" |
| @@ -1881,11 +1842,11 @@ Sets `flyspell-auto-correct-previous-pos' to nil" | |||
| 1881 | (unless (eq this-command (function flyspell-auto-correct-previous-word)) | 1842 | (unless (eq this-command (function flyspell-auto-correct-previous-word)) |
| 1882 | (setq flyspell-auto-correct-previous-pos nil))) | 1843 | (setq flyspell-auto-correct-previous-pos nil))) |
| 1883 | 1844 | ||
| 1884 | ;*---------------------------------------------------------------------*/ | 1845 | ;;*---------------------------------------------------------------------*/ |
| 1885 | ;* flyspell-auto-correct-previous-word ... */ | 1846 | ;;* flyspell-auto-correct-previous-word ... */ |
| 1886 | ;*---------------------------------------------------------------------*/ | 1847 | ;;*---------------------------------------------------------------------*/ |
| 1887 | (defun flyspell-auto-correct-previous-word (position) | 1848 | (defun flyspell-auto-correct-previous-word (position) |
| 1888 | "*Auto correct the first mispelled word that occurs before point. | 1849 | "Auto correct the first mispelled word that occurs before point. |
| 1889 | But don't look beyond what's visible on the screen." | 1850 | But don't look beyond what's visible on the screen." |
| 1890 | (interactive "d") | 1851 | (interactive "d") |
| 1891 | 1852 | ||
| @@ -1935,9 +1896,9 @@ But don't look beyond what's visible on the screen." | |||
| 1935 | ;; the point may have moved so reset this | 1896 | ;; the point may have moved so reset this |
| 1936 | (setq flyspell-auto-correct-previous-pos (point)))))))) | 1897 | (setq flyspell-auto-correct-previous-pos (point)))))))) |
| 1937 | 1898 | ||
| 1938 | ;*---------------------------------------------------------------------*/ | 1899 | ;;*---------------------------------------------------------------------*/ |
| 1939 | ;* flyspell-correct-word ... */ | 1900 | ;;* flyspell-correct-word ... */ |
| 1940 | ;*---------------------------------------------------------------------*/ | 1901 | ;;*---------------------------------------------------------------------*/ |
| 1941 | (defun flyspell-correct-word (event) | 1902 | (defun flyspell-correct-word (event) |
| 1942 | "Pop up a menu of possible corrections for a misspelled word. | 1903 | "Pop up a menu of possible corrections for a misspelled word. |
| 1943 | The word checked is the word at the mouse position." | 1904 | The word checked is the word at the mouse position." |
| @@ -1955,12 +1916,12 @@ The word checked is the word at the mouse position." | |||
| 1955 | (word (car word)) | 1916 | (word (car word)) |
| 1956 | poss) | 1917 | poss) |
| 1957 | ;; now check spelling of word. | 1918 | ;; now check spelling of word. |
| 1958 | (process-send-string ispell-process "%\n") ;put in verbose mode | 1919 | (ispell-send-string "%\n") ;put in verbose mode |
| 1959 | (process-send-string ispell-process (concat "^" word "\n")) | 1920 | (ispell-send-string (concat "^" word "\n")) |
| 1960 | ;; wait until ispell has processed word | 1921 | ;; wait until ispell has processed word |
| 1961 | (while (progn | 1922 | (while (progn |
| 1962 | (accept-process-output ispell-process) | 1923 | (accept-process-output ispell-process) |
| 1963 | (not (string= "" (car ispell-filter))))) | 1924 | (not (string= "" (car ispell-filter))))) |
| 1964 | (setq ispell-filter (cdr ispell-filter)) | 1925 | (setq ispell-filter (cdr ispell-filter)) |
| 1965 | (if (consp ispell-filter) | 1926 | (if (consp ispell-filter) |
| 1966 | (setq poss (ispell-parse-output (car ispell-filter)))) | 1927 | (setq poss (ispell-parse-output (car ispell-filter)))) |
| @@ -1973,16 +1934,16 @@ The word checked is the word at the mouse position." | |||
| 1973 | (error "Ispell: error in Ispell process")) | 1934 | (error "Ispell: error in Ispell process")) |
| 1974 | ((featurep 'xemacs) | 1935 | ((featurep 'xemacs) |
| 1975 | (flyspell-xemacs-popup | 1936 | (flyspell-xemacs-popup |
| 1976 | event poss word cursor-location start end save)) | 1937 | poss word cursor-location start end save)) |
| 1977 | (t | 1938 | (t |
| 1978 | ;; The word is incorrect, we have to propose a replacement. | 1939 | ;; The word is incorrect, we have to propose a replacement. |
| 1979 | (flyspell-do-correct (flyspell-emacs-popup event poss word) | 1940 | (flyspell-do-correct (flyspell-emacs-popup event poss word) |
| 1980 | poss word cursor-location start end save))) | 1941 | poss word cursor-location start end save))) |
| 1981 | (ispell-pdict-save t)))))) | 1942 | (ispell-pdict-save t)))))) |
| 1982 | 1943 | ||
| 1983 | ;*---------------------------------------------------------------------*/ | 1944 | ;;*---------------------------------------------------------------------*/ |
| 1984 | ;* flyspell-do-correct ... */ | 1945 | ;;* flyspell-do-correct ... */ |
| 1985 | ;*---------------------------------------------------------------------*/ | 1946 | ;;*---------------------------------------------------------------------*/ |
| 1986 | (defun flyspell-do-correct (replace poss word cursor-location start end save) | 1947 | (defun flyspell-do-correct (replace poss word cursor-location start end save) |
| 1987 | "The popup menu callback." | 1948 | "The popup menu callback." |
| 1988 | ;; Originally, the XEmacs code didn't do the (goto-char save) here and did | 1949 | ;; Originally, the XEmacs code didn't do the (goto-char save) here and did |
| @@ -2031,9 +1992,9 @@ The word checked is the word at the mouse position." | |||
| 2031 | (goto-char save) | 1992 | (goto-char save) |
| 2032 | nil))) | 1993 | nil))) |
| 2033 | 1994 | ||
| 2034 | ;*---------------------------------------------------------------------*/ | 1995 | ;;*---------------------------------------------------------------------*/ |
| 2035 | ;* flyspell-ajust-cursor-point ... */ | 1996 | ;;* flyspell-ajust-cursor-point ... */ |
| 2036 | ;*---------------------------------------------------------------------*/ | 1997 | ;;*---------------------------------------------------------------------*/ |
| 2037 | (defun flyspell-ajust-cursor-point (save cursor-location old-max) | 1998 | (defun flyspell-ajust-cursor-point (save cursor-location old-max) |
| 2038 | (if (>= save cursor-location) | 1999 | (if (>= save cursor-location) |
| 2039 | (let ((new-pos (+ save (- (point-max) old-max)))) | 2000 | (let ((new-pos (+ save (- (point-max) old-max)))) |
| @@ -2045,9 +2006,9 @@ The word checked is the word at the mouse position." | |||
| 2045 | (t new-pos)))) | 2006 | (t new-pos)))) |
| 2046 | (goto-char save))) | 2007 | (goto-char save))) |
| 2047 | 2008 | ||
| 2048 | ;*---------------------------------------------------------------------*/ | 2009 | ;;*---------------------------------------------------------------------*/ |
| 2049 | ;* flyspell-emacs-popup ... */ | 2010 | ;;* flyspell-emacs-popup ... */ |
| 2050 | ;*---------------------------------------------------------------------*/ | 2011 | ;;*---------------------------------------------------------------------*/ |
| 2051 | (defun flyspell-emacs-popup (event poss word) | 2012 | (defun flyspell-emacs-popup (event poss word) |
| 2052 | "The Emacs popup menu." | 2013 | "The Emacs popup menu." |
| 2053 | (if (not event) | 2014 | (if (not event) |
| @@ -2087,10 +2048,10 @@ The word checked is the word at the mouse position." | |||
| 2087 | ispell-dictionary)) | 2048 | ispell-dictionary)) |
| 2088 | menu))))) | 2049 | menu))))) |
| 2089 | 2050 | ||
| 2090 | ;*---------------------------------------------------------------------*/ | 2051 | ;;*---------------------------------------------------------------------*/ |
| 2091 | ;* flyspell-xemacs-popup ... */ | 2052 | ;;* flyspell-xemacs-popup ... */ |
| 2092 | ;*---------------------------------------------------------------------*/ | 2053 | ;;*---------------------------------------------------------------------*/ |
| 2093 | (defun flyspell-xemacs-popup (event poss word cursor-location start end save) | 2054 | (defun flyspell-xemacs-popup (poss word cursor-location start end save) |
| 2094 | "The XEmacs popup menu." | 2055 | "The XEmacs popup menu." |
| 2095 | (let* ((corrects (if flyspell-sort-corrections | 2056 | (let* ((corrects (if flyspell-sort-corrections |
| 2096 | (sort (car (cdr (cdr poss))) 'string<) | 2057 | (sort (car (cdr (cdr poss))) 'string<) |
| @@ -2160,9 +2121,9 @@ The word checked is the word at the mouse position." | |||
| 2160 | ispell-dictionary)) | 2121 | ispell-dictionary)) |
| 2161 | menu)))) | 2122 | menu)))) |
| 2162 | 2123 | ||
| 2163 | ;*---------------------------------------------------------------------*/ | 2124 | ;;*---------------------------------------------------------------------*/ |
| 2164 | ;* Some example functions for real autocorrecting */ | 2125 | ;;* Some example functions for real autocorrecting */ |
| 2165 | ;*---------------------------------------------------------------------*/ | 2126 | ;;*---------------------------------------------------------------------*/ |
| 2166 | (defun flyspell-maybe-correct-transposition (beg end poss) | 2127 | (defun flyspell-maybe-correct-transposition (beg end poss) |
| 2167 | "Check replacements for transposed characters. | 2128 | "Check replacements for transposed characters. |
| 2168 | 2129 | ||
| @@ -2219,16 +2180,16 @@ This function is meant to be added to `flyspell-incorrect-hook'." | |||
| 2219 | (setq i (1+ i)))) | 2180 | (setq i (1+ i)))) |
| 2220 | nil))) | 2181 | nil))) |
| 2221 | 2182 | ||
| 2222 | ;*---------------------------------------------------------------------*/ | 2183 | ;;*---------------------------------------------------------------------*/ |
| 2223 | ;* flyspell-already-abbrevp ... */ | 2184 | ;;* flyspell-already-abbrevp ... */ |
| 2224 | ;*---------------------------------------------------------------------*/ | 2185 | ;;*---------------------------------------------------------------------*/ |
| 2225 | (defun flyspell-already-abbrevp (table word) | 2186 | (defun flyspell-already-abbrevp (table word) |
| 2226 | (let ((sym (abbrev-symbol word table))) | 2187 | (let ((sym (abbrev-symbol word table))) |
| 2227 | (and sym (symbolp sym)))) | 2188 | (and sym (symbolp sym)))) |
| 2228 | 2189 | ||
| 2229 | ;*---------------------------------------------------------------------*/ | 2190 | ;;*---------------------------------------------------------------------*/ |
| 2230 | ;* flyspell-change-abbrev ... */ | 2191 | ;;* flyspell-change-abbrev ... */ |
| 2231 | ;*---------------------------------------------------------------------*/ | 2192 | ;;*---------------------------------------------------------------------*/ |
| 2232 | (defun flyspell-change-abbrev (table old new) | 2193 | (defun flyspell-change-abbrev (table old new) |
| 2233 | (set (abbrev-symbol old table) new)) | 2194 | (set (abbrev-symbol old table) new)) |
| 2234 | 2195 | ||