]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix filenotify.el issue for kqueue
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 22 Mar 2017 19:33:03 +0000 (19:33 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 22 Mar 2017 19:33:03 +0000 (19:33 +0000)
* lisp/filenotify.el (file-notify-add-watch): Use directory
for remote file name handlers.

* test/lisp/filenotify-tests.el (file-notify-test01-add-watch):
Create/delete temporary file only for "kqueue".
(file-notify-test02-rm-watch): Create/delete temporary files.

lisp/filenotify.el
test/lisp/filenotify-tests.el

index 7eb6229976a382c4b410a5082629173822395383..80e9f898b2e9cfa22594247ac80b0fc1ae8e096f 100644 (file)
@@ -347,13 +347,7 @@ FILE is the name of the file whose event is being reported."
     (if handler
        ;; A file name handler could exist even if there is no local
        ;; file notification support.
-       (setq desc (funcall
-                   handler 'file-notify-add-watch
-                    ;; kqueue does not report file changes in
-                    ;; directory monitor.  So we must watch the file
-                    ;; itself.
-                    (if (eq file-notify--library 'kqueue) file dir)
-                    flags callback))
+       (setq desc (funcall handler 'file-notify-add-watch dir flags callback))
 
       ;; Check, whether Emacs has been compiled with file notification
       ;; support.
@@ -391,6 +385,8 @@ FILE is the name of the file whose event is being reported."
 
       ;; Call low-level function.
       (setq desc (funcall
+                  ;; kqueue does not report file changes in directory
+                  ;; monitor.  So we must watch the file itself.
                   func (if (eq file-notify--library 'kqueue) file dir)
                   l-flags 'file-notify-callback)))
 
index 654e1af1123cbf3762d293476e8278fad7229364..329ea58d3bb81cf61a7b82ac37f20c259a15952c 100644 (file)
@@ -294,13 +294,20 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
                (file-notify-add-watch
                 temporary-file-directory '(change attribute-change) #'ignore)))
         (file-notify-rm-watch file-notify--test-desc)
-        (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
+
+        ;; File monitors like kqueue insist, that the watched file
+        ;; exists.  Directory monitors are not bound to this
+        ;; restriction.
+        (when (string-equal (file-notify--test-library) "kqueue")
+          (write-region
+           "any text" nil file-notify--test-tmpfile nil 'no-message))
         (should
          (setq file-notify--test-desc
                (file-notify-add-watch
                 file-notify--test-tmpfile '(change attribute-change) #'ignore)))
         (file-notify-rm-watch file-notify--test-desc)
-        (delete-file file-notify--test-tmpfile)
+        (when (string-equal (file-notify--test-library) "kqueue")
+          (delete-file file-notify--test-tmpfile))
 
         ;; Check error handling.
         (should-error (file-notify-add-watch 1 2 3 4)
@@ -378,6 +385,8 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
       (progn
         (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
               file-notify--test-tmpfile1 (file-notify--test-make-temp-name))
+        (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
+        (write-region "any text" nil file-notify--test-tmpfile1 nil 'no-message)
         (should
          (setq file-notify--test-desc
                (file-notify-add-watch
@@ -390,6 +399,8 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
         (file-notify-rm-watch file-notify--test-desc)
         (file-notify-rm-watch file-notify--test-desc)
         (file-notify-rm-watch file-notify--test-desc1)
+        (delete-file file-notify--test-tmpfile)
+        (delete-file file-notify--test-tmpfile1)
 
         ;; The environment shall be cleaned up.
         (file-notify--test-cleanup-p))