diff options
| author | Agustín Martín | 2008-12-20 18:34:41 +0000 |
|---|---|---|
| committer | Agustín Martín | 2008-12-20 18:34:41 +0000 |
| commit | 0aef89e720844f6b6787647937df18eabb71cf09 (patch) | |
| tree | 7fb173be964c0c4cf6384e7f571ca12e74503dca | |
| parent | 99b72cc426dc014815eba2ea30324ead423c301b (diff) | |
| download | emacs-0aef89e720844f6b6787647937df18eabb71cf09.tar.gz emacs-0aef89e720844f6b6787647937df18eabb71cf09.zip | |
* textmodes/ispell.el (ispell-check-minver): New function.
(ispell-check-version): Rewrite spellchecker and version checking.
Use (ispell-check-minver). Handle hunspell versions.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/textmodes/ispell.el | 120 |
2 files changed, 89 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4450c96f4c3..c16f7bcc2b4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-12-20 Agustin Martin <agustin.martin@hispalinux.es> | ||
| 2 | |||
| 3 | * textmodes/ispell.el (ispell-check-minver): New function. | ||
| 4 | (ispell-check-version): Rewrite spellchecker and version checking. | ||
| 5 | Use (ispell-check-minver). Handle hunspell versions. | ||
| 6 | |||
| 1 | 2008-12-20 Chong Yidong <cyd@stupidchicken.com> | 7 | 2008-12-20 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 8 | ||
| 3 | * ido.el (ido-read-internal): Handle `confirm' and | 9 | * ido.el (ido-read-internal): Handle `confirm' and |
| @@ -35,7 +41,7 @@ | |||
| 35 | (authors-canonical-author-name): Doc fix. Respect authors-fixed-case. | 41 | (authors-canonical-author-name): Doc fix. Respect authors-fixed-case. |
| 36 | (authors): Ensure error buffer is writable. | 42 | (authors): Ensure error buffer is writable. |
| 37 | 43 | ||
| 38 | 2008-12-18 Agustín Martín <agustin.martin@hispalinux.es> | 44 | 2008-12-18 Agustin Martin <agustin.martin@hispalinux.es> |
| 39 | 45 | ||
| 40 | (ispell-really-hunspell): New variable to signal hunspell. | 46 | (ispell-really-hunspell): New variable to signal hunspell. |
| 41 | (ispell-check-version): | 47 | (ispell-check-version): |
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 3936eb4ce07..c8ee2c4b7c0 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el | |||
| @@ -196,6 +196,42 @@ | |||
| 196 | ;; Improved message reference matching in `ispell-message'. | 196 | ;; Improved message reference matching in `ispell-message'. |
| 197 | ;; Fixed bug in returning to nroff mode from tex mode. | 197 | ;; Fixed bug in returning to nroff mode from tex mode. |
| 198 | 198 | ||
| 199 | ;;; Compatibility code for xemacs and (not too) older emacsen: | ||
| 200 | |||
| 201 | (if (fboundp 'version<=) | ||
| 202 | (defalias 'ispell-check-minver 'version<=) | ||
| 203 | (defun ispell-check-minver (minver version) | ||
| 204 | "Check if string VERSION is at least string MINVER. | ||
| 205 | Both must be in [0-9]+.[0-9]+... format. This is a fallback | ||
| 206 | compatibility function in case version<= is not available." | ||
| 207 | (let ((pending t) | ||
| 208 | (return t) | ||
| 209 | start-ver start-mver) | ||
| 210 | ;; Loop until an absolute greater or smaller condition is reached | ||
| 211 | ;; or until no elements are left in any of version and minver. In | ||
| 212 | ;; this case version is exactly the minimal, so return OK. | ||
| 213 | (while pending | ||
| 214 | (let (ver mver) | ||
| 215 | (if (string-match "[0-9]+" version start-ver) | ||
| 216 | (setq start-ver (match-end 0) | ||
| 217 | ver (string-to-int (substring version (match-beginning 0) (match-end 0))))) | ||
| 218 | (if (string-match "[0-9]+" minver start-mver) | ||
| 219 | (setq start-mver (match-end 0) | ||
| 220 | mver (string-to-int (substring minver (match-beginning 0) (match-end 0))))) | ||
| 221 | |||
| 222 | (if (or ver mver) | ||
| 223 | (progn | ||
| 224 | (or ver (setq ver 0)) | ||
| 225 | (or mver (setq mver 0)) | ||
| 226 | ;; If none of below conditions match, this element is the | ||
| 227 | ;; same. Go checking next element. | ||
| 228 | (if (> ver mver) | ||
| 229 | (setq pending nil) | ||
| 230 | (if (< ver mver) | ||
| 231 | (setq pending nil | ||
| 232 | return nil)))) | ||
| 233 | (setq pending nil)))) | ||
| 234 | return))) | ||
| 199 | 235 | ||
| 200 | ;;; Code: | 236 | ;;; Code: |
| 201 | 237 | ||
| @@ -714,7 +750,7 @@ Otherwise returns the library directory name, if that is defined." | |||
| 714 | (default-directory (or (and (boundp 'temporary-file-directory) | 750 | (default-directory (or (and (boundp 'temporary-file-directory) |
| 715 | temporary-file-directory) | 751 | temporary-file-directory) |
| 716 | default-directory)) | 752 | default-directory)) |
| 717 | result status) | 753 | result status ispell-program-version) |
| 718 | (save-excursion | 754 | (save-excursion |
| 719 | (let ((buf (get-buffer " *ispell-tmp*"))) | 755 | (let ((buf (get-buffer " *ispell-tmp*"))) |
| 720 | (if buf (kill-buffer buf))) | 756 | (if buf (kill-buffer buf))) |
| @@ -746,43 +782,51 @@ Otherwise returns the library directory name, if that is defined." | |||
| 746 | (if (not (memq status '(0 nil))) | 782 | (if (not (memq status '(0 nil))) |
| 747 | (error "%s exited with %s %s" ispell-program-name | 783 | (error "%s exited with %s %s" ispell-program-name |
| 748 | (if (stringp status) "signal" "code") status)) | 784 | (if (stringp status) "signal" "code") status)) |
| 749 | (setq case-fold-search t | 785 | |
| 750 | status (re-search-forward | 786 | ;; Get relevant version strings. Only xx.yy.... format works well |
| 751 | (concat "\\<\\(" | 787 | (let (case-fold-search) |
| 752 | (format "%d" (car ispell-required-version)) | 788 | (setq ispell-program-version |
| 753 | "\\)\\.\\([0-9]*\\)\\.\\([0-9]*\\)\\>") | 789 | (and (search-forward-regexp "\\([0-9]+\\.[0-9\\.]+\\)" nil t) |
| 754 | nil t) | 790 | (match-string 1))) |
| 755 | case-fold-search case-fold-search-val) | 791 | |
| 756 | (if (or (not status) ; major version mismatch | 792 | ;; Make sure these variables are (re-)initialized to the default value |
| 757 | (< (car (read-from-string (match-string-no-properties 2))) | 793 | (setq ispell-really-aspell nil |
| 758 | (car (cdr ispell-required-version)))) ; minor version mismatch | 794 | ispell-aspell-supports-utf8 nil |
| 759 | (error "%s version 3 release %d.%d.%d or greater is required" | 795 | ispell-really-hunspell nil) |
| 760 | ispell-program-name (car ispell-required-version) | 796 | |
| 761 | (car (cdr ispell-required-version)) | 797 | (goto-char (point-min)) |
| 762 | (car (cdr (cdr ispell-required-version)))) | 798 | (or (setq ispell-really-aspell |
| 763 | 799 | (and (search-forward-regexp | |
| 764 | ;; check that it is the correct version. | 800 | "(but really Aspell \\([0-9]+\\.[0-9\\.]+\\)?)" nil t) |
| 765 | (if (and (= (car (read-from-string (match-string-no-properties 2))) | 801 | (match-string 1))) |
| 766 | (car (cdr ispell-required-version))) | 802 | (setq ispell-really-hunspell |
| 767 | (< (car (read-from-string (match-string-no-properties 3))) | 803 | (and (search-forward-regexp |
| 768 | (car (cdr (cdr ispell-required-version))))) | 804 | "(but really Hunspell \\([0-9]+\\.[0-9\\.]+\\)?)" nil t) |
| 769 | (setq ispell-offset 0)) | 805 | (match-string 1))))) |
| 770 | 806 | ||
| 771 | ;; Check to see if it's really aspell or hunspell. | 807 | (let ((aspell-minver "0.50") |
| 772 | (goto-char (point-min)) | 808 | (aspell8-minver "0.60") |
| 773 | (let (case-fold-search) | 809 | (ispell0-minver "3.1.0") |
| 774 | (or | 810 | (ispell-minver "3.1.12") |
| 775 | (setq ispell-really-aspell | 811 | (hunspell8-minver "1.1.6")) |
| 776 | (and (search-forward-regexp | 812 | |
| 777 | "(but really Aspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t) | 813 | (if (ispell-check-minver ispell0-minver ispell-program-version) |
| 778 | (progn | 814 | (or (ispell-check-minver ispell-minver ispell-program-version) |
| 779 | (setq ispell-aspell-supports-utf8 | 815 | (setq ispell-offset 0)) |
| 780 | (not (version< (match-string 1) "0.60"))) | 816 | (error "%s release %s or greater is required" |
| 781 | t))) | 817 | ispell-program-name |
| 782 | (setq ispell-really-hunspell | 818 | ispell-minver)) |
| 783 | (search-forward-regexp | 819 | |
| 784 | "(but really Hunspell \\(.*?\\)\\(-[0-9]+\\)?)" nil t)) | 820 | (cond |
| 785 | ))) | 821 | (ispell-really-aspell |
| 822 | (if (ispell-check-minver aspell-minver ispell-really-aspell) | ||
| 823 | (if (ispell-check-minver aspell8-minver ispell-really-aspell) | ||
| 824 | (setq ispell-aspell-supports-utf8 t)) | ||
| 825 | (setq ispell-really-aspell nil))) | ||
| 826 | (ispell-really-hunspell | ||
| 827 | (or (ispell-check-minver hunspell8-minver ispell-really-hunspell) | ||
| 828 | (setq ispell-really-hunspell nil))))) | ||
| 829 | |||
| 786 | (kill-buffer (current-buffer))) | 830 | (kill-buffer (current-buffer))) |
| 787 | result)) | 831 | result)) |
| 788 | 832 | ||