]> code.delx.au - gnu-emacs/blobdiff - src/cmds.c
Protoize
[gnu-emacs] / src / cmds.c
index 336bf1154f9259bab5a2c381d097587ffea092e4..f49cfc221be995d291a6316b2fd7fab7487b5782 100644 (file)
@@ -31,10 +31,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "dispextern.h"
 #include "frame.h"
 
-Lisp_Object Qkill_forward_chars, Qkill_backward_chars;
+static Lisp_Object Qkill_forward_chars, Qkill_backward_chars;
 
 /* A possible value for a buffer's overwrite-mode variable.  */
-Lisp_Object Qoverwrite_mode_binary;
+static Lisp_Object Qoverwrite_mode_binary;
 
 static int internal_self_insert (int, EMACS_INT);
 \f
@@ -352,7 +352,7 @@ internal_self_insert (int c, EMACS_INT n)
     {
       str[0] = (SINGLE_BYTE_CHAR_P (c)
                ? c
-               : multibyte_char_to_unibyte (c, Qnil));
+               : multibyte_char_to_unibyte (c));
       len = 1;
     }
   if (!NILP (overwrite)
@@ -381,33 +381,37 @@ internal_self_insert (int c, EMACS_INT n)
        {
          EMACS_INT pos = PT;
          EMACS_INT pos_byte = PT_BYTE;
+
+         /* FIXME: Check for integer overflow when calculating
+            target_clm and actual_clm.  */
+
          /* Column the cursor should be placed at after this insertion.
             The correct value should be calculated only when necessary.  */
-         int target_clm = ((int) current_column () /* iftc */
-                           + n * (int) XINT (Fchar_width (make_number (c))));
-
-             /* The actual cursor position after the trial of moving
-                to column TARGET_CLM.  It is greater than TARGET_CLM
-                if the TARGET_CLM is middle of multi-column
-                character.  In that case, the new point is set after
-                that character.  */
-             int actual_clm
-               = (int) XFASTINT (Fmove_to_column (make_number (target_clm),
-                                                  Qnil));
-
-             chars_to_delete = PT - pos;
-
-             if (actual_clm > target_clm)
-           { /* We will delete too many columns.  Let's fill columns
-                    by spaces so that the remaining text won't move.  */
+         EMACS_INT target_clm = (current_column ()
+                                 + n * XINT (Fchar_width (make_number (c))));
+
+         /* The actual cursor position after the trial of moving
+            to column TARGET_CLM.  It is greater than TARGET_CLM
+            if the TARGET_CLM is middle of multi-column
+            character.  In that case, the new point is set after
+            that character.  */
+         EMACS_INT actual_clm
+           = XFASTINT (Fmove_to_column (make_number (target_clm), Qnil));
+
+         chars_to_delete = PT - pos;
+
+         if (actual_clm > target_clm)
+           {
+             /* We will delete too many columns.  Let's fill columns
+                by spaces so that the remaining text won't move.  */
              EMACS_INT actual = PT_BYTE;
              DEC_POS (actual);
              if (FETCH_CHAR (actual) == '\t')
                /* Rather than add spaces, let's just keep the tab. */
                chars_to_delete--;
              else
-                 spaces_to_insert = actual_clm - target_clm;
-               }
+               spaces_to_insert = actual_clm - target_clm;
+           }
 
          SET_PT_BOTH (pos, pos_byte);
        }
@@ -481,23 +485,23 @@ internal_self_insert (int c, EMACS_INT n)
        : (c == ' ' || c == '\n'))
       && !NILP (BVAR (current_buffer, auto_fill_function)))
     {
-      Lisp_Object tem;
+      Lisp_Object auto_fill_result;
 
       if (c == '\n')
        /* After inserting a newline, move to previous line and fill
           that.  Must have the newline in place already so filling and
           justification, if any, know where the end is going to be.  */
        SET_PT_BOTH (PT - 1, PT_BYTE - 1);
-      tem = call0 (BVAR (current_buffer, auto_fill_function));
+      auto_fill_result = call0 (BVAR (current_buffer, auto_fill_function));
       /* Test PT < ZV in case the auto-fill-function is strange.  */
       if (c == '\n' && PT < ZV)
        SET_PT_BOTH (PT + 1, PT_BYTE + 1);
-      if (!NILP (tem))
+      if (!NILP (auto_fill_result))
        hairy = 2;
     }
 
   /* Run hooks for electric keys.  */
-  call1 (Vrun_hooks, Qpost_self_insert_hook);
+  Frun_hooks (1, &Qpost_self_insert_hook);
 
   return hairy;
 }
@@ -507,20 +511,11 @@ internal_self_insert (int c, EMACS_INT n)
 void
 syms_of_cmds (void)
 {
-  Qkill_backward_chars = intern_c_string ("kill-backward-chars");
-  staticpro (&Qkill_backward_chars);
-
-  Qkill_forward_chars = intern_c_string ("kill-forward-chars");
-  staticpro (&Qkill_forward_chars);
-
-  Qoverwrite_mode_binary = intern_c_string ("overwrite-mode-binary");
-  staticpro (&Qoverwrite_mode_binary);
-
-  Qexpand_abbrev = intern_c_string ("expand-abbrev");
-  staticpro (&Qexpand_abbrev);
-
-  Qpost_self_insert_hook = intern_c_string ("post-self-insert-hook");
-  staticpro (&Qpost_self_insert_hook);
+  DEFSYM (Qkill_backward_chars, "kill-backward-chars");
+  DEFSYM (Qkill_forward_chars, "kill-forward-chars");
+  DEFSYM (Qoverwrite_mode_binary, "overwrite-mode-binary");
+  DEFSYM (Qexpand_abbrev, "expand-abbrev");
+  DEFSYM (Qpost_self_insert_hook, "post-self-insert-hook");
 
   DEFVAR_LISP ("post-self-insert-hook", Vpost_self_insert_hook,
               doc: /* Hook run at the end of `self-insert-command'.