]> code.delx.au - gnu-emacs/blobdiff - src/keyboard.c
Update copyright year to 2014 by running admin/update-copyright.
[gnu-emacs] / src / keyboard.c
index dbc0bccd2321bf1d1c9ced32b4c1c79f6ffca88a..5430e7971b463c6a4470f42a9d2f7520de0c76ad 100644 (file)
@@ -1,6 +1,6 @@
 /* Keyboard and mouse input; editor command loop.
 
-Copyright (C) 1985-1989, 1993-1997, 1999-2013 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1997, 1999-2014 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -241,8 +241,6 @@ Lisp_Object Qrecompute_lucid_menubar, Qactivate_menubar_hook;
 
 static Lisp_Object Qecho_area_clear_hook;
 
-static Lisp_Object Qdefault_error_output;
-
 /* Hooks to run before and after each command.  */
 static Lisp_Object Qpre_command_hook;
 static Lisp_Object Qpost_command_hook;
@@ -349,6 +347,7 @@ static Lisp_Object Qmodifier_cache;
 /* Symbols to use for parts of windows.  */
 Lisp_Object Qmode_line;
 Lisp_Object Qvertical_line;
+Lisp_Object Qright_divider, Qbottom_divider;
 static Lisp_Object Qvertical_scroll_bar;
 Lisp_Object Qmenu_bar;
 
@@ -823,7 +822,7 @@ This function is called by the editor initialization to begin editing.  */)
     return Qnil;
 
   command_loop_level++;
-  update_mode_lines = 1;
+  update_mode_lines = 17;
 
   if (command_loop_level
       && current_buffer != XBUFFER (XWINDOW (selected_window)->contents))
@@ -850,7 +849,7 @@ recursive_edit_unwind (Lisp_Object buffer)
     Fset_buffer (buffer);
 
   command_loop_level--;
-  update_mode_lines = 1;
+  update_mode_lines = 18;
 }
 
 \f
@@ -1074,8 +1073,7 @@ cmd_error_internal (Lisp_Object data, const char *context)
   Vquit_flag = Qnil;
   Vinhibit_quit = Qt;
 
-  /* Use user's specified output function,
-     initially it is our Fdefault_error_output.  */
+  /* Use user's specified output function if any.  */
   if (!NILP (Vcommand_error_function))
     call3 (Vcommand_error_function, data,
           context ? build_string (context) : empty_unibyte_string,
@@ -1084,17 +1082,15 @@ cmd_error_internal (Lisp_Object data, const char *context)
   Vsignaling_function = Qnil;
 }
 
-DEFUN ("default-error-output", Fdefault_error_output,
-       Sdefault_error_output, 3, 3, 0,
-       doc: /* Produce default output for the error message,
-into the messages buffer and the echo area.  */)
+DEFUN ("command-error-default-function", Fcommand_error_default_function,
+       Scommand_error_default_function, 3, 3, 0,
+       doc: /* Produce default output for unhandled error message.
+Default value of `command-error-function'.  */)
   (Lisp_Object data, Lisp_Object context, Lisp_Object signal)
 {
   struct frame *sf = SELECTED_FRAME ();
-  const char *sz_context;
 
-  CHECK_STRING(context);
-  sz_context = XSTRING(context)->data;
+  CHECK_STRING (context);
 
   /* If the window system or terminal frame hasn't been initialized
      yet, or we're not interactive, write the message to stderr and exit.  */
@@ -1113,7 +1109,7 @@ into the messages buffer and the echo area.  */)
           || noninteractive)
     {
       print_error_message (data, Qexternal_debugging_output,
-                          sz_context, signal);
+                          SSDATA (context), signal);
       Fterpri (Qexternal_debugging_output);
       Fkill_emacs (make_number (-1));
     }
@@ -1124,8 +1120,9 @@ into the messages buffer and the echo area.  */)
       message_log_maybe_newline ();
       bitch_at_user ();
 
-      print_error_message (data, Qt, sz_context, signal);
+      print_error_message (data, Qt, SSDATA (context), signal);
     }
+  return Qnil;
 }
 
 static Lisp_Object command_loop_2 (Lisp_Object);
@@ -1325,6 +1322,8 @@ static void adjust_point_for_property (ptrdiff_t, bool);
 /* The last boundary auto-added to buffer-undo-list.  */
 Lisp_Object last_undo_boundary;
 
+extern Lisp_Object Qregion_extract_function;
+
 /* FIXME: This is wrong rather than test window-system, we should call
    a new set-selection, which will then dispatch to x-set-selection, or
    tty-set-selection, or w32-set-selection, ...  */
@@ -1633,16 +1632,11 @@ command_loop_1 (void)
                  && NILP (Fmemq (Vthis_command,
                                  Vselection_inhibit_update_commands)))
                {
-                 ptrdiff_t beg =
-                   XINT (Fmarker_position (BVAR (current_buffer, mark)));
-                 ptrdiff_t end = PT;
-                 if (beg < end)
-                   call2 (Qx_set_selection, QPRIMARY,
-                          make_buffer_string (beg, end, 0));
-                 else if (beg > end)
-                   call2 (Qx_set_selection, QPRIMARY,
-                          make_buffer_string (end, beg, 0));
-                 /* Don't set empty selections.  */
+                 Lisp_Object txt
+                   = call1 (Fsymbol_value (Qregion_extract_function), Qnil);
+                 if (XINT (Flength (txt)) > 0)
+                   /* Don't set empty selections.  */
+                   call2 (Qx_set_selection, QPRIMARY, txt);
                }
 
              if (current_buffer != prev_buffer || MODIFF != prev_modiff)
@@ -1671,7 +1665,7 @@ command_loop_1 (void)
               cluster to prevent automatic composition.  To recover
               the automatic composition, we must update the
               display.  */
-           windows_or_buffers_changed++;
+           windows_or_buffers_changed = 21;
          if (!already_adjusted)
            adjust_point_for_property (last_point_position,
                                       MODIFF != prev_modiff);
@@ -1778,8 +1772,8 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
                    than skip both boundaries.  However, this code
                    also stops anywhere in a non-sticky text-property,
                    which breaks (e.g.) Org mode.  */
-                && (val = get_pos_property (make_number (end),
-                                            Qinvisible, Qnil),
+                && (val = Fget_pos_property (make_number (end),
+                                             Qinvisible, Qnil),
                     TEXT_PROP_MEANS_INVISIBLE (val))
 #endif
                 && !NILP (val = get_char_property_and_overlay
@@ -1796,8 +1790,8 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
            }
          while (beg > BEGV
 #if 0
-                && (val = get_pos_property (make_number (beg),
-                                            Qinvisible, Qnil),
+                && (val = Fget_pos_property (make_number (beg),
+                                             Qinvisible, Qnil),
                     TEXT_PROP_MEANS_INVISIBLE (val))
 #endif
                 && !NILP (val = get_char_property_and_overlay
@@ -1850,12 +1844,12 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
                   to the other end would mean moving backwards and thus
                   could lead to an infinite loop.  */
                ;
-             else if (val = get_pos_property (make_number (PT),
-                                              Qinvisible, Qnil),
+             else if (val = Fget_pos_property (make_number (PT),
+                                               Qinvisible, Qnil),
                       TEXT_PROP_MEANS_INVISIBLE (val)
-                      && (val = get_pos_property
-                          (make_number (PT == beg ? end : beg),
-                           Qinvisible, Qnil),
+                      && (val = (Fget_pos_property
+                                 (make_number (PT == beg ? end : beg),
+                                  Qinvisible, Qnil)),
                           !TEXT_PROP_MEANS_INVISIBLE (val)))
                (check_composition = check_display = 1,
                 SET_PT (PT == beg ? end : beg));
@@ -1960,10 +1954,7 @@ int poll_suppress_count;
 
 static struct atimer *poll_timer;
 
-/* Poll for input, so that we catch a C-g if it comes in.  This
-   function is called from x_make_frame_visible, see comment
-   there.  */
-
+/* Poll for input, so that we catch a C-g if it comes in.  */
 void
 poll_for_input_1 (void)
 {
@@ -2093,7 +2084,7 @@ bind_polling_period (int n)
 \f
 /* Apply the control modifier to CHARACTER.  */
 
-#ifndef WINDOWSNT
+#ifndef HAVE_NTGUI
 static
 #endif
 int
@@ -3229,8 +3220,6 @@ read_char (int commandflag, Lisp_Object map,
   RETURN_UNGCPRO (c);
 }
 
-#ifdef HAVE_MENUS
-
 /* Record a key that came from a mouse menu.
    Record it for echoing, for this-command-keys, and so on.  */
 
@@ -3261,13 +3250,11 @@ record_menu_key (Lisp_Object c)
   /* Record this character as part of the current key.  */
   add_command_key (c);
 
-  /* Re-reading in the middle of a command */
+  /* Re-reading in the middle of a command */
   last_input_event = c;
   num_input_events++;
 }
 
-#endif /* HAVE_MENUS */
-
 /* Return true if should recognize C as "the help character".  */
 
 static bool
@@ -5313,6 +5300,20 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
          dy = yret = wy;
        }
       /* Nothing special for part == ON_SCROLL_BAR.  */
+      else if (part == ON_RIGHT_DIVIDER)
+       {
+         posn = Qright_divider;
+         width = WINDOW_RIGHT_DIVIDER_WIDTH (w);
+         dx = xret = wx;
+         dy = yret = wy;
+       }
+      else if (part == ON_BOTTOM_DIVIDER)
+       {
+         posn = Qbottom_divider;
+         width = WINDOW_BOTTOM_DIVIDER_WIDTH (w);
+         dx = xret = wx;
+         dy = yret = wy;
+       }
 
       /* For clicks in the text area, fringes, or margins, call
         buffer_posn_from_coords to extract TEXTPOS, the buffer
@@ -8366,7 +8367,6 @@ read_char_x_menu_prompt (Lisp_Object map,
   if (! menu_prompting)
     return Qnil;
 
-#ifdef HAVE_MENUS
   /* If we got to this point via a mouse click,
      use a real menu for mouse selection.  */
   if (EVENT_HAS_PARAMETERS (prev_event)
@@ -8412,7 +8412,6 @@ read_char_x_menu_prompt (Lisp_Object map,
        *used_mouse_menu = 1;
       return value;
     }
-#endif /* HAVE_MENUS */
   return Qnil ;
 }
 
@@ -10155,7 +10154,7 @@ On such systems, Emacs starts a subshell instead of suspending.  */)
      with a window system; but suspend should be disabled in that case.  */
   get_tty_size (fileno (CURTTY ()->input), &width, &height);
   if (width != old_width || height != old_height)
-    change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
+    change_frame_size (SELECTED_FRAME (), width, height, 0, 0, 0, 0);
 
   /* Run suspend-resume-hook.  */
   hook = intern ("suspend-resume-hook");
@@ -10991,6 +10990,8 @@ syms_of_keyboard (void)
   DEFSYM (Qvertical_line, "vertical-line");
   DEFSYM (Qvertical_scroll_bar, "vertical-scroll-bar");
   DEFSYM (Qmenu_bar, "menu-bar");
+  DEFSYM (Qright_divider, "right-divider");
+  DEFSYM (Qbottom_divider, "bottom-divider");
 
   DEFSYM (Qmouse_fixup_help_message, "mouse-fixup-help-message");
 
@@ -11123,7 +11124,7 @@ syms_of_keyboard (void)
   defsubr (&Sabort_recursive_edit);
   defsubr (&Sexit_recursive_edit);
   defsubr (&Srecursion_depth);
-  defsubr (&Sdefault_error_output);
+  defsubr (&Scommand_error_default_function);
   defsubr (&Stop_level);
   defsubr (&Sdiscard_input);
   defsubr (&Sopen_dribble_file);
@@ -11414,18 +11415,19 @@ tool-bar separators natively.  Otherwise it is unused (e.g. on GTK).  */);
   DEFVAR_KBOARD ("overriding-terminal-local-map",
                 Voverriding_terminal_local_map,
                 doc: /* Per-terminal keymap that takes precedence over all other keymaps.
-
 This variable is intended to let commands such as `universal-argument'
 set up a different keymap for reading the next command.
 
 `overriding-terminal-local-map' has a separate binding for each
-terminal device.
-See Info node `(elisp)Multiple Terminals'.  */);
+terminal device.  See Info node `(elisp)Multiple Terminals'.  */);
 
   DEFVAR_LISP ("overriding-local-map", Voverriding_local_map,
-              doc: /* Keymap that overrides almost all other local keymaps.
-If this variable is non-nil, it is used as a keymap--replacing the
-buffer's local map, the minor mode keymaps, and char property keymaps.  */);
+              doc: /* Keymap that replaces (overrides) local keymaps.
+If this variable is non-nil, Emacs looks up key bindings in this
+keymap INSTEAD OF the keymap char property, minor mode maps, and the
+buffer's local map.  Hence, the only active keymaps would be
+`overriding-terminal-local-map', this keymap, and `global-keymap', in
+order of precedence.  */);
   Voverriding_local_map = Qnil;
 
   DEFVAR_LISP ("overriding-local-map-menu-flag", Voverriding_local_map_menu_flag,
@@ -11602,18 +11604,14 @@ The value of that variable is passed to `quit-flag' and later causes a
 peculiar kind of quitting.  */);
   Vthrow_on_input = Qnil;
 
-  DEFSYM (Qdefault_error_output, "default-error-output");
   DEFVAR_LISP ("command-error-function", Vcommand_error_function,
-              doc: /* If non-nil, function to output error messages.
-The arguments are the error data, a list of the form
- (SIGNALED-CONDITIONS . SIGNAL-DATA)
-such as just as `condition-case' would bind its variable to,
-the context (a string which normally goes at the start of the message),
-and the Lisp function within which the error was signaled.
-
-This variable is initialized with Emacs default error output function.
-It is suggested that user functions are added using add-function.  */);
-  Vcommand_error_function = Qdefault_error_output;
+              doc: /* Function to output error messages.
+Called with three arguments:
+- the error data, a list of the form (SIGNALED-CONDITION . SIGNAL-DATA)
+  such as what `condition-case' would bind its variable to,
+- the context (a string which normally goes at the start of the message),
+- the Lisp function within which the error was signaled.  */);
+  Vcommand_error_function = intern ("command-error-default-function");
 
   DEFVAR_LISP ("enable-disabled-menus-and-buttons",
               Venable_disabled_menus_and_buttons,