]> code.delx.au - gnu-emacs/blobdiff - src/cmds.c
* window.c (Fwindow_live_p): Use WINDOW_LIVE_P.
[gnu-emacs] / src / cmds.c
index 72cc26cb3aece59cadbbf65d33e64dc58d39e341..b3394c2fc4ea12299045f1845599114f0db9cfb8 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;
 
@@ -116,7 +117,6 @@ With positive N, a non-empty line at the end counts as one line\n\
   int opoint = PT, opoint_byte = PT_BYTE;
   int pos, pos_byte;
   int count, shortage;
-  int temp;
 
   if (NILP (n))
     count = 1;
@@ -153,7 +153,10 @@ DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line,
   0, 1, "p",
   "Move point to beginning of current line.\n\
 With argument N not nil or 1, move forward N - 1 lines first.\n\
-If scan reaches end of buffer, stop there without error.")
+If point reaches the beginning or end of buffer, it stops there.\n\
+This command does not move point across a field boundary\n\
+unless it would move beyond there to a different line.\n\
+If N is nil or 1, and point starts at a field boundary, point does not move.")
   (n)
      Lisp_Object n;
 {
@@ -163,6 +166,7 @@ If scan reaches end of buffer, stop there without error.")
     CHECK_NUMBER (n, 0);
 
   SET_PT (XINT (Fline_beginning_position (n)));
+  
   return Qnil;
 }
 
@@ -170,13 +174,13 @@ DEFUN ("end-of-line", Fend_of_line, Send_of_line,
   0, 1, "p",
   "Move point to end of current line.\n\
 With argument N not nil or 1, move forward N - 1 lines first.\n\
-If scan reaches end of buffer, stop there without error.")
+If point reaches the beginning or end of buffer, it stops there.\n\
+This command does not move point across a field boundary\n\
+unless it would move beyond there to a different line.\n\
+If N is nil or 1, and point starts at a field boundary, point does not move.")
   (n)
      Lisp_Object n;
 {
-  register int pos;
-  register int stop;
-
   if (NILP (n))
     XSETFASTINT (n, 1);
   else
@@ -326,6 +330,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;
@@ -338,24 +343,31 @@ internal_self_insert (c, noautofill)
   /* Length of multi-byte form of C.  */
   int len;
   /* Working buffer and pointer for multi-byte form of C.  */
-  unsigned char workbuf[4], *str;
+  unsigned char str[MAX_MULTIBYTE_LENGTH];
   int chars_to_delete = 0;
   int spaces_to_insert = 0;
 
   overwrite = current_buffer->overwrite_mode;
-  if (!NILP (Vbefore_change_function) || !NILP (Vafter_change_function)
-      || !NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
+  if (!NILP (Vbefore_change_functions) || !NILP (Vafter_change_functions))
     hairy = 1;
 
   /* At first, get multi-byte form of C in STR.  */
   if (!NILP (current_buffer->enable_multibyte_characters))
     {
       c = unibyte_char_to_multibyte (c);
-      len = CHAR_STRING (c, workbuf, str);
+      len = CHAR_STRING (c, 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;
-
+    {
+      str[0] = (SINGLE_BYTE_CHAR_P (c)
+               ? c
+               : multibyte_char_to_unibyte (c, Qnil));
+      len = 1;
+    }
   if (!NILP (overwrite)
       && PT < ZV)
     {
@@ -387,7 +399,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;
@@ -429,7 +441,7 @@ internal_self_insert (c, noautofill)
 
       sym = Fexpand_abbrev ();
 
-      /* If we expanded an abbrev which has only a hook,
+      /* If we expanded an abbrev which has a hook,
         and the hook has a non-nil `no-self-insert' property,
         return right away--don't really self-insert.  */
       if (! NILP (sym) && ! NILP (XSYMBOL (sym)->function)
@@ -447,7 +459,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 +467,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))
     {
@@ -479,7 +493,6 @@ internal_self_insert (c, noautofill)
        hairy = 2;
     }
 
-#ifdef HAVE_FACES
   /* If previous command specified a face to use, use it.  */
   if (!NILP (Vself_insert_face)
       && EQ (current_kboard->Vlast_command, Vself_insert_face_command))
@@ -488,7 +501,6 @@ internal_self_insert (c, noautofill)
                          Qface, Vself_insert_face, Qnil);
       Vself_insert_face = Qnil;
     }
-#endif
 
   synt = SYNTAX (c);
   if ((synt == Sclose || synt == Smath)
@@ -503,6 +515,7 @@ internal_self_insert (c, noautofill)
 \f
 /* module initialization */
 
+void
 syms_of_cmds ()
 {
   Qkill_backward_chars = intern ("kill-backward-chars");
@@ -542,6 +555,7 @@ More precisely, a char with closeparen syntax is self-inserted.");
   defsubr (&Sself_insert_command);
 }
 
+void
 keys_of_cmds ()
 {
   int n;