Subject: bug#21241: 25.0.50; gfilenotify doesn't indicate when limits are reached

From: Paul Eggert <[email-masked]>
Date: Fri, 14 Aug 2015 18:27:39 -0700

Michael Albinus writes:

> I would also agree to favor inotify when available.

Let's give that a try, then.  I installed the attached patch as master commit 
200c2b10faf298bf65e8b6dbd0cb9ef00b2f95d6.

> On OS X (better: on systems which have defined HAVE_NS), we should
> disable gfilenotify, because the Glib main loop won't be used (ns_select
> is used rather than xg_select).

configure.ac was trying to do that, but there was a typo.  Should also be fixed 
in the attached patch.
>From 3f9999c2c0b0eb96c7e7e83fd5dd97da4ca301d1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Fri, 14 Aug 2015 18:20:35 -0700
Subject: [PATCH] Default to inotify instead of gfile

* configure.ac (with_file_notification): Fix typo that
prevented suppression of file notification if HAVE_NS.
(NOTIFY_OBJ): Prefer inotify to gfile if both exist and
with_file_notification is 'yes' (Bug#21241).
* etc/NEWS: Mention this.
---
 configure.ac | 34 ++++++++++++++++------------------
 etc/NEWS     |  4 ++++
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/configure.ac b/configure.ac
index 16d4484..9f8089f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -365,7 +365,7 @@ AC_ARG_WITH([file-notification],[AS_HELP_STRING([--with-file-notification=LIB],
     * ) AC_MSG_ERROR(['--with-file-notification=$withval' is invalid;
 this option's value should be 'yes', 'no', 'gfile', 'inotify' or 'w32'.
 'yes' is a synonym for 'w32' on MS-Windows, for 'no' on Nextstep,
-otherwise for the first of 'gfile' or 'inotify' that is usable.])
+otherwise for the first of 'inotify' or 'gfile' that is usable.])
     ;;
    esac
    with_file_notification=$val
@@ -2674,7 +2674,7 @@ NOTIFY_SUMMARY=no
 
 dnl FIXME?  Don't auto-detect on NS, but do allow someone to specify
 dnl a particular library.  This doesn't make much sense?
-if test "${HAVE_ns}" = yes && test ${with_file_notification} = yes; then
+if test "${HAVE_NS}" = yes && test ${with_file_notification} = yes; then
   with_file_notification=no
 fi
 
@@ -2694,22 +2694,7 @@ case $with_file_notification,$opsys in
     fi ;;
 esac
 
-dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
-dnl has been added in glib 2.24.  It has been tested under
-dnl GNU/Linux only.  We take precedence over inotify, but this makes
-dnl only sense when glib has been compiled with inotify support.  How
-dnl to check?
-case $with_file_notification,$NOTIFY_OBJ in
-  gfile, | yes,)
-    EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
-    if test "$HAVE_GFILENOTIFY" = "yes"; then
-       AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
-       NOTIFY_OBJ=gfilenotify.o
-       NOTIFY_SUMMARY="yes -lgio (gfile)"
-    fi ;;
-esac
-
-dnl inotify is only available on GNU/Linux.
+dnl inotify is available only on GNU/Linux.
 case $with_file_notification,$NOTIFY_OBJ in
   inotify, | yes,)
     AC_CHECK_HEADER(sys/inotify.h)
@@ -2723,6 +2708,19 @@ case $with_file_notification,$NOTIFY_OBJ in
     fi ;;
 esac
 
+dnl g_file_monitor exists since glib 2.18.  G_FILE_MONITOR_EVENT_MOVED
+dnl has been added in glib 2.24.  It has been tested under
+dnl GNU/Linux only.
+case $with_file_notification,$NOTIFY_OBJ in
+  gfile,* | yes,)
+    EMACS_CHECK_MODULES([GFILENOTIFY], [gio-2.0 >= 2.24])
+    if test "$HAVE_GFILENOTIFY" = "yes"; then
+       AC_DEFINE(HAVE_GFILENOTIFY, 1, [Define to 1 if using GFile.])
+       NOTIFY_OBJ=gfilenotify.o
+       NOTIFY_SUMMARY="yes -lgio (gfile)"
+    fi ;;
+esac
+
 case $with_file_notification,$NOTIFY_OBJ in
   yes,* | no,* | *,?*) ;;
   *) AC_MSG_ERROR([File notification '$with_file_notification' requested but requirements not found.]) ;;
diff --git a/etc/NEWS b/etc/NEWS
index f131981..bbcdc0c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -43,6 +43,10 @@ or by sticking with Emacs 24.4.
 If gnustep-config is not available, the old heuristics are used.
 
 ---
+** 'configure' now prefers inotify to gfile for file notification,
+unless gfile is explicitly requested via --with-file-notification='gfile'.
+
+---
 ** The configure option '--with-pkg-config-prog' has been removed.
 Use './configure PKG_CONFIG=/full/name/of/pkg-config' if you need to.
 
-- 
2.1.0