]> code.delx.au - gnu-emacs/commitdiff
Fix watching directories using w32notify.c.
authorEli Zaretskii <eliz@gnu.org>
Wed, 27 Nov 2013 16:03:02 +0000 (18:03 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 27 Nov 2013 16:03:02 +0000 (18:03 +0200)
 src/w32notify.c (Fw32notify_add_watch): If the argument FILE is a
 directory, watch it and not its parent.
 (add_watch): Allow empty string in FILE.

 lisp/filenotify.el (file-notify-add-watch): Don't special-case
 w32notify when computing the directory to watch.

lisp/ChangeLog
lisp/filenotify.el
src/ChangeLog
src/w32notify.c

index 50f587d1126ea794ad09794e27b2a3b38cb0ece7..3ff0a40b2e45a1f53377134b94208cb40763ab97 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-27  Eli Zaretskii  <eliz@gnu.org>
+
+       * filenotify.el (file-notify-add-watch): Don't special-case
+       w32notify when computing the directory to watch.
+
 2013-11-27  Glenn Morris  <rgm@gnu.org>
 
        Make bootstrap without generated uni-*.el files possible again.
index c980d7207147f95a27998d014260161059b0c961..72ee0ced785ef8c3ee5e55bf84748b293d6e7cb4 100644 (file)
@@ -237,8 +237,7 @@ FILE is the name of the file whose event is being reported."
 
   (let* ((handler (find-file-name-handler file 'file-notify-add-watch))
         (dir (directory-file-name
-              (if (or (and (not handler) (eq file-notify--library 'w32notify))
-                      (file-directory-p file))
+              (if (file-directory-p file)
                   file
                 (file-name-directory file))))
        desc func l-flags)
index 7b518fdc2399bd4e96c560d534d9cf043c406cc2..b43f758cec458aa8a84f8b590fdd6366fab56127 100644 (file)
@@ -1,3 +1,9 @@
+2013-11-27  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32notify.c (Fw32notify_add_watch): If the argument FILE is a
+       directory, watch it and not its parent.
+       (add_watch): Allow empty string in FILE.
+
 2013-11-27  Martin Rudalics  <rudalics@gmx.at>
 
        * window.c (Fset_window_start, window_resize_apply)
index a48a83daf53090a0d43b4b7e74c5c0e18e3a0ed3..1f2ef83b2fdd863a5191c5d2f3be554d9b41c704 100644 (file)
@@ -324,7 +324,7 @@ add_watch (const char *parent_dir, const char *file, BOOL subdirs, DWORD flags)
   HANDLE hdir;
   struct notification *dirwatch = NULL;
 
-  if (!file || !*file)
+  if (!file)
     return NULL;
 
   hdir = CreateFile (parent_dir,
@@ -526,13 +526,21 @@ generate notifications correctly, though.  */)
       report_file_error ("GetFullPathName failed",
                         Fcons (lisp_errstr, Fcons (file, Qnil)));
     }
-  /* We need the parent directory without the slash that follows it.
-     If BASENAME is NULL, the argument was the root directory on its
-     drive.  */
-  if (basename)
-    basename[-1] = '\0';
+  /* filenotify.el always passes us a directory, either the parent
+     directory of a file to be watched, or the directory to be
+     watched.  */
+  if (file_directory_p (parent_dir))
+    basename = "";
   else
-    subdirs = TRUE;
+    {
+      /* This should only happen if we are called directly, not via
+        filenotify.el.  If BASENAME is NULL, the argument was the
+        root directory on its drive.  */
+      if (basename)
+       basename[-1] = '\0';
+      else
+       subdirs = TRUE;
+    }
 
   if (!NILP (Fmember (Qsubtree, filter)))
     subdirs = TRUE;