diff src/charset.c @ 88641:203bb5221b98

(Fcharset_priority_list, Fset_charset_priority): New functions.
author Dave Love <fx@gnu.org>
date Sat, 25 May 2002 23:19:01 +0000
parents ad7c09ee6cf9
children 7e7e9519784d
line wrap: on
line diff
--- a/src/charset.c	Sat May 25 23:13:09 2002 +0000
+++ b/src/charset.c	Sat May 25 23:19:01 2002 +0000
@@ -940,7 +940,6 @@
   return Qnil;
 }
 
-/* Fixme: Should this record the alias relationships for diagnostics?  */
 DEFUN ("define-charset-alias", Fdefine_charset_alias,
        Sdefine_charset_alias, 2, 2, 0,
        doc: /* Define ALIAS as an alias for charset CHARSET.  */)
@@ -951,7 +950,6 @@
 
   CHECK_CHARSET_GET_ATTR (charset, attr);
   Fputhash (alias, attr, Vcharset_hash_table);
-  /* Fixme: should the ordered list be updated too?  */
   Vcharset_list = Fcons (alias, Vcharset_list);
   return Qnil;
 }
@@ -1708,6 +1706,49 @@
   return Qnil;
 }
 
+DEFUN ("charset-priority-list", Fcharset_priority_list,
+       Scharset_priority_list, 0, 1, 0,
+       doc: /* Return the list of charsets ordered by priority.
+HIGHESTP non-nil means just return the highest priority one.  */)
+     (highestp)
+     Lisp_Object highestp;
+{
+  Lisp_Object val = Qnil, list = Vcharset_ordered_list;
+
+  if (!NILP (highestp))
+    return CHARSET_NAME (CHARSET_FROM_ID (Fcar (list)));
+
+  while (!NILP (list))
+    {
+      val = Fcons (CHARSET_NAME (CHARSET_FROM_ID (XCAR (list))), val);
+      list = XCDR (list);
+    }
+  return Fnreverse (val);
+}
+
+DEFUN ("set-charset-priority", Fset_charset_priority, Sset_charset_priority,
+       1, MANY, 0,
+       doc: /* Assign higher priority to the charsets given as arguments.
+usage: (set-charset-priority &rest charsets)  */)
+       (nargs, args)
+     int nargs;
+     Lisp_Object *args;
+{
+  Lisp_Object new_head = Qnil, old_list, id, arglist[2];
+  int i;
+
+  old_list = Fcopy_sequence (Vcharset_ordered_list);
+  for (i = 0; i < nargs; i++)
+    {
+      CHECK_CHARSET_GET_ID (args[i], id);
+      old_list = Fdelq (id, old_list);
+      new_head = Fcons (id, new_head);
+    }
+  arglist[0] = Fnreverse (new_head);
+  arglist[1] = old_list;
+  Vcharset_ordered_list = Fnconc (2, arglist);
+  return Qnil;
+}
 
 void
 init_charset ()
@@ -1807,6 +1848,8 @@
   defsubr (&Scharset_after);
   defsubr (&Siso_charset);
   defsubr (&Sclear_charset_maps);
+  defsubr (&Scharset_priority_list);
+  defsubr (&Sset_charset_priority);
 
   DEFVAR_LISP ("charset-map-directory", &Vcharset_map_directory,
 	       doc: /* Directory of charset map files that come with GNU Emacs.