diff options
| author | Stefan Monnier | 2012-05-18 15:04:07 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2012-05-18 15:04:07 -0400 |
| commit | 60c4db3a60a7b7f0b835201efbd767ce12fa18d3 (patch) | |
| tree | 06b59826e754f8497dd8d2d0a7dd877cd70e1dc6 | |
| parent | 29473393648da830a6e954672e59cfbf4012049b (diff) | |
| download | emacs-60c4db3a60a7b7f0b835201efbd767ce12fa18d3.tar.gz emacs-60c4db3a60a7b7f0b835201efbd767ce12fa18d3.zip | |
* lisp/textmodes/flyspell.el: Commenting style, plus code simplifications.
(flyspell-default-deplacement-commands): Don't spell check after
repeated window/frame switches (e.g. triggered by mouse-movement).
(flyspell-delay-commands, flyspell-deplacement-commands): Use mapc.
(flyspell-debug-signal-word-checked): Simplify and fit in 80 cols.
(flyspell-casechars-cache, flyspell-ispell-casechars-cache)
(flyspell-not-casechars-cache, flyspell-ispell-not-casechars-cache):
Remove unused vars.
(flyspell-get-casechars, flyspell-get-not-casechars):
Simplify; Don't bother removing a ] just to add it back.
* lisp/textmodes/ispell.el (ispell-program-name): Use executable-find.
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/textmodes/flyspell.el | 257 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 47 |
3 files changed, 134 insertions, 184 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 30cd1843b30..58bf5a025d1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,17 @@ | |||
| 1 | 2012-05-18 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * textmodes/flyspell.el: Commenting style, plus code simplifications. | ||
| 4 | (flyspell-default-deplacement-commands): Don't spell check after | ||
| 5 | repeated window/frame switches (e.g. triggered by mouse-movement). | ||
| 6 | (flyspell-delay-commands, flyspell-deplacement-commands): Use mapc. | ||
| 7 | (flyspell-debug-signal-word-checked): Simplify and fit in 80 cols. | ||
| 8 | (flyspell-casechars-cache, flyspell-ispell-casechars-cache) | ||
| 9 | (flyspell-not-casechars-cache, flyspell-ispell-not-casechars-cache): | ||
| 10 | Remove unused vars. | ||
| 11 | (flyspell-get-casechars, flyspell-get-not-casechars): | ||
| 12 | Simplify; Don't bother removing a ] just to add it back. | ||
| 13 | * textmodes/ispell.el (ispell-program-name): Use executable-find. | ||
| 14 | |||
| 1 | 2012-05-18 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> | 15 | 2012-05-18 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> |
| 2 | 16 | ||
| 3 | * calc/calc-lang.el (math-C-parse-bess, math-C-parse-fma): | 17 | * calc/calc-lang.el (math-C-parse-bess, math-C-parse-fma): |
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index af924dd403b..c0b0a837a9d 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -143,10 +143,9 @@ whose length is specified by `flyspell-delay'." | |||
| 143 | :type '(repeat (symbol))) | 143 | :type '(repeat (symbol))) |
| 144 | 144 | ||
| 145 | (defcustom flyspell-default-deplacement-commands | 145 | (defcustom flyspell-default-deplacement-commands |
| 146 | '(next-line | 146 | '(next-line previous-line |
| 147 | previous-line | 147 | handle-switch-frame handle-select-window |
| 148 | scroll-up | 148 | scroll-up scroll-down) |
| 149 | scroll-down) | ||
| 150 | "The standard list of deplacement commands for Flyspell. | 149 | "The standard list of deplacement commands for Flyspell. |
| 151 | See `flyspell-deplacement-commands'." | 150 | See `flyspell-deplacement-commands'." |
| 152 | :group 'flyspell | 151 | :group 'flyspell |
| @@ -631,7 +630,7 @@ in your .emacs file. | |||
| 631 | (defun flyspell-delay-commands () | 630 | (defun flyspell-delay-commands () |
| 632 | "Install the standard set of Flyspell delayed commands." | 631 | "Install the standard set of Flyspell delayed commands." |
| 633 | (mapc 'flyspell-delay-command flyspell-default-delayed-commands) | 632 | (mapc 'flyspell-delay-command flyspell-default-delayed-commands) |
| 634 | (mapcar 'flyspell-delay-command flyspell-delayed-commands)) | 633 | (mapc 'flyspell-delay-command flyspell-delayed-commands)) |
| 635 | 634 | ||
| 636 | ;;*---------------------------------------------------------------------*/ | 635 | ;;*---------------------------------------------------------------------*/ |
| 637 | ;;* flyspell-delay-command ... */ | 636 | ;;* flyspell-delay-command ... */ |
| @@ -639,7 +638,7 @@ in your .emacs file. | |||
| 639 | (defun flyspell-delay-command (command) | 638 | (defun flyspell-delay-command (command) |
| 640 | "Set COMMAND to be delayed, for Flyspell. | 639 | "Set COMMAND to be delayed, for Flyspell. |
| 641 | When flyspell `post-command-hook' is invoked because a delayed command | 640 | When flyspell `post-command-hook' is invoked because a delayed command |
| 642 | as been used the current word is not immediately checked. | 641 | has been used, the current word is not immediately checked. |
| 643 | It will be checked only after `flyspell-delay' seconds." | 642 | It will be checked only after `flyspell-delay' seconds." |
| 644 | (interactive "SDelay Flyspell after Command: ") | 643 | (interactive "SDelay Flyspell after Command: ") |
| 645 | (put command 'flyspell-delayed t)) | 644 | (put command 'flyspell-delayed t)) |
| @@ -650,16 +649,15 @@ It will be checked only after `flyspell-delay' seconds." | |||
| 650 | (defun flyspell-deplacement-commands () | 649 | (defun flyspell-deplacement-commands () |
| 651 | "Install the standard set of Flyspell deplacement commands." | 650 | "Install the standard set of Flyspell deplacement commands." |
| 652 | (mapc 'flyspell-deplacement-command flyspell-default-deplacement-commands) | 651 | (mapc 'flyspell-deplacement-command flyspell-default-deplacement-commands) |
| 653 | (mapcar 'flyspell-deplacement-command flyspell-deplacement-commands)) | 652 | (mapc 'flyspell-deplacement-command flyspell-deplacement-commands)) |
| 654 | 653 | ||
| 655 | ;;*---------------------------------------------------------------------*/ | 654 | ;;*---------------------------------------------------------------------*/ |
| 656 | ;;* flyspell-deplacement-command ... */ | 655 | ;;* flyspell-deplacement-command ... */ |
| 657 | ;;*---------------------------------------------------------------------*/ | 656 | ;;*---------------------------------------------------------------------*/ |
| 658 | (defun flyspell-deplacement-command (command) | 657 | (defun flyspell-deplacement-command (command) |
| 659 | "Set COMMAND that implement cursor movements, for Flyspell. | 658 | "Set COMMAND that implement cursor movements, for Flyspell. |
| 660 | When flyspell `post-command-hook' is invoked because of a deplacement command | 659 | When flyspell `post-command-hook' is invoked because a deplacement command |
| 661 | as been used the current word is checked only if the previous command was | 660 | has been used, the current word is not checked." |
| 662 | not the very same deplacement command." | ||
| 663 | (interactive "SDeplacement Flyspell after Command: ") | 661 | (interactive "SDeplacement Flyspell after Command: ") |
| 664 | (put command 'flyspell-deplacement t)) | 662 | (put command 'flyspell-deplacement t)) |
| 665 | 663 | ||
| @@ -680,12 +678,12 @@ not the very same deplacement command." | |||
| 680 | ;;* post command hook, we will check, if the word at this position */ | 678 | ;;* post command hook, we will check, if the word at this position */ |
| 681 | ;;* has to be spell checked. */ | 679 | ;;* has to be spell checked. */ |
| 682 | ;;*---------------------------------------------------------------------*/ | 680 | ;;*---------------------------------------------------------------------*/ |
| 683 | (defvar flyspell-pre-buffer nil) | 681 | (defvar flyspell-pre-buffer nil "Buffer current before `this-command'.") |
| 684 | (defvar flyspell-pre-point nil) | 682 | (defvar flyspell-pre-point nil "Point before running `this-command'") |
| 685 | (defvar flyspell-pre-column nil) | 683 | (defvar flyspell-pre-column nil "Column before running `this-command'") |
| 686 | (defvar flyspell-pre-pre-buffer nil) | 684 | (defvar flyspell-pre-pre-buffer nil) |
| 687 | (defvar flyspell-pre-pre-point nil) | 685 | (defvar flyspell-pre-pre-point nil) |
| 688 | (make-variable-buffer-local 'flyspell-pre-point) | 686 | (make-variable-buffer-local 'flyspell-pre-point) ;Why?? --Stef |
| 689 | 687 | ||
| 690 | ;;*---------------------------------------------------------------------*/ | 688 | ;;*---------------------------------------------------------------------*/ |
| 691 | ;;* flyspell-previous-command ... */ | 689 | ;;* flyspell-previous-command ... */ |
| @@ -709,18 +707,18 @@ not the very same deplacement command." | |||
| 709 | ;;;###autoload | 707 | ;;;###autoload |
| 710 | (defun flyspell-mode-off () | 708 | (defun flyspell-mode-off () |
| 711 | "Turn Flyspell mode off." | 709 | "Turn Flyspell mode off." |
| 712 | ;; we remove the hooks | 710 | ;; We remove the hooks. |
| 713 | (remove-hook 'post-command-hook (function flyspell-post-command-hook) t) | 711 | (remove-hook 'post-command-hook (function flyspell-post-command-hook) t) |
| 714 | (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t) | 712 | (remove-hook 'pre-command-hook (function flyspell-pre-command-hook) t) |
| 715 | (remove-hook 'after-change-functions 'flyspell-after-change-function t) | 713 | (remove-hook 'after-change-functions 'flyspell-after-change-function t) |
| 716 | (remove-hook 'hack-local-variables-hook | 714 | (remove-hook 'hack-local-variables-hook |
| 717 | (function flyspell-hack-local-variables-hook) t) | 715 | (function flyspell-hack-local-variables-hook) t) |
| 718 | ;; we remove all the flyspell highlightings | 716 | ;; We remove all the flyspell highlightings. |
| 719 | (flyspell-delete-all-overlays) | 717 | (flyspell-delete-all-overlays) |
| 720 | ;; we have to erase pre cache variables | 718 | ;; We have to erase pre cache variables. |
| 721 | (setq flyspell-pre-buffer nil) | 719 | (setq flyspell-pre-buffer nil) |
| 722 | (setq flyspell-pre-point nil) | 720 | (setq flyspell-pre-point nil) |
| 723 | ;; we mark the mode as killed | 721 | ;; We mark the mode as killed. |
| 724 | (setq flyspell-mode nil)) | 722 | (setq flyspell-mode nil)) |
| 725 | 723 | ||
| 726 | ;;*---------------------------------------------------------------------*/ | 724 | ;;*---------------------------------------------------------------------*/ |
| @@ -732,9 +730,8 @@ More precisely, it applies to the word that was before point | |||
| 732 | before the current command." | 730 | before the current command." |
| 733 | (let ((ispell-otherchars (ispell-get-otherchars))) | 731 | (let ((ispell-otherchars (ispell-get-otherchars))) |
| 734 | (cond | 732 | (cond |
| 735 | ((or (not (numberp flyspell-pre-point)) | 733 | ((not (and (numberp flyspell-pre-point) |
| 736 | (not (bufferp flyspell-pre-buffer)) | 734 | (buffer-live-p flyspell-pre-buffer))) |
| 737 | (not (buffer-live-p flyspell-pre-buffer))) | ||
| 738 | nil) | 735 | nil) |
| 739 | ((and (eq flyspell-pre-pre-point flyspell-pre-point) | 736 | ((and (eq flyspell-pre-pre-point flyspell-pre-point) |
| 740 | (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) | 737 | (eq flyspell-pre-pre-buffer flyspell-pre-buffer)) |
| @@ -794,21 +791,15 @@ before the current command." | |||
| 794 | ;;* flyspell-check-changed-word-p ... */ | 791 | ;;* flyspell-check-changed-word-p ... */ |
| 795 | ;;*---------------------------------------------------------------------*/ | 792 | ;;*---------------------------------------------------------------------*/ |
| 796 | (defun flyspell-check-changed-word-p (start stop) | 793 | (defun flyspell-check-changed-word-p (start stop) |
| 797 | "Return t when the changed word has to be checked. | 794 | "Return non-nil when the changed word has to be checked. |
| 798 | The answer depends of several criteria. | 795 | The answer depends of several criteria. |
| 799 | Mostly we check word delimiters." | 796 | Mostly we check word delimiters." |
| 800 | (cond | 797 | (not (and (not (and (memq (char-after start) '(?\n ? )) (> stop start))) |
| 801 | ((and (memq (char-after start) '(?\n ? )) (> stop start)) | 798 | (numberp flyspell-pre-point) |
| 802 | t) | 799 | (or |
| 803 | ((not (numberp flyspell-pre-point)) | 800 | (and (>= flyspell-pre-point start) (<= flyspell-pre-point stop)) |
| 804 | t) | 801 | (let ((pos (point))) |
| 805 | ((and (>= flyspell-pre-point start) (<= flyspell-pre-point stop)) | 802 | (or (>= pos start) (<= pos stop) (= pos (1+ stop)))))))) |
| 806 | nil) | ||
| 807 | ((let ((pos (point))) | ||
| 808 | (or (>= pos start) (<= pos stop) (= pos (1+ stop)))) | ||
| 809 | nil) | ||
| 810 | (t | ||
| 811 | t))) | ||
| 812 | 803 | ||
| 813 | ;;*---------------------------------------------------------------------*/ | 804 | ;;*---------------------------------------------------------------------*/ |
| 814 | ;;* flyspell-check-word-p ... */ | 805 | ;;* flyspell-check-word-p ... */ |
| @@ -820,7 +811,7 @@ Mostly we check word delimiters." | |||
| 820 | (let ((ispell-otherchars (ispell-get-otherchars))) | 811 | (let ((ispell-otherchars (ispell-get-otherchars))) |
| 821 | (cond | 812 | (cond |
| 822 | ((<= (- (point-max) 1) (point-min)) | 813 | ((<= (- (point-max) 1) (point-min)) |
| 823 | ;; the buffer is not filled enough | 814 | ;; The buffer is not filled enough. |
| 824 | nil) | 815 | nil) |
| 825 | ((and (and (> (current-column) 0) | 816 | ((and (and (> (current-column) 0) |
| 826 | (not (eq (current-column) flyspell-pre-column))) | 817 | (not (eq (current-column) flyspell-pre-column))) |
| @@ -831,15 +822,15 @@ Mostly we check word delimiters." | |||
| 831 | (not (looking-at ispell-otherchars))) | 822 | (not (looking-at ispell-otherchars))) |
| 832 | (or flyspell-consider-dash-as-word-delimiter-flag | 823 | (or flyspell-consider-dash-as-word-delimiter-flag |
| 833 | (not (looking-at "-")))))) | 824 | (not (looking-at "-")))))) |
| 834 | ;; yes because we have reached or typed a word delimiter. | 825 | ;; Yes because we have reached or typed a word delimiter. |
| 835 | t) | 826 | t) |
| 836 | ((symbolp this-command) | 827 | ((symbolp this-command) |
| 837 | (cond | 828 | (cond |
| 838 | ((get this-command 'flyspell-deplacement) | 829 | ((get this-command 'flyspell-deplacement) |
| 839 | (not (eq flyspell-previous-command this-command))) | 830 | (not (eq flyspell-previous-command this-command))) |
| 840 | ((get this-command 'flyspell-delayed) | 831 | ((get this-command 'flyspell-delayed) |
| 841 | ;; the current command is not delayed, that | 832 | ;; The current command is not delayed, that |
| 842 | ;; is that we must check the word now | 833 | ;; is that we must check the word now. |
| 843 | (and (not unread-command-events) | 834 | (and (not unread-command-events) |
| 844 | (sit-for flyspell-delay))) | 835 | (sit-for flyspell-delay))) |
| 845 | (t t))) | 836 | (t t))) |
| @@ -877,53 +868,51 @@ Mostly we check word delimiters." | |||
| 877 | (oldbuf (current-buffer)) | 868 | (oldbuf (current-buffer)) |
| 878 | (point (point))) | 869 | (point (point))) |
| 879 | (with-current-buffer (get-buffer-create "*flyspell-debug*") | 870 | (with-current-buffer (get-buffer-create "*flyspell-debug*") |
| 880 | (insert "WORD:\n") | 871 | (insert |
| 881 | (insert (format " this-cmd : %S\n" this-command)) | 872 | "WORD:\n" |
| 882 | (insert (format " delayed : %S\n" (and (symbolp this-command) | 873 | (format " this-cmd : %S\n" this-command) |
| 883 | (get this-command 'flyspell-delayed)))) | 874 | (format " delayed : %S\n" (and (symbolp this-command) |
| 884 | (insert (format " point : %S\n" point)) | 875 | (get this-command |
| 885 | (insert (format " prev-char : [%c] %S\n" | 876 | 'flyspell-delayed))) |
| 886 | (with-current-buffer oldbuf | 877 | (format " point : %S\n" point) |
| 887 | (let ((c (if (> (point) (point-min)) | 878 | (format " prev-char : [%c] %S\n" |
| 888 | (save-excursion | 879 | (with-current-buffer oldbuf |
| 889 | (backward-char 1) | 880 | (if (bobp) ?\ (char-before))) |
| 890 | (char-after (point))) | 881 | (with-current-buffer oldbuf |
| 891 | ? ))) | 882 | (if (bobp) |
| 892 | c)) | 883 | nil |
| 893 | (with-current-buffer oldbuf | 884 | (save-excursion |
| 894 | (let ((c (if (> (point) (point-min)) | 885 | (backward-char 1) |
| 895 | (save-excursion | 886 | (and (looking-at (flyspell-get-not-casechars)) |
| 896 | (backward-char 1) | 887 | (or (string= "" ispell-otherchars) |
| 897 | (and (and (looking-at (flyspell-get-not-casechars)) 1) | 888 | (not (looking-at ispell-otherchars))) |
| 898 | (or (string= "" ispell-otherchars) | 889 | (or flyspell-consider-dash-as-word-delimiter-flag |
| 899 | (not (looking-at ispell-otherchars))) | 890 | (not (looking-at "\\-"))) |
| 900 | (and (or flyspell-consider-dash-as-word-delimiter-flag | 891 | 2))))) |
| 901 | (not (looking-at "\\-"))) 2)))))) | 892 | (format " because : %S\n" |
| 902 | c)))) | 893 | (cond |
| 903 | (insert (format " because : %S\n" | 894 | ((not (and (symbolp this-command) |
| 904 | (cond | 895 | (get this-command 'flyspell-delayed))) |
| 905 | ((not (and (symbolp this-command) | 896 | ;; The current command is not delayed, that |
| 906 | (get this-command 'flyspell-delayed))) | 897 | ;; is that we must check the word now. |
| 907 | ;; the current command is not delayed, that | 898 | 'not-delayed) |
| 908 | ;; is that we must check the word now | 899 | ((with-current-buffer oldbuf |
| 909 | 'not-delayed) | 900 | (if (bobp) |
| 910 | ((with-current-buffer oldbuf | 901 | nil |
| 911 | (let ((c (if (> (point) (point-min)) | 902 | (save-excursion |
| 912 | (save-excursion | 903 | (backward-char 1) |
| 913 | (backward-char 1) | 904 | (and (looking-at (flyspell-get-not-casechars)) |
| 914 | (and (looking-at (flyspell-get-not-casechars)) | 905 | (or (string= "" ispell-otherchars) |
| 915 | (or (string= "" ispell-otherchars) | 906 | (not (looking-at ispell-otherchars))) |
| 916 | (not (looking-at ispell-otherchars))) | 907 | (or flyspell-consider-dash-as-word-delimiter-flag |
| 917 | (or flyspell-consider-dash-as-word-delimiter-flag | 908 | (not (looking-at "\\-"))))))) |
| 918 | (not (looking-at "\\-")))))))) | 909 | ;; Yes because we have reached or typed a word delimiter. |
| 919 | c)) | 910 | 'separator) |
| 920 | ;; yes because we have reached or typed a word delimiter. | 911 | ((not (integerp flyspell-delay)) |
| 921 | 'separator) | 912 | ;; Yes because the user set up a no-delay configuration. |
| 922 | ((not (integerp flyspell-delay)) | 913 | 'no-delay) |
| 923 | ;; yes because the user had set up a no-delay configuration. | 914 | (t |
| 924 | 'no-delay) | 915 | 'sit-for)))) |
| 925 | (t | ||
| 926 | 'sit-for)))) | ||
| 927 | (goto-char (point-max))))) | 916 | (goto-char (point-max))))) |
| 928 | 917 | ||
| 929 | ;;*---------------------------------------------------------------------*/ | 918 | ;;*---------------------------------------------------------------------*/ |
| @@ -946,7 +935,7 @@ Mostly we check word delimiters." | |||
| 946 | ;;* 2- the word that used to be the current word before the */ | 935 | ;;* 2- the word that used to be the current word before the */ |
| 947 | ;;* THIS-COMMAND is checked if: */ | 936 | ;;* THIS-COMMAND is checked if: */ |
| 948 | ;;* a- the previous word is different from the current word */ | 937 | ;;* a- the previous word is different from the current word */ |
| 949 | ;;* b- the previous word as not just been checked by the */ | 938 | ;;* b- the previous word has not just been checked by the */ |
| 950 | ;;* previous FLYSPELL-POST-COMMAND-HOOK */ | 939 | ;;* previous FLYSPELL-POST-COMMAND-HOOK */ |
| 951 | ;;* 3- the words changed by the THIS-COMMAND that are neither the */ | 940 | ;;* 3- the words changed by the THIS-COMMAND that are neither the */ |
| 952 | ;;* previous word nor the current word */ | 941 | ;;* previous word nor the current word */ |
| @@ -973,7 +962,7 @@ Mostly we check word delimiters." | |||
| 973 | ;; we remember which word we have just checked. | 962 | ;; we remember which word we have just checked. |
| 974 | ;; this will be used next time we will check a word | 963 | ;; this will be used next time we will check a word |
| 975 | ;; to compare the next current word with the word | 964 | ;; to compare the next current word with the word |
| 976 | ;; that as been registered in the pre-command-hook | 965 | ;; that has been registered in the pre-command-hook |
| 977 | ;; that is these variables are used within the predicate | 966 | ;; that is these variables are used within the predicate |
| 978 | ;; FLYSPELL-CHECK-PRE-WORD-P | 967 | ;; FLYSPELL-CHECK-PRE-WORD-P |
| 979 | (setq flyspell-pre-pre-buffer (current-buffer)) | 968 | (setq flyspell-pre-pre-buffer (current-buffer)) |
| @@ -1240,63 +1229,8 @@ misspelling and skips redundant spell-checking step." | |||
| 1240 | (>= (match-end 0) b)))))) | 1229 | (>= (match-end 0) b)))))) |
| 1241 | (flyspell-math-tex-command-p))) | 1230 | (flyspell-math-tex-command-p))) |
| 1242 | 1231 | ||
| 1243 | ;;*---------------------------------------------------------------------*/ | 1232 | (defalias 'flyspell-get-casechars 'ispell-get-casechars) |
| 1244 | ;;* flyspell-casechars-cache ... */ | 1233 | (defalias 'flyspell-get-not-casechars 'ispell-get-not-casechars) |
| 1245 | ;;*---------------------------------------------------------------------*/ | ||
| 1246 | (defvar flyspell-casechars-cache nil) | ||
| 1247 | (defvar flyspell-ispell-casechars-cache nil) | ||
| 1248 | (make-variable-buffer-local 'flyspell-casechars-cache) | ||
| 1249 | (make-variable-buffer-local 'flyspell-ispell-casechars-cache) | ||
| 1250 | |||
| 1251 | ;;*---------------------------------------------------------------------*/ | ||
| 1252 | ;;* flyspell-get-casechars ... */ | ||
| 1253 | ;;*---------------------------------------------------------------------*/ | ||
| 1254 | (defun flyspell-get-casechars () | ||
| 1255 | "This function builds a string that is the regexp of word chars. | ||
| 1256 | In order to avoid one useless string construction, | ||
| 1257 | this function changes the last char of the `ispell-casechars' string." | ||
| 1258 | (let ((ispell-casechars (ispell-get-casechars))) | ||
| 1259 | (cond | ||
| 1260 | ((eq ispell-parser 'tex) | ||
| 1261 | (setq flyspell-ispell-casechars-cache ispell-casechars) | ||
| 1262 | (setq flyspell-casechars-cache | ||
| 1263 | (concat (substring ispell-casechars | ||
| 1264 | 0 | ||
| 1265 | (- (length ispell-casechars) 1)) | ||
| 1266 | "]")) | ||
| 1267 | flyspell-casechars-cache) | ||
| 1268 | (t | ||
| 1269 | (setq flyspell-ispell-casechars-cache ispell-casechars) | ||
| 1270 | (setq flyspell-casechars-cache ispell-casechars) | ||
| 1271 | flyspell-casechars-cache)))) | ||
| 1272 | |||
| 1273 | ;;*---------------------------------------------------------------------*/ | ||
| 1274 | ;;* flyspell-get-not-casechars-cache ... */ | ||
| 1275 | ;;*---------------------------------------------------------------------*/ | ||
| 1276 | (defvar flyspell-not-casechars-cache nil) | ||
| 1277 | (defvar flyspell-ispell-not-casechars-cache nil) | ||
| 1278 | (make-variable-buffer-local 'flyspell-not-casechars-cache) | ||
| 1279 | (make-variable-buffer-local 'flyspell-ispell-not-casechars-cache) | ||
| 1280 | |||
| 1281 | ;;*---------------------------------------------------------------------*/ | ||
| 1282 | ;;* flyspell-get-not-casechars ... */ | ||
| 1283 | ;;*---------------------------------------------------------------------*/ | ||
| 1284 | (defun flyspell-get-not-casechars () | ||
| 1285 | "This function builds a string that is the regexp of non-word chars." | ||
| 1286 | (let ((ispell-not-casechars (ispell-get-not-casechars))) | ||
| 1287 | (cond | ||
| 1288 | ((eq ispell-parser 'tex) | ||
| 1289 | (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) | ||
| 1290 | (setq flyspell-not-casechars-cache | ||
| 1291 | (concat (substring ispell-not-casechars | ||
| 1292 | 0 | ||
| 1293 | (- (length ispell-not-casechars) 1)) | ||
| 1294 | "]")) | ||
| 1295 | flyspell-not-casechars-cache) | ||
| 1296 | (t | ||
| 1297 | (setq flyspell-ispell-not-casechars-cache ispell-not-casechars) | ||
| 1298 | (setq flyspell-not-casechars-cache ispell-not-casechars) | ||
| 1299 | flyspell-not-casechars-cache)))) | ||
| 1300 | 1234 | ||
| 1301 | ;;*---------------------------------------------------------------------*/ | 1235 | ;;*---------------------------------------------------------------------*/ |
| 1302 | ;;* flyspell-get-word ... */ | 1236 | ;;* flyspell-get-word ... */ |
| @@ -1433,7 +1367,7 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1433 | (goto-char buffer-scan-pos) | 1367 | (goto-char buffer-scan-pos) |
| 1434 | (let ((keep t)) | 1368 | (let ((keep t)) |
| 1435 | ;; Iterate on string search until string is found as word, | 1369 | ;; Iterate on string search until string is found as word, |
| 1436 | ;; not as substring | 1370 | ;; not as substring. |
| 1437 | (while keep | 1371 | (while keep |
| 1438 | (if (search-forward word | 1372 | (if (search-forward word |
| 1439 | flyspell-large-region-end t) | 1373 | flyspell-large-region-end t) |
| @@ -1449,13 +1383,14 @@ The buffer to mark them in is `flyspell-large-region-buffer'." | |||
| 1449 | (when (or | 1383 | (when (or |
| 1450 | ;; Size matches, we really found it. | 1384 | ;; Size matches, we really found it. |
| 1451 | (= found-length misspell-length) | 1385 | (= found-length misspell-length) |
| 1452 | ;; Matches as part of a boundary-char separated word | 1386 | ;; Matches as part of a boundary-char separated |
| 1387 | ;; word. | ||
| 1453 | (member word | 1388 | (member word |
| 1454 | (split-string found ispell-otherchars)) | 1389 | (split-string found ispell-otherchars)) |
| 1455 | ;; Misspelling has higher length than | 1390 | ;; Misspelling has higher length than |
| 1456 | ;; what flyspell considers the | 1391 | ;; what flyspell considers the word. |
| 1457 | ;; word. Caused by boundary-chars | 1392 | ;; Caused by boundary-chars mismatch. |
| 1458 | ;; mismatch. Validating seems safe. | 1393 | ;; Validating seems safe. |
| 1459 | (< found-length misspell-length) | 1394 | (< found-length misspell-length) |
| 1460 | ;; ispell treats beginning of some TeX | 1395 | ;; ispell treats beginning of some TeX |
| 1461 | ;; commands as nroff control sequences | 1396 | ;; commands as nroff control sequences |
| @@ -1920,11 +1855,11 @@ This command proposes various successive corrections for the current word." | |||
| 1920 | (interactive) | 1855 | (interactive) |
| 1921 | (let ((pos (point)) | 1856 | (let ((pos (point)) |
| 1922 | (old-max (point-max))) | 1857 | (old-max (point-max))) |
| 1923 | ;; use the correct dictionary | 1858 | ;; Use the correct dictionary. |
| 1924 | (flyspell-accept-buffer-local-defs) | 1859 | (flyspell-accept-buffer-local-defs) |
| 1925 | (if (and (eq flyspell-auto-correct-pos pos) | 1860 | (if (and (eq flyspell-auto-correct-pos pos) |
| 1926 | (consp flyspell-auto-correct-region)) | 1861 | (consp flyspell-auto-correct-region)) |
| 1927 | ;; we have already been using the function at the same location | 1862 | ;; We have already been using the function at the same location. |
| 1928 | (let* ((start (car flyspell-auto-correct-region)) | 1863 | (let* ((start (car flyspell-auto-correct-region)) |
| 1929 | (len (cdr flyspell-auto-correct-region))) | 1864 | (len (cdr flyspell-auto-correct-region))) |
| 1930 | (flyspell-unhighlight-at start) | 1865 | (flyspell-unhighlight-at start) |
| @@ -1946,7 +1881,7 @@ This command proposes various successive corrections for the current word." | |||
| 1946 | (flyspell-display-next-corrections flyspell-auto-correct-ring)) | 1881 | (flyspell-display-next-corrections flyspell-auto-correct-ring)) |
| 1947 | (flyspell-ajust-cursor-point pos (point) old-max) | 1882 | (flyspell-ajust-cursor-point pos (point) old-max) |
| 1948 | (setq flyspell-auto-correct-pos (point))) | 1883 | (setq flyspell-auto-correct-pos (point))) |
| 1949 | ;; fetch the word to be checked | 1884 | ;; Fetch the word to be checked. |
| 1950 | (let ((word (flyspell-get-word))) | 1885 | (let ((word (flyspell-get-word))) |
| 1951 | (if (consp word) | 1886 | (if (consp word) |
| 1952 | (let ((start (car (cdr word))) | 1887 | (let ((start (car (cdr word))) |
| @@ -1954,30 +1889,30 @@ This command proposes various successive corrections for the current word." | |||
| 1954 | (word (car word)) | 1889 | (word (car word)) |
| 1955 | poss ispell-filter) | 1890 | poss ispell-filter) |
| 1956 | (setq flyspell-auto-correct-word word) | 1891 | (setq flyspell-auto-correct-word word) |
| 1957 | ;; now check spelling of word. | 1892 | ;; Now check spelling of word.. |
| 1958 | (ispell-send-string "%\n") ;put in verbose mode | 1893 | (ispell-send-string "%\n") ;Put in verbose mode. |
| 1959 | (ispell-send-string (concat "^" word "\n")) | 1894 | (ispell-send-string (concat "^" word "\n")) |
| 1960 | ;; wait until ispell has processed word. | 1895 | ;; Wait until ispell has processed word. |
| 1961 | (while (progn | 1896 | (while (progn |
| 1962 | (accept-process-output ispell-process) | 1897 | (accept-process-output ispell-process) |
| 1963 | (not (string= "" (car ispell-filter))))) | 1898 | (not (string= "" (car ispell-filter))))) |
| 1964 | ;; Remove leading empty element | 1899 | ;; Remove leading empty element. |
| 1965 | (setq ispell-filter (cdr ispell-filter)) | 1900 | (setq ispell-filter (cdr ispell-filter)) |
| 1966 | ;; ispell process should return something after word is sent. | 1901 | ;; Ispell process should return something after word is sent. |
| 1967 | ;; Tag word as valid (i.e., skip) otherwise | 1902 | ;; Tag word as valid (i.e., skip) otherwise. |
| 1968 | (or ispell-filter | 1903 | (or ispell-filter |
| 1969 | (setq ispell-filter '(*))) | 1904 | (setq ispell-filter '(*))) |
| 1970 | (if (consp ispell-filter) | 1905 | (if (consp ispell-filter) |
| 1971 | (setq poss (ispell-parse-output (car ispell-filter)))) | 1906 | (setq poss (ispell-parse-output (car ispell-filter)))) |
| 1972 | (cond | 1907 | (cond |
| 1973 | ((or (eq poss t) (stringp poss)) | 1908 | ((or (eq poss t) (stringp poss)) |
| 1974 | ;; don't correct word | 1909 | ;; Don't correct word. |
| 1975 | t) | 1910 | t) |
| 1976 | ((null poss) | 1911 | ((null poss) |
| 1977 | ;; ispell error | 1912 | ;; Ispell error. |
| 1978 | (error "Ispell: error in Ispell process")) | 1913 | (error "Ispell: error in Ispell process")) |
| 1979 | (t | 1914 | (t |
| 1980 | ;; the word is incorrect, we have to propose a replacement | 1915 | ;; The word is incorrect, we have to propose a replacement. |
| 1981 | (let ((replacements (if flyspell-sort-corrections | 1916 | (let ((replacements (if flyspell-sort-corrections |
| 1982 | (sort (car (cdr (cdr poss))) 'string<) | 1917 | (sort (car (cdr (cdr poss))) 'string<) |
| 1983 | (car (cdr (cdr poss)))))) | 1918 | (car (cdr (cdr poss)))))) |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index db058d05f35..892f43e09fe 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -349,9 +349,9 @@ Must be greater than 1." | |||
| 349 | :group 'ispell) | 349 | :group 'ispell) |
| 350 | 350 | ||
| 351 | (defcustom ispell-program-name | 351 | (defcustom ispell-program-name |
| 352 | (or (locate-file "aspell" exec-path exec-suffixes 'file-executable-p) | 352 | (or (executable-find "aspell") |
| 353 | (locate-file "ispell" exec-path exec-suffixes 'file-executable-p) | 353 | (executable-find "ispell") |
| 354 | (locate-file "hunspell" exec-path exec-suffixes 'file-executable-p) | 354 | (executable-find "hunspell") |
| 355 | "ispell") | 355 | "ispell") |
| 356 | "Program invoked by \\[ispell-word] and \\[ispell-region] commands." | 356 | "Program invoked by \\[ispell-word] and \\[ispell-region] commands." |
| 357 | :type 'string | 357 | :type 'string |
| @@ -909,7 +909,7 @@ Otherwise returns the library directory name, if that is defined." | |||
| 909 | 909 | ||
| 910 | ;;;###autoload | 910 | ;;;###autoload |
| 911 | (defvar ispell-menu-map nil "Key map for ispell menu.") | 911 | (defvar ispell-menu-map nil "Key map for ispell menu.") |
| 912 | ;;; redo menu when loading ispell to get dictionary modifications | 912 | ;; Redo menu when loading ispell to get dictionary modifications |
| 913 | (setq ispell-menu-map nil) | 913 | (setq ispell-menu-map nil) |
| 914 | 914 | ||
| 915 | ;;;###autoload | 915 | ;;;###autoload |
| @@ -1175,7 +1175,7 @@ The variable `ispell-library-directory' defines their location." | |||
| 1175 | (push name dict-list))) | 1175 | (push name dict-list))) |
| 1176 | dict-list)) | 1176 | dict-list)) |
| 1177 | 1177 | ||
| 1178 | ;;; define commands in menu in opposite order you want them to appear. | 1178 | ;; Define commands in menu in opposite order you want them to appear. |
| 1179 | ;;;###autoload | 1179 | ;;;###autoload |
| 1180 | (if ispell-menu-map-needed | 1180 | (if ispell-menu-map-needed |
| 1181 | (progn | 1181 | (progn |
| @@ -1372,9 +1372,9 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs." | |||
| 1372 | (defvar ispell-pdict-modified-p nil | 1372 | (defvar ispell-pdict-modified-p nil |
| 1373 | "Non-nil means personal dictionary has modifications to be saved.") | 1373 | "Non-nil means personal dictionary has modifications to be saved.") |
| 1374 | 1374 | ||
| 1375 | ;;; If you want to save the dictionary when quitting, must do so explicitly. | 1375 | ;; If you want to save the dictionary when quitting, must do so explicitly. |
| 1376 | ;;; When non-nil, the spell session is terminated. | 1376 | ;; When non-nil, the spell session is terminated. |
| 1377 | ;;; When numeric, contains cursor location in buffer, and cursor remains there. | 1377 | ;; When numeric, contains cursor location in buffer, and cursor remains there. |
| 1378 | (defvar ispell-quit nil) | 1378 | (defvar ispell-quit nil) |
| 1379 | 1379 | ||
| 1380 | (defvar ispell-process-directory nil | 1380 | (defvar ispell-process-directory nil |
| @@ -1874,10 +1874,10 @@ which is in `ispell-local-dictionary-alist' or `ispell-dictionary-alist'." | |||
| 1874 | (list word start end)))) | 1874 | (list word start end)))) |
| 1875 | 1875 | ||
| 1876 | 1876 | ||
| 1877 | ;;; Global ispell-pdict-modified-p is set by ispell-command-loop and | 1877 | ;; Global ispell-pdict-modified-p is set by ispell-command-loop and |
| 1878 | ;;; tracks changes in the dictionary. The global may either be | 1878 | ;; tracks changes in the dictionary. The global may either be |
| 1879 | ;;; a value or a list, whose value is the state of whether the | 1879 | ;; a value or a list, whose value is the state of whether the |
| 1880 | ;;; dictionary needs to be saved. | 1880 | ;; dictionary needs to be saved. |
| 1881 | 1881 | ||
| 1882 | ;;;###autoload | 1882 | ;;;###autoload |
| 1883 | (defun ispell-pdict-save (&optional no-query force-save) | 1883 | (defun ispell-pdict-save (&optional no-query force-save) |
| @@ -2416,8 +2416,8 @@ if defined." | |||
| 2416 | (setq start end)))))) ; else move start to next line of input | 2416 | (setq start end)))))) ; else move start to next line of input |
| 2417 | 2417 | ||
| 2418 | 2418 | ||
| 2419 | ;;; This function destroys the mark location if it is in the word being | 2419 | ;; This function destroys the mark location if it is in the word being |
| 2420 | ;;; highlighted. | 2420 | ;; highlighted. |
| 2421 | (defun ispell-highlight-spelling-error-generic (start end &optional highlight | 2421 | (defun ispell-highlight-spelling-error-generic (start end &optional highlight |
| 2422 | refresh) | 2422 | refresh) |
| 2423 | "Highlight the word from START to END with a kludge using `inverse-video'. | 2423 | "Highlight the word from START to END with a kludge using `inverse-video'. |
| @@ -2549,7 +2549,7 @@ scrolling the current window. Leave the new window selected." | |||
| 2549 | (set-window-start (next-window) top)))) | 2549 | (set-window-start (next-window) top)))) |
| 2550 | 2550 | ||
| 2551 | 2551 | ||
| 2552 | ;;; Should we add a compound word match return value? | 2552 | ;; Should we add a compound word match return value? |
| 2553 | (defun ispell-parse-output (output &optional accept-list shift) | 2553 | (defun ispell-parse-output (output &optional accept-list shift) |
| 2554 | "Parse the OUTPUT string from Ispell process and return: | 2554 | "Parse the OUTPUT string from Ispell process and return: |
| 2555 | 1: t for an exact match. | 2555 | 1: t for an exact match. |
| @@ -2615,8 +2615,8 @@ When asynchronous processes are not supported, `run' is always returned." | |||
| 2615 | 2615 | ||
| 2616 | 2616 | ||
| 2617 | (defun ispell-start-process () | 2617 | (defun ispell-start-process () |
| 2618 | "Start the ispell process, with support for no asynchronous processes. | 2618 | "Start the Ispell process, with support for no asynchronous processes. |
| 2619 | Keeps argument list for future ispell invocations for no async support." | 2619 | Keeps argument list for future Ispell invocations for no async support." |
| 2620 | ;; Local dictionary becomes the global dictionary in use. | 2620 | ;; Local dictionary becomes the global dictionary in use. |
| 2621 | (setq ispell-current-dictionary | 2621 | (setq ispell-current-dictionary |
| 2622 | (or ispell-local-dictionary ispell-dictionary)) | 2622 | (or ispell-local-dictionary ispell-dictionary)) |
| @@ -2792,11 +2792,11 @@ With CLEAR, buffer session localwords are cleaned." | |||
| 2792 | (if (not (and ispell-process | 2792 | (if (not (and ispell-process |
| 2793 | (eq (ispell-process-status) 'run))) | 2793 | (eq (ispell-process-status) 'run))) |
| 2794 | (or no-error | 2794 | (or no-error |
| 2795 | (error "There is no ispell process running!")) | 2795 | (error "There is no Ispell process running!")) |
| 2796 | (if ispell-async-processp | 2796 | (if ispell-async-processp |
| 2797 | (delete-process ispell-process) | 2797 | (delete-process ispell-process) |
| 2798 | ;; synchronous processes | 2798 | ;; Synchronous processes. |
| 2799 | (ispell-send-string "\n") ; make sure side effects occurred. | 2799 | (ispell-send-string "\n") ; Make sure side effects occurred. |
| 2800 | (kill-buffer ispell-output-buffer) | 2800 | (kill-buffer ispell-output-buffer) |
| 2801 | (kill-buffer ispell-session-buffer) | 2801 | (kill-buffer ispell-session-buffer) |
| 2802 | (setq ispell-output-buffer nil | 2802 | (setq ispell-output-buffer nil |
| @@ -2805,8 +2805,8 @@ With CLEAR, buffer session localwords are cleaned." | |||
| 2805 | (message "Ispell process killed") | 2805 | (message "Ispell process killed") |
| 2806 | nil)) | 2806 | nil)) |
| 2807 | 2807 | ||
| 2808 | ;;; ispell-change-dictionary is set in some people's hooks. Maybe this should | 2808 | ;; ispell-change-dictionary is set in some people's hooks. Maybe this should |
| 2809 | ;;; call ispell-init-process rather than wait for a spell checking command? | 2809 | ;; call ispell-init-process rather than wait for a spell checking command? |
| 2810 | 2810 | ||
| 2811 | ;;;###autoload | 2811 | ;;;###autoload |
| 2812 | (defun ispell-change-dictionary (dict &optional arg) | 2812 | (defun ispell-change-dictionary (dict &optional arg) |
| @@ -3411,6 +3411,7 @@ If optional INTERIOR-FRAG is non-nil then the word may be a character | |||
| 3411 | sequence inside of a word. | 3411 | sequence inside of a word. |
| 3412 | 3412 | ||
| 3413 | Standard ispell choices are then available." | 3413 | Standard ispell choices are then available." |
| 3414 | ;; FIXME: completion-at-point-function. | ||
| 3414 | (interactive "P") | 3415 | (interactive "P") |
| 3415 | (let ((cursor-location (point)) | 3416 | (let ((cursor-location (point)) |
| 3416 | (case-fold-search-val case-fold-search) | 3417 | (case-fold-search-val case-fold-search) |
| @@ -3943,7 +3944,7 @@ Both should not be used to define a buffer-local dictionary." | |||
| 3943 | (ispell-send-string (concat "@" string "\n")))))))) | 3944 | (ispell-send-string (concat "@" string "\n")))))))) |
| 3944 | 3945 | ||
| 3945 | 3946 | ||
| 3946 | ;;; returns optionally adjusted region-end-point. | 3947 | ;; Returns optionally adjusted region-end-point. |
| 3947 | 3948 | ||
| 3948 | ;; If comment-padright is defined, newcomment must be loaded. | 3949 | ;; If comment-padright is defined, newcomment must be loaded. |
| 3949 | (declare-function comment-add "newcomment" (arg)) | 3950 | (declare-function comment-add "newcomment" (arg)) |