Mercurial > hg > xemacs-beta
comparison lisp/mule/mule-charset.el @ 2298:7d67f0ab192c
[xemacs-hg @ 2004-09-22 02:25:06 by stephent]
revert premature commit <87acvjavpu.fsf@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Wed, 22 Sep 2004 02:25:06 +0000 |
parents | 13a418960a88 |
children | 6e11554a16aa |
comparison
equal
deleted
inserted
replaced
2297:13a418960a88 | 2298:7d67f0ab192c |
---|---|
60 (or (memq (char-charset (char-after (point))) list) | 60 (or (memq (char-charset (char-after (point))) list) |
61 (setq list (cons (char-charset (char-after (point))) list))) | 61 (setq list (cons (char-charset (char-after (point))) list))) |
62 (forward-char)))) | 62 (forward-char)))) |
63 list)) | 63 list)) |
64 | 64 |
65 (defun fixed-charsets-in-region (start end &optional buffer) | |
66 "Return a list of the charsets in the region between START and END. | |
67 BUFFER defaults to the current buffer if omitted." | |
68 (let (list) | |
69 (save-excursion | |
70 (if buffer | |
71 (set-buffer buffer)) | |
72 (save-restriction | |
73 (narrow-to-region start end) | |
74 (goto-char (point-min)) | |
75 (let ((prev-charset nil)) | |
76 (while (not (eobp)) | |
77 (let* ((charset (char-charset (char-after (point))))) | |
78 (if (not (eq prev-charset charset)) | |
79 (progn | |
80 (setq prev-charset charset) | |
81 (or (memq charset list) | |
82 (setq list (cons charset list)))))) | |
83 (forward-char))))) | |
84 list)) | |
85 | |
86 (defun list-charsets-in-region (start end &optional buffer) | |
87 "Return a list of the charsets in the region between START and END. | |
88 BUFFER defaults to the current buffer if omitted." | |
89 (let (list) | |
90 (save-excursion | |
91 (if buffer | |
92 (set-buffer buffer)) | |
93 (save-restriction | |
94 (narrow-to-region start end) | |
95 (goto-char (point-min)) | |
96 ;; this could be optimized by maintaining prev-charset and checking | |
97 ;; for equality, but memq is not that slow for a short list. | |
98 (while (not (eobp)) | |
99 (let* ((charset (char-charset (char-after (point))))) | |
100 (or (memq charset list) | |
101 (setq list (cons charset list)))) | |
102 (forward-char)))) | |
103 list)) | |
104 | |
105 (defun hash-charsets-in-region (start end &optional buffer) | |
106 "Return a list of the charsets in the region between START and END. | |
107 BUFFER defaults to the current buffer if omitted." | |
108 (let ((ht (make-hash-table :size 10))) | |
109 (save-excursion | |
110 (if buffer | |
111 (set-buffer buffer)) | |
112 (save-restriction | |
113 (narrow-to-region start end) | |
114 (goto-char (point-min)) | |
115 (while (not (eobp)) | |
116 (puthash (char-charset (char-after (point))) t ht) | |
117 (forward-char)))) | |
118 (hash-table-key-list ht))) | |
119 | |
120 (defun c-charsets-in-region (start end &optional buffer) | |
121 "Return a list of the charsets in the region between START and END. | |
122 BUFFER defaults to the current buffer if omitted." | |
123 (setq buffer (or buffer (current-buffer))) | |
124 (charsets-in-region-internal buffer start end)) | |
125 | |
126 (defun charsets-in-string (string) | 65 (defun charsets-in-string (string) |
127 "Return a list of the charsets in STRING." | 66 "Return a list of the charsets in STRING." |
128 (let (list) | 67 (let (list) |
129 (mapc (lambda (ch) | 68 (mapc (lambda (ch) |
130 ;; the first test will usually succeed on testing the | 69 ;; the first test will usually succeed on testing the |
132 (or (memq (char-charset ch) list) | 71 (or (memq (char-charset ch) list) |
133 (setq list (cons (char-charset ch) list)))) | 72 (setq list (cons (char-charset ch) list)))) |
134 string) | 73 string) |
135 list)) | 74 list)) |
136 | 75 |
137 (defun c-charsets-in-string (string) | |
138 "Return a list of the charsets in STRING." | |
139 (charsets-in-string-internal string nil nil)) | |
140 | |
141 (or (fboundp 'charsets-in-string) | |
142 (defalias 'charsets-in-string 'c-charsets-in-string)) | |
143 (defalias 'find-charset-string 'charsets-in-string) | 76 (defalias 'find-charset-string 'charsets-in-string) |
144 (or (fboundp 'charsets-in-region) | |
145 (defalias 'charsets-in-region 'c-charsets-in-region)) | |
146 (defalias 'find-charset-region 'charsets-in-region) | 77 (defalias 'find-charset-region 'charsets-in-region) |
147 | 78 |
148 | 79 |
149 ;;;; Charset accessors | 80 ;;;; Charset accessors |
150 | 81 |