diff options
| author | Dave Love | 2001-12-15 17:59:27 +0000 |
|---|---|---|
| committer | Dave Love | 2001-12-15 17:59:27 +0000 |
| commit | e6432b687486c8803fea2e39d69a085076a54048 (patch) | |
| tree | 93503735381a1cb677c021b31a730cda07ce396b | |
| parent | 878c3fe8996e576a5ffa0523fc85f91137edd9cd (diff) | |
| download | emacs-e6432b687486c8803fea2e39d69a085076a54048.tar.gz emacs-e6432b687486c8803fea2e39d69a085076a54048.zip | |
Don't require cl.
(indian-glyph-char, indian-glyph-max-char)
(indian-char-glyph): Moved from indian.el
(indian--puthash-char, mapthread): Don't quote lambda.
(indian--map): New function.
(indian--puthash-v, indian--puthash-c, indian--puthash-m)
(indian--puthash-cv): Use it.
| -rw-r--r-- | lisp/language/ind-util.el | 107 |
1 files changed, 75 insertions, 32 deletions
diff --git a/lisp/language/ind-util.el b/lisp/language/ind-util.el index 3a0dc098f6a..5799f2c5f39 100644 --- a/lisp/language/ind-util.el +++ b/lisp/language/ind-util.el | |||
| @@ -39,7 +39,6 @@ | |||
| 39 | ;; used in quail/indian.el for typing Indian script in Emacs. | 39 | ;; used in quail/indian.el for typing Indian script in Emacs. |
| 40 | 40 | ||
| 41 | (eval-and-compile | 41 | (eval-and-compile |
| 42 | (require 'cl) | ||
| 43 | 42 | ||
| 44 | (defun range (from to) | 43 | (defun range (from to) |
| 45 | "Make the list of the integers of range FROM to TO." | 44 | "Make the list of the integers of range FROM to TO." |
| @@ -52,7 +51,8 @@ | |||
| 52 | (regexp-opt | 51 | (regexp-opt |
| 53 | (sort | 52 | (sort |
| 54 | (let (dummy) | 53 | (let (dummy) |
| 55 | (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) hashtbl) | 54 | (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) |
| 55 | hashtbl) | ||
| 56 | dummy) | 56 | dummy) |
| 57 | (function (lambda (x y) (> (length x) (length y)))))))) | 57 | (function (lambda (x y) (> (length x) (length y)))))))) |
| 58 | 58 | ||
| @@ -205,7 +205,7 @@ FUNCTION will be called 15 times." | |||
| 205 | (lambda (x) | 205 | (lambda (x) |
| 206 | (apply | 206 | (apply |
| 207 | 'mapthread | 207 | 'mapthread |
| 208 | `(lambda (&rest y) (apply (quote ,function) ,x y)) | 208 | (lambda (&rest y) (apply function x y)) |
| 209 | seqrest)) | 209 | seqrest)) |
| 210 | seq1) | 210 | seq1) |
| 211 | (mapcar function seq1))) | 211 | (mapcar function seq1))) |
| @@ -221,45 +221,49 @@ FUNCTION will be called 15 times." | |||
| 221 | (if (char-valid-p char) (setq char (char-to-string char))) | 221 | (if (char-valid-p char) (setq char (char-to-string char))) |
| 222 | (puthash char (car trans-char) encode-hash) | 222 | (puthash char (car trans-char) encode-hash) |
| 223 | (mapc | 223 | (mapc |
| 224 | '(lambda (trans) | 224 | (lambda (trans) |
| 225 | (puthash trans char decode-hash)) | 225 | (puthash trans char decode-hash)) |
| 226 | trans-char)))) | 226 | trans-char)))) |
| 227 | 227 | ||
| 228 | (defun indian--map (f l1 l2) | ||
| 229 | (while l1 | ||
| 230 | (funcall f (pop l1) (pop l2)))) | ||
| 231 | |||
| 228 | (defun indian--puthash-v (v trans-v hashtbls) | 232 | (defun indian--puthash-v (v trans-v hashtbls) |
| 229 | (mapcar* | 233 | (indian--map |
| 230 | '(lambda (v trans-v) | 234 | (lambda (v trans-v) |
| 231 | (indian--puthash-char (car v) trans-v hashtbls)) | 235 | (indian--puthash-char (car v) trans-v hashtbls)) |
| 232 | v trans-v)) | 236 | v trans-v)) |
| 233 | 237 | ||
| 234 | (defun indian--puthash-c (c trans-c halant hashtbls) | 238 | (defun indian--puthash-c (c trans-c halant hashtbls) |
| 235 | (mapcar* | 239 | (indian--map |
| 236 | '(lambda (c trans-c) | 240 | (lambda (c trans-c) |
| 237 | (if (char-valid-p c) (setq c (char-to-string c))) | 241 | (if (char-valid-p c) (setq c (char-to-string c))) |
| 238 | (indian--puthash-char (concat c halant) trans-c hashtbls)) | 242 | (indian--puthash-char (concat c halant) trans-c hashtbls)) |
| 239 | c trans-c)) | 243 | c trans-c)) |
| 240 | 244 | ||
| 241 | (defun indian--puthash-m (m trans-m hashtbls) | 245 | (defun indian--puthash-m (m trans-m hashtbls) |
| 242 | (mapcar* | 246 | (indian--map |
| 243 | '(lambda (m trans-m) | 247 | (lambda (m trans-m) |
| 244 | (indian--puthash-char m trans-m hashtbls)) | 248 | (indian--puthash-char m trans-m hashtbls)) |
| 245 | m trans-m)) | 249 | m trans-m)) |
| 246 | 250 | ||
| 247 | (defun indian--puthash-cv (c trans-c v trans-v hashtbls) | 251 | (defun indian--puthash-cv (c trans-c v trans-v hashtbls) |
| 248 | (mapcar* | 252 | (indian--map |
| 249 | '(lambda (c trans-c) | 253 | (lambda (c trans-c) |
| 250 | (mapcar* | 254 | (indian--map |
| 251 | (lambda (v trans-v) | 255 | (lambda (v trans-v) |
| 252 | (when (and c trans-c v trans-v) | 256 | (when (and c trans-c v trans-v) |
| 253 | (if (char-valid-p c) (setq c (char-to-string c))) | 257 | (if (char-valid-p c) (setq c (char-to-string c))) |
| 254 | (setq v (if (char-valid-p (cadr v)) (char-to-string (cadr v)) "")) | 258 | (setq v (if (char-valid-p (cadr v)) (char-to-string (cadr v)) "")) |
| 255 | (if (stringp trans-c) (setq trans-c (list trans-c))) | 259 | (if (stringp trans-c) (setq trans-c (list trans-c))) |
| 256 | (if (stringp trans-v) (setq trans-v (list trans-v))) | 260 | (if (stringp trans-v) (setq trans-v (list trans-v))) |
| 257 | (indian--puthash-char | 261 | (indian--puthash-char |
| 258 | (concat c v) | 262 | (concat c v) |
| 259 | (apply 'append | 263 | (apply 'append |
| 260 | (mapthread 'concat trans-c trans-v)) | 264 | (mapthread 'concat trans-c trans-v)) |
| 261 | hashtbls))) | 265 | hashtbls))) |
| 262 | v trans-v)) | 266 | v trans-v)) |
| 263 | c trans-c)) | 267 | c trans-c)) |
| 264 | 268 | ||
| 265 | (defun indian-make-hash (table trans-table) | 269 | (defun indian-make-hash (table trans-table) |
| @@ -306,7 +310,9 @@ FUNCTION will be called 15 times." | |||
| 306 | (goto-char (point-min)) | 310 | (goto-char (point-min)) |
| 307 | (while (re-search-forward regexp nil t) | 311 | (while (re-search-forward regexp nil t) |
| 308 | (let ((matchstr (gethash (match-string 0) | 312 | (let ((matchstr (gethash (match-string 0) |
| 309 | (if ,encode-p (car ,hashtable) (cdr ,hashtable))))) | 313 | (if ,encode-p |
| 314 | (car ,hashtable) | ||
| 315 | (cdr ,hashtable))))) | ||
| 310 | (if matchstr (replace-match matchstr)))))))) | 316 | (if matchstr (replace-match matchstr)))))))) |
| 311 | 317 | ||
| 312 | ;;; | 318 | ;;; |
| @@ -987,10 +993,47 @@ Returns new end position." | |||
| 987 | (let ((len (- (match-end 0) (match-beginning 0))) | 993 | (let ((len (- (match-end 0) (match-beginning 0))) |
| 988 | subst) | 994 | subst) |
| 989 | (if (= len 1) | 995 | (if (= len 1) |
| 990 | (setq subst (aref indian-2-column-to-ucs-chartable (char-after (match-beginning 0)))) | 996 | (setq subst (aref indian-2-column-to-ucs-chartable |
| 997 | (char-after (match-beginning 0)))) | ||
| 991 | (setq subst (assoc (match-string 0) alist))) | 998 | (setq subst (assoc (match-string 0) alist))) |
| 992 | (replace-match (if subst subst "?")))) | 999 | (replace-match (if subst subst "?")))) |
| 993 | (indian-compose-region (point-min) (point-max)))))) | 1000 | (indian-compose-region (point-min) (point-max)))))) |
| 1001 | |||
| 1002 | ;;;###autoload | ||
| 1003 | (defun indian-glyph-char (index &optional script) | ||
| 1004 | "Return character of charset `indian-glyph' made from glyph index INDEX. | ||
| 1005 | The variable `indian-default-script' specifies the script of the glyph. | ||
| 1006 | Optional argument SCRIPT, if non-nil, overrides `indian-default-script'. | ||
| 1007 | See also the function `indian-char-glyph'." | ||
| 1008 | (or script | ||
| 1009 | (setq script indian-default-script)) | ||
| 1010 | (let ((offset (get script 'indian-glyph-code-offset))) | ||
| 1011 | (or (integerp offset) | ||
| 1012 | (error "Invalid script name: %s" script)) | ||
| 1013 | (or (and (>= index 0) (< index 256)) | ||
| 1014 | (error "Invalid glyph index: %d" index)) | ||
| 1015 | (setq index (+ offset index)) | ||
| 1016 | (make-char 'indian-glyph (+ (/ index 96) 32) (+ (% index 96) 32)))) | ||
| 1017 | |||
| 1018 | (defvar indian-glyph-max-char | ||
| 1019 | (indian-glyph-char | ||
| 1020 | 255 (aref indian-script-table (1- (length indian-script-table)))) | ||
| 1021 | "The maximum valid code of characters in the charset `indian-glyph'.") | ||
| 1022 | |||
| 1023 | ;;;###autoload | ||
| 1024 | (defun indian-char-glyph (char) | ||
| 1025 | "Return information about the glphy code for CHAR of `indian-glyph' charset. | ||
| 1026 | The value is (INDEX . SCRIPT), where INDEX is the glyph index | ||
| 1027 | in the font that Indian script name SCRIPT specifies. | ||
| 1028 | See also the function `indian-glyph-char'." | ||
| 1029 | (let ((split (split-char char)) | ||
| 1030 | code) | ||
| 1031 | (or (eq (car split) 'indian-glyph) | ||
| 1032 | (error "Charset of `%c' is not indian-glyph" char)) | ||
| 1033 | (or (<= char indian-glyph-max-char) | ||
| 1034 | (error "Invalid indian-glyph char: %d" char)) | ||
| 1035 | (setq code (+ (* (- (nth 1 split) 32) 96) (nth 2 split) -32)) | ||
| 1036 | (cons (% code 256) (aref indian-script-table (/ code 256))))) | ||
| 994 | 1037 | ||
| 995 | (provide 'ind-util) | 1038 | (provide 'ind-util) |
| 996 | 1039 | ||