Add function prototype for resize_mini_window.
[bpt/emacs.git] / src / cmds.c
index 72cc26c..64e7eac 100644 (file)
@@ -27,6 +27,7 @@ Boston, MA 02111-1307, USA.  */
 #include "syntax.h"
 #include "window.h"
 #include "keyboard.h"
+#include "dispextern.h"
 
 Lisp_Object Qkill_forward_chars, Qkill_backward_chars, Vblink_paren_function;
 
@@ -162,7 +163,14 @@ If scan reaches end of buffer, stop there without error.")
   else
     CHECK_NUMBER (n, 0);
 
-  SET_PT (XINT (Fline_beginning_position (n)));
+  {
+    int pos = XFASTINT (Fline_beginning_position (n));
+    if (INTEGERP (current_buffer->minibuffer_prompt_length)
+       && pos < XFASTINT (current_buffer->minibuffer_prompt_length))
+      pos = XFASTINT (current_buffer->minibuffer_prompt_length);
+    SET_PT (pos);
+  }
+  
   return Qnil;
 }
 
@@ -326,6 +334,7 @@ Whichever character you type to run this command is inserted.")
    return 0.  A value of 1 indicates this *might* not have been simple.
    A value of 2 means this did things that call for an undo boundary.  */
 
+int
 internal_self_insert (c, noautofill)
      int c;
      int noautofill;
@@ -352,10 +361,19 @@ internal_self_insert (c, noautofill)
     {
       c = unibyte_char_to_multibyte (c);
       len = CHAR_STRING (c, workbuf, str);
+      if (len == 1)
+       /* If C has modifier bits, this makes C an appropriate
+           one-byte char.  */
+       c = *str;
     }
   else
-    workbuf[0] = c, str = workbuf, len = 1;
-
+    {
+      workbuf[0] = (SINGLE_BYTE_CHAR_P (c)
+                   ? c
+                   : multibyte_char_to_unibyte (c, Qnil));
+      str = workbuf;
+      len = 1;
+    }
   if (!NILP (overwrite)
       && PT < ZV)
     {
@@ -387,7 +405,7 @@ internal_self_insert (c, noautofill)
                    && XINT (current_buffer->tab_width) > 0
                    && XFASTINT (current_buffer->tab_width) < 20
                    && (target_clm = (current_column () 
-                                     + XINT (Fchar_width (make_number (c2)))),
+                                     + XINT (Fchar_width (make_number (c)))),
                        target_clm % XFASTINT (current_buffer->tab_width)))))
        {
          int pos = PT;
@@ -447,7 +465,7 @@ internal_self_insert (c, noautofill)
 
   if (chars_to_delete)
     {
-      string = make_multibyte_string (str, 1, len);
+      string = make_string_from_bytes (str, 1, len);
       if (spaces_to_insert)
        {
          tem = Fmake_string (make_number (spaces_to_insert),
@@ -455,13 +473,15 @@ internal_self_insert (c, noautofill)
          string = concat2 (tem, string);
        }
 
-      replace_range (PT, PT + chars_to_delete, string, 1, 1, 0);
+      replace_range (PT, PT + chars_to_delete, string, 1, 1, 1);
       Fforward_char (make_number (1 + spaces_to_insert));
     }
   else
     insert_and_inherit (str, len);
 
-  if ((c == ' ' || c == '\n')
+  if ((CHAR_TABLE_P (Vauto_fill_chars)
+       ? !NILP (CHAR_TABLE_REF (Vauto_fill_chars, c))
+       : (c == ' ' || c == '\n'))
       && !noautofill
       && !NILP (current_buffer->auto_fill_function))
     {
@@ -503,6 +523,7 @@ internal_self_insert (c, noautofill)
 \f
 /* module initialization */
 
+void
 syms_of_cmds ()
 {
   Qkill_backward_chars = intern ("kill-backward-chars");
@@ -542,6 +563,7 @@ More precisely, a char with closeparen syntax is self-inserted.");
   defsubr (&Sself_insert_command);
 }
 
+void
 keys_of_cmds ()
 {
   int n;