[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 344750a: Handle quoted remote file names for file n
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 344750a: Handle quoted remote file names for file notifications |
Date: |
Fri, 2 Feb 2018 12:51:45 -0500 (EST) |
branch: master
commit 344750aef4a8e8c67b1857cf0fe413ba855026d6
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
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.
---
lisp/filenotify.el | 19 ++++++++++---------
test/lisp/filenotify-tests.el | 5 +++--
test/lisp/files-tests.el | 9 ++++++++-
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index 442dc89..d88578b 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -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
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index f2feef6..219fa74 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -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.")
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 6b394cd..90e5ebf 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -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."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 344750a: Handle quoted remote file names for file notifications,
Michael Albinus <=