]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle quoted remote file names for file notifications
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 2 Feb 2018 17:51:25 +0000 (18:51 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 2 Feb 2018 17:51:25 +0000 (18:51 +0100)
* lisp/filenotify.el (file-notify-add-watch): Do not suppress
other file name handlers when FILE is quoted.

* test/lisp/filenotify-tests.el
(file-notify-test-remote-temporary-file-directory):
Beware quoted `temporary-file-directory'.

* test/lisp/files-tests.el
(files-tests-file-name-non-special-quote-unquote): Improve test.

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

index 442dc8915711da464168cb71a812b0891d06f9b7..d88578b65c8df54bbda848e3427d60cbcb49f677 100644 (file)
@@ -307,15 +307,12 @@ FILE is the name of the file whose event is being reported."
   (unless (functionp callback)
     (signal 'wrong-type-argument `(,callback)))
 
-  (let* ((quoted (file-name-quoted-p file))
-         (file (file-name-unquote file))
-         (file-name-handler-alist (if quoted nil file-name-handler-alist))
-         (handler (find-file-name-handler file 'file-notify-add-watch))
-        (dir (directory-file-name
-              (if (file-directory-p file)
-                  file
-                (file-name-directory file))))
-         desc func l-flags)
+  (let ((handler (find-file-name-handler file 'file-notify-add-watch))
+       (dir (directory-file-name
+             (if (file-directory-p file)
+                 file
+               (file-name-directory file))))
+        desc func l-flags)
 
     (unless (file-directory-p dir)
       (signal 'file-notify-error `("Directory does not exist" ,dir)))
@@ -366,6 +363,10 @@ FILE is the name of the file whose event is being reported."
                   func (if (eq file-notify--library 'kqueue) file dir)
                   l-flags 'file-notify-callback)))
 
+    ;; We do not want to enter quoted file names into the hash.
+    (setq file (file-name-unquote file)
+          dir  (file-name-unquote dir))
+
     ;; Modify `file-notify-descriptors'.
     (let ((watch (file-notify--watch-make
                   dir
index f2feef6132b994deeeac788f8e9eb12536091fbc..219fa746119dd6871b56ed5b24140f3757827174 100644 (file)
        'tramp-default-host-alist
        `("\\`mock\\'" nil ,(system-name)))
       ;; Emacs' Makefile sets $HOME to a nonexistent value.  Needed in
-      ;; batch mode only, therefore.
+      ;; batch mode only, therefore.  `temporary-file-directory' might
+      ;; be quoted, so we unquote it just in case.
       (unless (and (null noninteractive) (file-directory-p "~/"))
-        (setenv "HOME" temporary-file-directory))
+        (setenv "HOME" (file-name-unquote temporary-file-directory)))
       (format "/mock::%s" temporary-file-directory)))
   "Temporary directory for Tramp tests.")
 
index 6b394cd5b7b1eebe9086a6d73e08bf50ed8f4ce4..90e5ebf2153d8f0d0f5c4ca4f650d645ba5588f3 100644 (file)
@@ -268,7 +268,14 @@ be $HOME."
     (should (file-name-quoted-p (file-name-quote temporary-file-directory)))
     (should (equal temporary-file-directory
                    (file-name-unquote
-                    (file-name-quote temporary-file-directory))))))
+                    (file-name-quote temporary-file-directory))))
+    ;; It does not hurt to quote/unquote a file several times.
+    (should (equal (file-name-quote temporary-file-directory)
+                   (file-name-quote
+                    (file-name-quote temporary-file-directory))))
+    (should (equal (file-name-unquote temporary-file-directory)
+                   (file-name-unquote
+                    (file-name-unquote temporary-file-directory))))))
 
 (ert-deftest files-tests--file-name-non-special--subprocess ()
   "Check that Bug#25949 is fixed."