diff options
| author | Karl Heuer | 1994-12-10 02:01:31 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-12-10 02:01:31 +0000 |
| commit | e29702dd6f8df3e4d0f458b5ded44832ea75c4b1 (patch) | |
| tree | 98899fd400582c907deca0c7a2cd1e58946ed56b | |
| parent | c3aa5fec86eb1be49ae277015812cf12afb7eb8d (diff) | |
| download | emacs-e29702dd6f8df3e4d0f458b5ded44832ea75c4b1.tar.gz emacs-e29702dd6f8df3e4d0f458b5ded44832ea75c4b1.zip | |
Added ispell-offset for version consistency.
(ispell-dictionary-alist): updated dictionaries & better match defaults
(ispell-alternate-dictionary): added /usr/shar path
(ispell-menu-map-needed): redo changes that made this incompatible
with earlier versions of emacs19.
(ispell-required-version): changed to assure version 3.1.12 accessed.
(ispell-word): Correctly accept buffer-local information.
Does not try to modify read-only buffer on 'm' command.
(ispell-command-loop): fixed bug that corrupted buffers.
removed scrolling when *Choices* buffer shrinks.
(check-ispell-version): Correctly identifies new version requirements.
(ispell-region): Interaction updated for version 3.1.12+
Buffer read-only modification improvement. Dictionary messages added.
(ispell-message-text-end): skips additional shell files.
(ispell-buffer-local-parsing): extended-char mode now matches text mode
| -rw-r--r-- | lisp/textmodes/ispell.el | 495 |
1 files changed, 270 insertions, 225 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 9e201848032..4dd8b1aaf00 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -5,9 +5,11 @@ | |||
| 5 | ;;; Copyright (C) 1994 Free Software Foundation, Inc. | 5 | ;;; Copyright (C) 1994 Free Software Foundation, Inc. |
| 6 | ;;; | 6 | ;;; |
| 7 | ;;; | 7 | ;;; |
| 8 | ;;; Authors : Ken Stevens et. al. | 8 | ;;; Authors : Ken Stevens <k.stevens@ieee.org> |
| 9 | ;;; Last Modified On: Thu Dec 8 13:17:41 EST 1994 | ||
| 10 | ;;; Update Revision : 2.34 | ||
| 9 | ;;; Syntax : emacs-lisp | 11 | ;;; Syntax : emacs-lisp |
| 10 | ;;; Status : Release with 3.1.05 ispell. | 12 | ;;; Status : Release with 3.1.12+ ispell. |
| 11 | ;;; Version : International Ispell Version 3.1 by Geoff Kuenning. | 13 | ;;; Version : International Ispell Version 3.1 by Geoff Kuenning. |
| 12 | ;;; Bug Reports : ispell-el-bugs@itcorp.com | 14 | ;;; Bug Reports : ispell-el-bugs@itcorp.com |
| 13 | ;;; | 15 | ;;; |
| @@ -127,7 +129,22 @@ | |||
| 127 | ;;; | 129 | ;;; |
| 128 | ;;; HISTORY | 130 | ;;; HISTORY |
| 129 | ;;; | 131 | ;;; |
| 130 | ;;; Revision 2.30 1994/5/20 15:58:52 stevens | 132 | ;;; Revision 2.34 1994/12/08 13:17:41 stevens |
| 133 | ;;; Interaction corrected to function with all 3.1 ispell versions. | ||
| 134 | ;;; | ||
| 135 | ;;; Revision 2.33 1994/11/24 02:31:20 stevens | ||
| 136 | ;;; Repaired bug introduced in 2.32 that corrupts buffers when correcting. | ||
| 137 | ;;; Improved buffer scrolling. Nondestructive buffer selections allowed. | ||
| 138 | ;;; | ||
| 139 | ;;; Revision 2.32 1994/10/31 21:10:08 geoff | ||
| 140 | ;;; Many revisions accepted from RMS/FSF. I think (though I don't know) that | ||
| 141 | ;;; this represents an 'official' version. | ||
| 142 | ;;; | ||
| 143 | ;;; Revision 2.31 1994/5/31 10:18:17 stevens | ||
| 144 | ;;; Repaired comments. buffer-local commands executed in `ispell-word' now. | ||
| 145 | ;;; German dictionary described for extended character mode. Dict messages. | ||
| 146 | ;;; | ||
| 147 | ;;; Revision 2.30 1994/5/20 22:18:36 stevens | ||
| 131 | ;;; Continue ispell from ispell-word, C-z functionality fixed. | 148 | ;;; Continue ispell from ispell-word, C-z functionality fixed. |
| 132 | ;;; | 149 | ;;; |
| 133 | ;;; Revision 2.29 1994/5/12 09:44:33 stevens | 150 | ;;; Revision 2.29 1994/5/12 09:44:33 stevens |
| @@ -330,8 +347,10 @@ Must be greater than 1.") | |||
| 330 | 347 | ||
| 331 | (defvar ispell-alternate-dictionary | 348 | (defvar ispell-alternate-dictionary |
| 332 | (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2") | 349 | (cond ((file-exists-p "/usr/dict/web2") "/usr/dict/web2") |
| 350 | ((file-exists-p "/usr/share/dict/web2") "/usr/share/dict/web2") | ||
| 333 | ((file-exists-p "/usr/dict/words") "/usr/dict/words") | 351 | ((file-exists-p "/usr/dict/words") "/usr/dict/words") |
| 334 | ((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words") | 352 | ((file-exists-p "/usr/lib/dict/words") "/usr/lib/dict/words") |
| 353 | ((file-exists-p "/usr/share/dict/words") "/usr/share/dict/words") | ||
| 335 | ((file-exists-p "/sys/dict") "/sys/dict") | 354 | ((file-exists-p "/sys/dict") "/sys/dict") |
| 336 | (t "/usr/dict/words")) | 355 | (t "/usr/dict/words")) |
| 337 | "*Alternate dictionary for spelling help.") | 356 | "*Alternate dictionary for spelling help.") |
| @@ -352,7 +371,7 @@ Some machines (like the NeXT) don't support \"-i\"") | |||
| 352 | This must be an absolute file name.") | 371 | This must be an absolute file name.") |
| 353 | 372 | ||
| 354 | (defvar ispell-look-p (file-exists-p ispell-look-command) | 373 | (defvar ispell-look-p (file-exists-p ispell-look-command) |
| 355 | "*Non-nil means use `look; rather than `grep'. | 374 | "*Non-nil means use `look' rather than `grep'. |
| 356 | Default is based on whether `look' seems to be available.") | 375 | Default is based on whether `look' seems to be available.") |
| 357 | 376 | ||
| 358 | (defvar ispell-have-new-look nil | 377 | (defvar ispell-have-new-look nil |
| @@ -381,8 +400,9 @@ Otherwise use the minibuffer.") | |||
| 381 | The function must take one string argument and return a string.") | 400 | The function must take one string argument and return a string.") |
| 382 | 401 | ||
| 383 | (defvar ispell-personal-dictionary nil | 402 | (defvar ispell-personal-dictionary nil |
| 384 | "*File name of your personal spelling dictionary. | 403 | "*File name of your personal spelling dictionary, or nil. |
| 385 | If nil, default dictionary `~/.ispell_words' is used.") | 404 | If nil, the default personal dictionary, \"~/.ispell_DICTNAME\" is used, |
| 405 | where DICTNAME is the name of your default dictionary.") | ||
| 386 | 406 | ||
| 387 | (defvar ispell-silently-savep nil | 407 | (defvar ispell-silently-savep nil |
| 388 | "*When non-nil, save the personal dictionary without confirmation.") | 408 | "*When non-nil, save the personal dictionary without confirmation.") |
| @@ -395,8 +415,8 @@ This is passed to the ispell process using the `-d' switch and is | |||
| 395 | used as key in `ispell-dictionary-alist' (which see). | 415 | used as key in `ispell-dictionary-alist' (which see). |
| 396 | 416 | ||
| 397 | You should set this variable before your first use of Emacs spell-checking | 417 | You should set this variable before your first use of Emacs spell-checking |
| 398 | commands in the Emacs session, or else use the \\[ispell-change-dictionary] command to | 418 | commands in the Emacs session, or else use the \\[ispell-change-dictionary] |
| 399 | change it. Otherwise, this variable only takes effect in a newly | 419 | command to change it. Otherwise, this variable only takes effect in a newly |
| 400 | started Ispell process.") | 420 | started Ispell process.") |
| 401 | 421 | ||
| 402 | (defvar ispell-extra-args nil | 422 | (defvar ispell-extra-args nil |
| @@ -411,37 +431,49 @@ for language-specific arguments.") | |||
| 411 | "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil) | 431 | "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil) |
| 412 | ("english" ; make english explicitly selectable | 432 | ("english" ; make english explicitly selectable |
| 413 | "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil) | 433 | "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B") nil) |
| 434 | ("british" ; british version | ||
| 435 | "[A-Za-z]" "[^A-Za-z]" "[']" nil ("-B" "-d" "british") nil) | ||
| 414 | ("deutsch" ; deutsch.aff | 436 | ("deutsch" ; deutsch.aff |
| 415 | "[a-zA-Z\"]" "[^a-zA-Z\"]" "[---']" t ("-C") nil) | 437 | "[a-zA-Z\"]" "[^a-zA-Z\"]" "[']" t ("-C") "~tex") |
| 416 | ("deutsch8" | 438 | ("deutsch8" |
| 417 | "[a-zA-Z\304\326\334\344\366\337\374]" | 439 | "[a-zA-Z\304\326\334\344\366\337\374]" |
| 418 | "[^a-zA-Z\304\326\334\344\366\337\374]" | 440 | "[^a-zA-Z\304\326\334\344\366\337\374]" |
| 419 | "[---']" t ("-C" "-d" "deutsch") "~latin1") | 441 | "[']" t ("-C" "-d" "deutsch") "~latin1") |
| 442 | ("nederlands" ; nederlands.aff | ||
| 443 | "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" | ||
| 444 | "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" | ||
| 445 | "[']" t ("-C") nil) | ||
| 420 | ("nederlands8" ; dutch8.aff | 446 | ("nederlands8" ; dutch8.aff |
| 421 | "[A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" | 447 | "[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]" | 448 | "[^A-Za-z\300-\305\307\310-\317\322-\326\331-\334\340-\345\347\350-\357\361\362-\366\371-\374]" |
| 423 | "[---']" t ("-C") nil))) | 449 | "[']" t ("-C") nil))) |
| 424 | 450 | ||
| 425 | ;;;###autoload | 451 | ;;;###autoload |
| 426 | (defvar ispell-dictionary-alist-2 | 452 | (defvar ispell-dictionary-alist-2 |
| 427 | '(("svenska" ;7 bit swedish mode | 453 | '(("svenska" ;7 bit swedish mode |
| 428 | "[A-Za-z}{|\\133\\135\\\\]" "[^A-Za-z}{|\\133\\135\\\\]" | 454 | "[A-Za-z}{|\\133\\135\\\\]" "[^A-Za-z}{|\\133\\135\\\\]" |
| 429 | "[---']" nil ("-C") nil) | 455 | "[']" nil ("-C") nil) |
| 430 | ("svenska8" ;8 bit swedish mode | 456 | ("svenska8" ;8 bit swedish mode |
| 431 | "[A-Za-z\345\344\366\305\304\366]" "[^A-Za-z\345\344\366\305\304\366]" | 457 | "[A-Za-z\345\344\366\305\304\366]" "[^A-Za-z\345\344\366\305\304\366]" |
| 432 | "[---']" nil ("-C" "-d" "svenska") "~list") ; Add `"-T" "list"' instead? | 458 | "[']" nil ("-C" "-d" "svenska") "~list") ; Add `"-T" "list"' instead? |
| 433 | ("francais" | 459 | ("francais7" |
| 434 | "[A-Za-z]" "[^A-Za-z]" "[`'^-]" t nil nil) | 460 | "[A-Za-z]" "[^A-Za-z]" "[`'^---]" t nil nil) |
| 435 | ("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]" | 461 | ("francais" ; francais.aff |
| 436 | "[^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]" "[---']" | 462 | "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]" |
| 437 | t nil "~list") | 463 | "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374]" |
| 464 | "[---']" t nil "~list") | ||
| 465 | ("francais-tex" ; francais.aff | ||
| 466 | "[A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]" | ||
| 467 | "[^A-Za-z\300\302\306\307\310\311\312\313\316\317\324\331\333\334\340\342\347\350\351\352\353\356\357\364\371\373\374\\]" | ||
| 468 | "[---'^`\"]" t nil "~tex") | ||
| 438 | ("dansk" ; dansk.aff | 469 | ("dansk" ; dansk.aff |
| 439 | "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]" | 470 | "[A-Z\306\330\305a-z\346\370\345]" "[^A-Z\306\330\305a-z\346\370\345]" |
| 440 | "[---]" nil ("-C") nil) | 471 | "" nil ("-C") nil) |
| 441 | )) | 472 | )) |
| 442 | 473 | ||
| 443 | ;; ispell-dictionary-alist is set up from two subvariables above | 474 | |
| 444 | ;; to avoid having very long lines in loaddefs.el. | 475 | ;;; ispell-dictionary-alist is set up from two subvariables above |
| 476 | ;;; to avoid having very long lines in loaddefs.el. | ||
| 445 | ;;;###autoload | 477 | ;;;###autoload |
| 446 | (defvar ispell-dictionary-alist | 478 | (defvar ispell-dictionary-alist |
| 447 | (append ispell-dictionary-alist-1 ispell-dictionary-alist-2) | 479 | (append ispell-dictionary-alist-1 ispell-dictionary-alist-2) |
| @@ -474,7 +506,7 @@ ISPELL-ARGS is a list of additional arguments passed to the ispell | |||
| 474 | subprocess. | 506 | subprocess. |
| 475 | 507 | ||
| 476 | EXTENDED-CHARACTER-MODE should be used when dictionaries are used which | 508 | EXTENDED-CHARACTER-MODE should be used when dictionaries are used which |
| 477 | have been configured in Ispell's parse.y. (For example, umlauts | 509 | have been configured in an Ispell affix file. (For example, umlauts |
| 478 | can be encoded as \\\"a, a\\\", \"a, ...) Defaults are ~tex and ~nroff | 510 | can be encoded as \\\"a, a\\\", \"a, ...) Defaults are ~tex and ~nroff |
| 479 | in English. This has the same effect as the command-line `-T' option. | 511 | in English. This has the same effect as the command-line `-T' option. |
| 480 | The buffer Major Mode controls Ispell's parsing in tex or nroff mode, | 512 | The buffer Major Mode controls Ispell's parsing in tex or nroff mode, |
| @@ -486,21 +518,30 @@ Note that the CASECHARS and OTHERCHARS slots of the alist should | |||
| 486 | contain the same character set as casechars and otherchars in the | 518 | contain the same character set as casechars and otherchars in the |
| 487 | language.aff file \(e.g., english.aff\).") | 519 | language.aff file \(e.g., english.aff\).") |
| 488 | 520 | ||
| 521 | |||
| 489 | ;;;###autoload | 522 | ;;;###autoload |
| 490 | (defvar ispell-menu-map nil) | 523 | (defvar ispell-menu-map nil "Key map for ispell menu") |
| 491 | 524 | ||
| 492 | ;;; Set up the map. | ||
| 493 | ;;;###autoload | 525 | ;;;###autoload |
| 494 | (defconst ispell-menu-map-needed | 526 | (defvar ispell-menu-lucid nil "Spelling menu for Lucid Emacs.") |
| 495 | ;; Verify this is not Lucid Emacs. | 527 | |
| 496 | (and (not ispell-menu-map) (boundp 'system-key-alist))) | 528 | ;;; Break out lucid menu and split into several calls to avoid having |
| 529 | ;;; long lines in loaddefs.el. Detect need off following constant. | ||
| 497 | 530 | ||
| 498 | ;;;###autoload | 531 | ;;;###autoload |
| 532 | (defconst ispell-menu-map-needed ; make sure this is not Lucid Emacs | ||
| 533 | (and (not ispell-menu-map) | ||
| 534 | ;; make sure this isn't Lucid Emacs | ||
| 535 | (featurep 'menu-bar) (string-lessp "19" emacs-version))) | ||
| 536 | |||
| 537 | |||
| 538 | ;;; setup dictionary | ||
| 539 | ;;;###autoload | ||
| 499 | (if ispell-menu-map-needed | 540 | (if ispell-menu-map-needed |
| 500 | (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) | 541 | (let ((dicts (reverse (cons (cons "default" nil) ispell-dictionary-alist))) |
| 501 | name) | 542 | name) |
| 502 | ;; Can put in defvar when external defines are removed. | ||
| 503 | (setq ispell-menu-map (make-sparse-keymap "Spell")) | 543 | (setq ispell-menu-map (make-sparse-keymap "Spell")) |
| 544 | ;; add the dictionaries to the bottom of the list. | ||
| 504 | (while dicts | 545 | (while dicts |
| 505 | (setq name (car (car dicts)) | 546 | (setq name (car (car dicts)) |
| 506 | dicts (cdr dicts)) | 547 | dicts (cdr dicts)) |
| @@ -510,10 +551,10 @@ language.aff file \(e.g., english.aff\).") | |||
| 510 | (list 'lambda () '(interactive) | 551 | (list 'lambda () '(interactive) |
| 511 | (list 'ispell-change-dictionary name)))))))) | 552 | (list 'ispell-change-dictionary name)))))))) |
| 512 | 553 | ||
| 554 | ;;; define commands in menu in opposite order you want them to appear. | ||
| 513 | ;;;###autoload | 555 | ;;;###autoload |
| 514 | (if ispell-menu-map-needed | 556 | (if ispell-menu-map-needed |
| 515 | (progn | 557 | (progn |
| 516 | ;; Define commands in opposite order you want them to appear in menu. | ||
| 517 | (define-key ispell-menu-map [ispell-change-dictionary] | 558 | (define-key ispell-menu-map [ispell-change-dictionary] |
| 518 | '("Change Dictionary" . ispell-change-dictionary)) | 559 | '("Change Dictionary" . ispell-change-dictionary)) |
| 519 | (define-key ispell-menu-map [ispell-kill-ispell] | 560 | (define-key ispell-menu-map [ispell-kill-ispell] |
| @@ -543,46 +584,45 @@ language.aff file \(e.g., english.aff\).") | |||
| 543 | (define-key ispell-menu-map [ispell-message] | 584 | (define-key ispell-menu-map [ispell-message] |
| 544 | '("Check Message" . ispell-message)) | 585 | '("Check Message" . ispell-message)) |
| 545 | (define-key ispell-menu-map [ispell-help] | 586 | (define-key ispell-menu-map [ispell-help] |
| 587 | ;; use (x-popup-menu last-nonmenu-event(list "" ispell-help-list)) ? | ||
| 546 | '("Help" . (lambda () (interactive) (describe-function 'ispell-help)))) | 588 | '("Help" . (lambda () (interactive) (describe-function 'ispell-help)))) |
| 547 | (put 'ispell-region 'menu-enable 'mark-active))) | 589 | (put 'ispell-region 'menu-enable 'mark-active) |
| 548 | 590 | (fset 'ispell-menu-map (symbol-value 'ispell-menu-map)))) | |
| 549 | ;;;###autoload | 591 | |
| 550 | (fset 'ispell-menu-map (symbol-value 'ispell-menu-map)) | 592 | ;;; Xemacs version 19 |
| 551 | 593 | (if (and (string-lessp "19" emacs-version) | |
| 552 | (cond | 594 | (string-match "Lucid" emacs-version)) |
| 553 | ((and (string-lessp "19" emacs-version) | 595 | (let ((dicts (cons (cons "default" nil) ispell-dictionary-alist)) |
| 554 | (string-match "Lucid" emacs-version)) | 596 | (current-menubar (or current-menubar default-menubar)) |
| 555 | (let ((dicts (cons (cons "default" nil) ispell-dictionary-alist)) | 597 | (menu |
| 556 | (current-menubar (or current-menubar default-menubar)) | 598 | '(["Help" (describe-function 'ispell-help) t] |
| 557 | (menu | 599 | ;;["Help" (popup-menu ispell-help-list) t] |
| 558 | '(["Help" (describe-function 'ispell-help) t] | 600 | ["Check Message" ispell-message t] |
| 559 | ;;["Help" (popup-menu ispell-help-list) t] | 601 | ["Check Buffer" ispell-buffer t] |
| 560 | ["Check Message" ispell-message t] | 602 | ["Check Word" ispell-word t] |
| 561 | ["Check Buffer" ispell-buffer t] | 603 | ["Check Region" ispell-region (or (not zmacs-regions) (mark))] |
| 562 | ["Check Word" ispell-word t] | 604 | ["Continue Check" ispell-continue t] |
| 563 | ["Check Region" ispell-region (or (not zmacs-regions) (mark))] | 605 | ["Complete Word Frag"ispell-complete-word-interior-frag t] |
| 564 | ["Continue Check" ispell-continue t] | 606 | ["Complete Word" ispell-complete-word t] |
| 565 | ["Complete Word Frag"ispell-complete-word-interior-frag t] | 607 | ["Kill Process" ispell-kill-ispell t] |
| 566 | ["Complete Word" ispell-complete-word t] | 608 | "-" |
| 567 | ["Kill Process" ispell-kill-ispell t] | 609 | ["Save Dictionary" (ispell-pdict-save t) t] |
| 568 | "-" | 610 | ["Change Dictionary" ispell-change-dictionary t])) |
| 569 | ["Save Dictionary" (ispell-pdict-save t) t] | 611 | name) |
| 570 | ["Change Dictionary" ispell-change-dictionary t])) | 612 | (while dicts |
| 571 | name) | 613 | (setq name (car (car dicts)) |
| 572 | (while dicts | 614 | dicts (cdr dicts)) |
| 573 | (setq name (car (car dicts)) | 615 | (if (stringp name) |
| 574 | dicts (cdr dicts)) | 616 | (setq menu (append menu |
| 575 | (if (stringp name) | 617 | (list |
| 576 | (setq menu (append menu | 618 | (vector (concat "Select " (capitalize name)) |
| 577 | (list | 619 | (list 'ispell-change-dictionary name) |
| 578 | (vector (concat "Select " (capitalize name)) | 620 | t)))))) |
| 579 | (list 'ispell-change-dictionary name) | 621 | (setq ispell-menu-lucid menu) |
| 580 | t)))))) | 622 | (if current-menubar |
| 581 | (defvar ispell-menu-lucid menu "Lucid's spelling menu.") | 623 | (progn |
| 582 | (if current-menubar | 624 | (delete-menu-item '("Edit" "Spell")) ; in case already defined |
| 583 | (progn | 625 | (add-menu '("Edit") "Spell" ispell-menu-lucid))))) |
| 584 | (delete-menu-item '("Edit" "Spell")) ; in case already defined | ||
| 585 | (add-menu '("Edit") "Spell" ispell-menu-lucid)))))) | ||
| 586 | 626 | ||
| 587 | 627 | ||
| 588 | ;;; ********************************************************************** | 628 | ;;; ********************************************************************** |
| @@ -590,9 +630,12 @@ language.aff file \(e.g., english.aff\).") | |||
| 590 | ;;; ********************************************************************** | 630 | ;;; ********************************************************************** |
| 591 | 631 | ||
| 592 | 632 | ||
| 593 | ;;; This doesn't match the LAST patch number -- this is for 3.1 or 3.0.09 | 633 | ;;; The version must be 3.1 or greater for this version of ispell.el |
| 594 | (defconst ispell-required-versions '("3.1." "3.0.09") | 634 | ;;; There is an incompatibility between versin 3.1.12 and lower versions. |
| 635 | (defconst ispell-required-version '("3.1." 12) | ||
| 595 | "Ispell versions with which this version of ispell.el is known to work.") | 636 | "Ispell versions with which this version of ispell.el is known to work.") |
| 637 | (defvar ispell-offset 1 | ||
| 638 | "Offset that maps protocol differences between ispell 3.1 versions.") | ||
| 596 | 639 | ||
| 597 | (defun ispell-get-casechars () | 640 | (defun ispell-get-casechars () |
| 598 | (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))) | 641 | (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))) |
| @@ -614,8 +657,8 @@ language.aff file \(e.g., english.aff\).") | |||
| 614 | "Non-nil means personal dictionary has modifications to be saved.") | 657 | "Non-nil means personal dictionary has modifications to be saved.") |
| 615 | 658 | ||
| 616 | ;;; If you want to save the dictionary when quitting, must do so explicitly. | 659 | ;;; If you want to save the dictionary when quitting, must do so explicitly. |
| 617 | ;; When non-nil, the spell session is terminated. | 660 | ;;; When non-nil, the spell session is terminated. |
| 618 | ;; When numeric, contains cursor location in buffer, and cursor remains there. | 661 | ;;; When numeric, contains cursor location in buffer, and cursor remains there. |
| 619 | (defvar ispell-quit nil) | 662 | (defvar ispell-quit nil) |
| 620 | 663 | ||
| 621 | (defvar ispell-filter nil | 664 | (defvar ispell-filter nil |
| @@ -643,7 +686,7 @@ language.aff file \(e.g., english.aff\).") | |||
| 643 | ;;; be used. Do not redefine default value or it will override the global! | 686 | ;;; be used. Do not redefine default value or it will override the global! |
| 644 | (defvar ispell-local-dictionary nil | 687 | (defvar ispell-local-dictionary nil |
| 645 | "If non-nil, a dictionary to use for Ispell commands in this buffer. | 688 | "If non-nil, a dictionary to use for Ispell commands in this buffer. |
| 646 | The value should be a string, which is a file name. | 689 | The value must be a string dictionary name in `ispell-dictionary-alist'. |
| 647 | This variable becomes buffer-local when set in any fashion. | 690 | This variable becomes buffer-local when set in any fashion. |
| 648 | 691 | ||
| 649 | Setting ispell-local-dictionary to a value has the same effect as | 692 | Setting ispell-local-dictionary to a value has the same effect as |
| @@ -704,7 +747,7 @@ Currently the only other valid parser is 'tex. | |||
| 704 | 747 | ||
| 705 | You can set this variable in hooks in your init file -- eg: | 748 | You can set this variable in hooks in your init file -- eg: |
| 706 | 749 | ||
| 707 | \(add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))") | 750 | (add-hook 'tex-mode-hook (function (lambda () (setq ispell-parser 'tex))))") |
| 708 | 751 | ||
| 709 | (defvar ispell-region-end (make-marker) | 752 | (defvar ispell-region-end (make-marker) |
| 710 | "Marker that allows spelling continuations.") | 753 | "Marker that allows spelling continuations.") |
| @@ -712,11 +755,13 @@ You can set this variable in hooks in your init file -- eg: | |||
| 712 | (defvar ispell-check-only nil | 755 | (defvar ispell-check-only nil |
| 713 | "If non-nil, `ispell-word' does not try to correct the word.") | 756 | "If non-nil, `ispell-word' does not try to correct the word.") |
| 714 | 757 | ||
| 758 | |||
| 715 | ;;; ********************************************************************** | 759 | ;;; ********************************************************************** |
| 716 | ;;; ********************************************************************** | 760 | ;;; ********************************************************************** |
| 717 | 761 | ||
| 718 | 762 | ||
| 719 | (defalias 'ispell 'ispell-buffer) | 763 | (if (string-lessp "19" emacs-version) |
| 764 | (defalias 'ispell 'ispell-buffer)) | ||
| 720 | 765 | ||
| 721 | ;;;###autoload (define-key global-map "\M-$" 'ispell-word) | 766 | ;;;###autoload (define-key global-map "\M-$" 'ispell-word) |
| 722 | 767 | ||
| @@ -724,7 +769,7 @@ You can set this variable in hooks in your init file -- eg: | |||
| 724 | (defun ispell-word (&optional following quietly continue) | 769 | (defun ispell-word (&optional following quietly continue) |
| 725 | "Check spelling of word under or before the cursor. | 770 | "Check spelling of word under or before the cursor. |
| 726 | If the word is not found in dictionary, display possible corrections | 771 | If the word is not found in dictionary, display possible corrections |
| 727 | in a window and so you can choose one. | 772 | in a window allowing you to choose one. |
| 728 | 773 | ||
| 729 | With a prefix argument (or if CONTINUE is non-nil), | 774 | With a prefix argument (or if CONTINUE is non-nil), |
| 730 | resume interrupted spell-checking of a buffer or region. | 775 | resume interrupted spell-checking of a buffer or region. |
| @@ -745,7 +790,7 @@ or \\[ispell-region] to update the Ispell process." | |||
| 745 | (if (interactive-p) | 790 | (if (interactive-p) |
| 746 | (setq following ispell-following-word | 791 | (setq following ispell-following-word |
| 747 | quietly ispell-quietly)) | 792 | quietly ispell-quietly)) |
| 748 | (ispell-buffer-local-dict) ; use the correct dictionary | 793 | (ispell-accept-buffer-local-defs) ; use the correct dictionary |
| 749 | (let ((cursor-location (point)) ; retain cursor location | 794 | (let ((cursor-location (point)) ; retain cursor location |
| 750 | (word (ispell-get-word following)) | 795 | (word (ispell-get-word following)) |
| 751 | start end poss replace) | 796 | start end poss replace) |
| @@ -758,7 +803,6 @@ or \\[ispell-region] to update the Ispell process." | |||
| 758 | (or quietly | 803 | (or quietly |
| 759 | (message "Checking spelling of %s..." | 804 | (message "Checking spelling of %s..." |
| 760 | (funcall ispell-format-word word))) | 805 | (funcall ispell-format-word word))) |
| 761 | (ispell-init-process) ; erases ispell output buffer | ||
| 762 | (process-send-string ispell-process "%\n") ;put in verbose mode | 806 | (process-send-string ispell-process "%\n") ;put in verbose mode |
| 763 | (process-send-string ispell-process (concat "^" word "\n")) | 807 | (process-send-string ispell-process (concat "^" word "\n")) |
| 764 | ;; wait until ispell has processed word | 808 | ;; wait until ispell has processed word |
| @@ -785,16 +829,17 @@ or \\[ispell-region] to update the Ispell process." | |||
| 785 | (setq replace (ispell-command-loop | 829 | (setq replace (ispell-command-loop |
| 786 | (car (cdr (cdr poss))) | 830 | (car (cdr (cdr poss))) |
| 787 | (car (cdr (cdr (cdr poss)))) | 831 | (car (cdr (cdr (cdr poss)))) |
| 788 | (car poss) | 832 | (car poss) start end))) |
| 789 | start end))) | ||
| 790 | (cond ((equal 0 replace) | 833 | (cond ((equal 0 replace) |
| 791 | (ispell-add-per-file-word-list (car poss))) | 834 | (ispell-add-per-file-word-list (car poss))) |
| 792 | (replace | 835 | (replace |
| 793 | (delete-region start end) | ||
| 794 | (setq word (if (atom replace) replace (car replace)) | 836 | (setq word (if (atom replace) replace (car replace)) |
| 795 | cursor-location (+ (- (length word) (- end start)) | 837 | cursor-location (+ (- (length word) (- end start)) |
| 796 | cursor-location)) | 838 | cursor-location)) |
| 797 | (insert word) | 839 | (if (not (equal word (car poss))) |
| 840 | (progn | ||
| 841 | (delete-region start end) | ||
| 842 | (insert word))) | ||
| 798 | (if (not (atom replace)) ; recheck spelling of replacement | 843 | (if (not (atom replace)) ; recheck spelling of replacement |
| 799 | (progn | 844 | (progn |
| 800 | (goto-char cursor-location) | 845 | (goto-char cursor-location) |
| @@ -810,7 +855,7 @@ or \\[ispell-region] to update the Ispell process." | |||
| 810 | "Return the word for spell-checking according to ispell syntax. | 855 | "Return the word for spell-checking according to ispell syntax. |
| 811 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' | 856 | If optional argument FOLLOWING is non-nil or if `ispell-following-word' |
| 812 | is non-nil when called interactively, then the following word | 857 | is non-nil when called interactively, then the following word |
| 813 | \(rather than preceeding\) is checked when the cursor is not over a word. | 858 | \(rather than preceding\) is checked when the cursor is not over a word. |
| 814 | Optional second argument contains otherchars that can be included in word | 859 | Optional second argument contains otherchars that can be included in word |
| 815 | many times. | 860 | many times. |
| 816 | 861 | ||
| @@ -892,88 +937,88 @@ Highlights the word, which is assumed to run from START to END. | |||
| 892 | Global `ispell-pdict-modified-p' becomes a list where the only value | 937 | Global `ispell-pdict-modified-p' becomes a list where the only value |
| 893 | indicates whether the dictionary has been modified when option `a' or `i' is | 938 | indicates whether the dictionary has been modified when option `a' or `i' is |
| 894 | used." | 939 | used." |
| 895 | (let (highlighted | 940 | (let ((textbuf (current-buffer)) |
| 896 | (oldwin) | 941 | (count ?0) |
| 897 | (textbuf (current-buffer))) | 942 | (line 2) |
| 943 | (max-lines (- (window-height) 4)) ; assure 4 context lines. | ||
| 944 | (choices miss) | ||
| 945 | (window-min-height (min window-min-height | ||
| 946 | ispell-choices-win-default-height)) | ||
| 947 | (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) | ||
| 948 | (skipped 0) | ||
| 949 | char num result textwin highlighted) | ||
| 950 | |||
| 951 | ;; setup the *Choices* buffer with valid data. | ||
| 952 | (save-excursion | ||
| 953 | (set-buffer (get-buffer-create ispell-choices-buffer)) | ||
| 954 | (setq mode-line-format "-- %b --") | ||
| 955 | (erase-buffer) | ||
| 956 | (if guess | ||
| 957 | (progn | ||
| 958 | (insert "Affix rules generate and capitalize " | ||
| 959 | "this word as shown below:\n\t") | ||
| 960 | (while guess | ||
| 961 | (if (> (+ 4 (current-column) (length (car guess))) | ||
| 962 | (window-width)) | ||
| 963 | (progn | ||
| 964 | (insert "\n\t") | ||
| 965 | (setq line (1+ line)))) | ||
| 966 | (insert (car guess) " ") | ||
| 967 | (setq guess (cdr guess))) | ||
| 968 | (insert "\nUse option `i' if this is a correct composition" | ||
| 969 | " from the derivative root.\n") | ||
| 970 | (setq line (+ line (if choices 3 2))))) | ||
| 971 | (while (and choices | ||
| 972 | (< (if (> (+ 7 (current-column) (length (car choices)) | ||
| 973 | (if (> count ?~) 3 0)) | ||
| 974 | (window-width)) | ||
| 975 | (progn | ||
| 976 | (insert "\n") | ||
| 977 | (setq line (1+ line))) | ||
| 978 | line) | ||
| 979 | max-lines)) | ||
| 980 | ;; not so good if there are over 20 or 30 options, but then, if | ||
| 981 | ;; there are that many you don't want to scan them all anyway... | ||
| 982 | (while (memq count command-characters) ; skip command characters. | ||
| 983 | (setq count (1+ count) | ||
| 984 | skipped (1+ skipped))) | ||
| 985 | (insert "(" count ") " (car choices) " ") | ||
| 986 | (setq choices (cdr choices) | ||
| 987 | count (1+ count))) | ||
| 988 | (setq count (- count ?0 skipped))) | ||
| 989 | |||
| 990 | ;; Assure word is visible | ||
| 991 | (if (not (pos-visible-in-window-p end)) | ||
| 992 | (sit-for 0)) | ||
| 993 | ;; Display choices for misspelled word. | ||
| 994 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) | ||
| 995 | (if choices-window | ||
| 996 | (if (not (equal line (window-height choices-window))) | ||
| 997 | ;; *Choices* window changed size. Adjust the choices window | ||
| 998 | ;; without scrolling the spelled window when possible | ||
| 999 | (let ((window-line (- line (window-height choices-window))) | ||
| 1000 | (visible (progn (forward-line -1) (point)))) | ||
| 1001 | (move-to-window-line 0) | ||
| 1002 | (forward-line window-line) | ||
| 1003 | (set-window-start (selected-window) | ||
| 1004 | (if (> (point) visible) visible (point))) | ||
| 1005 | (goto-char end) | ||
| 1006 | (select-window (previous-window)) ; *Choices* window | ||
| 1007 | (enlarge-window window-line)) | ||
| 1008 | (select-window choices-window)) | ||
| 1009 | ;; Overlay *Choices* window when it isn't showing | ||
| 1010 | (ispell-overlay-window (max line ispell-choices-win-default-height))) | ||
| 1011 | (switch-to-buffer ispell-choices-buffer) | ||
| 1012 | (goto-char (point-min))) | ||
| 1013 | |||
| 1014 | (select-window (setq textwin (next-window))) | ||
| 1015 | |||
| 1016 | ;; highlight word, protecting current buffer status | ||
| 898 | (unwind-protect | 1017 | (unwind-protect |
| 899 | (let ((count ?0) | 1018 | (progn |
| 900 | (line 2) | ||
| 901 | (max-lines (- (window-height) 4)) ; assure 4 context lines. | ||
| 902 | (choices miss) | ||
| 903 | (window-min-height (min window-min-height | ||
| 904 | ispell-choices-win-default-height)) | ||
| 905 | (command-characters '( ? ?i ?a ?A ?r ?R ?? ?x ?X ?q ?l ?u ?m )) | ||
| 906 | (skipped 0) | ||
| 907 | char num result) | ||
| 908 | (save-excursion | ||
| 909 | (set-buffer (get-buffer-create ispell-choices-buffer)) | ||
| 910 | (setq mode-line-format "-- %b --") | ||
| 911 | (erase-buffer) | ||
| 912 | (if guess | ||
| 913 | (progn | ||
| 914 | (insert "Affix rules generate and capitalize " | ||
| 915 | "this word as shown below:\n\t") | ||
| 916 | (while guess | ||
| 917 | (if (> (+ 4 (current-column) (length (car guess))) | ||
| 918 | (window-width)) | ||
| 919 | (progn | ||
| 920 | (insert "\n\t") | ||
| 921 | (setq line (1+ line)))) | ||
| 922 | (insert (car guess) " ") | ||
| 923 | (setq guess (cdr guess))) | ||
| 924 | (insert "\nUse option `i' if this is a correct composition" | ||
| 925 | " from the derivative root.\n") | ||
| 926 | (setq line (+ line (if choices 3 2))))) | ||
| 927 | (while (and choices | ||
| 928 | (< (if (> (+ 7 (current-column) (length (car choices)) | ||
| 929 | (if (> count ?~) 3 0)) | ||
| 930 | (window-width)) | ||
| 931 | (progn | ||
| 932 | (insert "\n") | ||
| 933 | (setq line (1+ line))) | ||
| 934 | line) | ||
| 935 | max-lines)) | ||
| 936 | ;; not so good if there are over 20 or 30 options, but then, if | ||
| 937 | ;; there are that many you don't want to scan them all anyway... | ||
| 938 | (while (memq count command-characters) ; skip command characters. | ||
| 939 | (setq count (1+ count) | ||
| 940 | skipped (1+ skipped))) | ||
| 941 | (insert "(" count ") " (car choices) " ") | ||
| 942 | (setq choices (cdr choices) | ||
| 943 | count (1+ count))) | ||
| 944 | (setq count (- count ?0 skipped))) | ||
| 945 | |||
| 946 | (let ((choices-window (get-buffer-window ispell-choices-buffer))) | ||
| 947 | (if choices-window | ||
| 948 | (if (not (equal line (window-height choices-window))) | ||
| 949 | (progn | ||
| 950 | (save-excursion | ||
| 951 | (let ((cur-point (point))) | ||
| 952 | (move-to-window-line (- line (window-height choices-window))) | ||
| 953 | (if (<= (point) cur-point) | ||
| 954 | (set-window-start (selected-window) (point))))) | ||
| 955 | (select-window (previous-window)) | ||
| 956 | (enlarge-window (- line (window-height choices-window)))) | ||
| 957 | (select-window choices-window)) | ||
| 958 | (ispell-overlay-window (max line | ||
| 959 | ispell-choices-win-default-height)) | ||
| 960 | (switch-to-buffer ispell-choices-buffer))) | ||
| 961 | (goto-char (point-min)) | ||
| 962 | |||
| 963 | ;; This is the window that holds the buffer. | ||
| 964 | (setq oldwin (next-window)) | ||
| 965 | |||
| 966 | ;; Select it. | ||
| 967 | (select-window oldwin) | ||
| 968 | ;; Put point at the end of the word. | ||
| 969 | (goto-char end) | ||
| 970 | |||
| 971 | ;; Highlight the word. | ||
| 972 | (if ispell-highlight-p | 1019 | (if ispell-highlight-p |
| 973 | (progn | 1020 | (ispell-highlight-spelling-error start end t)) |
| 974 | (ispell-highlight-spelling-error start end t) | 1021 | ;; Loop until a valid choice is made. |
| 975 | (setq highlighted t))) | ||
| 976 | |||
| 977 | (while | 1022 | (while |
| 978 | (eq | 1023 | (eq |
| 979 | t | 1024 | t |
| @@ -1000,7 +1045,7 @@ used." | |||
| 1000 | (setq num (- char ?0 skipped))) | 1045 | (setq num (- char ?0 skipped))) |
| 1001 | 1046 | ||
| 1002 | (cond | 1047 | (cond |
| 1003 | ((= char ? ) nil) ; accept word this time only | 1048 | ((= char ? ) nil) ; accept word this time only |
| 1004 | ((= char ?i) ; accept and insert word into pers dict | 1049 | ((= char ?i) ; accept and insert word into pers dict |
| 1005 | (process-send-string ispell-process (concat "*" word "\n")) | 1050 | (process-send-string ispell-process (concat "*" word "\n")) |
| 1006 | (setq ispell-pdict-modified-p '(t)) ; dictionary modified! | 1051 | (setq ispell-pdict-modified-p '(t)) ; dictionary modified! |
| @@ -1041,7 +1086,7 @@ used." | |||
| 1041 | (setq ispell-quit (or (not ispell-checking-message) | 1086 | (setq ispell-quit (or (not ispell-checking-message) |
| 1042 | (point)) | 1087 | (point)) |
| 1043 | ispell-pdict-modified-p nil)) | 1088 | ispell-pdict-modified-p nil)) |
| 1044 | t)) ; continue if they don't quit. | 1089 | t)) ; continue if they don't quit. |
| 1045 | ((= char ?l) | 1090 | ((= char ?l) |
| 1046 | (let ((new-word (read-string | 1091 | (let ((new-word (read-string |
| 1047 | "Lookup string (`*' is wildcard): " | 1092 | "Lookup string (`*' is wildcard): " |
| @@ -1109,11 +1154,11 @@ used." | |||
| 1109 | t) | 1154 | t) |
| 1110 | (t (ding) t)))))) | 1155 | (t (ding) t)))))) |
| 1111 | result) | 1156 | result) |
| 1112 | ;; Unhighlight the word we highlighted. | 1157 | ;; protected |
| 1113 | (and highlighted ispell-highlight-p | 1158 | (if ispell-highlight-p ; unhighlight |
| 1114 | (save-window-excursion | 1159 | (save-window-excursion |
| 1115 | (select-window oldwin) | 1160 | (select-window textwin) |
| 1116 | (ispell-highlight-spelling-error start end nil)))))) | 1161 | (ispell-highlight-spelling-error start end)))))) |
| 1117 | 1162 | ||
| 1118 | 1163 | ||
| 1119 | ;;;###autoload | 1164 | ;;;###autoload |
| @@ -1294,7 +1339,7 @@ otherwise it is displayed normally." | |||
| 1294 | 1339 | ||
| 1295 | (defun ispell-highlight-spelling-error-lucid (start end &optional highlight) | 1340 | (defun ispell-highlight-spelling-error-lucid (start end &optional highlight) |
| 1296 | "Highlight the word from START to END using `isearch-highlight'. | 1341 | "Highlight the word from START to END using `isearch-highlight'. |
| 1297 | When the optional third arg HIGHLIGHT is set, the word is highlighted | 1342 | When the optional third arg HIGHLIGHT is set, the word is highlighted, |
| 1298 | otherwise it is displayed normally." | 1343 | otherwise it is displayed normally." |
| 1299 | (if highlight | 1344 | (if highlight |
| 1300 | (isearch-highlight start end) | 1345 | (isearch-highlight start end) |
| @@ -1316,16 +1361,16 @@ The variable `ispell-highlight-face' selects the face to use for highlighting." | |||
| 1316 | (delete-overlay ispell-overlay))) | 1361 | (delete-overlay ispell-overlay))) |
| 1317 | 1362 | ||
| 1318 | 1363 | ||
| 1319 | ;;; Choose a highlight function at load time. | 1364 | (defun ispell-highlight-spelling-error (start end &optional highlight) |
| 1320 | (defun ispell-highlight-spelling-error (start end highlight) | ||
| 1321 | (cond | 1365 | (cond |
| 1322 | ((string-match "Lucid" emacs-version) | 1366 | ((string-match "Lucid" emacs-version) |
| 1323 | (ispell-highlight-spelling-error-lucid start end highlight)) | 1367 | (ispell-highlight-spelling-error-lucid start end highlight)) |
| 1324 | ((and (string-lessp "19" emacs-version) (featurep 'faces) | 1368 | ((and (string-lessp "19" emacs-version) |
| 1325 | window-system) | 1369 | (featurep 'faces) window-system) |
| 1326 | (ispell-highlight-spelling-error-overlay start end highlight)) | 1370 | (ispell-highlight-spelling-error-overlay start end highlight)) |
| 1327 | (t (ispell-highlight-spelling-error-generic start end highlight)))) | 1371 | (t (ispell-highlight-spelling-error-generic start end highlight)))) |
| 1328 | 1372 | ||
| 1373 | |||
| 1329 | (defun ispell-overlay-window (height) | 1374 | (defun ispell-overlay-window (height) |
| 1330 | "Create a window covering the top HEIGHT lines of the current window. | 1375 | "Create a window covering the top HEIGHT lines of the current window. |
| 1331 | Ensure that the line above point is still visible but otherwise avoid | 1376 | Ensure that the line above point is still visible but otherwise avoid |
| @@ -1397,31 +1442,28 @@ scrolling the current window. Leave the new window selected." | |||
| 1397 | ;; option is the only way I can think of to do this that works with | 1442 | ;; option is the only way I can think of to do this that works with |
| 1398 | ;; all versions, since versions earlier than 3.0.09 didn't identify | 1443 | ;; all versions, since versions earlier than 3.0.09 didn't identify |
| 1399 | ;; themselves on startup. | 1444 | ;; themselves on startup. |
| 1400 | ;; | ||
| 1401 | (save-excursion | 1445 | (save-excursion |
| 1402 | (set-buffer (get-buffer-create " *ispell-tmp*")) | 1446 | (set-buffer (get-buffer-create " *ispell-tmp*")) |
| 1403 | (erase-buffer) | 1447 | (erase-buffer) |
| 1404 | (let ((status (call-process ispell-program-name nil t nil "-v")) | 1448 | (let ((status (call-process ispell-program-name nil t nil "-v")) |
| 1405 | (case-fold-search t)) | 1449 | (case-fold-search t)) |
| 1406 | (goto-char (point-min)) | 1450 | (goto-char (point-min)) |
| 1407 | (cond ((not (memq status '(0 nil))) | 1451 | (if (not (memq status '(0 nil))) |
| 1408 | (error "%s exited with %s %s" ispell-program-name | 1452 | (error "%s exited with %s %s" ispell-program-name |
| 1409 | (if (stringp status) "signal" "code") status)) | 1453 | (if (stringp status) "signal" "code") status)) |
| 1410 | ((not (re-search-forward | 1454 | (if (not (re-search-forward |
| 1411 | (concat "\\b\\(" | 1455 | (concat "\\b\\(" |
| 1412 | (mapconcat 'regexp-quote | 1456 | (regexp-quote (car ispell-required-version)) |
| 1413 | ispell-required-versions | 1457 | "\\)\\([0-9]*\\)\\b") |
| 1414 | "\\|") | 1458 | nil t)) |
| 1415 | "\\)\\b") | 1459 | (error |
| 1416 | nil t)) | 1460 | "%s version %s* is required: try renaming ispell4.el to ispell.el" |
| 1417 | (error "%s version %s is required: try renaming ispell4.el to ispell.el" | 1461 | ispell-program-name (car ispell-required-version)) |
| 1418 | ispell-program-name | 1462 | ;; check that it is the correct version. |
| 1419 | (car ispell-required-versions) | 1463 | (if (< (car (read-from-string (buffer-substring |
| 1420 | ;(if (re-search-forward "version \\([0-9][0-9.]+\\)\\b" | 1464 | (match-beginning 2) (match-end 2)))) |
| 1421 | ; nil t) | 1465 | (car (cdr ispell-required-version))) |
| 1422 | ; (buffer-substring (match-beginning 1) (match-end 1)) | 1466 | (setq ispell-offset 0))) |
| 1423 | ; "an unknown version") | ||
| 1424 | ))) | ||
| 1425 | (kill-buffer (current-buffer))))) | 1467 | (kill-buffer (current-buffer))))) |
| 1426 | 1468 | ||
| 1427 | 1469 | ||
| @@ -1555,11 +1597,11 @@ With prefix argument, set the default directory." | |||
| 1555 | (ispell-accept-buffer-local-defs) ; set up dictionary, local words, etc. | 1597 | (ispell-accept-buffer-local-defs) ; set up dictionary, local words, etc. |
| 1556 | (unwind-protect | 1598 | (unwind-protect |
| 1557 | (save-excursion | 1599 | (save-excursion |
| 1558 | (message "Spell checking %s..." | 1600 | (message "Spell checking %s using %s dictionary..." |
| 1559 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) | 1601 | (if (and (= reg-start (point-min)) (= reg-end (point-max))) |
| 1560 | (buffer-name) "region")) | 1602 | (buffer-name) "region") |
| 1561 | ;Eliminated to keep ispell-message displaying each piece: (sit-for 0) | 1603 | (or ispell-dictionary "default")) |
| 1562 | ;; must be top level, not in ispell-command-loop for keeping window. | 1604 | ;; Returns cursor to original location. |
| 1563 | (save-window-excursion | 1605 | (save-window-excursion |
| 1564 | (goto-char reg-start) | 1606 | (goto-char reg-start) |
| 1565 | (let ((transient-mark-mode nil)) | 1607 | (let ((transient-mark-mode nil)) |
| @@ -1572,7 +1614,7 @@ With prefix argument, set the default directory." | |||
| 1572 | (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS | 1614 | (cond ; LOOK AT THIS LINE AND SKIP OR PROCESS |
| 1573 | ((eolp) ; END OF LINE, just go to next line. | 1615 | ((eolp) ; END OF LINE, just go to next line. |
| 1574 | (forward-char 1)) | 1616 | (forward-char 1)) |
| 1575 | ((and (null ispell-check-comments) ; SKIPING COMMENTS | 1617 | ((and (null ispell-check-comments) ; SKIPPING COMMENTS |
| 1576 | comment-start ; skip comments that start on the line. | 1618 | comment-start ; skip comments that start on the line. |
| 1577 | (search-forward comment-start end t)) ; or found here. | 1619 | (search-forward comment-start end t)) ; or found here. |
| 1578 | (if (= (- (point) start) (length comment-start)) | 1620 | (if (= (- (point) start) (length comment-start)) |
| @@ -1594,7 +1636,8 @@ With prefix argument, set the default directory." | |||
| 1594 | (re-search-forward "[][()$]" limit t)) | 1636 | (re-search-forward "[][()$]" limit t)) |
| 1595 | (setq string | 1637 | (setq string |
| 1596 | (concat "^" (buffer-substring start limit) | 1638 | (concat "^" (buffer-substring start limit) |
| 1597 | "\n"))) | 1639 | "\n") |
| 1640 | offset-change (- offset-change ispell-offset))) | ||
| 1598 | (goto-char limit)))) | 1641 | (goto-char limit)))) |
| 1599 | ((and ispell-skip-tib ; SKIP TIB REFERENCES! | 1642 | ((and ispell-skip-tib ; SKIP TIB REFERENCES! |
| 1600 | (re-search-forward ispell-tib-ref-beginning end t)) | 1643 | (re-search-forward ispell-tib-ref-beginning end t)) |
| @@ -1618,13 +1661,15 @@ With prefix argument, set the default directory." | |||
| 1618 | (re-search-forward "[][()$]" limit t)) | 1661 | (re-search-forward "[][()$]" limit t)) |
| 1619 | (setq string | 1662 | (setq string |
| 1620 | (concat "^" (buffer-substring start limit) | 1663 | (concat "^" (buffer-substring start limit) |
| 1621 | "\n"))) | 1664 | "\n") |
| 1665 | offset-change (- offset-change ispell-offset))) | ||
| 1622 | (goto-char limit)))) | 1666 | (goto-char limit)))) |
| 1623 | ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS | 1667 | ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS |
| 1624 | (forward-char 1)) | 1668 | (forward-char 1)) |
| 1625 | ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS | 1669 | ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS |
| 1626 | (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS | 1670 | (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS |
| 1627 | (setq string (concat "^" (buffer-substring start end) "\n")) | 1671 | (setq string (concat "^" (buffer-substring start end) "\n") |
| 1672 | offset-change (- offset-change ispell-offset)) | ||
| 1628 | (goto-char end)) | 1673 | (goto-char end)) |
| 1629 | (t (beginning-of-line 2))) ; EMPTY LINE, skip it. | 1674 | (t (beginning-of-line 2))) ; EMPTY LINE, skip it. |
| 1630 | 1675 | ||
| @@ -1670,15 +1715,13 @@ With prefix argument, set the default directory." | |||
| 1670 | (ispell-command-loop | 1715 | (ispell-command-loop |
| 1671 | (car (cdr (cdr poss))) | 1716 | (car (cdr (cdr poss))) |
| 1672 | (car (cdr (cdr (cdr poss)))) | 1717 | (car (cdr (cdr (cdr poss)))) |
| 1673 | (car poss) | 1718 | (car poss) word-start word-end)) |
| 1674 | word-start word-end)) | ||
| 1675 | (save-window-excursion | 1719 | (save-window-excursion |
| 1676 | (setq replace | 1720 | (setq replace |
| 1677 | (ispell-command-loop | 1721 | (ispell-command-loop |
| 1678 | (car (cdr (cdr poss))) | 1722 | (car (cdr (cdr poss))) |
| 1679 | (car (cdr (cdr (cdr poss)))) | 1723 | (car (cdr (cdr (cdr poss)))) |
| 1680 | (car poss) | 1724 | (car poss) word-start word-end)))) |
| 1681 | word-start word-end)))) | ||
| 1682 | (cond | 1725 | (cond |
| 1683 | ((and replace (listp replace)) | 1726 | ((and replace (listp replace)) |
| 1684 | ;; REPLACEMENT WORD entered. Recheck line | 1727 | ;; REPLACEMENT WORD entered. Recheck line |
| @@ -1692,8 +1735,10 @@ With prefix argument, set the default directory." | |||
| 1692 | (setq reg-end (+ reg-end change) | 1735 | (setq reg-end (+ reg-end change) |
| 1693 | offset-change (+ offset-change | 1736 | offset-change (+ offset-change |
| 1694 | change))) | 1737 | change))) |
| 1695 | (delete-region word-start word-end) | 1738 | (if (not (equal (car replace) (car poss))) |
| 1696 | (insert (car replace)) | 1739 | (progn |
| 1740 | (delete-region word-start word-end) | ||
| 1741 | (insert (car replace)))) | ||
| 1697 | ;; I only need to recheck typed-in replacements | 1742 | ;; I only need to recheck typed-in replacements |
| 1698 | (if (not (eq 'query-replace | 1743 | (if (not (eq 'query-replace |
| 1699 | (car (cdr replace)))) | 1744 | (car (cdr replace)))) |
| @@ -1740,7 +1785,10 @@ With prefix argument, set the default directory." | |||
| 1740 | offset-change (+ offset-change change) | 1785 | offset-change (+ offset-change change) |
| 1741 | end (+ end change))))) | 1786 | end (+ end change))))) |
| 1742 | (if (not ispell-quit) | 1787 | (if (not ispell-quit) |
| 1743 | (message "Continuing spelling check...")) | 1788 | (message |
| 1789 | (concat "Continuing spelling check using " | ||
| 1790 | (or ispell-dictionary "default") | ||
| 1791 | " dictionary..."))) | ||
| 1744 | (sit-for 0))) | 1792 | (sit-for 0))) |
| 1745 | ;; finished with line! | 1793 | ;; finished with line! |
| 1746 | (setq ispell-filter (cdr ispell-filter))))) | 1794 | (setq ispell-filter (cdr ispell-filter))))) |
| @@ -1863,6 +1911,7 @@ Standard ispell choices are then available." | |||
| 1863 | (interactive) | 1911 | (interactive) |
| 1864 | (ispell-complete-word t)) | 1912 | (ispell-complete-word t)) |
| 1865 | 1913 | ||
| 1914 | |||
| 1866 | ;;; ********************************************************************** | 1915 | ;;; ********************************************************************** |
| 1867 | ;;; Ispell Minor Mode | 1916 | ;;; Ispell Minor Mode |
| 1868 | ;;; ********************************************************************** | 1917 | ;;; ********************************************************************** |
| @@ -1912,6 +1961,7 @@ warns you if the previous word is incorrectly spelled." | |||
| 1912 | (ispell-word nil t)) | 1961 | (ispell-word nil t)) |
| 1913 | (call-interactively (key-binding (this-command-keys))))) | 1962 | (call-interactively (key-binding (this-command-keys))))) |
| 1914 | 1963 | ||
| 1964 | |||
| 1915 | ;;; ********************************************************************** | 1965 | ;;; ********************************************************************** |
| 1916 | ;;; Ispell Message | 1966 | ;;; Ispell Message |
| 1917 | ;;; ********************************************************************** | 1967 | ;;; ********************************************************************** |
| @@ -1926,14 +1976,14 @@ warns you if the previous word is incorrectly spelled." | |||
| 1926 | ;; Matches uuencoded text | 1976 | ;; Matches uuencoded text |
| 1927 | "^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM" | 1977 | "^begin [0-9][0-9][0-9] .*\nM.*\nM.*\nM" |
| 1928 | ;; Matches shell files (esp. auto-decoding) | 1978 | ;; Matches shell files (esp. auto-decoding) |
| 1929 | "^#! /bin/sh" | 1979 | "^#! /bin/[ck]?sh" |
| 1930 | ;; Matches context difference listing | 1980 | ;; Matches context difference listing |
| 1931 | "\\(diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*" | 1981 | "\\(diff -c .*\\)?\n\\*\\*\\* .*\n--- .*\n\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*" |
| 1932 | ;; Matches "----------------- cut here" | 1982 | ;; Matches "----------------- cut here" |
| 1933 | "^[-=_]+\\s ?cut here") | 1983 | "^[-=_]+\\s ?cut here") |
| 1934 | "\\|") | 1984 | "\\|") |
| 1935 | "*End of text which will be checked in ispell-message. | 1985 | "*End of text which will be checked in ispell-message. |
| 1936 | If it is a string, limit at first occurence of that regular expression. | 1986 | If it is a string, limit at first occurrence of that regular expression. |
| 1937 | Otherwise, it must be a function which is called to get the limit.") | 1987 | Otherwise, it must be a function which is called to get the limit.") |
| 1938 | 1988 | ||
| 1939 | 1989 | ||
| @@ -1953,7 +2003,7 @@ in your .emacs file: | |||
| 1953 | (add-hook 'mail-send-hook 'ispell-message) | 2003 | (add-hook 'mail-send-hook 'ispell-message) |
| 1954 | (add-hook 'mh-before-send-letter-hook 'ispell-message) | 2004 | (add-hook 'mh-before-send-letter-hook 'ispell-message) |
| 1955 | 2005 | ||
| 1956 | you can bind this to the key C-c i in GNUS or mail by adding to | 2006 | You can bind this to the key C-c i in GNUS or mail by adding to |
| 1957 | `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression: | 2007 | `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression: |
| 1958 | (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))" | 2008 | (function (lambda () (local-set-key \"\\C-ci\" 'ispell-message)))" |
| 1959 | (interactive) | 2009 | (interactive) |
| @@ -2030,13 +2080,8 @@ you can bind this to the key C-c i in GNUS or mail by adding to | |||
| 2030 | (while (< (point) limit) | 2080 | (while (< (point) limit) |
| 2031 | ;; Skip across text cited from other messages. | 2081 | ;; Skip across text cited from other messages. |
| 2032 | (while (and (looking-at cite-regexp-start) | 2082 | (while (and (looking-at cite-regexp-start) |
| 2033 | (< (point) limit)) | 2083 | (< (point) limit) |
| 2034 | (let ((point1 (point))) | 2084 | (zerop (forward-line 1)))) |
| 2035 | (forward-line 1) | ||
| 2036 | ;; If there's no next line, go to the end of this one | ||
| 2037 | ;; so that the loop stops looping. | ||
| 2038 | (if (eq point1 (point)) | ||
| 2039 | (end-of-line)))) | ||
| 2040 | (if (< (point) limit) | 2085 | (if (< (point) limit) |
| 2041 | ;; Check the next batch of lines that *aren't* cited. | 2086 | ;; Check the next batch of lines that *aren't* cited. |
| 2042 | (let ((end (save-excursion | 2087 | (let ((end (save-excursion |
| @@ -2082,7 +2127,7 @@ Includes latex/nroff modes and extended character mode." | |||
| 2082 | (let ((extended-char-mode (ispell-get-extended-character-mode))) | 2127 | (let ((extended-char-mode (ispell-get-extended-character-mode))) |
| 2083 | (if extended-char-mode | 2128 | (if extended-char-mode |
| 2084 | (process-send-string ispell-process (concat extended-char-mode "\n")))) | 2129 | (process-send-string ispell-process (concat extended-char-mode "\n")))) |
| 2085 | ;; Set buffer-local parsing mode and extended charater mode, if specified. | 2130 | ;; Set buffer-local parsing mode and extended character mode, if specified. |
| 2086 | (save-excursion | 2131 | (save-excursion |
| 2087 | (goto-char (point-min)) | 2132 | (goto-char (point-min)) |
| 2088 | ;; Uses last valid definition | 2133 | ;; Uses last valid definition |
| @@ -2094,9 +2139,9 @@ Includes latex/nroff modes and extended character mode." | |||
| 2094 | ;; space separated definitions. | 2139 | ;; space separated definitions. |
| 2095 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) | 2140 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) |
| 2096 | (cond ((string-match "latex-mode" string) | 2141 | (cond ((string-match "latex-mode" string) |
| 2097 | (process-send-string ispell-process "+\n")) | 2142 | (process-send-string ispell-process "+\n~tex\n")) |
| 2098 | ((string-match "nroff-mode" string) | 2143 | ((string-match "nroff-mode" string) |
| 2099 | (process-send-string ispell-process "-\n")) | 2144 | (process-send-string ispell-process "-\n~nroff")) |
| 2100 | ((string-match "~" string) ; Set extended character mode. | 2145 | ((string-match "~" string) ; Set extended character mode. |
| 2101 | (process-send-string ispell-process (concat string "\n"))) | 2146 | (process-send-string ispell-process (concat string "\n"))) |
| 2102 | (t (message "Illegal Ispell Parsing argument!") | 2147 | (t (message "Illegal Ispell Parsing argument!") |
| @@ -2154,8 +2199,8 @@ Both should not be used to define a buffer-local dictionary." | |||
| 2154 | (setq ispell-buffer-local-name (buffer-name))) | 2199 | (setq ispell-buffer-local-name (buffer-name))) |
| 2155 | (let ((end (save-excursion (end-of-line) (point))) | 2200 | (let ((end (save-excursion (end-of-line) (point))) |
| 2156 | string) | 2201 | string) |
| 2157 | ;; This used to treat " specially, but that loses for some | 2202 | ;; buffer-local words separated by a space, and can contain |
| 2158 | ;; people using them to fake accented letters. | 2203 | ;; any character other than a space. |
| 2159 | (while (re-search-forward " *\\([^ ]+\\)" end t) | 2204 | (while (re-search-forward " *\\([^ ]+\\)" end t) |
| 2160 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) | 2205 | (setq string (buffer-substring (match-beginning 1) (match-end 1))) |
| 2161 | (process-send-string ispell-process (concat "@" string "\n"))))))) | 2206 | (process-send-string ispell-process (concat "@" string "\n"))))))) |
| @@ -2201,7 +2246,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 2201 | reg-end) | 2246 | reg-end) |
| 2202 | 2247 | ||
| 2203 | 2248 | ||
| 2204 | (defconst ispell-version "2.30 -- Fri May 20 15:58:52 MDT 1994") | 2249 | (defconst ispell-version "2.34 -- Thu Dec 8 13:17:41 EST 1994") |
| 2205 | 2250 | ||
| 2206 | (provide 'ispell) | 2251 | (provide 'ispell) |
| 2207 | 2252 | ||