]> git.eshelyaron.com Git - emacs.git/commitdiff
(coding-system-list): Moved here from
authorKenichi Handa <handa@m17n.org>
Thu, 18 Feb 1999 13:11:24 +0000 (13:11 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 18 Feb 1999 13:11:24 +0000 (13:11 +0000)
mule-util.el to avoid autoloading mule-util by the call of
select-safe-coding-system.

lisp/international/mule.el

index b8f91b9ed905b769694672bef75454eabbb6affa..0c5c78c49e06d11438314d2af59daad505169d1e 100644 (file)
@@ -481,6 +481,25 @@ coding system whose eol-type is N."
          (setq len (/ len 2))))
       (setcdr tem (cons coding-system (cdr tem))))))
 
+(defun coding-system-list (&optional base-only)
+  "Return a list of all existing coding systems.
+If optional arg BASE-ONLY is non-nil, only base coding systems are listed."
+  (let* ((codings (copy-sequence coding-system-list))
+        (tail (cons nil codings)))
+    ;; Remove subsidiary coding systems (eol variants) and alias
+    ;; coding systems (if necessary).
+    (while (cdr tail)
+      (let* ((coding (car (cdr tail)))
+            (aliases (coding-system-get coding 'alias-coding-systems)))
+       (if (or
+            ;; CODING is an eol variant if not in ALIASES.
+            (not (memq coding aliases))
+            ;; CODING is an alias if it is not car of ALIASES.
+            (and base-only (not (eq coding (car aliases)))))
+           (setcdr tail (cdr (cdr tail)))
+         (setq tail (cdr tail)))))
+    codings))
+
 ;; Make subsidiary coding systems (eol-type variants) of CODING-SYSTEM.
 (defun make-subsidiary-coding-system (coding-system)
   (let ((coding-spec (coding-system-spec coding-system))