1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-27 07:37:33 +00:00

Handle quoted remote file names for file notifications

* 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.
This commit is contained in:
Michael Albinus 2018-02-02 18:51:25 +01:00
parent b86b8ee072
commit 344750aef4
3 changed files with 21 additions and 12 deletions

View 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

View File

@ -57,9 +57,10 @@
'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.")

View 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."