]> code.delx.au - gnu-emacs/blobdiff - src/keyboard.c
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[gnu-emacs] / src / keyboard.c
index 0ad6d18c0440a21f994dcb44161551a853bf2a74..8edd705135f603f7750e417eec6dd75932afac32 100644 (file)
@@ -1,6 +1,7 @@
 /* Keyboard and mouse input; editor command loop.
 
-Copyright (C) 1985-1989, 1993-1997, 1999-2012  Free Software Foundation, Inc.
+Copyright (C) 1985-1989, 1993-1997, 1999-2013 Free Software Foundation,
+Inc.
 
 This file is part of GNU Emacs.
 
@@ -313,12 +314,18 @@ static Lisp_Object Qfunction_key;
 Lisp_Object Qmouse_click;
 #ifdef HAVE_NTGUI
 Lisp_Object Qlanguage_change;
+#ifdef WINDOWSNT
+Lisp_Object Qfile_w32notify;
+#endif
 #endif
 static Lisp_Object Qdrag_n_drop;
 static Lisp_Object Qsave_session;
 #ifdef HAVE_DBUS
 static Lisp_Object Qdbus_event;
 #endif
+#ifdef HAVE_INOTIFY
+static Lisp_Object Qfile_inotify;
+#endif /* HAVE_INOTIFY */
 static Lisp_Object Qconfig_changed_event;
 
 /* Lisp_Object Qmouse_movement; - also an event header */
@@ -1116,8 +1123,7 @@ cmd_error_internal (Lisp_Object data, const char *context)
 
   Vsignaling_function = Qnil;
 }
-\f
-Lisp_Object command_loop_1 (void);
+
 static Lisp_Object command_loop_2 (Lisp_Object);
 static Lisp_Object top_level_1 (Lisp_Object);
 
@@ -1154,7 +1160,7 @@ command_loop (void)
    value to us.  A value of nil means that command_loop_1 itself
    returned due to end of file (or end of kbd macro).  */
 
-Lisp_Object
+static Lisp_Object
 command_loop_2 (Lisp_Object ignore)
 {
   register Lisp_Object val;
@@ -1172,7 +1178,7 @@ top_level_2 (void)
   return Feval (Vtop_level, Qnil);
 }
 
-Lisp_Object
+static Lisp_Object
 top_level_1 (Lisp_Object ignore)
 {
   /* On entry to the outer level, run the startup file */
@@ -3904,6 +3910,18 @@ kbd_buffer_get_event (KBOARD **kbp,
                              make_number (event->modifiers)));
          kbd_fetch_ptr = event + 1;
        }
+#endif
+#ifdef WINDOWSNT
+      else if (event->kind == FILE_NOTIFY_EVENT)
+       {
+         /* Make an event (file-notify (DESCRIPTOR ACTION FILE) CALLBACK).  */
+         obj = Fcons (Qfile_w32notify,
+                      list2 (list3 (make_number (event->code),
+                                    XCAR (event->arg),
+                                    XCDR (event->arg)),
+                             event->frame_or_window));
+         kbd_fetch_ptr = event + 1;
+       }
 #endif
       else if (event->kind == SAVE_SESSION_EVENT)
         {
@@ -3961,6 +3979,13 @@ kbd_buffer_get_event (KBOARD **kbp,
          obj = make_lispy_event (event);
          kbd_fetch_ptr = event + 1;
        }
+#endif
+#ifdef HAVE_INOTIFY
+      else if (event->kind == FILE_NOTIFY_EVENT)
+        {
+          obj = make_lispy_event (event);
+          kbd_fetch_ptr = event + 1;
+        }
 #endif
       else if (event->kind == CONFIG_CHANGED_EVENT)
        {
@@ -5114,7 +5139,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, Lisp_Object y,
            string_info = Fcons (string, make_number (charpos));
          textpos = (w == XWINDOW (selected_window)
                     && current_buffer == XBUFFER (w->buffer))
-           ? PT : XMARKER (w->pointm)->charpos;
+           ? PT : marker_position (w->pointm);
 
          xret = wx;
          yret = wy;
@@ -5875,6 +5900,13 @@ make_lispy_event (struct input_event *event)
       }
 #endif /* HAVE_DBUS */
 
+#ifdef HAVE_INOTIFY
+    case FILE_NOTIFY_EVENT:
+      {
+        return Fcons (Qfile_inotify, event->arg);
+      }
+#endif /* HAVE_INOTIFY */
+
     case CONFIG_CHANGED_EVENT:
        return Fcons (Qconfig_changed_event,
                       Fcons (event->arg,
@@ -6669,37 +6701,35 @@ get_input_pending (int flags)
 void
 record_asynch_buffer_change (void)
 {
-  struct input_event event;
-  Lisp_Object tem;
-  EVENT_INIT (event);
-
-  event.kind = BUFFER_SWITCH_EVENT;
-  event.frame_or_window = Qnil;
-  event.arg = Qnil;
-
   /* We don't need a buffer-switch event unless Emacs is waiting for input.
      The purpose of the event is to make read_key_sequence look up the
      keymaps again.  If we aren't in read_key_sequence, we don't need one,
      and the event could cause trouble by messing up (input-pending-p).
      Note: Fwaiting_for_user_input_p always returns nil when async
      subprocesses aren't supported.  */
-  tem = Fwaiting_for_user_input_p ();
-  if (NILP (tem))
-    return;
+  if (!NILP (Fwaiting_for_user_input_p ()))
+    {
+      struct input_event event;
+
+      EVENT_INIT (event);
+      event.kind = BUFFER_SWITCH_EVENT;
+      event.frame_or_window = Qnil;
+      event.arg = Qnil;
 
-  /* Make sure no interrupt happens while storing the event.  */
+      /* Make sure no interrupt happens while storing the event.  */
 #ifdef USABLE_SIGIO
-  if (interrupt_input)
-    kbd_buffer_store_event (&event);
-  else
+      if (interrupt_input)
+       kbd_buffer_store_event (&event);
+      else
 #endif
-    {
-      stop_polling ();
-      kbd_buffer_store_event (&event);
-      start_polling ();
+       {
+         stop_polling ();
+         kbd_buffer_store_event (&event);
+         start_polling ();
+       }
     }
 }
-\f
+
 /* Read any terminal input already buffered up by the system
    into the kbd_buffer, but do not wait.
 
@@ -6960,10 +6990,7 @@ tty_read_avail_input (struct terminal *terminal,
             an EAGAIN error.  Does anybody know of a situation
             where a retry is actually needed?  */
 #if 0
-         nread < 0 && (errno == EAGAIN
-#ifdef EFAULT
-                       || errno == EFAULT
-#endif
+         nread < 0 && (errno == EAGAIN || errno == EFAULT
 #ifdef EBADSLT
                        || errno == EBADSLT
 #endif
@@ -10692,7 +10719,7 @@ handle_interrupt (bool in_signal_handler)
       fflush (stdout);
       reset_all_sys_modes ();
 
-#ifdef SIGTSTP                 /* Support possible in later USG versions */
+#ifdef SIGTSTP
 /*
  * On systems which can suspend the current process and return to the original
  * shell, this command causes the user to end up back at the shell.
@@ -11337,10 +11364,18 @@ syms_of_keyboard (void)
   DEFSYM (Qlanguage_change, "language-change");
 #endif
 
+#ifdef WINDOWSNT
+  DEFSYM (Qfile_w32notify, "file-w32notify");
+#endif
+
 #ifdef HAVE_DBUS
   DEFSYM (Qdbus_event, "dbus-event");
 #endif
 
+#ifdef HAVE_INOTIFY
+  DEFSYM (Qfile_inotify, "file-inotify");
+#endif /* HAVE_INOTIFY */
+
   DEFSYM (QCenable, ":enable");
   DEFSYM (QCvisible, ":visible");
   DEFSYM (QChelp, ":help");
@@ -12097,11 +12132,20 @@ keys_of_keyboard (void)
                            "dbus-handle-event");
 #endif
 
+#ifdef HAVE_INOTIFY
+  /* Define a special event which is raised for inotify callback
+     functions.  */
+  initial_define_lispy_key (Vspecial_event_map, "file-inotify",
+                            "inotify-handle-event");
+#endif /* HAVE_INOTIFY */
+
   initial_define_lispy_key (Vspecial_event_map, "config-changed-event",
                            "ignore");
 #if defined (WINDOWSNT)
   initial_define_lispy_key (Vspecial_event_map, "language-change",
                            "ignore");
+  initial_define_lispy_key (Vspecial_event_map, "file-w32notify",
+                           "w32notify-handle-event");
 #endif
 }