(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)))
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
'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.")
(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."