diff options
| -rw-r--r-- | lisp/textmodes/ispell.el | 1279 |
1 files changed, 700 insertions, 579 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 082190f5bc5..d038d61493c 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -7,11 +7,12 @@ | |||
| 7 | ;;; | 7 | ;;; |
| 8 | ;;; Authors : Ken Stevens et. al. | 8 | ;;; Authors : Ken Stevens et. al. |
| 9 | ;;; Last Modified By: Ken Stevens <k.stevens@ieee.org> | 9 | ;;; Last Modified By: Ken Stevens <k.stevens@ieee.org> |
| 10 | ;;; Last Modified On: Tue Feb 15 16:11:14 MST 1994 | 10 | ;;; Last Modified On: Fri May 20 15:58:52 MDT 1994 |
| 11 | ;;; Update Revision : 2.26 | 11 | ;;; Update Revision : 2.30 |
| 12 | ;;; Syntax : emacs-lisp | 12 | ;;; Syntax : emacs-lisp |
| 13 | ;;; Status : Release with 3.1.03 ispell. | 13 | ;;; Status : Release with 3.1.05 ispell. |
| 14 | ;;; Version : International Ispell Version 3.1 by Geoff Kuenning. | 14 | ;;; Version : International Ispell Version 3.1 by Geoff Kuenning. |
| 15 | ;;; Bug Reports : ispell-el-bugs@itcorp.com | ||
| 15 | ;;; | 16 | ;;; |
| 16 | ;;; This file is part of GNU Emacs. | 17 | ;;; This file is part of GNU Emacs. |
| 17 | ;;; | 18 | ;;; |
| @@ -129,9 +130,27 @@ | |||
| 129 | ;;; | 130 | ;;; |
| 130 | ;;; HISTORY | 131 | ;;; HISTORY |
| 131 | ;;; | 132 | ;;; |
| 132 | ;;; Revision 2.26 | 133 | ;;; Revision 2.30 1994/5/20 15:58:52 stevens |
| 134 | ;;; Continue ispell from ispell-word, C-z functionality fixed. | ||
| 135 | ;;; | ||
| 136 | ;;; Revision 2.29 1994/5/12 09:44:33 stevens | ||
| 137 | ;;; Restored ispell-use-ptys-p, ispell-message aborts sends with interrupt. | ||
| 138 | ;;; defined fn ispell | ||
| 139 | ;;; | ||
| 140 | ;;; Revision 2.28 1994/4/28 16:24:40 stevens | ||
| 141 | ;;; Window checking when ispell-message put on gnus-inews-article-hook jwz. | ||
| 142 | ;;; prefixed ispell- to highlight functions and horiz-scroll fn. | ||
| 143 | ;;; Try and respect case of word in ispell-complete-word. | ||
| 144 | ;;; Ignore non-char events. Ispell-use-ptys-p commented out. Lucid menu. | ||
| 145 | ;;; Better interrupt handling. ispell-message improvements from Ethan. | ||
| 146 | ;;; | ||
| 147 | ;;; Revision 2.27 | ||
| 148 | ;;; version 18 explicit C-g handling disabled as it didn't work. Added | ||
| 149 | ;;; ispell-extra-args for ispell customization (jwz) | ||
| 150 | ;;; | ||
| 151 | ;;; Revision 2.26 1994/2/15 16:11:14 stevens | ||
| 133 | ;;; name changes for copyright assignment. Added word-frags in complete-word. | 152 | ;;; name changes for copyright assignment. Added word-frags in complete-word. |
| 134 | ;;; Horizontal scroll (John Conover) Query-replace matches words now. bugs. | 153 | ;;; Horizontal scroll (John Conover). Query-replace matches words now. bugs. |
| 135 | ;;; | 154 | ;;; |
| 136 | ;;; Revision 2.25 | 155 | ;;; Revision 2.25 |
| 137 | ;;; minor mods, upgraded ispell-message | 156 | ;;; minor mods, upgraded ispell-message |
| @@ -269,26 +288,26 @@ | |||
| 269 | ;;; Code: | 288 | ;;; Code: |
| 270 | 289 | ||
| 271 | (defvar ispell-highlight-p t | 290 | (defvar ispell-highlight-p t |
| 272 | "*When not nil, spelling errors will be highlighted.") | 291 | "*Highlight spelling errors when non-nil.") |
| 273 | 292 | ||
| 274 | (defvar ispell-highlight-face 'highlight | 293 | (defvar ispell-highlight-face 'highlight |
| 275 | "*The face used for ispell highlighting. For Emacses with overlays. | 294 | "*The face used for ispell highlighting. For Emacses with overlays. |
| 276 | Common values for GNU emacs are highlight, modeline, secondary-selection, | 295 | Common values for GNU emacs are highlight, modeline, secondary-selection, |
| 277 | region, and underline. | 296 | region, and underline. |
| 278 | This variable can be set by the user to whatever face they desire. | 297 | This variable can be set by the user to whatever face they desire. |
| 279 | It's most convenient if the cursor color and highlight color are | 298 | It's most convenient if the cursor color and highlight color are |
| 280 | slightly different.") | 299 | slightly different.") |
| 281 | 300 | ||
| 282 | (defvar ispell-check-comments nil | 301 | (defvar ispell-check-comments nil |
| 283 | "*When true, the spelling of comments in region is checked.") | 302 | "*Spelling of comments checked when non-nil.") |
| 284 | 303 | ||
| 285 | (defvar ispell-query-replace-choices nil | 304 | (defvar ispell-query-replace-choices nil |
| 286 | "*When true and spell checking a region, the correction will be made | 305 | "*Corrections made throughout region when non-nil. |
| 287 | throughout the buffer using \\[query-replace].") | 306 | Uses query-replace (\\[query-replace]) for corrections.") |
| 288 | 307 | ||
| 289 | (defvar ispell-skip-tib nil | 308 | (defvar ispell-skip-tib nil |
| 290 | "*If non-nil, the spelling of references for the tib(1) bibliography | 309 | "*Does not spell check tib(1) bibliography references when non-nil. |
| 291 | program are skipped. Otherwise any text between strings matching the regexps | 310 | Skips any text between strings matching regular expressions |
| 292 | ispell-tib-ref-beginning and ispell-tib-ref-end is ignored. | 311 | ispell-tib-ref-beginning and ispell-tib-ref-end is ignored. |
| 293 | 312 | ||
| 294 | TeX users beware: Any field starting with [. will skip until a .] -- even | 313 | TeX users beware: Any field starting with [. will skip until a .] -- even |
| @@ -306,8 +325,8 @@ a [.5mm] type of number....") | |||
| 306 | This minimizes redisplay thrashing.") | 325 | This minimizes redisplay thrashing.") |
| 307 | 326 | ||
| 308 | (defvar ispell-choices-win-default-height 2 | 327 | (defvar ispell-choices-win-default-height 2 |
| 309 | "*The default size of the *Choices*, including status line. | 328 | "*The default size of the *Choices* window, including status line. |
| 310 | Must be greater than 1.") | 329 | Must be greater than 1.") |
| 311 | 330 | ||
| 312 | (defvar ispell-program-name "ispell" | 331 | (defvar ispell-program-name "ispell" |
| 313 | "Program invoked by \\[ispell-word] and \\[ispell-region] commands.") | 332 | "Program invoked by \\[ispell-word] and \\[ispell-region] commands.") |
| @@ -336,39 +355,36 @@ Some machines (like the NeXT) don't support \"-i\"") | |||
| 336 | Must contain complete path!") | 355 | Must contain complete path!") |
| 337 | 356 | ||
| 338 | (defvar ispell-look-p (file-exists-p ispell-look-command) | 357 | (defvar ispell-look-p (file-exists-p ispell-look-command) |
| 339 | "*Use look. Should be nil if your UNIX doesn't have this program. | 358 | "*Use look rather than grep when non-nil. |
| 340 | Attempts to automatically reset if look not available") | 359 | Attempts to automatically reset if look not available") |
| 341 | 360 | ||
| 342 | (defvar ispell-have-new-look nil | 361 | (defvar ispell-have-new-look nil |
| 343 | "*Non-nil means use the `-r' option (regexp) when running `look'.") | 362 | "*Non-nil uses the `-r' option (regexp) when running look.") |
| 344 | 363 | ||
| 345 | (defvar ispell-look-options (if ispell-have-new-look "-dfr" "-df") | 364 | (defvar ispell-look-options (if ispell-have-new-look "-dfr" "-df") |
| 346 | "Options for ispell-look-command") | 365 | "Options for ispell-look-command.") |
| 347 | 366 | ||
| 348 | (defvar ispell-use-ptys-p nil | 367 | (defvar ispell-use-ptys-p nil |
| 349 | "When t, Emacs uses pty's to communicate with Ispell. | 368 | "When non-nil, emacs will use pty's to communicate with ispell. |
| 350 | When nil, Emacs uses pipes.") | 369 | When nil, emacs will use pipes.") |
| 351 | 370 | ||
| 352 | (defvar ispell-following-word nil | 371 | (defvar ispell-following-word nil |
| 353 | "*If non-nil the \\[ispell-word] command will check the spelling | 372 | "*Check word under or following cursor when non-nil. |
| 354 | of the word under or following \(rather than preceding\) the cursor | 373 | Otherwise the preceding word is checked by ispell-word (\\[ispell-word]).") |
| 355 | when called interactively.") | ||
| 356 | 374 | ||
| 357 | (defvar ispell-help-in-bufferp t | 375 | (defvar ispell-help-in-bufferp nil |
| 358 | "*If non-nil, the \\[ispell-help] command will display its | 376 | "*Interactive keymap help is displayed in a buffer when non-nil. |
| 359 | message in a buffer. Otherwise the minibuffer will be used.") | 377 | Otherwise help is shown in the minibuffer.") |
| 360 | 378 | ||
| 361 | (defvar ispell-quietly nil | 379 | (defvar ispell-quietly nil |
| 362 | "*If non-nil, the \\[ispell-word] command will suppress all | 380 | "*Messages suppressed in ispell-word when non-nil and interactive.") |
| 363 | non-corrective messages when called interactively.") | ||
| 364 | 381 | ||
| 365 | (defvar ispell-format-word (function upcase) | 382 | (defvar ispell-format-word (function upcase) |
| 366 | "*The function called to format the word whose spelling is being checked, | 383 | "*Formatting function for displaying word being spell checked. |
| 367 | in diagnostic messages to the user. The function must take one string | 384 | The function must take one string argument and return a string.") |
| 368 | argument and return a string.") | ||
| 369 | 385 | ||
| 370 | (defvar ispell-personal-dictionary nil | 386 | (defvar ispell-personal-dictionary nil |
| 371 | "*A string or nil. If nil, the default directory, ~/.ispell_words is used.") | 387 | "*A string or nil. If nil, the default directory ~/.ispell_words is used.") |
| 372 | 388 | ||
| 373 | (defvar ispell-silently-savep nil | 389 | (defvar ispell-silently-savep nil |
| 374 | "*When non-nil, save the personal dictionary without user verification.") | 390 | "*When non-nil, save the personal dictionary without user verification.") |
| @@ -385,40 +401,47 @@ your .emacs), or use the \\[ispell-change-dictionary] command to | |||
| 385 | change it, as changing this variable only takes effect in a newly | 401 | change it, as changing this variable only takes effect in a newly |
| 386 | started ispell process.") | 402 | started ispell process.") |
| 387 | 403 | ||
| 388 | ;;;###autoload | 404 | (defvar ispell-extra-args nil |
| 405 | "*If non-nil, a list of extra switches to pass to the ispell program. | ||
| 406 | For example, '(\"-W\" \"3\") to cause it to accept all 1-3 character | ||
| 407 | words as correct. See also `ispell-dictionary-alist', which may be used | ||
| 408 | for language-specific arguments.") | ||
| 409 | |||
| 389 | (defvar ispell-dictionary-alist ; sk 9-Aug-1991 18:28 | 410 | (defvar ispell-dictionary-alist ; sk 9-Aug-1991 18:28 |
| 390 | '((nil ; default (english.aff) | 411 | '((nil ; default (english.aff) |
| 391 | "[A-Za-z]" "[^A-Za-z]" "[-']" nil ("-B") nil) | 412 | "[A-Za-z]" "[^A-Za-z]" "[---']" nil ("-B") nil) |
| 392 | ("english" ; make english explicitly selectable | 413 | ("english" ; make english explicitly selectable |
| 393 | "[A-Za-z]" "[^A-Za-z]" "[-']" nil ("-B") nil) | 414 | "[A-Za-z]" "[^A-Za-z]" "[---']" nil ("-B") nil) |
| 394 | ("deutsch" ; deutsch.aff | 415 | ("deutsch" ; deutsch.aff |
| 395 | "[a-zA-Z\"]" "[^a-zA-Z\"]" "[-']" t ("-C") nil) | 416 | "[a-zA-Z\"]" "[^a-zA-Z\"]" "[---']" t ("-C") nil) |
| 396 | ("deutsch8" | 417 | ("deutsch8" |
| 397 | "[a-zA-Z\304\326\334\344\366\337\374]" | 418 | "[a-zA-Z\304\326\334\344\366\337\374]" |
| 398 | "[^a-zA-Z\304\326\334\344\366\337\374]" | 419 | "[^a-zA-Z\304\326\334\344\366\337\374]" |
| 399 | "[-']" t ("-C" "-d" "deutsch") "~latin1") | 420 | "[---']" t ("-C" "-d" "deutsch") "~latin1") |
| 400 | ("nederlands8" ; dutch8.aff | 421 | ("nederlands8" ; dutch8.aff |
| 401 | "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" | 422 | "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" |
| 402 | "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" | 423 | "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" |
| 403 | "[-']" t ("-C") nil) | 424 | "[---']" t ("-C") nil) |
| 404 | ("svenska" ;7 bit swedish mode | 425 | ("svenska" ;7 bit swedish mode |
| 405 | "[A-Za-z}{|\\133\\135\\\\]" "[^A-Za-z}{|\\133\\135\\\\]" | 426 | "[A-Za-z}{|\\133\\135\\\\]" "[^A-Za-z}{|\\133\\135\\\\]" |
| 406 | "[-']" nil ("-C") nil) | 427 | "[---']" nil ("-C") nil) |
| 407 | ("svenska8" ;8 bit swedish mode | 428 | ("svenska8" ;8 bit swedish mode |
| 408 | "[A-Za-z\345\344\366\305\304\366]" "[^A-Za-z\345\344\366\305\304\366]" | 429 | "[A-Za-z\345\344\366\305\304\366]" "[^A-Za-z\345\344\366\305\304\366]" |
| 409 | "[-']" nil ("-C" "-d" "svenska") "~list") ; Add `"-T" "list"' instead? | 430 | "[---']" nil ("-C" "-d" "svenska") "~list") ; Add `"-T" "list"' instead? |
| 410 | ("francais" | 431 | ("francais" |
| 411 | "[A-Za-z]" "[^A-Za-z]" "[-`'\^]" nil nil nil) | 432 | "[A-Za-z]" "[^A-Za-z]" "[`'^---]" t nil nil) |
| 412 | ("danish" ; danish.aff | 433 | ("francais8" "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\346\347\350\351\352\353\356\357\364\371\373\374]" |
| 434 | "[^A-Za-z\300\302\304\306\307\310\311\312\313\316\317\324\326\331\333\334\340\342\344\346\347\350\351\352\353\356\357\364\366\371\373\374]" "[---']" | ||
| 435 | t nil "~list") | ||
| 436 | ("dansk" ; dansk.aff | ||
| 413 | "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]" | 437 | "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]" |
| 414 | "[-]" nil ("-C") nil) | 438 | "[---]" nil ("-C") nil) |
| 415 | ) | 439 | ) |
| 416 | "An alist of dictionaries and their associated parameters. | 440 | "An alist of dictionaries and their associated parameters. |
| 417 | 441 | ||
| 418 | Each element of this list is also a list: | 442 | Each element of this list is also a list: |
| 419 | 443 | ||
| 420 | \(DICTIONARY-NAME | 444 | \(DICTIONARY-NAME CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P |
| 421 | CASECHARS NOT-CASECHARS OTHERCHARS MANY-OTHERCHARS-P | ||
| 422 | ISPELL-ARGS EXTENDED-CHARACTER-MODE\) | 445 | ISPELL-ARGS EXTENDED-CHARACTER-MODE\) |
| 423 | 446 | ||
| 424 | DICTIONARY-NAME is a possible value of variable ispell-dictionary, nil | 447 | DICTIONARY-NAME is a possible value of variable ispell-dictionary, nil |
| @@ -456,50 +479,87 @@ contain the same character set as casechars and otherchars in the | |||
| 456 | language.aff file \(e.g., english.aff\).") | 479 | language.aff file \(e.g., english.aff\).") |
| 457 | 480 | ||
| 458 | 481 | ||
| 459 | ;;; ispell-menu-map from menu-bar.el | ||
| 460 | |||
| 461 | ;;;###autoload | ||
| 462 | (defvar ispell-menu-map nil) | ||
| 463 | ;;;###autoload | ||
| 464 | (if (null ispell-menu-map) | ||
| 465 | (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) | ||
| 466 | name) | ||
| 467 | (setq ispell-menu-map (make-sparse-keymap "Spell")) | ||
| 468 | (while dicts | ||
| 469 | (setq name (car (car dicts)) | ||
| 470 | dicts (cdr dicts)) | ||
| 471 | (if (stringp name) | ||
| 472 | (define-key ispell-menu-map (vector (intern name)) | ||
| 473 | (cons (concat "Select " (capitalize name)) | ||
| 474 | (list 'lambda () '(interactive) | ||
| 475 | (list 'ispell-change-dictionary name)))))) | ||
| 476 | ;; Why do we need an alias here? | ||
| 477 | (defalias 'ispell-menu-map ispell-menu-map) | ||
| 478 | ;; Define commands in opposite order you want them to appear in menu. | ||
| 479 | (define-key ispell-menu-map [ispell-change-dictionary] | ||
| 480 | '("Change Dictionary" . ispell-change-dictionary)) | ||
| 481 | (define-key ispell-menu-map [ispell-kill-ispell] | ||
| 482 | '("Kill Process" . ispell-kill-ispell)) | ||
| 483 | (define-key ispell-menu-map [ispell-pdict-save] | ||
| 484 | '("Save Dictionary" . (lambda () (interactive) (ispell-pdict-save t)))) | ||
| 485 | (define-key ispell-menu-map [ispell-complete-word] | ||
| 486 | '("Complete Word" . ispell-complete-word)) | ||
| 487 | (define-key ispell-menu-map [ispell-complete-word-interior-frag] | ||
| 488 | '("Complete Word Frag" . ispell-complete-word-interior-frag)) | ||
| 489 | (define-key ispell-menu-map [ispell-continue] | ||
| 490 | '("Continue Check" . ispell-continue)) | ||
| 491 | (define-key ispell-menu-map [ispell-region] | ||
| 492 | '("Check Region" . ispell-region)) | ||
| 493 | (define-key ispell-menu-map [ispell-word] | ||
| 494 | '("Check Word" . ispell-word)) | ||
| 495 | (define-key ispell-menu-map [ispell-buffer] | ||
| 496 | '("Check Buffer" . ispell-buffer)) | ||
| 497 | (define-key ispell-menu-map [ispell-message] | ||
| 498 | '("Check Message" . ispell-message)) | ||
| 499 | (define-key ispell-menu-map [ispell-help] | ||
| 500 | '("Help" . (lambda () (interactive) (describe-function 'ispell-help)))) | ||
| 501 | )) | ||
| 502 | 482 | ||
| 483 | (cond | ||
| 484 | ((and (string-lessp "19" emacs-version) | ||
| 485 | (string-match "Lucid" emacs-version)) | ||
| 486 | (let ((dicts (cons (cons "default" nil) ispell-dictionary-alist)) | ||
| 487 | (current-menubar (or current-menubar default-menubar)) | ||
| 488 | (menu | ||
| 489 | '(["Help" (describe-function 'ispell-help) t] | ||
| 490 | ;;["Help" (popup-menu ispell-help-list) t] | ||
| 491 | ["Check Message" ispell-message t] | ||
| 492 | ["Check Buffer" ispell-buffer t] | ||
| 493 | ["Check Word" ispell-word t] | ||
| 494 | ["Check Region" ispell-region (or (not zmacs-regions) (mark))] | ||
| 495 | ["Continue Check" ispell-continue t] | ||
| 496 | ["Complete Word Frag"ispell-complete-word-interior-frag t] | ||
| 497 | ["Complete Word" ispell-complete-word t] | ||
| 498 | ["Kill Process" ispell-kill-ispell t] | ||
| 499 | "-" | ||
| 500 | ["Save Dictionary" (ispell-pdict-save t) t] | ||
| 501 | ["Change Dictionary" ispell-change-dictionary t])) | ||
| 502 | name) | ||
| 503 | (while dicts | ||
| 504 | (setq name (car (car dicts)) | ||
| 505 | dicts (cdr dicts)) | ||
| 506 | (if (stringp name) | ||
| 507 | (setq menu (append menu | ||
| 508 | (list | ||
| 509 | (vector (concat "Select " (capitalize name)) | ||
| 510 | (list 'ispell-change-dictionary name) | ||
| 511 | t)))))) | ||
| 512 | (defvar ispell-menu-lucid menu "Lucid's spelling menu.") | ||
| 513 | (if current-menubar | ||
| 514 | (progn | ||
| 515 | (delete-menu-item '("Edit" "Spell")) ; in case already defined | ||
| 516 | (add-menu '("Edit") "Spell" ispell-menu-lucid))))) | ||
| 517 | |||
| 518 | ;; cond-case: | ||
| 519 | ((and (featurep 'menu-bar) ; GNU emacs | ||
| 520 | (string-lessp "19" emacs-version)) | ||
| 521 | (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) | ||
| 522 | name) | ||
| 523 | (defvar ispell-menu-map nil) | ||
| 524 | ;; Can put in defvar when external defines are removed. | ||
| 525 | (setq ispell-menu-map (make-sparse-keymap "Spell")) | ||
| 526 | (while dicts | ||
| 527 | (setq name (car (car dicts)) | ||
| 528 | dicts (cdr dicts)) | ||
| 529 | (if (stringp name) | ||
| 530 | (define-key ispell-menu-map (vector (intern name)) | ||
| 531 | (cons (concat "Select " (capitalize name)) | ||
| 532 | (list 'lambda () '(interactive) | ||
| 533 | (list 'ispell-change-dictionary name)))))) | ||
| 534 | ;; Why do we need an alias here? | ||
| 535 | (defalias 'ispell-menu-map ispell-menu-map) | ||
| 536 | ;; Define commands in opposite order you want them to appear in menu. | ||
| 537 | (define-key ispell-menu-map [ispell-change-dictionary] | ||
| 538 | '("Change Dictionary" . ispell-change-dictionary)) | ||
| 539 | (define-key ispell-menu-map [ispell-kill-ispell] | ||
| 540 | '("Kill Process" . ispell-kill-ispell)) | ||
| 541 | (define-key ispell-menu-map [ispell-pdict-save] | ||
| 542 | '("Save Dictionary" . (lambda () (interactive) (ispell-pdict-save t)))) | ||
| 543 | (define-key ispell-menu-map [ispell-complete-word] | ||
| 544 | '("Complete Word" . ispell-complete-word)) | ||
| 545 | (define-key ispell-menu-map [ispell-complete-word-interior-frag] | ||
| 546 | '("Complete Word Frag" . ispell-complete-word-interior-frag)) | ||
| 547 | (define-key ispell-menu-map [ispell-continue] | ||
| 548 | '("Continue Check" . ispell-continue)) | ||
| 549 | (define-key ispell-menu-map [ispell-region] | ||
| 550 | '("Check Region" . ispell-region)) | ||
| 551 | (define-key ispell-menu-map [ispell-word] | ||
| 552 | '("Check Word" . ispell-word)) | ||
| 553 | (define-key ispell-menu-map [ispell-buffer] | ||
| 554 | '("Check Buffer" . ispell-buffer)) | ||
| 555 | (define-key ispell-menu-map [ispell-message] | ||
| 556 | '("Check Message" . ispell-message)) | ||
| 557 | (define-key ispell-menu-map [ispell-help] | ||
| 558 | '("Help" . (lambda () (interactive) | ||
| 559 | (describe-function 'ispell-help) | ||
| 560 | ;(x-popup-menu last-nonmenu-event(list "" ispell-help-list)) | ||
| 561 | )))) | ||
| 562 | (put 'ispell-region 'menu-enable 'mark-active))) | ||
| 503 | 563 | ||
| 504 | 564 | ||
| 505 | ;;; ********************************************************************** | 565 | ;;; ********************************************************************** |
| @@ -525,14 +585,15 @@ language.aff file \(e.g., english.aff\).") | |||
| 525 | (nth 6 (assoc ispell-dictionary ispell-dictionary-alist))) | 585 | (nth 6 (assoc ispell-dictionary ispell-dictionary-alist))) |
| 526 | 586 | ||
| 527 | (defvar ispell-process nil | 587 | (defvar ispell-process nil |
| 528 | "Holds the process object for 'ispell'") | 588 | "The process object for Ispell") |
| 529 | 589 | ||
| 530 | (defvar ispell-pdict-modified-p nil | 590 | (defvar ispell-pdict-modified-p nil |
| 531 | "T when the personal dictionary has modifications that need to be written.") | 591 | "T when the personal dictionary has modifications that need to be written.") |
| 532 | 592 | ||
| 533 | ;;; If you want to save the dictionary when quitting, must do so explicitly. | 593 | ;;; If you want to save the dictionary when quitting, must do so explicitly. |
| 534 | (defvar ispell-quit nil | 594 | (defvar ispell-quit nil |
| 535 | "Set to t or point when user wants to abort ispell session.") | 595 | "When non-nil the spell session is terminated. |
| 596 | When numeric, contains cursor location in buffer, and cursor remains there.") | ||
| 536 | 597 | ||
| 537 | (defvar ispell-filter nil | 598 | (defvar ispell-filter nil |
| 538 | "Output filter from piped calls to ispell.") | 599 | "Output filter from piped calls to ispell.") |
| @@ -581,9 +642,9 @@ There should be only one dictionary keyword definition per file, and it | |||
| 581 | should be followed by a correct dictionary name in ispell-dictionary-alist.") | 642 | should be followed by a correct dictionary name in ispell-dictionary-alist.") |
| 582 | 643 | ||
| 583 | (defconst ispell-parsing-keyword "Local IspellParsing: " | 644 | (defconst ispell-parsing-keyword "Local IspellParsing: " |
| 584 | "The keyword for overriding default ispell parsing as determined by | 645 | "The keyword for overriding default ispell parsing. |
| 585 | the buffer's major mode and extended-character mode as determined by the | 646 | Determined by the buffer's major mode and extended-character mode as well as |
| 586 | default dictionary. | 647 | the default dictionary. |
| 587 | 648 | ||
| 588 | The above keyword string should be followed by `latex-mode' or | 649 | The above keyword string should be followed by `latex-mode' or |
| 589 | `nroff-mode' to put the current buffer into the desired parsing mode. | 650 | `nroff-mode' to put the current buffer into the desired parsing mode. |
| @@ -592,11 +653,13 @@ Extended character mode can be changed for this buffer by placing | |||
| 592 | a `~' followed by an extended-character mode -- such as `~.tex'.") | 653 | a `~' followed by an extended-character mode -- such as `~.tex'.") |
| 593 | 654 | ||
| 594 | (defvar ispell-local-pdict ispell-personal-dictionary | 655 | (defvar ispell-local-pdict ispell-personal-dictionary |
| 595 | "A buffer local variable. If a personal dictionary is specified for | 656 | "A buffer local variable containing the current personal dictionary. |
| 596 | the current buffer which is different from the current personal dictionary, | 657 | If a personal dictionary is specified for the current buffer which is |
| 597 | the effect will be similar to calling \\[ispell-change-dictionary]. | 658 | different from the current personal dictionary, the effect will be similar |
| 598 | This variable is automatically set when defined in the file with either | 659 | to calling \\[ispell-change-dictionary]. This variable is automatically |
| 599 | ispell-pdict-keyword or the local variable syntax. | 660 | set when defined in the file with either ispell-pdict-keyword or the |
| 661 | local variable syntax. | ||
| 662 | |||
| 600 | If using Local variable syntax, the dictionary must be nil or a string.") | 663 | If using Local variable syntax, the dictionary must be nil or a string.") |
| 601 | 664 | ||
| 602 | (make-variable-buffer-local 'ispell-local-pdict) | 665 | (make-variable-buffer-local 'ispell-local-pdict) |
| @@ -626,6 +689,8 @@ You can set this variable in hooks in your init file -- eg: | |||
| 626 | ;;; ********************************************************************** | 689 | ;;; ********************************************************************** |
| 627 | 690 | ||
| 628 | 691 | ||
| 692 | (defalias 'ispell 'ispell-buffer) | ||
| 693 | |||
| 629 | ;;;###autoload (define-key global-map "\M-$" 'ispell-word) | 694 | ;;;###autoload (define-key global-map "\M-$" 'ispell-word) |
| 630 | 695 | ||
| 631 | ;;;###autoload | 696 | ;;;###autoload |
| @@ -633,15 +698,15 @@ You can set this variable in hooks in your init file -- eg: | |||
| 633 | "Check spelling of word under or before the cursor. | 698 | "Check spelling of word under or before the cursor. |
| 634 | If word not found in dictionary, display possible corrections in a window | 699 | If word not found in dictionary, display possible corrections in a window |
| 635 | and let user select. | 700 | and let user select. |
| 636 | With a prefix argument (or if CONTINUE is non-nil), | 701 | With a prefix argument (or if CONTINUE is non-nil), |
| 637 | resume interrupted spell-checking of a buffer or region. | 702 | resume interrupted spell-checking of a buffer or region. |
| 638 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' | 703 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' |
| 639 | is non-nil when called interactively, then the following word | 704 | is non-nil when called interactively, then the following word |
| 640 | \(rather than preceding\) is checked when the cursor is not over a word. | 705 | \(rather than preceding\) is checked when the cursor is not over a word. |
| 641 | When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil | 706 | When the optional argument QUIETLY is non-nil or `ispell-quietly' is non-nil |
| 642 | when called interactively, non-corrective messages are suppressed. | 707 | when called interactively, non-corrective messages are suppressed. |
| 643 | 708 | ||
| 644 | Word syntax described by `ispell-dictionary-alist' (which see). | 709 | Word syntax described by `ispell-dictionary-alist' (which see). |
| 645 | 710 | ||
| 646 | This will check or reload the dictionary. Use \\[ispell-change-dictionary] | 711 | This will check or reload the dictionary. Use \\[ispell-change-dictionary] |
| 647 | or \\[ispell-region] to update the Ispell process." | 712 | or \\[ispell-region] to update the Ispell process." |
| @@ -688,15 +753,15 @@ or \\[ispell-region] to update the Ispell process." | |||
| 688 | (t ; prompt for correct word. | 753 | (t ; prompt for correct word. |
| 689 | (unwind-protect | 754 | (unwind-protect |
| 690 | (progn | 755 | (progn |
| 691 | (if ispell-highlight-p | 756 | (if ispell-highlight-p ;highlight word |
| 692 | (highlight-spelling-error start end t)) ; highlight word | 757 | (ispell-highlight-spelling-error start end t)) |
| 693 | (setq replace (ispell-command-loop | 758 | (setq replace (ispell-command-loop |
| 694 | (car (cdr (cdr poss))) | 759 | (car (cdr (cdr poss))) |
| 695 | (car (cdr (cdr (cdr poss)))) | 760 | (car (cdr (cdr (cdr poss)))) |
| 696 | (car poss)))) | 761 | (car poss)))) |
| 697 | ;; protected | 762 | ;; protected |
| 698 | (if ispell-highlight-p ; clear highlight | 763 | (if ispell-highlight-p ; clear highlight |
| 699 | (highlight-spelling-error start end))) | 764 | (ispell-highlight-spelling-error start end))) |
| 700 | (cond ((equal 0 replace) | 765 | (cond ((equal 0 replace) |
| 701 | (ispell-add-per-file-word-list (car poss))) | 766 | (ispell-add-per-file-word-list (car poss))) |
| 702 | (replace | 767 | (replace |
| @@ -721,10 +786,10 @@ or \\[ispell-region] to update the Ispell process." | |||
| 721 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' | 786 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' |
| 722 | is non-nil when called interactively, then the following word | 787 | is non-nil when called interactively, then the following word |
| 723 | \(rather than preceeding\) is checked when the cursor is not over a word. | 788 | \(rather than preceeding\) is checked when the cursor is not over a word. |
| 724 | Optional second argument contains otherchars that can be included in word | 789 | Optional second argument contains otherchars that can be included in word |
| 725 | many times. | 790 | many times. |
| 726 | 791 | ||
| 727 | Word syntax described by `ispell-dictionary-alist' (which see)." | 792 | Word syntax described by `ispell-dictionary-alist' (which see)." |
| 728 | (let* ((ispell-casechars (ispell-get-casechars)) | 793 | (let* ((ispell-casechars (ispell-get-casechars)) |
| 729 | (ispell-not-casechars (ispell-get-not-casechars)) | 794 | (ispell-not-casechars (ispell-get-not-casechars)) |
| 730 | (ispell-otherchars (ispell-get-otherchars)) | 795 | (ispell-otherchars (ispell-get-otherchars)) |
| @@ -778,7 +843,6 @@ many times. | |||
| 778 | ;;; a value or a list, whose value is the state of whether the | 843 | ;;; a value or a list, whose value is the state of whether the |
| 779 | ;;; dictionary needs to be saved. | 844 | ;;; dictionary needs to be saved. |
| 780 | 845 | ||
| 781 | ;;;###autoload | ||
| 782 | (defun ispell-pdict-save (&optional no-query force-save) | 846 | (defun ispell-pdict-save (&optional no-query force-save) |
| 783 | "Check to see if the personal dictionary has been modified. | 847 | "Check to see if the personal dictionary has been modified. |
| 784 | If so, ask if it needs to be saved." | 848 | If so, ask if it needs to be saved." |
| @@ -796,210 +860,220 @@ If so, ask if it needs to be saved." | |||
| 796 | "Display possible corrections from list MISS. | 860 | "Display possible corrections from list MISS. |
| 797 | GUESS lists possibly valid affix construction of WORD. | 861 | GUESS lists possibly valid affix construction of WORD. |
| 798 | Returns nil to keep word. | 862 | Returns nil to keep word. |
| 799 | 0 to insert locally into buffer-local dictionary. | 863 | Returns 0 to insert locally into buffer-local dictionary. |
| 800 | string for new chosen word. | 864 | Returns string for new chosen word. |
| 801 | list for new replacement word (will be rechecked). | 865 | Returns list for new replacement word (will be rechecked). |
| 802 | Optional second argument means replace misspelling in | ||
| 803 | the rest of the region. | ||
| 804 | Global `ispell-pdict-modified-p' becomes a list where the only value | 866 | Global `ispell-pdict-modified-p' becomes a list where the only value |
| 805 | indicates whether the dictionary has been modified when option `a' or `i' is | 867 | indicates whether the dictionary has been modified when option `a' or `i' is |
| 806 | used." | 868 | used." |
| 807 | (unwind-protect | 869 | (unwind-protect |
| 808 | (save-window-excursion | 870 | (save-window-excursion |
| 809 | (let ((count ?0) | 871 | (let ((count ?0) |
| 810 | (line 2) | 872 | (line 2) |
| 811 | (max-lines (- (window-height) 4)) ; assure 4 context lines. | 873 | (max-lines (- (window-height) 4)) ; assure 4 context lines. |
| 812 | (choices miss) | 874 | (choices miss) |
| 813 | (window-min-height (min window-min-height | 875 | (window-min-height (min window-min-height |
| 814 | ispell-choices-win-default-height)) | 876 | ispell-choices-win-default-height)) |
| 815 | (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) | 877 | (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) |
| 816 | (skipped 0) | 878 | (skipped 0) |
| 817 | char num result) | 879 | char num result) |
| 818 | (save-excursion | 880 | (save-excursion |
| 819 | (if ispell-keep-choices-win | 881 | (if ispell-keep-choices-win |
| 820 | (select-window (previous-window)) | 882 | (select-window (previous-window)) |
| 821 | (set-buffer (get-buffer-create ispell-choices-buffer)) | 883 | (set-buffer (get-buffer-create ispell-choices-buffer)) |
| 822 | (setq mode-line-format "-- %b --")) | 884 | (setq mode-line-format "-- %b --")) |
| 823 | (if (equal (get-buffer ispell-choices-buffer) (current-buffer)) | 885 | (if (equal (get-buffer ispell-choices-buffer) (current-buffer)) |
| 824 | (erase-buffer) | 886 | (erase-buffer) |
| 825 | (error "Bogus, dude! I should be in the *Choices* buffer, but I'm not!")) | 887 | (error (concat "Bogus, dude! I should be in the *Choices*" |
| 826 | (if guess | 888 | " buffer, but I'm not!"))) |
| 827 | (progn | 889 | (if guess |
| 828 | (insert | 890 | (progn |
| 829 | "Affix rules generate and capitalize this word as shown below:\n\t") | 891 | (insert "Affix rules generate and capitalize " |
| 830 | (while guess | 892 | "this word as shown below:\n\t") |
| 831 | (if (> (+ 4 (current-column) (length (car guess))) | 893 | (while guess |
| 832 | (window-width)) | 894 | (if (> (+ 4 (current-column) (length (car guess))) |
| 833 | (progn | 895 | (window-width)) |
| 834 | (insert "\n\t") | 896 | (progn |
| 835 | (setq line (1+ line)))) | 897 | (insert "\n\t") |
| 836 | (insert (car guess) " ") | 898 | (setq line (1+ line)))) |
| 837 | (setq guess (cdr guess))) | 899 | (insert (car guess) " ") |
| 838 | (insert "\nUse option `i' if this is a correct composition from the derivative root\n") | 900 | (setq guess (cdr guess))) |
| 839 | (setq line (+ line (if choices 3 2))))) | 901 | (insert "\nUse option `i' if this is a correct composition" |
| 840 | (while (and choices | 902 | " from the derivative root.\n") |
| 841 | (< (if (> (+ 7 (current-column) (length (car choices)) | 903 | (setq line (+ line (if choices 3 2))))) |
| 842 | (if (> count ?~) 3 0)) | 904 | (while (and choices |
| 843 | (window-width)) | 905 | (< (if (> (+ 7 (current-column) (length (car choices)) |
| 844 | (progn | 906 | (if (> count ?~) 3 0)) |
| 845 | (insert "\n") | 907 | (window-width)) |
| 846 | (setq line (1+ line))) | 908 | (progn |
| 847 | line) | 909 | (insert "\n") |
| 848 | max-lines)) | 910 | (setq line (1+ line))) |
| 849 | ;; not so good if there are over 20 or 30 options, but then, if | 911 | line) |
| 850 | ;; there are that many you don't want to have to scan them all anyway... | 912 | max-lines)) |
| 851 | (while (memq count command-characters) ; skip command characters. | 913 | ;; not so good if there are over 20 or 30 options, but then, if |
| 852 | (setq count (1+ count) | 914 | ;; there are that many you don't want to scan them all anyway... |
| 853 | skipped (1+ skipped))) | 915 | (while (memq count command-characters) ; skip command characters. |
| 854 | (insert "(" count ") " (car choices) " ") | 916 | (setq count (1+ count) |
| 855 | (setq choices (cdr choices) | 917 | skipped (1+ skipped))) |
| 856 | count (1+ count))) | 918 | (insert "(" count ") " (car choices) " ") |
| 857 | (setq count (- count ?0 skipped))) | 919 | (setq choices (cdr choices) |
| 858 | 920 | count (1+ count))) | |
| 859 | (if ispell-keep-choices-win | 921 | (setq count (- count ?0 skipped))) |
| 860 | (if (> line ispell-keep-choices-win) | 922 | |
| 861 | (progn | 923 | (if ispell-keep-choices-win |
| 862 | (switch-to-buffer ispell-choices-buffer) | 924 | (if (> line ispell-keep-choices-win) |
| 863 | (select-window (next-window)) | ||
| 864 | (save-excursion | ||
| 865 | (let ((cur-point (point))) | ||
| 866 | (move-to-window-line (- line ispell-keep-choices-win)) | ||
| 867 | (if (<= (point) cur-point) | ||
| 868 | (set-window-start (selected-window) (point))))) | ||
| 869 | (select-window (previous-window)) | ||
| 870 | (enlarge-window (- line ispell-keep-choices-win)) | ||
| 871 | (goto-char (point-min)))) | ||
| 872 | (ispell-overlay-window (max line ispell-choices-win-default-height))) | ||
| 873 | (switch-to-buffer ispell-choices-buffer) | ||
| 874 | (goto-char (point-min)) | ||
| 875 | (select-window (next-window)) | ||
| 876 | (while | ||
| 877 | (eq | ||
| 878 | t | ||
| 879 | (setq | ||
| 880 | result | ||
| 881 | (progn | ||
| 882 | (undo-boundary) | ||
| 883 | (message "C-h or ? for more options; SPC to leave unchanged, Character to replace word") | ||
| 884 | (let ((inhibit-quit t)) | ||
| 885 | (setq char (read-char) | ||
| 886 | skipped 0) | ||
| 887 | ;; Implement quit by using the X command to get out. | ||
| 888 | (if (eq char (nth 3 (current-input-mode))) | ||
| 889 | (setq char ?X | ||
| 890 | quit-flag nil))) | ||
| 891 | ;; Adjust num to array offset skipping command characters. | ||
| 892 | (let ((com-chars command-characters)) | ||
| 893 | (while com-chars | ||
| 894 | (if (and (> (car com-chars) ?0) (< (car com-chars) char)) | ||
| 895 | (setq skipped (1+ skipped))) | ||
| 896 | (setq com-chars (cdr com-chars))) | ||
| 897 | (setq num (- char ?0 skipped))) | ||
| 898 | |||
| 899 | (cond | ||
| 900 | ((= char ? ) nil) ; accept word this time only | ||
| 901 | ((= char ?i) ; accept and insert word into pers dict | ||
| 902 | (process-send-string ispell-process (concat "*" word "\n")) | ||
| 903 | (setq ispell-pdict-modified-p '(t)) ; dictionary was modified! | ||
| 904 | nil) | ||
| 905 | ((or (= char ?a) (= char ?A)) ; accept word, don't insert in dict | ||
| 906 | (process-send-string ispell-process (concat "@" word "\n")) | ||
| 907 | (if (null ispell-pdict-modified-p) | ||
| 908 | (setq ispell-pdict-modified-p | ||
| 909 | (list ispell-pdict-modified-p))) | ||
| 910 | (if (= char ?A) 0)) ; return 0 for ispell-add buffer-local | ||
| 911 | ((or (= char ?r) (= char ?R)) ; type in replacement | ||
| 912 | (if (or (= char ?R) ispell-query-replace-choices) | ||
| 913 | (list (read-string "Query-replacement for: " word) t) | ||
| 914 | (cons (read-string "Replacement for: " word) nil))) | ||
| 915 | ((or (= char ??) (= char help-char) (= char ?\C-h)) | ||
| 916 | (ispell-help) | ||
| 917 | t) | ||
| 918 | ;; Quit and move point back. | ||
| 919 | ((= char ?x) | ||
| 920 | (ispell-pdict-save ispell-silently-savep) | ||
| 921 | (message "Exited spell-checking") | ||
| 922 | (setq ispell-quit t) | ||
| 923 | nil) | ||
| 924 | ;; Quit and preserve point. | ||
| 925 | ((= char ?X) | ||
| 926 | (ispell-pdict-save ispell-silently-savep) | ||
| 927 | (message | ||
| 928 | (substitute-command-keys | ||
| 929 | "Spell-checking suspended; use C-u \\[ispell-word] to resume")) | ||
| 930 | (setq ispell-quit (max (point-min) (- (point) (length word)))) | ||
| 931 | nil) | ||
| 932 | ((= char ?q) | ||
| 933 | (if (y-or-n-p "Really quit ignoring changes? ") | ||
| 934 | (progn | 925 | (progn |
| 935 | (ispell-kill-ispell t) ; terminate process. | 926 | (switch-to-buffer ispell-choices-buffer) |
| 936 | (setq ispell-quit t | 927 | (select-window (next-window)) |
| 937 | ispell-pdict-modified-p nil)) | 928 | (save-excursion |
| 938 | t)) ; continue if they don't quit. | 929 | (let ((cur-point (point))) |
| 939 | ((= char ?l) | 930 | (move-to-window-line (- line ispell-keep-choices-win)) |
| 940 | (let ((new-word (read-string "Lookup string (`*' is wildcard): " | 931 | (if (<= (point) cur-point) |
| 941 | word)) | 932 | (set-window-start (selected-window) (point))))) |
| 942 | (new-line 2)) | 933 | (select-window (previous-window)) |
| 943 | (if new-word | 934 | (enlarge-window (- line ispell-keep-choices-win)) |
| 944 | (progn | 935 | (goto-char (point-min)))) |
| 945 | (save-excursion | 936 | (ispell-overlay-window (max line |
| 946 | (set-buffer (get-buffer-create ispell-choices-buffer)) | 937 | ispell-choices-win-default-height))) |
| 947 | (erase-buffer) | 938 | (switch-to-buffer ispell-choices-buffer) |
| 948 | (setq count ?0 | 939 | (goto-char (point-min)) |
| 949 | skipped 0 | 940 | (select-window (next-window)) |
| 950 | mode-line-format "-- %b --" | 941 | (while |
| 951 | miss (lookup-words new-word) | 942 | (eq |
| 952 | choices miss) | 943 | t |
| 953 | (while (and choices ; adjust choices window. | 944 | (setq |
| 954 | (< (if (> (+ 7 (current-column) | 945 | result |
| 955 | (length (car choices)) | 946 | (progn |
| 956 | (if (> count ?~) 3 0)) | 947 | (undo-boundary) |
| 957 | (window-width)) | 948 | (message (concat "C-h or ? for more options; SPC to leave " |
| 958 | (progn | 949 | "unchanged, Character to replace word")) |
| 959 | (insert "\n") | 950 | (let ((inhibit-quit t)) |
| 960 | (setq new-line (1+ new-line))) | 951 | (setq char (if (fboundp 'read-char-exclusive) |
| 961 | new-line) | 952 | (read-char-exclusive) |
| 962 | max-lines)) | 953 | (read-char)) |
| 963 | (while (memq count command-characters) | 954 | skipped 0) |
| 964 | (setq count (1+ count) | 955 | (if (or quit-flag (= char ?\C-g)) ; C-g is like typing q |
| 965 | skipped (1+ skipped))) | 956 | (setq char ?q |
| 966 | (insert "(" count ") " (car choices) " ") | 957 | quit-flag nil))) |
| 967 | (setq choices (cdr choices) | 958 | ;; Adjust num to array offset skipping command characters. |
| 968 | count (1+ count))) | 959 | (let ((com-chars command-characters)) |
| 969 | (setq count (- count ?0 skipped))) | 960 | (while com-chars |
| 970 | (select-window (previous-window)) | 961 | (if (and (> (car com-chars) ?0) (< (car com-chars) char)) |
| 971 | (if (/= new-line line) | 962 | (setq skipped (1+ skipped))) |
| 963 | (setq com-chars (cdr com-chars))) | ||
| 964 | (setq num (- char ?0 skipped))) | ||
| 965 | |||
| 966 | (cond | ||
| 967 | ((= char ? ) nil) ; accept word this time only | ||
| 968 | ((= char ?i) ; accept and insert word into pers dict | ||
| 969 | (process-send-string ispell-process (concat "*" word "\n")) | ||
| 970 | (setq ispell-pdict-modified-p '(t)) ; dictionary modified! | ||
| 971 | nil) | ||
| 972 | ((or (= char ?a) (= char ?A)) ; accept word without insert | ||
| 973 | (process-send-string ispell-process (concat "@" word "\n")) | ||
| 974 | (if (null ispell-pdict-modified-p) | ||
| 975 | (setq ispell-pdict-modified-p | ||
| 976 | (list ispell-pdict-modified-p))) | ||
| 977 | (if (= char ?A) 0)) ; return 0 for ispell-add buffer-local | ||
| 978 | ((or (= char ?r) (= char ?R)) ; type in replacement | ||
| 979 | (if (or (= char ?R) ispell-query-replace-choices) | ||
| 980 | (list (read-string "Query-replacement for: " word) t) | ||
| 981 | (cons (read-string "Replacement for: " word) nil))) | ||
| 982 | ((or (= char ??) (= char help-char) (= char ?\C-h)) | ||
| 983 | (ispell-help) | ||
| 984 | t) | ||
| 985 | ;; Quit and move point back. | ||
| 986 | ((= char ?x) | ||
| 987 | (ispell-pdict-save ispell-silently-savep) | ||
| 988 | (message "Exited spell-checking") | ||
| 989 | (setq ispell-quit t) | ||
| 990 | nil) | ||
| 991 | ;; Quit and preserve point. | ||
| 992 | ((= char ?X) | ||
| 993 | (ispell-pdict-save ispell-silently-savep) | ||
| 994 | (message | ||
| 995 | (substitute-command-keys | ||
| 996 | (concat "Spell-checking suspended;" | ||
| 997 | " use C-u \\[ispell-word] to resume"))) | ||
| 998 | (setq ispell-quit (max (point-min) | ||
| 999 | (- (point) (length word)))) | ||
| 1000 | nil) | ||
| 1001 | ((= char ?q) | ||
| 1002 | (if (y-or-n-p "Really quit ignoring changes? ") | ||
| 1003 | (progn | ||
| 1004 | (ispell-kill-ispell t) ; terminate process. | ||
| 1005 | (setq ispell-quit (or (not ispell-checking-message) | ||
| 1006 | (point)) | ||
| 1007 | ispell-pdict-modified-p nil)) | ||
| 1008 | t)) ; continue if they don't quit. | ||
| 1009 | ((= char ?l) | ||
| 1010 | (let ((new-word (read-string | ||
| 1011 | "Lookup string (`*' is wildcard): " | ||
| 1012 | word)) | ||
| 1013 | (new-line 2)) | ||
| 1014 | (if new-word | ||
| 972 | (progn | 1015 | (progn |
| 973 | (if (> new-line line) | 1016 | (save-excursion |
| 974 | (enlarge-window (- new-line line)) | 1017 | (set-buffer (get-buffer-create |
| 975 | (shrink-window (- line new-line))) | 1018 | ispell-choices-buffer)) |
| 976 | (setq line new-line))) | 1019 | (erase-buffer) |
| 977 | (select-window (next-window))))) | 1020 | (setq count ?0 |
| 978 | t) ; reselect from new choices | 1021 | skipped 0 |
| 979 | ((= char ?u) | 1022 | mode-line-format "-- %b --" |
| 980 | (process-send-string ispell-process | 1023 | miss (lookup-words new-word) |
| 981 | (concat "*" (downcase word) "\n")) | 1024 | choices miss) |
| 982 | (setq ispell-pdict-modified-p '(t)) ; dictionary was modified! | 1025 | (while (and choices ; adjust choices window. |
| 983 | nil) | 1026 | (< (if (> (+ 7 (current-column) |
| 984 | ((= char ?m) ; type in what to insert | 1027 | (length (car choices)) |
| 985 | (process-send-string | 1028 | (if (> count ?~) 3 0)) |
| 986 | ispell-process (concat "*" (read-string "Insert: " word) "\n")) | 1029 | (window-width)) |
| 987 | (setq ispell-pdict-modified-p '(t)) | 1030 | (progn |
| 988 | (cons word nil)) | 1031 | (insert "\n") |
| 989 | ((and (>= num 0) (< num count)) | 1032 | (setq new-line |
| 990 | (if ispell-query-replace-choices ; Query replace when flag set. | 1033 | (1+ new-line))) |
| 991 | (list (nth num miss) 'query-replace) | 1034 | new-line) |
| 992 | (nth num miss))) | 1035 | max-lines)) |
| 993 | ((= char ?\C-l) | 1036 | (while (memq count command-characters) |
| 994 | (redraw-display) t) | 1037 | (setq count (1+ count) |
| 995 | ((= char ?\C-r) | 1038 | skipped (1+ skipped))) |
| 996 | (save-window-excursion (recursive-edit)) t) | 1039 | (insert "(" count ") " (car choices) " ") |
| 997 | ((= char ?\C-z) | 1040 | (setq choices (cdr choices) |
| 998 | (funcall (key-binding "\C-z")) | 1041 | count (1+ count))) |
| 999 | t) | 1042 | (setq count (- count ?0 skipped))) |
| 1000 | (t (ding) t)))))) | 1043 | (select-window (previous-window)) |
| 1001 | result)) | 1044 | (if (/= new-line line) |
| 1002 | (if (not ispell-keep-choices-win) (bury-buffer ispell-choices-buffer)))) | 1045 | (progn |
| 1046 | (if (> new-line line) | ||
| 1047 | (enlarge-window (- new-line line)) | ||
| 1048 | (shrink-window (- line new-line))) | ||
| 1049 | (setq line new-line))) | ||
| 1050 | (select-window (next-window))))) | ||
| 1051 | t) ; reselect from new choices | ||
| 1052 | ((= char ?u) | ||
| 1053 | (process-send-string ispell-process | ||
| 1054 | (concat "*" (downcase word) "\n")) | ||
| 1055 | (setq ispell-pdict-modified-p '(t)) ; dictionary modified! | ||
| 1056 | nil) | ||
| 1057 | ((= char ?m) ; type in what to insert | ||
| 1058 | (process-send-string | ||
| 1059 | ispell-process (concat "*" (read-string "Insert: " word) | ||
| 1060 | "\n")) | ||
| 1061 | (setq ispell-pdict-modified-p '(t)) | ||
| 1062 | (cons word nil)) | ||
| 1063 | ((and (>= num 0) (< num count)) | ||
| 1064 | (if ispell-query-replace-choices ; Query replace flag | ||
| 1065 | (list (nth num miss) 'query-replace) | ||
| 1066 | (nth num miss))) | ||
| 1067 | ((= char ?\C-l) | ||
| 1068 | (redraw-display) t) | ||
| 1069 | ((= char ?\C-r) | ||
| 1070 | (save-window-excursion (recursive-edit)) t) | ||
| 1071 | ((= char ?\C-z) | ||
| 1072 | (funcall (key-binding "\C-z")) | ||
| 1073 | t) | ||
| 1074 | (t (ding) t)))))) | ||
| 1075 | result)) | ||
| 1076 | (if (not ispell-keep-choices-win) (bury-buffer ispell-choices-buffer)))) | ||
| 1003 | 1077 | ||
| 1004 | 1078 | ||
| 1005 | ;;;###autoload | 1079 | ;;;###autoload |
| @@ -1027,9 +1101,12 @@ DIGIT: Replace the word with a digit offered in the *Choices* buffer. | |||
| 1027 | 'C-r': recursive edit | 1101 | 'C-r': recursive edit |
| 1028 | 'C-z': suspend emacs or iconify frame" | 1102 | 'C-z': suspend emacs or iconify frame" |
| 1029 | 1103 | ||
| 1030 | (let ((help-1 "[r/R]eplace word; [a/A]ccept for this session; [i]nsert into private dictionary") | 1104 | (let ((help-1 (concat "[r/R]eplace word; [a/A]ccept for this session; " |
| 1031 | (help-2 "[l]ook a word up in alternate dictionary; e[x/X]it; [q]uit session") | 1105 | "[i]nsert into private dictionary")) |
| 1032 | (help-3 "[u]ncapitalized insert into dictionary. Type 'C-h d ispell-help' for more help")) | 1106 | (help-2 (concat "[l]ook a word up in alternate dictionary; " |
| 1107 | "e[x/X]it; [q]uit session")) | ||
| 1108 | (help-3 (concat "[u]ncapitalized insert into dictionary. " | ||
| 1109 | "Type 'C-h d ispell-help' for more help"))) | ||
| 1033 | (save-window-excursion | 1110 | (save-window-excursion |
| 1034 | (if ispell-help-in-bufferp | 1111 | (if ispell-help-in-bufferp |
| 1035 | (progn | 1112 | (progn |
| @@ -1039,16 +1116,17 @@ DIGIT: Replace the word with a digit offered in the *Choices* buffer. | |||
| 1039 | (sit-for 5) | 1116 | (sit-for 5) |
| 1040 | (kill-buffer "*Ispell Help*")) | 1117 | (kill-buffer "*Ispell Help*")) |
| 1041 | (select-window (minibuffer-window)) | 1118 | (select-window (minibuffer-window)) |
| 1042 | (enlarge-window 2) | 1119 | ;;(enlarge-window 2) |
| 1043 | (erase-buffer) | 1120 | (erase-buffer) |
| 1044 | (cond ((string-match "Lucid" emacs-version) | 1121 | (cond ((string-match "Lucid" emacs-version) |
| 1045 | (message help-3) | 1122 | (message help-3) |
| 1046 | (enlarge-window 1) | 1123 | (enlarge-window 1) |
| 1047 | (message help-2) | 1124 | (message help-2) |
| 1048 | (enlarge-window 1) | 1125 | (enlarge-window 1) |
| 1049 | (message help-1)) | 1126 | (message help-1) |
| 1127 | (goto-char (point-min))) | ||
| 1050 | (t | 1128 | (t |
| 1051 | (if (string-match "^19\\." emacs-version) | 1129 | (if (string-lessp "19" emacs-version) |
| 1052 | (message nil)) | 1130 | (message nil)) |
| 1053 | (enlarge-window 2) | 1131 | (enlarge-window 2) |
| 1054 | (insert (concat help-1 "\n" help-2 "\n" help-3)))) | 1132 | (insert (concat help-1 "\n" help-2 "\n" help-3)))) |
| @@ -1058,11 +1136,12 @@ DIGIT: Replace the word with a digit offered in the *Choices* buffer. | |||
| 1058 | 1136 | ||
| 1059 | (defun lookup-words (word &optional lookup-dict) | 1137 | (defun lookup-words (word &optional lookup-dict) |
| 1060 | "Look up word in word-list dictionary. | 1138 | "Look up word in word-list dictionary. |
| 1061 | A `*' is serves as a wild card. If no wild cards, `look' is used if it exists. | 1139 | A `*' serves as a wild card. If no wild cards, `look' is used if it exists. |
| 1062 | Otherwise the variable `ispell-grep-command' contains the command used to | 1140 | Otherwise the variable `ispell-grep-command' contains the command used to |
| 1063 | search for the words (usually egrep). | 1141 | search for the words (usually egrep). |
| 1142 | |||
| 1064 | Optional second argument contains the dictionary to use; the default is | 1143 | Optional second argument contains the dictionary to use; the default is |
| 1065 | `ispell-alternate-dictionary'." | 1144 | `ispell-alternate-dictionary'." |
| 1066 | ;; We don't use the filter for this function, rather the result is written | 1145 | ;; We don't use the filter for this function, rather the result is written |
| 1067 | ;; into a buffer. Hence there is no need to save the filter values. | 1146 | ;; into a buffer. Hence there is no need to save the filter values. |
| 1068 | (if (null lookup-dict) | 1147 | (if (null lookup-dict) |
| @@ -1153,7 +1232,7 @@ Optional second argument contains the dictionary to use; the default is | |||
| 1153 | 1232 | ||
| 1154 | ;;; This function destroys the mark location if it is in the word being | 1233 | ;;; This function destroys the mark location if it is in the word being |
| 1155 | ;;; highlighted. | 1234 | ;;; highlighted. |
| 1156 | (defun highlight-spelling-error-generic (start end &optional highlight) | 1235 | (defun ispell-highlight-spelling-error-generic (start end &optional highlight) |
| 1157 | "Highlight the word from START to END with a kludge using `inverse-video'. | 1236 | "Highlight the word from START to END with a kludge using `inverse-video'. |
| 1158 | When the optional third arg HIGHLIGHT is set, the word is highlighted; | 1237 | When the optional third arg HIGHLIGHT is set, the word is highlighted; |
| 1159 | otherwise it is displayed normally." | 1238 | otherwise it is displayed normally." |
| @@ -1173,7 +1252,7 @@ otherwise it is displayed normally." | |||
| 1173 | (set-buffer-modified-p modified))) ; don't modify if flag not set. | 1252 | (set-buffer-modified-p modified))) ; don't modify if flag not set. |
| 1174 | 1253 | ||
| 1175 | 1254 | ||
| 1176 | (defun highlight-spelling-error-lucid (start end &optional highlight) | 1255 | (defun ispell-highlight-spelling-error-lucid (start end &optional highlight) |
| 1177 | "Highlight the word from START to END using `isearch-highlight'. | 1256 | "Highlight the word from START to END using `isearch-highlight'. |
| 1178 | When the optional third arg HIGHLIGHT is set, the word is highlighted | 1257 | When the optional third arg HIGHLIGHT is set, the word is highlighted |
| 1179 | otherwise it is displayed normally." | 1258 | otherwise it is displayed normally." |
| @@ -1184,11 +1263,12 @@ otherwise it is displayed normally." | |||
| 1184 | ) | 1263 | ) |
| 1185 | 1264 | ||
| 1186 | 1265 | ||
| 1187 | (defun highlight-spelling-error-overlay (start end &optional highlight) | 1266 | (defun ispell-highlight-spelling-error-overlay (start end &optional highlight) |
| 1188 | "Highlight the word from START to END using overlays. | 1267 | "Highlight the word from START to END using overlays. |
| 1189 | When the optional third arg HIGHLIGHT is set, the word is highlighted | 1268 | When the optional third arg HIGHLIGHT is set, the word is highlighted |
| 1190 | otherwise it is displayed normally. | 1269 | otherwise it is displayed normally. |
| 1191 | The variable ispell-highlight-face selects the face that will be used | 1270 | |
| 1271 | The variable ispell-highlight-face selects the face that will be used | ||
| 1192 | for highlighting." | 1272 | for highlighting." |
| 1193 | (if highlight | 1273 | (if highlight |
| 1194 | (progn | 1274 | (progn |
| @@ -1198,13 +1278,14 @@ for highlighting." | |||
| 1198 | 1278 | ||
| 1199 | 1279 | ||
| 1200 | ;;; Choose a highlight function at load time. | 1280 | ;;; Choose a highlight function at load time. |
| 1201 | (fset 'highlight-spelling-error | 1281 | (fset 'ispell-highlight-spelling-error |
| 1202 | (symbol-function | 1282 | (symbol-function |
| 1203 | (cond | 1283 | (cond |
| 1204 | ((string-match "Lucid" emacs-version) 'highlight-spelling-error-lucid) | 1284 | ((string-match "Lucid" emacs-version) |
| 1205 | ((and (string-match "^19\\." emacs-version) | 1285 | 'ispell-highlight-spelling-error-lucid) |
| 1206 | (featurep 'faces)) 'highlight-spelling-error-overlay) | 1286 | ((and (string-lessp "19" emacs-version) (featurep 'faces)) |
| 1207 | (t 'highlight-spelling-error-generic)))) | 1287 | 'ispell-highlight-spelling-error-overlay) |
| 1288 | (t 'ispell-highlight-spelling-error-generic)))) | ||
| 1208 | 1289 | ||
| 1209 | 1290 | ||
| 1210 | (defun ispell-overlay-window (height) | 1291 | (defun ispell-overlay-window (height) |
| @@ -1218,6 +1299,12 @@ scrolling the current window. Leave the old window selected." | |||
| 1218 | ;; hidden by new window, scroll it to just below new win | 1299 | ;; hidden by new window, scroll it to just below new win |
| 1219 | ;; otherwise set top line of other win so it doesn't scroll. | 1300 | ;; otherwise set top line of other win so it doesn't scroll. |
| 1220 | (if (< oldot top) (setq top oldot)) | 1301 | (if (< oldot top) (setq top oldot)) |
| 1302 | ;; NB: Lemacs 19.9 bug: If a window of size N (N includes the mode | ||
| 1303 | ;; line) is demanded, the last line is not visible. | ||
| 1304 | ;; At least this happens on AIX 3.2, lemacs w/ Motif, font 9x15. | ||
| 1305 | ;; So we increment the height for this case. | ||
| 1306 | (if (string-match "19\.9.*Lucid" (emacs-version)) | ||
| 1307 | (setq height (1+ height))) | ||
| 1221 | (split-window nil height) | 1308 | (split-window nil height) |
| 1222 | (set-window-start (next-window) top)))) | 1309 | (set-window-start (next-window) top)))) |
| 1223 | 1310 | ||
| @@ -1273,11 +1360,6 @@ scrolling the current window. Leave the old window selected." | |||
| 1273 | ;; all versions, since versions earlier than 3.0.09 didn't identify | 1360 | ;; all versions, since versions earlier than 3.0.09 didn't identify |
| 1274 | ;; themselves on startup. | 1361 | ;; themselves on startup. |
| 1275 | ;; | 1362 | ;; |
| 1276 | ;; If the ispell.el file ever supports more than one version of the | ||
| 1277 | ;; external ispell program, then this should be reworked to accept more | ||
| 1278 | ;; than one version, but until that happens, doing so would be false | ||
| 1279 | ;; generality. | ||
| 1280 | ;; | ||
| 1281 | (save-excursion | 1363 | (save-excursion |
| 1282 | (set-buffer (get-buffer-create " *ispell-tmp*")) | 1364 | (set-buffer (get-buffer-create " *ispell-tmp*")) |
| 1283 | (erase-buffer) | 1365 | (erase-buffer) |
| @@ -1338,6 +1420,7 @@ scrolling the current window. Leave the old window selected." | |||
| 1338 | (list "-p" | 1420 | (list "-p" |
| 1339 | (expand-file-name | 1421 | (expand-file-name |
| 1340 | ispell-personal-dictionary))))) | 1422 | ispell-personal-dictionary))))) |
| 1423 | (setq args (append args ispell-extra-args)) | ||
| 1341 | args))) | 1424 | args))) |
| 1342 | ispell-filter nil | 1425 | ispell-filter nil |
| 1343 | ispell-filter-continue nil | 1426 | ispell-filter-continue nil |
| @@ -1366,7 +1449,6 @@ scrolling the current window. Leave the old window selected." | |||
| 1366 | (concat extended-char-mode "\n")))) | 1449 | (concat extended-char-mode "\n")))) |
| 1367 | (process-kill-without-query ispell-process))) | 1450 | (process-kill-without-query ispell-process))) |
| 1368 | 1451 | ||
| 1369 | |||
| 1370 | ;;;###autoload | 1452 | ;;;###autoload |
| 1371 | (defun ispell-kill-ispell (&optional no-error) | 1453 | (defun ispell-kill-ispell (&optional no-error) |
| 1372 | "Kill current ispell process (so that you may start a fresh one). | 1454 | "Kill current ispell process (so that you may start a fresh one). |
| @@ -1433,211 +1515,247 @@ With prefix argument, set the default directory." | |||
| 1433 | (interactive "r") ; Don't flag errors on read-only bufs. | 1515 | (interactive "r") ; Don't flag errors on read-only bufs. |
| 1434 | (ispell-accept-buffer-local-defs) ; set up dictionary, local words, etc. | 1516 | (ispell-accept-buffer-local-defs) ; set up dictionary, local words, etc. |
| 1435 | (unwind-protect | 1517 | (unwind-protect |
| 1436 | (save-excursion | 1518 | (save-excursion |
| 1437 | (message "Spell checking %s..." | 1519 | (message "Spell checking %s..." |
| 1438 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) | 1520 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) |
| 1439 | (buffer-name) "region")) | 1521 | (buffer-name) "region")) |
| 1440 | (sit-for 0) | 1522 | (sit-for 0) |
| 1441 | ;; must be top level now, not inside ispell-command-loop for keeping window. | 1523 | ;; must be top level, not in ispell-command-loop for keeping window. |
| 1442 | (save-window-excursion | 1524 | (save-window-excursion |
| 1443 | (if ispell-keep-choices-win | 1525 | (if ispell-keep-choices-win |
| 1444 | (let ((window-min-height ispell-choices-win-default-height)) | 1526 | (let ((ocb (current-buffer)) |
| 1445 | ;; This keeps the default window size when choices window saved. | 1527 | (window-min-height ispell-choices-win-default-height)) |
| 1446 | (setq ispell-keep-choices-win ispell-choices-win-default-height) | 1528 | (or (eq ocb (window-buffer (selected-window))) |
| 1447 | (ispell-overlay-window ispell-choices-win-default-height) | 1529 | (error |
| 1448 | (switch-to-buffer (get-buffer-create ispell-choices-buffer)) | 1530 | "current buffer is not visible in selected window: %s" |
| 1449 | (setq mode-line-format "-- %b --") | 1531 | ocb)) |
| 1450 | (erase-buffer) | 1532 | ;; This keeps the default window size when choices window saved |
| 1451 | (select-window (next-window)) | 1533 | (setq ispell-keep-choices-win |
| 1452 | (sit-for 0))) | 1534 | ispell-choices-win-default-height) |
| 1453 | (goto-char reg-start) | 1535 | (ispell-overlay-window ispell-choices-win-default-height) |
| 1454 | (let ((transient-mark-mode nil)) | 1536 | (switch-to-buffer (get-buffer-create ispell-choices-buffer)) |
| 1455 | (while (and (not ispell-quit) (< (point) reg-end)) | 1537 | (setq mode-line-format "-- %b --") |
| 1456 | (let ((start (point)) | 1538 | (erase-buffer) |
| 1457 | (offset-change 0) | 1539 | (select-window (next-window)) |
| 1458 | (end (save-excursion (end-of-line) (min (point) reg-end))) | 1540 | (or (eq (current-buffer) ocb) |
| 1459 | (ispell-casechars (ispell-get-casechars)) | 1541 | (error "ispell is confused about current buffer!")) |
| 1460 | string) | 1542 | (sit-for 0))) |
| 1461 | (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS | 1543 | (goto-char reg-start) |
| 1462 | ((eolp) ; END OF LINE, just go to next line. | 1544 | (let ((transient-mark-mode nil)) |
| 1463 | (forward-char 1)) | 1545 | (while (and (not ispell-quit) (< (point) reg-end)) |
| 1464 | ((and (null ispell-check-comments) ; SKIPING COMMENTS | 1546 | (let ((start (point)) |
| 1465 | comment-start ; skip comments that start on the line. | 1547 | (offset-change 0) |
| 1466 | (search-forward comment-start end t)) ; a comment is on this line. | 1548 | (end (save-excursion (end-of-line) (min (point) reg-end))) |
| 1467 | (if (= (- (point) start) (length comment-start)) | 1549 | (ispell-casechars (ispell-get-casechars)) |
| 1468 | ;; comment starts the line. We can skip the entire line or region | 1550 | string) |
| 1469 | (if (string= "" comment-end) ; skip to next line over comment | 1551 | (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS |
| 1470 | (beginning-of-line 2) | 1552 | ((eolp) ; END OF LINE, just go to next line. |
| 1471 | (search-forward comment-end reg-end 'limit)) ; jmp to comment end | 1553 | (forward-char 1)) |
| 1472 | ;; Comment starts later on line. Check for spelling before comment. | 1554 | ((and (null ispell-check-comments) ; SKIPING COMMENTS |
| 1473 | (let ((limit (- (point) (length comment-start)))) | 1555 | comment-start ; skip comments that start on the line. |
| 1474 | (goto-char (1- limit)) | 1556 | (search-forward comment-start end t)) ; or found here. |
| 1475 | (if (looking-at "\\\\") ; "quoted" comment, don't skip | 1557 | (if (= (- (point) start) (length comment-start)) |
| 1476 | ;; quoted comment. Skip over comment-start and continue. | 1558 | ;; comment starts the line. Skip entire line or region |
| 1477 | (if (= start (1- limit)) | 1559 | (if (string= "" comment-end) ; skip to next line |
| 1478 | (setq limit (+ limit (length comment-start))) | 1560 | (beginning-of-line 2) ; or jump to comment end. |
| 1479 | (setq limit (1- limit)))) | 1561 | (search-forward comment-end reg-end 'limit)) |
| 1480 | (goto-char start) | 1562 | ;; Comment later in line. Check spelling before comment. |
| 1481 | ;; Only check if there are "casechars" or math chars before comment | 1563 | (let ((limit (- (point) (length comment-start)))) |
| 1482 | (if (or (re-search-forward ispell-casechars limit t) | 1564 | (goto-char (1- limit)) |
| 1483 | (re-search-forward "[][()$]" limit t)) | 1565 | (if (looking-at "\\\\") ; "quoted" comment, don't skip |
| 1484 | (setq string (concat "^" (buffer-substring start limit) "\n"))) | 1566 | ;; quoted comment. Skip over comment-start |
| 1485 | (goto-char limit)))) | 1567 | (if (= start (1- limit)) |
| 1486 | ((and ispell-skip-tib ; SKIP TIB REFERENCES! | 1568 | (setq limit (+ limit (length comment-start))) |
| 1487 | (re-search-forward ispell-tib-ref-beginning end t)) | 1569 | (setq limit (1- limit)))) |
| 1488 | (if (= (- (point) 2) start) ; tib ref is 2 chars. | 1570 | (goto-char start) |
| 1489 | ;; Skip to end of tib ref, not necessarily on this line. | 1571 | ;; Only check when "casechars" or math before comment |
| 1490 | ;; Return an error if tib ref not found | 1572 | (if (or (re-search-forward ispell-casechars limit t) |
| 1491 | (if (not (re-search-forward ispell-tib-ref-end reg-end t)) | 1573 | (re-search-forward "[][()$]" limit t)) |
| 1492 | (progn | 1574 | (setq string |
| 1493 | (ispell-pdict-save ispell-silently-savep) | 1575 | (concat "^" (buffer-substring start limit) |
| 1494 | (ding) | 1576 | "\n"))) |
| 1495 | (message "Open tib reference--set `ispell-skip-tib' to nil to avoid this error") | 1577 | (goto-char limit)))) |
| 1496 | (setq ispell-quit (- (point) 2)))) ; leave dot at error loc. | 1578 | ((and ispell-skip-tib ; SKIP TIB REFERENCES! |
| 1497 | ;; tib ref starts later on line. Check spelling before tib. | 1579 | (re-search-forward ispell-tib-ref-beginning end t)) |
| 1498 | (let ((limit (- (point) 2))) | 1580 | (if (= (- (point) 2) start) ; tib ref is 2 chars. |
| 1499 | (goto-char start) | 1581 | ;; Skip to end of tib ref, not necessarily on this line. |
| 1500 | (if (or (re-search-forward ispell-casechars limit t) | 1582 | ;; Return an error if tib ref not found |
| 1501 | (re-search-forward "[][()$]" limit t)) | 1583 | (if (not(re-search-forward ispell-tib-ref-end reg-end t)) |
| 1502 | (setq string (concat "^" (buffer-substring start limit) "\n"))) | 1584 | (progn |
| 1503 | (goto-char limit)))) | 1585 | (ispell-pdict-save ispell-silently-savep) |
| 1504 | ((looking-at "[-#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS | 1586 | (ding) |
| 1505 | (forward-char 1)) | 1587 | (message |
| 1506 | ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS... | 1588 | (concat |
| 1507 | (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS... | 1589 | "Open tib reference--set `ispell-skip-tib'" |
| 1508 | (setq string (concat "^" (buffer-substring start end) "\n")) | 1590 | " to nil to avoid this error")) |
| 1509 | (goto-char end)) | 1591 | ;; keep cursor at error location |
| 1510 | (t (beginning-of-line 2))) ; EMPTY LINE, skip it. | 1592 | (setq ispell-quit (- (point) 2)))) |
| 1511 | 1593 | ;; tib ref starts later on line. Check spelling before tib. | |
| 1512 | (setq end (point)) ; "end" tracks end of region to check. | 1594 | (let ((limit (- (point) 2))) |
| 1513 | 1595 | (goto-char start) | |
| 1514 | (if string ; there is something to spell! | 1596 | (if (or (re-search-forward ispell-casechars limit t) |
| 1515 | (let (poss) | 1597 | (re-search-forward "[][()$]" limit t)) |
| 1516 | ;; send string to spell process and get input. | 1598 | (setq string |
| 1517 | (process-send-string ispell-process string) | 1599 | (concat "^" (buffer-substring start limit) |
| 1518 | (while (progn | 1600 | "\n"))) |
| 1519 | (accept-process-output ispell-process) | 1601 | (goto-char limit)))) |
| 1520 | ;; Last item of output contains a blank line. | 1602 | ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS |
| 1521 | (not (string= "" (car ispell-filter))))) | 1603 | (forward-char 1)) |
| 1522 | ;; parse all inputs from the stream one word at a time. | 1604 | ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS |
| 1523 | ;; Place in FIFO order and remove the blank item. | 1605 | (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS |
| 1524 | (setq ispell-filter (nreverse (cdr ispell-filter))) | 1606 | (setq string (concat "^" (buffer-substring start end) "\n")) |
| 1525 | (while (and (not ispell-quit) ispell-filter) | 1607 | (goto-char end)) |
| 1526 | (setq poss (ispell-parse-output (car ispell-filter))) | 1608 | (t (beginning-of-line 2))) ; EMPTY LINE, skip it. |
| 1527 | (if (listp poss) ; spelling error occurred. | 1609 | |
| 1528 | (let* ((word-start (+ start offset-change (car (cdr poss)))) | 1610 | (setq end (point)) ; "end" tracks end of region to check. |
| 1529 | (word-end (+ word-start (length (car poss)))) | 1611 | |
| 1530 | replace) | 1612 | (if string ; there is something to spell! |
| 1531 | (goto-char word-start) | 1613 | (let (poss) |
| 1532 | ;; The following lines adjust the horizontal scroll & point | 1614 | ;; send string to spell process and get input. |
| 1533 | (horiz-scroll) | 1615 | (process-send-string ispell-process string) |
| 1534 | (goto-char word-end) | 1616 | (while (progn |
| 1535 | (horiz-scroll) | 1617 | (accept-process-output ispell-process) |
| 1536 | (goto-char word-start) | 1618 | ;; Last item of output contains a blank line. |
| 1537 | (horiz-scroll) | 1619 | (not (string= "" (car ispell-filter))))) |
| 1538 | (if (/= word-end (progn | 1620 | ;; parse all inputs from the stream one word at a time. |
| 1539 | (search-forward (car poss) word-end t) | 1621 | ;; Place in FIFO order and remove the blank item. |
| 1540 | (point))) | 1622 | (setq ispell-filter (nreverse (cdr ispell-filter))) |
| 1541 | ;; This usually occurs due to filter pipe problems | 1623 | (while (and (not ispell-quit) ispell-filter) |
| 1542 | (error "Ispell misalignment: word `%s' point %d; please retry" | 1624 | (setq poss (ispell-parse-output (car ispell-filter))) |
| 1543 | (car poss) word-start)) | 1625 | (if (listp poss) ; spelling error occurred. |
| 1544 | (unwind-protect | 1626 | (let* ((word-start (+ start offset-change |
| 1545 | (progn | 1627 | (car (cdr poss)))) |
| 1546 | (if ispell-highlight-p | 1628 | (word-end (+ word-start |
| 1547 | (highlight-spelling-error word-start word-end t)) | 1629 | (length (car poss)))) |
| 1548 | (sit-for 0) ; update screen display | 1630 | replace) |
| 1549 | (setq replace (ispell-command-loop | 1631 | (goto-char word-start) |
| 1550 | (car (cdr (cdr poss))) | 1632 | ;; Adjust the horizontal scroll & point |
| 1551 | (car (cdr (cdr (cdr poss)))) | 1633 | (ispell-horiz-scroll) |
| 1552 | (car poss)))) | 1634 | (goto-char word-end) |
| 1553 | ;; protected | 1635 | (ispell-horiz-scroll) |
| 1554 | (if ispell-highlight-p | 1636 | (goto-char word-start) |
| 1555 | (highlight-spelling-error word-start word-end))) | 1637 | (ispell-horiz-scroll) |
| 1556 | (cond | 1638 | (if (/= word-end |
| 1557 | ((and replace (listp replace)) | 1639 | (progn |
| 1558 | ;; REPLACEMENT WORD entered. Recheck line starting with | 1640 | (search-forward (car poss) word-end t) |
| 1559 | ;; the replacement word. | 1641 | (point))) |
| 1560 | (setq ispell-filter nil | 1642 | ;; This occurs due to filter pipe problems |
| 1561 | string (buffer-substring word-start word-end)) | 1643 | (error |
| 1562 | (let ((change (- (length (car replace)) ; adjust | 1644 | (concat "Ispell misalignment: word " |
| 1563 | (length (car poss))))) ; regions | 1645 | "`%s' point %d; please retry") |
| 1564 | (setq reg-end (+ reg-end change) | 1646 | (car poss) word-start)) |
| 1565 | offset-change (+ offset-change change))) | 1647 | (unwind-protect |
| 1566 | (delete-region word-start word-end) | 1648 | (progn |
| 1567 | (insert (car replace)) | 1649 | (if ispell-highlight-p |
| 1568 | ;; I only need to recheck typed-in replacements. | 1650 | (ispell-highlight-spelling-error |
| 1569 | (if (not (eq 'query-replace (car (cdr replace)))) | 1651 | word-start word-end t)) |
| 1570 | (backward-char (length (car replace)))) | 1652 | (sit-for 0) ; update screen display |
| 1571 | (setq end (point)) ; reposition in region to recheck | 1653 | (setq replace (ispell-command-loop |
| 1572 | ;; when second arg exists, query-replace, saving regions | 1654 | (car (cdr (cdr poss))) |
| 1573 | (if (car (cdr replace)) | 1655 | (car (cdr (cdr (cdr poss)))) |
| 1574 | (unwind-protect | 1656 | (car poss)))) |
| 1575 | (save-window-excursion ; save if help is called. | 1657 | ;; protected |
| 1576 | (set-marker ispell-query-replace-marker reg-end) | 1658 | (if ispell-highlight-p |
| 1577 | ;; Assume case-replace & case-fold-search correct? | 1659 | (ispell-highlight-spelling-error |
| 1578 | (query-replace string (car replace) t)) | 1660 | word-start word-end))) |
| 1579 | ;; protected | 1661 | (cond |
| 1580 | (setq reg-end (marker-position | 1662 | ((and replace (listp replace)) |
| 1581 | ispell-query-replace-marker)) | 1663 | ;; REPLACEMENT WORD entered. Recheck line |
| 1582 | (set-marker ispell-query-replace-marker nil)))) | 1664 | ;; starting with the replacement word. |
| 1583 | ((or (null replace) (equal 0 replace)) ; ACCEPT/INSERT | 1665 | (setq ispell-filter nil |
| 1584 | (if (equal 0 replace) ; BUFFER-LOCAL DICTIONARY ADD | 1666 | string (buffer-substring word-start |
| 1585 | (setq reg-end (ispell-add-per-file-word-list | 1667 | word-end)) |
| 1586 | (car poss) reg-end))) | 1668 | (let ((change (- (length (car replace)) |
| 1587 | ;; This prevents us from pointing out the word that was | 1669 | (length (car poss))))) |
| 1588 | ;; just accepted (via 'i' or 'a') if it follows on the | 1670 | ;; adjust regions |
| 1589 | ;; same line. (The drawback of processing entire lines.) | 1671 | (setq reg-end (+ reg-end change) |
| 1590 | ;; Redo check following the accepted word. | 1672 | offset-change (+ offset-change |
| 1591 | (if (and ispell-pdict-modified-p | 1673 | change))) |
| 1592 | (listp ispell-pdict-modified-p)) | 1674 | (delete-region word-start word-end) |
| 1593 | ;; We have accepted or inserted a word. Re-check line | 1675 | (insert (car replace)) |
| 1594 | (setq ispell-pdict-modified-p ; fix update flag | 1676 | ;; I only need to recheck typed-in replacements |
| 1595 | (car ispell-pdict-modified-p) | 1677 | (if (not (eq 'query-replace |
| 1596 | ispell-filter nil ; don't continue check. | 1678 | (car (cdr replace)))) |
| 1597 | end word-start))) ; reposition continue loc | 1679 | (backward-char (length (car replace)))) |
| 1598 | (replace ; STRING REPLACEMENT for this word. | 1680 | (setq end (point)) ; reposition for recheck |
| 1599 | (delete-region word-start word-end) | 1681 | ;; when second arg exists, query-replace, saving regions |
| 1600 | (insert replace) | 1682 | (if (car (cdr replace)) |
| 1601 | (let ((change (- (length replace) (length (car poss))))) | 1683 | (unwind-protect |
| 1602 | (setq reg-end (+ reg-end change) | 1684 | (save-window-excursion |
| 1603 | offset-change (+ offset-change change) | 1685 | (set-marker |
| 1604 | end (+ end change))))) | 1686 | ispell-query-replace-marker reg-end) |
| 1605 | (if (not ispell-quit) | 1687 | ;; Assume case-replace & |
| 1606 | (message "Continuing spelling check...")) | 1688 | ;; case-fold-search correct? |
| 1607 | (sit-for 0))) | 1689 | (query-replace string (car replace) |
| 1608 | (setq ispell-filter (cdr ispell-filter))))) ; finished with line | 1690 | t)) |
| 1609 | (goto-char end))))) | 1691 | (setq reg-end |
| 1610 | (not ispell-quit)) | 1692 | (marker-position |
| 1611 | ;; protected | 1693 | ispell-query-replace-marker)) |
| 1612 | (if (get-buffer ispell-choices-buffer) | 1694 | (set-marker ispell-query-replace-marker |
| 1613 | (kill-buffer ispell-choices-buffer)) | 1695 | nil)))) |
| 1614 | (if ispell-quit | 1696 | ((or (null replace) |
| 1615 | (progn | 1697 | (equal 0 replace)) ; ACCEPT/INSERT |
| 1616 | ;; preserve or clear the region for ispell-continue. | 1698 | (if (equal 0 replace) ; BUFFER-LOCAL DICT ADD |
| 1617 | (if (not (numberp ispell-quit)) | 1699 | (setq reg-end |
| 1618 | (set-marker ispell-region-end nil) | 1700 | (ispell-add-per-file-word-list |
| 1619 | ;; Enable ispell-continue. | 1701 | (car poss) reg-end))) |
| 1620 | (set-marker ispell-region-end reg-end) | 1702 | ;; This avoids pointing out the word that was |
| 1621 | (goto-char ispell-quit)) | 1703 | ;; just accepted (via 'i' or 'a') if it follows |
| 1622 | ;; Check for aborting | 1704 | ;; on the same line. |
| 1623 | (if (and ispell-checking-message (numberp ispell-quit)) | 1705 | ;; Redo check following the accepted word. |
| 1624 | (progn | 1706 | (if (and ispell-pdict-modified-p |
| 1625 | (setq ispell-quit nil) | 1707 | (listp ispell-pdict-modified-p)) |
| 1626 | (error "Message send aborted."))) | 1708 | ;; Word accepted. Recheck line. |
| 1627 | (setq ispell-quit nil)) | 1709 | (setq ispell-pdict-modified-p ; update flag |
| 1628 | (set-marker ispell-region-end nil) | 1710 | (car ispell-pdict-modified-p) |
| 1629 | ;; Only save if successful exit. | 1711 | ispell-filter nil ; discontinue check |
| 1630 | (ispell-pdict-save ispell-silently-savep) | 1712 | end word-start))) ; reposition loc. |
| 1631 | (message "Spell-checking done")))) | 1713 | (replace ; STRING REPLACEMENT for this word. |
| 1714 | (delete-region word-start word-end) | ||
| 1715 | (insert replace) | ||
| 1716 | (let ((change (- (length replace) | ||
| 1717 | (length (car poss))))) | ||
| 1718 | (setq reg-end (+ reg-end change) | ||
| 1719 | offset-change (+ offset-change change) | ||
| 1720 | end (+ end change))))) | ||
| 1721 | (if (not ispell-quit) | ||
| 1722 | (message "Continuing spelling check...")) | ||
| 1723 | (sit-for 0))) | ||
| 1724 | ;; finished with line! | ||
| 1725 | (setq ispell-filter (cdr ispell-filter))))) | ||
| 1726 | (goto-char end))))) | ||
| 1727 | (not ispell-quit)) | ||
| 1728 | ;; protected | ||
| 1729 | (if (get-buffer ispell-choices-buffer) | ||
| 1730 | (kill-buffer ispell-choices-buffer)) | ||
| 1731 | (if ispell-quit | ||
| 1732 | (progn | ||
| 1733 | ;; preserve or clear the region for ispell-continue. | ||
| 1734 | (if (not (numberp ispell-quit)) | ||
| 1735 | (set-marker ispell-region-end nil) | ||
| 1736 | ;; Enable ispell-continue. | ||
| 1737 | (set-marker ispell-region-end reg-end) | ||
| 1738 | (goto-char ispell-quit)) | ||
| 1739 | ;; Check for aborting | ||
| 1740 | (if (and ispell-checking-message (numberp ispell-quit)) | ||
| 1741 | (progn | ||
| 1742 | (setq ispell-quit nil) | ||
| 1743 | (error "Message send aborted."))) | ||
| 1744 | (setq ispell-quit nil)) | ||
| 1745 | (set-marker ispell-region-end nil) | ||
| 1746 | ;; Only save if successful exit. | ||
| 1747 | (ispell-pdict-save ispell-silently-savep) | ||
| 1748 | (message "Spell-checking done")))) | ||
| 1632 | 1749 | ||
| 1633 | 1750 | ||
| 1634 | 1751 | ||
| 1635 | ;;;###autoload | 1752 | ;;;###autoload |
| 1636 | (defun ispell-buffer () | 1753 | (defun ispell-buffer () |
| 1637 | "Check the current buffer for spelling errors interactively." | 1754 | "Check the current buffer for spelling errors interactively." |
| 1638 | (interactive) | 1755 | (interactive) |
| 1639 | (ispell-region (point-min) (point-max))) | 1756 | (ispell-region (point-min) (point-max))) |
| 1640 | 1757 | ||
| 1758 | |||
| 1641 | ;;;###autoload | 1759 | ;;;###autoload |
| 1642 | (defun ispell-continue () | 1760 | (defun ispell-continue () |
| 1643 | (interactive) | 1761 | (interactive) |
| @@ -1651,9 +1769,8 @@ With prefix argument, set the default directory." | |||
| 1651 | 1769 | ||
| 1652 | 1770 | ||
| 1653 | ;;; Horizontal scrolling | 1771 | ;;; Horizontal scrolling |
| 1654 | (defun horiz-scroll () | 1772 | (defun ispell-horiz-scroll () |
| 1655 | "This function checks if the point is within the horizontal | 1773 | "Places point within the horizontal visibility of its window area." |
| 1656 | visibility of its window area." | ||
| 1657 | (if truncate-lines ; display truncating lines? | 1774 | (if truncate-lines ; display truncating lines? |
| 1658 | ;; See if display needs to be scrolled. | 1775 | ;; See if display needs to be scrolled. |
| 1659 | (let ((column (- (current-column) (max (window-hscroll) 1)))) | 1776 | (let ((column (- (current-column) (max (window-hscroll) 1)))) |
| @@ -1675,6 +1792,7 @@ may be a character sequence inside of a word. | |||
| 1675 | Standard ispell choices are then available." | 1792 | Standard ispell choices are then available." |
| 1676 | (interactive "P") | 1793 | (interactive "P") |
| 1677 | (let ((cursor-location (point)) | 1794 | (let ((cursor-location (point)) |
| 1795 | case-fold-search | ||
| 1678 | ispell-keep-choices-win | 1796 | ispell-keep-choices-win |
| 1679 | (word (ispell-get-word nil "\\*")) ; force "previous-word" processing. | 1797 | (word (ispell-get-word nil "\\*")) ; force "previous-word" processing. |
| 1680 | start end possibilities replacement) | 1798 | start end possibilities replacement) |
| @@ -1690,14 +1808,22 @@ Standard ispell choices are then available." | |||
| 1690 | ((null possibilities) | 1808 | ((null possibilities) |
| 1691 | (message "No match for \"%s\"" word)) | 1809 | (message "No match for \"%s\"" word)) |
| 1692 | (t ; There is a modification... | 1810 | (t ; There is a modification... |
| 1811 | (cond ; Try and respect case of word. | ||
| 1812 | ((string-match "^[^A-Z]+$" word) | ||
| 1813 | (setq possibilities (mapcar 'downcase possibilities))) | ||
| 1814 | ((string-match "^[^a-z]+$" word) | ||
| 1815 | (setq possibilities (mapcar 'upcase possibilities))) | ||
| 1816 | ((string-match "^[A-Z]" word) | ||
| 1817 | (setq possibilities (mapcar 'capitalize possibilities)))) | ||
| 1693 | (unwind-protect | 1818 | (unwind-protect |
| 1694 | (progn | 1819 | (progn |
| 1820 | (if ispell-highlight-p ; highlight word | ||
| 1821 | (ispell-highlight-spelling-error start end t)) | ||
| 1822 | (setq replacement | ||
| 1823 | (ispell-command-loop possibilities nil word))) | ||
| 1824 | ;; protected | ||
| 1695 | (if ispell-highlight-p | 1825 | (if ispell-highlight-p |
| 1696 | (highlight-spelling-error start end t)) ; highlight word | 1826 | (ispell-highlight-spelling-error start end))) ; un-highlight |
| 1697 | (setq replacement (ispell-command-loop possibilities nil word))) | ||
| 1698 | ;; protected | ||
| 1699 | (if ispell-highlight-p | ||
| 1700 | (highlight-spelling-error start end))) ; un-highlight | ||
| 1701 | (cond | 1827 | (cond |
| 1702 | ((equal 0 replacement) ; BUFFER-LOCAL ADDITION | 1828 | ((equal 0 replacement) ; BUFFER-LOCAL ADDITION |
| 1703 | (ispell-add-per-file-word-list word)) | 1829 | (ispell-add-per-file-word-list word)) |
| @@ -1719,8 +1845,7 @@ Standard ispell choices are then available." | |||
| 1719 | 1845 | ||
| 1720 | ;;;###autoload | 1846 | ;;;###autoload |
| 1721 | (defun ispell-complete-word-interior-frag () | 1847 | (defun ispell-complete-word-interior-frag () |
| 1722 | "Runs `ispell-complete-word' assuming that the word is a character sequence | 1848 | "Completes word matching character sequence inside a word." |
| 1723 | inside of a word." | ||
| 1724 | (interactive) | 1849 | (interactive) |
| 1725 | (ispell-complete-word t)) | 1850 | (ispell-complete-word t)) |
| 1726 | 1851 | ||
| @@ -1743,12 +1868,13 @@ inside of a word." | |||
| 1743 | ;; Matches difference listing | 1868 | ;; Matches difference listing |
| 1744 | "diff -c .*\n\\*\\*\\* .*\n--- " | 1869 | "diff -c .*\n\\*\\*\\* .*\n--- " |
| 1745 | ;; Matches "----------------- cut here" | 1870 | ;; Matches "----------------- cut here" |
| 1746 | "^[-=]+\\s cut here") | 1871 | "^[-=_]+\\s ?cut here") |
| 1747 | "\\|") | 1872 | "\\|") |
| 1748 | "*End of text which will be checked in ispell-message. | 1873 | "*End of text which will be checked in ispell-message. |
| 1749 | If it is a string, limit at first occurence of that regular expression. | 1874 | If it is a string, limit at first occurence of that regular expression. |
| 1750 | Otherwise, it must be a function which is called to get the limit.") | 1875 | Otherwise, it must be a function which is called to get the limit.") |
| 1751 | 1876 | ||
| 1877 | |||
| 1752 | ;;;###autoload | 1878 | ;;;###autoload |
| 1753 | (defun ispell-message () | 1879 | (defun ispell-message () |
| 1754 | "Check the spelling of a mail message or news post. | 1880 | "Check the spelling of a mail message or news post. |
| @@ -1770,17 +1896,21 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: | |||
| 1770 | (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))" | 1896 | (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))" |
| 1771 | (interactive) | 1897 | (interactive) |
| 1772 | (save-excursion | 1898 | (save-excursion |
| 1773 | (beginning-of-buffer) | 1899 | (goto-char (point-min)) |
| 1774 | (let* ((internal-messagep | 1900 | (let* ((internal-messagep (save-excursion |
| 1775 | (search-forward mail-header-separator nil t)) | 1901 | (re-search-forward |
| 1902 | (concat "^" | ||
| 1903 | (regexp-quote mail-header-separator) | ||
| 1904 | "$") | ||
| 1905 | nil t))) | ||
| 1776 | (limit (copy-marker | 1906 | (limit (copy-marker |
| 1777 | (cond | 1907 | (cond |
| 1778 | ((not ispell-message-text-end) (point-max)) | 1908 | ((not ispell-message-text-end) (point-max)) |
| 1779 | ((char-or-string-p ispell-message-text-end) | 1909 | ((char-or-string-p ispell-message-text-end) |
| 1780 | (if (re-search-forward ispell-message-text-end nil t) | 1910 | (if (re-search-forward ispell-message-text-end nil t) |
| 1781 | (match-beginning 0) | 1911 | (match-beginning 0) |
| 1782 | (point-max))) | 1912 | (point-max))) |
| 1783 | (t (min (point-max) (funcall ispell-message-text-end)))))) | 1913 | (t (min (point-max) (funcall ispell-message-text-end)))))) |
| 1784 | (cite-regexp ;Prefix of inserted text | 1914 | (cite-regexp ;Prefix of inserted text |
| 1785 | (cond | 1915 | (cond |
| 1786 | ((featurep 'supercite) ; sc 3.0 | 1916 | ((featurep 'supercite) ; sc 3.0 |
| @@ -1796,7 +1926,7 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: | |||
| 1796 | "^ \\|^\t"))) | 1926 | "^ \\|^\t"))) |
| 1797 | ((equal major-mode 'mh-letter-mode) ; mh mail message | 1927 | ((equal major-mode 'mh-letter-mode) ; mh mail message |
| 1798 | (ispell-non-empty-string mh-ins-buf-prefix)) | 1928 | (ispell-non-empty-string mh-ins-buf-prefix)) |
| 1799 | ((not internal-messagep) ; Assume nn sent us this message. | 1929 | ((not internal-messagep) ; Assume n sent us this message. |
| 1800 | (concat "In [a-zA-Z.]+ you write:" "\\|" | 1930 | (concat "In [a-zA-Z.]+ you write:" "\\|" |
| 1801 | "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|" | 1931 | "In <[^,;&+=]+> [^,;&+=]+ writes:" "\\|" |
| 1802 | " *> *")) | 1932 | " *> *")) |
| @@ -1806,22 +1936,19 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: | |||
| 1806 | (mail-yank-prefix ; vanilla mail message. | 1936 | (mail-yank-prefix ; vanilla mail message. |
| 1807 | (ispell-non-empty-string mail-yank-prefix)) | 1937 | (ispell-non-empty-string mail-yank-prefix)) |
| 1808 | (t "^ \\|^\t"))) | 1938 | (t "^ \\|^\t"))) |
| 1809 | (cite-regexp-start (concat "^[ \t]*$\\|" cite-regexp)) | 1939 | (cite-regexp-start (concat "^[ \t]*$\\|" cite-regexp)) |
| 1810 | (cite-regexp-end (concat "^\\(" cite-regexp "\\)")) | 1940 | (cite-regexp-end (concat "^\\(" cite-regexp "\\)")) |
| 1811 | (old-case-fold-search case-fold-search) | 1941 | (old-case-fold-search case-fold-search) |
| 1812 | (case-fold-search t) | 1942 | (case-fold-search t) |
| 1813 | (ispell-checking-message t)) | 1943 | (ispell-checking-message t)) |
| 1814 | (save-excursion | 1944 | (goto-char (point-min)) |
| 1815 | (beginning-of-buffer) | ||
| 1816 | ;; Skip header fields except Subject: without Re:'s | 1945 | ;; Skip header fields except Subject: without Re:'s |
| 1817 | ;;(search-forward mail-header-separator nil t) | 1946 | ;;(search-forward mail-header-separator nil t) |
| 1818 | (while (if internal-messagep | 1947 | (while (if internal-messagep |
| 1819 | (< (point) internal-messagep) | 1948 | (< (point) internal-messagep) |
| 1820 | (and (looking-at "[-a-zA-Z]+:\\|\t\\| ") | 1949 | (and (looking-at "[a-zA-Z---]+:\\|\t\\| ") |
| 1821 | (not (eobp)))) | 1950 | (not (eobp)))) |
| 1822 | 1951 | (if (looking-at "Subject: *") ; Spell check new subject fields | |
| 1823 | ;; spell check Subject: field without Re:'s. | ||
| 1824 | (if (looking-at "Subject: *") | ||
| 1825 | (progn | 1952 | (progn |
| 1826 | (goto-char (match-end 0)) | 1953 | (goto-char (match-end 0)) |
| 1827 | (if (and (not (looking-at ".*Re\\>")) | 1954 | (if (and (not (looking-at ".*Re\\>")) |
| @@ -1850,8 +1977,9 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: | |||
| 1850 | (match-beginning 0) | 1977 | (match-beginning 0) |
| 1851 | (marker-position limit))))) | 1978 | (marker-position limit))))) |
| 1852 | (ispell-region (point) end) | 1979 | (ispell-region (point) end) |
| 1853 | (goto-char end))))) | 1980 | (goto-char end)))) |
| 1854 | (set-marker limit nil)))) | 1981 | (set-marker limit nil)))) |
| 1982 | |||
| 1855 | 1983 | ||
| 1856 | (defun ispell-non-empty-string (string) | 1984 | (defun ispell-non-empty-string (string) |
| 1857 | (if (or (not string) (string-equal string "")) | 1985 | (if (or (not string) (string-equal string "")) |
| @@ -1865,19 +1993,16 @@ news-reply-mode-hook or mail-mode-hook to the following lambda expression: | |||
| 1865 | 1993 | ||
| 1866 | 1994 | ||
| 1867 | (defun ispell-accept-buffer-local-defs () | 1995 | (defun ispell-accept-buffer-local-defs () |
| 1868 | "Loads all buffer-local information, restarting ispell when necessary." | 1996 | "Load all buffer-local information, restarting ispell when necessary." |
| 1869 | (ispell-buffer-local-dict) ; May kill ispell-process. | 1997 | (ispell-buffer-local-dict) ; May kill ispell-process. |
| 1870 | (ispell-buffer-local-words) ; Will initialize ispell-process. | 1998 | (ispell-buffer-local-words) ; Will initialize ispell-process. |
| 1871 | (ispell-buffer-local-parsing)) | 1999 | (ispell-buffer-local-parsing)) |
| 1872 | 2000 | ||
| 1873 | 2001 | ||
| 1874 | ;;; Currently ispell version 3.0.09 (beta) doesn't fully support the "~" | ||
| 1875 | ;;; pipe mode command. Should be fixed in the next release. | ||
| 1876 | |||
| 1877 | (defun ispell-buffer-local-parsing () | 2002 | (defun ispell-buffer-local-parsing () |
| 1878 | "Places ispell into parsing mode for this buffer. | 2003 | "Place ispell into parsing mode for this buffer. |
| 1879 | This overrides the default parsing mode. | 2004 | Overrides the default parsing mode. |
| 1880 | This includes latex/nroff modes and extended character mode." | 2005 | Includes latex/nroff modes and extended character mode." |
| 1881 | ;; (ispell-init-process) must already be called. | 2006 | ;; (ispell-init-process) must already be called. |
| 1882 | (process-send-string ispell-process "!\n") ; Put process in terse mode. | 2007 | (process-send-string ispell-process "!\n") ; Put process in terse mode. |
| 1883 | ;; We assume all major modes with "tex-mode" in them should use latex parsing | 2008 | ;; We assume all major modes with "tex-mode" in them should use latex parsing |
| @@ -1914,7 +2039,7 @@ This includes latex/nroff modes and extended character mode." | |||
| 1914 | ;;; Can kill the current ispell process | 2039 | ;;; Can kill the current ispell process |
| 1915 | 2040 | ||
| 1916 | (defun ispell-buffer-local-dict () | 2041 | (defun ispell-buffer-local-dict () |
| 1917 | "Does necessary local dictionary initialization. | 2042 | "Initializes local dictionary. |
| 1918 | When a dictionary is defined in the buffer (see variable | 2043 | When a dictionary is defined in the buffer (see variable |
| 1919 | ispell-dictionary-keyword), it will override the local setting | 2044 | ispell-dictionary-keyword), it will override the local setting |
| 1920 | from \\[ispell-change-dictionary]. | 2045 | from \\[ispell-change-dictionary]. |
| @@ -1964,10 +2089,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 1964 | string) | 2089 | string) |
| 1965 | (while (re-search-forward " *\\([^ \"]+\\)" end t) | 2090 | (while (re-search-forward " *\\([^ \"]+\\)" end t) |
| 1966 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) | 2091 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) |
| 1967 | (process-send-string | 2092 | (process-send-string ispell-process (concat "@" string "\n"))))))) |
| 1968 | ispell-process (concat "@" (buffer-substring (match-beginning 1) | ||
| 1969 | (match-end 1)) | ||
| 1970 | "\n"))))))) | ||
| 1971 | 2093 | ||
| 1972 | 2094 | ||
| 1973 | ;;; returns optionally adjusted region-end-point. | 2095 | ;;; returns optionally adjusted region-end-point. |
| @@ -1980,8 +2102,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 1980 | (setq reg-end 0)) | 2102 | (setq reg-end 0)) |
| 1981 | (save-excursion | 2103 | (save-excursion |
| 1982 | (goto-char (point-min)) | 2104 | (goto-char (point-min)) |
| 1983 | (let ((case-fold-search nil) | 2105 | (let (case-fold-search line-okay search done string) |
| 1984 | line-okay search done string) | ||
| 1985 | (while (not done) | 2106 | (while (not done) |
| 1986 | (setq search (search-forward ispell-words-keyword nil 'move) | 2107 | (setq search (search-forward ispell-words-keyword nil 'move) |
| 1987 | line-okay (< (+ (length word) 1 ; 1 for space after word.. | 2108 | line-okay (< (+ (length word) 1 ; 1 for space after word.. |
| @@ -2011,7 +2132,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 2011 | reg-end) | 2132 | reg-end) |
| 2012 | 2133 | ||
| 2013 | 2134 | ||
| 2014 | (defconst ispell-version "2.26 Tue Feb 15 16:11:14 MST 1994") | 2135 | (defconst ispell-version "2.30 -- Fri May 20 15:58:52 MDT 1994") |
| 2015 | 2136 | ||
| 2016 | (provide 'ispell) | 2137 | (provide 'ispell) |
| 2017 | 2138 | ||