]> code.delx.au - gnu-emacs/blobdiff - src/coding.c
Fix pr-interface-map initialization
[gnu-emacs] / src / coding.c
index e4ecbf50f62154f9b2aca45f2fcc98f4d82d221d..bca75754156775cdf8c6d34f4d383c07e3412e1b 100644 (file)
@@ -13,7 +13,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -300,6 +300,8 @@ encode_coding_XXX (coding)
 #include "composite.h"
 #include "coding.h"
 #include "window.h"
+#include "frame.h"
+#include "termhooks.h"
 
 Lisp_Object Vcoding_system_hash_table;
 
@@ -327,6 +329,8 @@ Lisp_Object Qtarget_idx;
 Lisp_Object Qinsufficient_source, Qinconsistent_eol, Qinvalid_source;
 Lisp_Object Qinterrupted, Qinsufficient_memory;
 
+extern Lisp_Object Qcompletion_ignore_case;
+
 /* If a symbol has this property, evaluate the value to define the
    symbol as a coding system.  */
 static Lisp_Object Qcoding_system_define_form;
@@ -381,16 +385,10 @@ int inhibit_iso_escape_detection;
 /* Flag to make buffer-file-coding-system inherit from process-coding.  */
 int inherit_process_coding_system;
 
-/* Coding system to be used to encode text for terminal display.  */
-struct coding_system terminal_coding;
-
 /* Coding system to be used to encode text for terminal display when
    terminal coding system is nil.  */
 struct coding_system safe_terminal_coding;
 
-/* Coding system of what is sent from terminal keyboard.  */
-struct coding_system keyboard_coding;
-
 Lisp_Object Vfile_coding_system_alist;
 Lisp_Object Vprocess_coding_system_alist;
 Lisp_Object Vnetwork_coding_system_alist;
@@ -2661,7 +2659,6 @@ detect_coding_iso_2022 (coding, detect_info)
            break;
          single_shifting = 0;
          rejected |= CATEGORY_MASK_ISO_7BIT | CATEGORY_MASK_ISO_8BIT;
-         found |= CATEGORY_MASK_ISO_ELSE;
          break;
 
        case ISO_CODE_CSI:
@@ -7199,16 +7196,22 @@ DEFUN ("read-non-nil-coding-system", Fread_non_nil_coding_system,
 
 DEFUN ("read-coding-system", Fread_coding_system, Sread_coding_system, 1, 2, 0,
        doc: /* Read a coding system from the minibuffer, prompting with string PROMPT.
-If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.  */)
+If the user enters null input, return second argument DEFAULT-CODING-SYSTEM.
+Ignores case when completing coding systems (all Emacs coding systems
+are lower-case).  */)
      (prompt, default_coding_system)
      Lisp_Object prompt, default_coding_system;
 {
   Lisp_Object val;
+  int count = SPECPDL_INDEX ();
+
   if (SYMBOLP (default_coding_system))
-    XSETSTRING (default_coding_system, XPNTR (SYMBOL_NAME (default_coding_system)));
+    default_coding_system = SYMBOL_NAME (default_coding_system);
+  specbind (Qcompletion_ignore_case, Qt);
   val = Fcompleting_read (prompt, Vcoding_system_alist, Qnil,
                          Qt, Qnil, Qcoding_system_history,
                          default_coding_system, Qnil);
+  unbind_to (count, Qnil);
   return (SCHARS (val) == 0 ? Qnil : Fintern (val, Qnil));
 }
 
@@ -8006,7 +8009,7 @@ When called from a program, takes four arguments:
 START and END are buffer positions.
 
 Optional 4th arguments DESTINATION specifies where the decoded text goes.
-If nil, the region between START and END is replace by the decoded text.
+If nil, the region between START and END is replaced by the decoded text.
 If buffer, the decoded text is inserted in the buffer.
 If t, the decoded text is returned.
 
@@ -8287,23 +8290,22 @@ Return the corresponding character code in Big5.  */)
 }
 
 \f
-DEFUN ("set-terminal-coding-system-internal",
-       Fset_terminal_coding_system_internal,
-       Sset_terminal_coding_system_internal, 1, 1, 0,
+DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal,
+       Sset_terminal_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system)
+     (coding_system, terminal)
      Lisp_Object coding_system;
+     Lisp_Object terminal;
 {
+  struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
   CHECK_SYMBOL (coding_system);
-  setup_coding_system (Fcheck_coding_system (coding_system),
-                       &terminal_coding);
-
+  setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
   /* We had better not send unsafe characters to terminal.  */
-  terminal_coding.mode |= CODING_MODE_SAFE_ENCODING;
+  terminal_coding->mode |= CODING_MODE_SAFE_ENCODING;
   /* Characer composition should be disabled.  */
-  terminal_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
-  terminal_coding.src_multibyte = 1;
-  terminal_coding.dst_multibyte = 0;
+  terminal_coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
+  terminal_coding->src_multibyte = 1;
+  terminal_coding->dst_multibyte = 0;
   return Qnil;
 }
 
@@ -8324,39 +8326,47 @@ DEFUN ("set-safe-terminal-coding-system-internal",
   return Qnil;
 }
 
-DEFUN ("terminal-coding-system",
-       Fterminal_coding_system, Sterminal_coding_system, 0, 0, 0,
-       doc: /* Return coding system specified for terminal output.  */)
-     ()
+DEFUN ("terminal-coding-system", Fterminal_coding_system,
+       Sterminal_coding_system, 0, 1, 0,
+       doc: /* Return coding system specified for terminal output on the given terminal.
+TERMINAL may be a terminal id, a frame, or nil for the selected
+frame's terminal device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  Lisp_Object coding_system;
+  struct coding_system *terminal_coding
+    = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
+  Lisp_Object coding_system = CODING_ID_NAME (terminal_coding->id);
 
-  coding_system = CODING_ID_NAME (terminal_coding.id);
   /* For backward compatibility, return nil if it is `undecided'. */
   return (! EQ (coding_system, Qundecided) ? coding_system : Qnil);
 }
 
-DEFUN ("set-keyboard-coding-system-internal",
-       Fset_keyboard_coding_system_internal,
-       Sset_keyboard_coding_system_internal, 1, 1, 0,
+DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal,
+       Sset_keyboard_coding_system_internal, 1, 2, 0,
        doc: /* Internal use only.  */)
-     (coding_system)
+     (coding_system, terminal)
      Lisp_Object coding_system;
+     Lisp_Object terminal;
 {
+  struct terminal *t = get_terminal (terminal, 1);
   CHECK_SYMBOL (coding_system);
   setup_coding_system (Fcheck_coding_system (coding_system),
-                      &keyboard_coding);
+                      TERMINAL_KEYBOARD_CODING (t));
   /* Characer composition should be disabled.  */
-  keyboard_coding.common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
+  TERMINAL_KEYBOARD_CODING (t)->common_flags
+    &= ~CODING_ANNOTATE_COMPOSITION_MASK;
   return Qnil;
 }
 
 DEFUN ("keyboard-coding-system",
-       Fkeyboard_coding_system, Skeyboard_coding_system, 0, 0, 0,
+       Fkeyboard_coding_system, Skeyboard_coding_system, 0, 1, 0,
        doc: /* Return coding system specified for decoding keyboard input.  */)
-     ()
+     (terminal)
+     Lisp_Object terminal;
 {
-  return CODING_ID_NAME (keyboard_coding.id);
+  return CODING_ID_NAME (TERMINAL_KEYBOARD_CODING
+                        (get_terminal (terminal, 1))->id);
 }
 
 \f
@@ -8400,7 +8410,7 @@ contents (not yet decoded).  If `file-coding-system-alist' specifies a
 function to call for FILENAME, that function should examine the
 contents of BUFFER instead of reading the file.
 
-usage: (find-operation-coding-system OPERATION ARGUMENTS ...)  */)
+usage: (find-operation-coding-system OPERATION ARGUMENTS...)  */)
      (nargs, args)
      int nargs;
      Lisp_Object *args;
@@ -8641,11 +8651,11 @@ usage: (define-coding-system-internal ...)  */)
   else
     {
       charset_list = Fcopy_sequence (charset_list);
-      for (tail = charset_list; !NILP (tail); tail = Fcdr (tail))
+      for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
        {
          struct charset *charset;
 
-         val = Fcar (tail);
+         val = XCAR (tail);
          CHECK_CHARSET_GET_CHARSET (val, charset);
          if (EQ (coding_type, Qiso_2022)
              ? CHARSET_ISO_FINAL (charset) < 0
@@ -9825,8 +9835,6 @@ character.");
     Fdefine_coding_system_internal (coding_arg_max, args);
   }
 
-  setup_coding_system (Qno_conversion, &keyboard_coding);
-  setup_coding_system (Qundecided, &terminal_coding);
   setup_coding_system (Qno_conversion, &safe_terminal_coding);
 
   {