aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-02-08 06:09:08 +0000
committerRichard M. Stallman1995-02-08 06:09:08 +0000
commit1335d07805a8a5b9c930cec296bb0dea1e46b8b2 (patch)
tree57460f2de6e31bc2a5a68e66c3478f7f5ce29862
parent92beedc25e0b4f66041e793c2d0bf53cf93fef51 (diff)
downloademacs-1335d07805a8a5b9c930cec296bb0dea1e46b8b2.tar.gz
emacs-1335d07805a8a5b9c930cec296bb0dea1e46b8b2.zip
Personal dictionary save forced when called from menu,
Epoch compile support. (ispell-skip-sgml): Added variable for skipping SGML tags & references. (ispell-buffer-local-parsing): Hard wire set of ispell-skip-sgml-tags to sgml-mode. (ispell-pdict-save): Message improvement. (ispell-command-loop): Properly adjust screen with different settings of ispell-choices-win-default-height. (check-ispell-version): Use fundamental-mode as default-major-mode. (ispell-change-dictionary): Remove unnecessary process kills (ispell-region): Fold sgml support in with tib checking. (ispell-message): Skips checking of forwarded messages.
-rw-r--r--lisp/textmodes/ispell.el173
1 files changed, 119 insertions, 54 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 6f49747ef64..00d3703a3ca 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -6,8 +6,8 @@
6;;; 6;;;
7;;; 7;;;
8;;; Authors : Ken Stevens <k.stevens@ieee.org> 8;;; Authors : Ken Stevens <k.stevens@ieee.org>
9;;; Last Modified On: Thu Dec 8 13:17:41 EST 1994 9;;; Last Modified On: Mon Feb 6 17:39:38 EST 1995
10;;; Update Revision : 2.34 10;;; Update Revision : 2.36
11;;; Syntax : emacs-lisp 11;;; Syntax : emacs-lisp
12;;; Status : Release with 3.1.12+ ispell. 12;;; Status : Release with 3.1.12+ ispell.
13;;; Version : International Ispell Version 3.1 by Geoff Kuenning. 13;;; Version : International Ispell Version 3.1 by Geoff Kuenning.
@@ -129,6 +129,14 @@
129;;; 129;;;
130;;; HISTORY 130;;; HISTORY
131;;; 131;;;
132;;; Revision 2.36 1995/2/6 17:39:38 stevens
133;;; Properly adjust screen with different ispell-choices-win-default-height
134;;; settings. Skips SGML entity references.
135;;;
136;;; Revision 2.35 1995/1/13 14:16:46 stevens
137;;; Skips SGML tags, ispell-change-dictionary fix for add-hook, assure personal
138;;; dictionary is saved when called from the menu
139;;;
132;;; Revision 2.34 1994/12/08 13:17:41 stevens 140;;; Revision 2.34 1994/12/08 13:17:41 stevens
133;;; Interaction corrected to function with all 3.1 ispell versions. 141;;; Interaction corrected to function with all 3.1 ispell versions.
134;;; 142;;;
@@ -560,7 +568,7 @@ language.aff file \(e.g., english.aff\).")
560 (define-key ispell-menu-map [ispell-kill-ispell] 568 (define-key ispell-menu-map [ispell-kill-ispell]
561 '("Kill Process" . ispell-kill-ispell)) 569 '("Kill Process" . ispell-kill-ispell))
562 (define-key ispell-menu-map [ispell-pdict-save] 570 (define-key ispell-menu-map [ispell-pdict-save]
563 '("Save Dictionary" . (lambda () (interactive) (ispell-pdict-save t)))) 571 '("Save Dictionary" . (lambda () (interactive) (ispell-pdict-save t t))))
564 (define-key ispell-menu-map [ispell-complete-word] 572 (define-key ispell-menu-map [ispell-complete-word]
565 '("Complete Word" . ispell-complete-word)) 573 '("Complete Word" . ispell-complete-word))
566 (define-key ispell-menu-map [ispell-complete-word-interior-frag] 574 (define-key ispell-menu-map [ispell-complete-word-interior-frag]
@@ -606,7 +614,7 @@ language.aff file \(e.g., english.aff\).")
606 ["Complete Word" ispell-complete-word t] 614 ["Complete Word" ispell-complete-word t]
607 ["Kill Process" ispell-kill-ispell t] 615 ["Kill Process" ispell-kill-ispell t]
608 "-" 616 "-"
609 ["Save Dictionary" (ispell-pdict-save t) t] 617 ["Save Dictionary" (ispell-pdict-save t t) t]
610 ["Change Dictionary" ispell-change-dictionary t])) 618 ["Change Dictionary" ispell-change-dictionary t]))
611 name) 619 name)
612 (while dicts 620 (while dicts
@@ -720,6 +728,11 @@ The above keyword string should be followed by `latex-mode' or
720Extended character mode can be changed for this buffer by placing 728Extended character mode can be changed for this buffer by placing
721a `~' followed by an extended-character mode -- such as `~.tex'.") 729a `~' followed by an extended-character mode -- such as `~.tex'.")
722 730
731(defvar ispell-skip-sgml nil
732 "Skips spell checking of SGML tags and entity references when non-nil.
733This variable is set when major-mode is sgml-mode.")
734
735;;;###autoload
723(defvar ispell-local-pdict ispell-personal-dictionary 736(defvar ispell-local-pdict ispell-personal-dictionary
724 "A buffer local variable containing the current personal dictionary. 737 "A buffer local variable containing the current personal dictionary.
725If non-nil, the value must be a string, which is a file name. 738If non-nil, the value must be a string, which is a file name.
@@ -760,8 +773,9 @@ You can set this variable in hooks in your init file -- eg:
760;;; ********************************************************************** 773;;; **********************************************************************
761 774
762 775
763(if (string-lessp "19" emacs-version) 776(and (string-lessp "19" emacs-version)
764 (defalias 'ispell 'ispell-buffer)) 777 (not (boundp 'epoch::version))
778 (defalias 'ispell 'ispell-buffer))
765 779
766;;;###autoload (define-key global-map "\M-$" 'ispell-word) 780;;;###autoload (define-key global-map "\M-$" 'ispell-word)
767 781
@@ -921,7 +935,9 @@ If so, ask if it needs to be saved."
921 (setq ispell-pdict-modified-p (car ispell-pdict-modified-p))) 935 (setq ispell-pdict-modified-p (car ispell-pdict-modified-p)))
922 (if (or ispell-pdict-modified-p force-save) 936 (if (or ispell-pdict-modified-p force-save)
923 (if (or no-query (y-or-n-p "Personal dictionary modified. Save? ")) 937 (if (or no-query (y-or-n-p "Personal dictionary modified. Save? "))
924 (process-send-string ispell-process "#\n"))) 938 (progn
939 (process-send-string ispell-process "#\n")
940 (message "Personal dictionary saved."))))
925 ;; unassert variable, even if not saved to avoid questioning. 941 ;; unassert variable, even if not saved to avoid questioning.
926 (setq ispell-pdict-modified-p nil)) 942 (setq ispell-pdict-modified-p nil))
927 943
@@ -993,19 +1009,23 @@ used."
993 ;; Display choices for misspelled word. 1009 ;; Display choices for misspelled word.
994 (let ((choices-window (get-buffer-window ispell-choices-buffer))) 1010 (let ((choices-window (get-buffer-window ispell-choices-buffer)))
995 (if choices-window 1011 (if choices-window
996 (if (not (equal line (window-height choices-window))) 1012 (if (= line (window-height choices-window))
997 ;; *Choices* window changed size. Adjust the choices window 1013 (select-window choices-window)
998 ;; without scrolling the spelled window when possible 1014 ;; *Choices* window changed size. Adjust the choices window
999 (let ((window-line (- line (window-height choices-window))) 1015 ;; without scrolling the spelled window when possible
1000 (visible (progn (forward-line -1) (point)))) 1016 (let ((window-line (- line (window-height choices-window)))
1001 (move-to-window-line 0) 1017 (visible (progn (forward-line -1) (point))))
1002 (forward-line window-line) 1018 (if (< line ispell-choices-win-default-height)
1003 (set-window-start (selected-window) 1019 (setq window-line (+ window-line
1004 (if (> (point) visible) visible (point))) 1020 (- ispell-choices-win-default-height
1005 (goto-char end) 1021 line))))
1006 (select-window (previous-window)) ; *Choices* window 1022 (move-to-window-line 0)
1007 (enlarge-window window-line)) 1023 (forward-line window-line)
1008 (select-window choices-window)) 1024 (set-window-start (selected-window)
1025 (if (> (point) visible) visible (point)))
1026 (goto-char end)
1027 (select-window (previous-window)) ; *Choices* window
1028 (enlarge-window window-line)))
1009 ;; Overlay *Choices* window when it isn't showing 1029 ;; Overlay *Choices* window when it isn't showing
1010 (ispell-overlay-window (max line ispell-choices-win-default-height))) 1030 (ispell-overlay-window (max line ispell-choices-win-default-height)))
1011 (switch-to-buffer ispell-choices-buffer) 1031 (switch-to-buffer ispell-choices-buffer)
@@ -1122,11 +1142,19 @@ used."
1122 count (1+ count))) 1142 count (1+ count)))
1123 (setq count (- count ?0 skipped))) 1143 (setq count (- count ?0 skipped)))
1124 (select-window (previous-window)) 1144 (select-window (previous-window))
1125 (if (/= new-line line) 1145 (if (and (/= new-line line)
1126 (progn 1146 (> (max line new-line)
1147 ispell-choices-win-default-height))
1148 (let* ((minh ispell-choices-win-default-height)
1149 (gr-bl (if (< line minh) ; blanks
1150 (- minh line)
1151 0))
1152 (shr-bl (if (< new-line minh) ; blanks
1153 (- minh new-line)
1154 0)))
1127 (if (> new-line line) 1155 (if (> new-line line)
1128 (enlarge-window (- new-line line)) 1156 (enlarge-window (- new-line line gr-bl))
1129 (shrink-window (- line new-line))) 1157 (shrink-window (- line new-line shr-bl)))
1130 (setq line new-line))) 1158 (setq line new-line)))
1131 (select-window (next-window))))) 1159 (select-window (next-window)))))
1132 t) ; reselect from new choices 1160 t) ; reselect from new choices
@@ -1443,13 +1471,13 @@ scrolling the current window. Leave the new window selected."
1443 ;; all versions, since versions earlier than 3.0.09 didn't identify 1471 ;; all versions, since versions earlier than 3.0.09 didn't identify
1444 ;; themselves on startup. 1472 ;; themselves on startup.
1445 (save-excursion 1473 (save-excursion
1446 (set-buffer (get-buffer-create " *ispell-tmp*")) 1474 (let ((case-fold-search t)
1447 (erase-buffer) 1475 ;; avoid bugs when syntax of `.' changes in various default modes
1448 ;; Avoid obscure bugs caused by users who change the syntax of `.' in 1476 (default-major-mode 'fundamental-mode)
1449 ;; whatever default major mode the user uses, e.g. text mode. 1477 status)
1450 (fundamental-mode) 1478 (set-buffer (get-buffer-create " *ispell-tmp*"))
1451 (let ((status (call-process ispell-program-name nil t nil "-v")) 1479 (erase-buffer)
1452 (case-fold-search t)) 1480 (setq status (call-process ispell-program-name nil t nil "-v"))
1453 (goto-char (point-min)) 1481 (goto-char (point-min))
1454 (if (not (memq status '(0 nil))) 1482 (if (not (memq status '(0 nil)))
1455 (error "%s exited with %s %s" ispell-program-name 1483 (error "%s exited with %s %s" ispell-program-name
@@ -1548,6 +1576,9 @@ With NO-ERROR, just return non-nil if there was no Ispell running."
1548 nil)) 1576 nil))
1549 1577
1550 1578
1579;;; ispell-change-dictionary is set in some people's hooks. Maybe it should
1580;;; call ispell-init-process rather than wait for a spell checking command?
1581
1551;;;###autoload 1582;;;###autoload
1552(defun ispell-change-dictionary (dict &optional arg) 1583(defun ispell-change-dictionary (dict &optional arg)
1553 "Change `ispell-dictionary' (q.v.) and kill old Ispell process. 1584 "Change `ispell-dictionary' (q.v.) and kill old Ispell process.
@@ -1567,9 +1598,11 @@ With prefix argument, set the default directory."
1567 (message "Using %s dictionary" 1598 (message "Using %s dictionary"
1568 (or ispell-local-dictionary ispell-dictionary "default"))) 1599 (or ispell-local-dictionary ispell-dictionary "default")))
1569 ((and (equal dict ispell-dictionary) 1600 ((and (equal dict ispell-dictionary)
1570 (equal dict ispell-local-dictionary)) 1601 (or (null ispell-local-dictionary)
1602 (equal dict ispell-local-dictionary)))
1571 ;; Specified dictionary is the default already. No-op 1603 ;; Specified dictionary is the default already. No-op
1572 (message "No change, using %s dictionary" (or dict "default"))) 1604 (and (interactive-p)
1605 (message "No change, using %s dictionary" (or dict "default"))))
1573 (t ; reset dictionary! 1606 (t ; reset dictionary!
1574 (if (assoc dict ispell-dictionary-alist) 1607 (if (assoc dict ispell-dictionary-alist)
1575 (progn 1608 (progn
@@ -1607,7 +1640,8 @@ With prefix argument, set the default directory."
1607 ;; Returns cursor to original location. 1640 ;; Returns cursor to original location.
1608 (save-window-excursion 1641 (save-window-excursion
1609 (goto-char reg-start) 1642 (goto-char reg-start)
1610 (let ((transient-mark-mode nil)) 1643 (let ((transient-mark-mode nil)
1644 ref-type)
1611 (while (and (not ispell-quit) (< (point) reg-end)) 1645 (while (and (not ispell-quit) (< (point) reg-end))
1612 (let ((start (point)) 1646 (let ((start (point))
1613 (offset-change 0) 1647 (offset-change 0)
@@ -1642,23 +1676,41 @@ With prefix argument, set the default directory."
1642 "\n") 1676 "\n")
1643 offset-change (- offset-change ispell-offset))) 1677 offset-change (- offset-change ispell-offset)))
1644 (goto-char limit)))) 1678 (goto-char limit))))
1645 ((and ispell-skip-tib ; SKIP TIB REFERENCES! 1679 ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS
1646 (re-search-forward ispell-tib-ref-beginning end t)) 1680 (forward-char 1))
1647 (if (= (- (point) 2) start) ; tib ref is 2 chars. 1681 ((or (and ispell-skip-tib ; SKIP TIB REFERENCES OR SGML MARKUP
1648 ;; Skip to end of tib ref, not necessarily on this line. 1682 (re-search-forward ispell-tib-ref-beginning end t)
1649 ;; Return an error if tib ref not found 1683 (setq ref-type 'tib))
1650 (if (not(re-search-forward ispell-tib-ref-end reg-end t)) 1684 (and ispell-skip-sgml
1685 (search-forward "[<&]" end t)
1686 (setq ref-type 'sgml)))
1687 (if (or (and (eq 'tib ref-type) ; tib tag is 2 chars.
1688 (= (- (point) 2) start))
1689 (and (eq 'sgml ref-type) ; sgml skips 1 char.
1690 (= (- (point) 1) start)))
1691 ;; Skip to end of reference, not necessarily on this line
1692 ;; Return an error if tib/sgml reference not found
1693 (if (or
1694 (and
1695 (eq 'tib ref-type)
1696 (not
1697 (re-search-forward ispell-tib-ref-end reg-end t)))
1698 (and (eq 'sgml ref-type)
1699 (not (search-forward "[>;]" reg-end t))))
1651 (progn 1700 (progn
1652 (ispell-pdict-save ispell-silently-savep) 1701 (ispell-pdict-save ispell-silently-savep)
1653 (ding) 1702 (ding)
1654 (message 1703 (message
1655 (concat 1704 (concat
1656 "Open tib reference--set `ispell-skip-tib'" 1705 "Open tib or SGML command. Fix buffer or set "
1657 " to nil to avoid this error")) 1706 (if (eq 'tib ref-type)
1707 "ispell-skip-tib"
1708 "ispell-skip-sgml")
1709 " to nil"))
1658 ;; keep cursor at error location 1710 ;; keep cursor at error location
1659 (setq ispell-quit (- (point) 2)))) 1711 (setq ispell-quit (- (point) 2))))
1660 ;; tib ref starts later on line. Check spelling before tib. 1712 ;; Check spelling between reference and start of the line.
1661 (let ((limit (- (point) 2))) 1713 (let ((limit (- (point) (if (eq 'tib ref-type) 2 1))))
1662 (goto-char start) 1714 (goto-char start)
1663 (if (or (re-search-forward ispell-casechars limit t) 1715 (if (or (re-search-forward ispell-casechars limit t)
1664 (re-search-forward "[][()$]" limit t)) 1716 (re-search-forward "[][()$]" limit t))
@@ -1667,8 +1719,6 @@ With prefix argument, set the default directory."
1667 "\n") 1719 "\n")
1668 offset-change (- offset-change ispell-offset))) 1720 offset-change (- offset-change ispell-offset)))
1669 (goto-char limit)))) 1721 (goto-char limit))))
1670 ((looking-at "[---#@*+!%~^]") ; SKIP SPECIAL ISPELL CHARACTERS
1671 (forward-char 1))
1672 ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS 1722 ((or (re-search-forward ispell-casechars end t) ; TEXT EXISTS
1673 (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS 1723 (re-search-forward "[][()$]" end t)) ; or MATH COMMANDS
1674 (setq string (concat "^" (buffer-substring start end) "\n") 1724 (setq string (concat "^" (buffer-substring start end) "\n")
@@ -2085,14 +2135,27 @@ You can bind this to the key C-c i in GNUS or mail by adding to
2085 (while (and (looking-at cite-regexp-start) 2135 (while (and (looking-at cite-regexp-start)
2086 (< (point) limit) 2136 (< (point) limit)
2087 (zerop (forward-line 1)))) 2137 (zerop (forward-line 1))))
2138
2088 (if (< (point) limit) 2139 (if (< (point) limit)
2089 ;; Check the next batch of lines that *aren't* cited. 2140 (let* ((start (point))
2090 (let ((end (save-excursion 2141 ;; Check the next batch of lines that *aren't* cited.
2091 (if (re-search-forward cite-regexp-end limit 'end) 2142 (end-c (and (re-search-forward cite-regexp-end limit 'end)
2092 (match-beginning 0) 2143 (match-beginning 0)))
2093 (marker-position limit))))) 2144 ;; skip a forwarded message
2094 (ispell-region (point) end) 2145 (end-fwd (and (goto-char start)
2095 (goto-char end)))) 2146 (re-search-forward "---* Forwarded Message"
2147 limit 'end)))
2148 (end (or (and end-c end-fwd (min end-c end-fwd))
2149 end-c end-fwd
2150 ;; defalut to limit of text.
2151 (marker-position limit))))
2152 (goto-char start)
2153 (ispell-region start end)
2154 (if (and end-fwd (= end end-fwd))
2155 (progn
2156 (goto-char end)
2157 (search-forward "--- End of Forwarded Message" limit 'end))
2158 (goto-char end)))))
2096 (set-marker limit nil)))) 2159 (set-marker limit nil))))
2097 2160
2098 2161
@@ -2126,6 +2189,8 @@ Includes latex/nroff modes and extended character mode."
2126 (eq ispell-parser 'tex)) 2189 (eq ispell-parser 'tex))
2127 (process-send-string ispell-process "+\n") ; set ispell mode to tex 2190 (process-send-string ispell-process "+\n") ; set ispell mode to tex
2128 (process-send-string ispell-process "-\n")) ; set mode to normal (nroff) 2191 (process-send-string ispell-process "-\n")) ; set mode to normal (nroff)
2192 ;; Hard-wire test for SGML mode.
2193 (setq ispell-skip-sgml (eq 'sgml-mode major-mode))
2129 ;; Set default extended character mode for given buffer, if any. 2194 ;; Set default extended character mode for given buffer, if any.
2130 (let ((extended-char-mode (ispell-get-extended-character-mode))) 2195 (let ((extended-char-mode (ispell-get-extended-character-mode)))
2131 (if extended-char-mode 2196 (if extended-char-mode
@@ -2249,7 +2314,7 @@ Both should not be used to define a buffer-local dictionary."
2249 reg-end) 2314 reg-end)
2250 2315
2251 2316
2252(defconst ispell-version "2.34 -- Thu Dec 8 13:17:41 EST 1994") 2317(defconst ispell-version "2.36 -- Mon Feb 6 17:39:38 EST 1995")
2253 2318
2254(provide 'ispell) 2319(provide 'ispell)
2255 2320