Subject: Re: bug#19909: [PATCH] Error out if with-file-notification=w32 is specified on cygwin

From: Ken Brown <[email-masked]>
Date: Sat, 28 Feb 2015 11:32:29 -0500

On 2/28/2015 2:59 AM, Eli Zaretskii wrote:
>> Date: Fri, 27 Feb 2015 17:25:54 -0500
>> From: Ken Brown <[email-masked]>
>> CC: [email-masked], [email-masked]
>>
>> It looks like it might not take much effort.  What I did for now, just
>> for testing purposes, is to copy into w32notify.c whatever was necessary
>> to make the Cygwin-w32 build compile with w32 file notification.  I
>> tested it briefly and it seems to work.  Obviously it needs much more
>> testing to make sure this doesn't break anything else, and then we can
>> worry about how to do this right.
>
> Thanks.  A few comments:
>
>    . Cygwin doesn't need to call MultiByteToWideChar and
>      WideCharToMultiByte via function pointers, it can call them
>      directly.
>
>    . I think there shouldn't be a need to call filename_to_utf16 and
>      its ilk, but instead use the to_unicode etc., like the rest of
>      Cygwin-w32 code does.  E.g., just use GUI_ENCODE_FILE defined on
>      w32term.h.

It turns out that filename_to_utf16 wasn't even being called in the 
Cygwin-w32 build, because w32_unicode_filenames == 0.

It also turns out that when I "tested" the build, which I did via M-x 
auto-revert-tail-mode, I wasn't actually testing w32notify, because I 
forgot to do this:

diff --git a/src/emacs.c b/src/emacs.c
index ca5633d..342d0fe 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1334,11 +1334,12 @@ Using an Emacs configured with 
--with-x-toolkit=lucid does not have this problem
    globals_of_gfilenotify ();
  #endif

-#ifdef WINDOWSNT
-  globals_of_w32 ();
  #ifdef HAVE_W32NOTIFY
    globals_of_w32notify ();
  #endif
+
+#ifdef WINDOWSNT
+  globals_of_w32 ();
    /* Initialize environment from registry settings.  */
    init_environment (argv);
    init_ntproc (dumping); /* must precede init_editfns.  */
@@ -1512,11 +1513,12 @@ Using an Emacs configured with 
--with-x-toolkit=lucid does not have this problem
        syms_of_dbusbind ();
  #endif /* HAVE_DBUS */

-#ifdef WINDOWSNT
-      syms_of_ntterm ();
  #ifdef HAVE_W32NOTIFY
        syms_of_w32notify ();
-#endif /* HAVE_W32NOTIFY */
+#endif
+
+#ifdef WINDOWSNT
+      syms_of_ntterm ();
  #endif /* WINDOWSNT */

        syms_of_profiler ();

When I add that patch, auto-revert-tail-mode no longer works; there's no 
error message, but the buffer doesn't get auto-reverted when something 
is appended.

I think I have again lost motivation to pursue this further, since gfile 
works fine.  And glib is required for the default Cygwin-w32 build 
anyway, because ImageMagick brings it in, so why not just use it?

Ken