diff 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
line wrap: on
line diff
--- a/lisp/mule/mule-charset.el	Wed Sep 22 01:10:57 2004 +0000
+++ b/lisp/mule/mule-charset.el	Wed Sep 22 02:06:52 2004 +0000
@@ -62,6 +62,67 @@
 	  (forward-char))))
     list))
 
+(defun fixed-charsets-in-region (start end &optional buffer)
+  "Return a list of the charsets in the region between START and END.
+BUFFER defaults to the current buffer if omitted."
+  (let (list)
+    (save-excursion
+      (if buffer
+	  (set-buffer buffer))
+      (save-restriction
+	(narrow-to-region start end)
+	(goto-char (point-min))
+	(let ((prev-charset nil))
+	  (while (not (eobp))
+	    (let* ((charset (char-charset (char-after (point)))))
+	      (if (not (eq prev-charset charset))
+		  (progn
+		    (setq prev-charset charset)
+		    (or (memq charset list)
+			(setq list (cons charset list))))))
+	    (forward-char)))))
+    list))
+
+(defun list-charsets-in-region (start end &optional buffer)
+  "Return a list of the charsets in the region between START and END.
+BUFFER defaults to the current buffer if omitted."
+  (let (list)
+    (save-excursion
+      (if buffer
+	  (set-buffer buffer))
+      (save-restriction
+	(narrow-to-region start end)
+	(goto-char (point-min))
+	;; this could be optimized by maintaining prev-charset and checking
+	;; for equality, but memq is not that slow for a short list.
+	(while (not (eobp))
+	  (let* ((charset (char-charset (char-after (point)))))
+	    (or (memq charset list)
+		(setq list (cons charset list))))
+	  (forward-char))))
+    list))
+
+(defun hash-charsets-in-region (start end &optional buffer)
+  "Return a list of the charsets in the region between START and END.
+BUFFER defaults to the current buffer if omitted."
+  (let ((ht (make-hash-table :size 10)))
+    (save-excursion
+      (if buffer
+	  (set-buffer buffer))
+      (save-restriction
+	(narrow-to-region start end)
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (puthash (char-charset (char-after (point))) t ht)
+	  (forward-char))))
+    (hash-table-key-list ht)))
+
+(defun c-charsets-in-region (start end &optional buffer)
+  "Return a list of the charsets in the region between START and END.
+BUFFER defaults to the current buffer if omitted."
+  (setq buffer (or buffer (current-buffer)))
+  (charsets-in-region-internal buffer start end))
+
 (defun charsets-in-string (string)
   "Return a list of the charsets in STRING."
   (let (list)
@@ -73,7 +134,15 @@
 	  string)
     list))
 
+(defun c-charsets-in-string (string)
+  "Return a list of the charsets in STRING."
+  (charsets-in-string-internal string nil nil))
+
+(or (fboundp 'charsets-in-string)
+    (defalias 'charsets-in-string 'c-charsets-in-string))
 (defalias 'find-charset-string 'charsets-in-string)
+(or (fboundp 'charsets-in-region)
+    (defalias 'charsets-in-region 'c-charsets-in-region))
 (defalias 'find-charset-region 'charsets-in-region)