comparison lisp/mule/mule-charset.el @ 2297:13a418960a88

[xemacs-hg @ 2004-09-22 02:05:42 by stephent] various doc patches <87isa7awrh.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Wed, 22 Sep 2004 02:06:52 +0000
parents ce294639d321
children 7d67f0ab192c
comparison
equal deleted inserted replaced
2296:a58ea4d0d0cd 2297:13a418960a88
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
65 (defun charsets-in-string (string) 126 (defun charsets-in-string (string)
66 "Return a list of the charsets in STRING." 127 "Return a list of the charsets in STRING."
67 (let (list) 128 (let (list)
68 (mapc (lambda (ch) 129 (mapc (lambda (ch)
69 ;; the first test will usually succeed on testing the 130 ;; the first test will usually succeed on testing the
71 (or (memq (char-charset ch) list) 132 (or (memq (char-charset ch) list)
72 (setq list (cons (char-charset ch) list)))) 133 (setq list (cons (char-charset ch) list))))
73 string) 134 string)
74 list)) 135 list))
75 136
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))
76 (defalias 'find-charset-string 'charsets-in-string) 143 (defalias 'find-charset-string 'charsets-in-string)
144 (or (fboundp 'charsets-in-region)
145 (defalias 'charsets-in-region 'c-charsets-in-region))
77 (defalias 'find-charset-region 'charsets-in-region) 146 (defalias 'find-charset-region 'charsets-in-region)
78 147
79 148
80 ;;;; Charset accessors 149 ;;;; Charset accessors
81 150