summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2005-01-13 04:33:05 +0000
committerKenichi Handa <handa@m17n.org>2005-01-13 04:33:05 +0000
commit8253213c1029505f4ca6a8ff3f2e338579c1099c (patch)
tree0460f0a171c9487e671af1ea9ec75151cca24a63 /lisp
parente2244c1dd9d0d1d872fc2f0f9fd1b6079ad30951 (diff)
downloademacs-8253213c1029505f4ca6a8ff3f2e338579c1099c.tar.gz
(ispell-unified-chars-table): New variable.
(ispell-get-decoded-string): New function. (ispell-get-casechars, ispell-get-not-casechars) (ispell-get-otherchars): Call ispell-get-decoded-string.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/textmodes/ispell.el51
1 files changed, 45 insertions, 6 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index f3a7616bfd6..0c4aeb1bd24 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1074,15 +1074,54 @@ Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
(decode-coding-string str (ispell-get-coding-system))
str))
+(put 'ispell-unified-chars-table 'char-table-extra-slots 0)
+
+;; Char-table that maps an Unicode character (charset:
+;; latin-iso8859-1, mule-unicode-0100-24ff, mule-unicode-2500-34ff) to
+;; a string in which all equivalent characters are listed.
+
+(defconst ispell-unified-chars-table
+ (let ((table (make-char-table 'ispell-unified-chars-table)))
+ (map-char-table
+ #'(lambda (c v)
+ (if (and v (/= c v))
+ (let ((unified (or (aref table v) (string v))))
+ (aset table v (concat unified (string c))))))
+ ucs-mule-8859-to-mule-unicode)
+ table))
+
+;; Return a string decoded from Nth element of the current dictionary
+;; while splice equivalent characters into the string. This splicing
+;; is done only if the string is a regular expression of the form
+;; "[...]" because, otherwise, splicing will result in incorrect
+;; regular expression matching.
+
+(defun ispell-get-decoded-string (n)
+ (let* ((slot (assoc ispell-dictionary ispell-dictionary-alist))
+ (str (nth n slot)))
+ (when (and (> (length str) 0)
+ (not (multibyte-string-p str)))
+ (setq str (ispell-decode-string str))
+ (if (and (= (aref str 0) ?\[)
+ (eq (string-match "\\]" str) (1- (length str))))
+ (setq str
+ (string-as-multibyte
+ (mapconcat
+ #'(lambda (c)
+ (let ((unichar (aref ucs-mule-8859-to-mule-unicode c)))
+ (if unichar
+ (aref ispell-unified-chars-table unichar)
+ (string c))))
+ str ""))))
+ (setcar (nthcdr n slot) str))
+ str))
+
(defun ispell-get-casechars ()
- (ispell-decode-string
- (nth 1 (assoc ispell-dictionary ispell-dictionary-alist))))
+ (ispell-get-decoded-string 1))
(defun ispell-get-not-casechars ()
- (ispell-decode-string
- (nth 2 (assoc ispell-dictionary ispell-dictionary-alist))))
+ (ispell-get-decoded-string 2))
(defun ispell-get-otherchars ()
- (ispell-decode-string
- (nth 3 (assoc ispell-dictionary ispell-dictionary-alist))))
+ (ispell-get-decoded-string 3))
(defun ispell-get-many-otherchars-p ()
(nth 4 (assoc ispell-dictionary ispell-dictionary-alist)))
(defun ispell-get-ispell-args ()