aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-07-18 12:03:49 +0200
committerMichael Albinus2013-07-18 12:03:49 +0200
commite06ec67f56e7cce9b956e2882950379e96514266 (patch)
tree988cdc15f463410f4da9ae664c929409145bf6bb
parenta8cd4836451373f56b719cf3b80fb3344a3422db (diff)
downloademacs-e06ec67f56e7cce9b956e2882950379e96514266.tar.gz
emacs-e06ec67f56e7cce9b956e2882950379e96514266.zip
* filenotify.el (file-notify--library): Renamed from
`file-notify-support'. Do not autoload. Adapt all uses. (file-notify-supported-p): New defun. * autorevert.el (auto-revert-use-notify): Use `file-notify-supported-p' instead of `file-notify-support'. Adapt docstring. (auto-revert-notify-add-watch): Use `file-notify-supported-p'. * net/tramp.el (tramp-file-name-for-operation): Add `file-notify-supported-p'. * net/tramp-sh.el (tramp-sh-handle-file-notify-supported-p): New defun. (tramp-sh-file-name-handler-alist): Add it as handler for `file-notify-supported-p '. * net/tramp-adb.el (tramp-adb-file-name-handler-alist): * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add `ignore' as handler for `file-notify-*' functions.
-rw-r--r--lisp/ChangeLog24
-rw-r--r--lisp/autorevert.el22
-rw-r--r--lisp/filenotify.el40
-rw-r--r--lisp/net/tramp-adb.el3
-rw-r--r--lisp/net/tramp-gvfs.el3
-rw-r--r--lisp/net/tramp-sh.el10
-rw-r--r--lisp/net/tramp-smb.el3
-rw-r--r--lisp/net/tramp.el4
8 files changed, 80 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 25fd3e6171e..fc38ef046a4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,27 @@
12013-07-18 Michael Albinus <michael.albinus@gmx.de>
2
3 * filenotify.el (file-notify--library): Renamed from
4 `file-notify-support'. Do not autoload. Adapt all uses.
5 (file-notify-supported-p): New defun.
6
7 * autorevert.el (auto-revert-use-notify): Use
8 `file-notify-supported-p' instead of `file-notify-support'. Adapt
9 docstring.
10 (auto-revert-notify-add-watch): Use `file-notify-supported-p'.
11
12 * net/tramp.el (tramp-file-name-for-operation):
13 Add `file-notify-supported-p'.
14
15 * net/tramp-sh.el (tramp-sh-handle-file-notify-supported-p):
16 New defun.
17 (tramp-sh-file-name-handler-alist): Add it as handler for
18 `file-notify-supported-p '.
19
20 * net/tramp-adb.el (tramp-adb-file-name-handler-alist):
21 * net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
22 * net/tramp-smb.el (tramp-smb-file-name-handler-alist):
23 Add `ignore' as handler for `file-notify-*' functions.
24
12013-07-17 Eli Zaretskii <eliz@gnu.org> 252013-07-17 Eli Zaretskii <eliz@gnu.org>
2 26
3 * simple.el (line-move-partial, line-move): Don't start vscroll or 27 * simple.el (line-move-partial, line-move): Don't start vscroll or
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 00e88fc4a3d..5c593e2ef71 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -271,21 +271,20 @@ This variable becomes buffer local when set in any fashion.")
271 :type 'boolean 271 :type 'boolean
272 :version "24.4") 272 :version "24.4")
273 273
274(defcustom auto-revert-use-notify (and file-notify-support t) 274(defcustom auto-revert-use-notify
275 ;; We use the support of the local filesystem as default.
276 (file-notify-supported-p temporary-file-directory)
275 "If non-nil Auto Revert Mode uses file notification functions. 277 "If non-nil Auto Revert Mode uses file notification functions.
276This requires Emacs being compiled with file notification 278You should set this variable through Custom."
277support (see `file-notify-support'). You should set this variable
278through Custom."
279 :group 'auto-revert 279 :group 'auto-revert
280 :type 'boolean 280 :type 'boolean
281 :set (lambda (variable value) 281 :set (lambda (variable value)
282 (set-default variable (and file-notify-support value)) 282 (set-default variable value)
283 (unless (symbol-value variable) 283 (unless (symbol-value variable)
284 (when file-notify-support 284 (dolist (buf (buffer-list))
285 (dolist (buf (buffer-list)) 285 (with-current-buffer buf
286 (with-current-buffer buf 286 (when (symbol-value 'auto-revert-notify-watch-descriptor)
287 (when (symbol-value 'auto-revert-notify-watch-descriptor) 287 (auto-revert-notify-rm-watch))))))
288 (auto-revert-notify-rm-watch)))))))
289 :initialize 'custom-initialize-default 288 :initialize 'custom-initialize-default
290 :version "24.4") 289 :version "24.4")
291 290
@@ -513,7 +512,8 @@ will use an up-to-date value of `auto-revert-interval'"
513 (set (make-local-variable 'auto-revert-use-notify) nil)) 512 (set (make-local-variable 'auto-revert-use-notify) nil))
514 513
515 (when (and buffer-file-name auto-revert-use-notify 514 (when (and buffer-file-name auto-revert-use-notify
516 (not auto-revert-notify-watch-descriptor)) 515 (not auto-revert-notify-watch-descriptor)
516 (file-notify-supported-p buffer-file-name))
517 (setq auto-revert-notify-watch-descriptor 517 (setq auto-revert-notify-watch-descriptor
518 (ignore-errors 518 (ignore-errors
519 (file-notify-add-watch 519 (file-notify-add-watch
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index e170db2dd5f..c9a7e106faa 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -27,8 +27,7 @@
27 27
28;;; Code: 28;;; Code:
29 29
30;;;###autoload 30(defconst file-notify--library
31(defconst file-notify-support
32 (cond 31 (cond
33 ((featurep 'gfilenotify) 'gfilenotify) 32 ((featurep 'gfilenotify) 'gfilenotify)
34 ((featurep 'inotify) 'inotify) 33 ((featurep 'inotify) 'inotify)
@@ -191,6 +190,17 @@ car of that event, which is the symbol `file-notify'."
191 (funcall callback (list desc action file file1)) 190 (funcall callback (list desc action file file1))
192 (funcall callback (list desc action file))))))) 191 (funcall callback (list desc action file)))))))
193 192
193(defun file-notify-supported-p (file)
194 "Returns non-nil if filesystem pertaining to FILE could be watched."
195 (unless (stringp file)
196 (signal 'wrong-type-argument (list file)))
197 (setq file (expand-file-name file))
198
199 (let ((handler (find-file-name-handler file 'file-notify-supported-p)))
200 (if handler
201 (funcall handler 'file-notify-supported-p file)
202 (and file-notify--library t))))
203
194(defun file-notify-add-watch (file flags callback) 204(defun file-notify-add-watch (file flags callback)
195 "Add a watch for filesystem events pertaining to FILE. 205 "Add a watch for filesystem events pertaining to FILE.
196This arranges for filesystem events pertaining to FILE to be reported 206This arranges for filesystem events pertaining to FILE to be reported
@@ -238,7 +248,7 @@ FILE is the name of the file whose event is being reported."
238 248
239 (let* ((handler (find-file-name-handler file 'file-notify-add-watch)) 249 (let* ((handler (find-file-name-handler file 'file-notify-add-watch))
240 (dir (directory-file-name 250 (dir (directory-file-name
241 (if (or (and (not handler) (eq file-notify-support 'w32notify)) 251 (if (or (and (not handler) (eq file-notify--library 'w32notify))
242 (file-directory-p file)) 252 (file-directory-p file))
243 file 253 file
244 (file-name-directory file)))) 254 (file-name-directory file))))
@@ -259,32 +269,32 @@ FILE is the name of the file whose event is being reported."
259 269
260 ;; Check, whether Emacs has been compiled with file 270 ;; Check, whether Emacs has been compiled with file
261 ;; notification support. 271 ;; notification support.
262 (unless file-notify-support 272 (unless file-notify--library
263 (signal 'file-notify-error 273 (signal 'file-notify-error
264 '("No file notification package available"))) 274 '("No file notification package available")))
265 275
266 ;; Determine low-level function to be called. 276 ;; Determine low-level function to be called.
267 (setq func (cond 277 (setq func (cond
268 ((eq file-notify-support 'gfilenotify) 'gfile-add-watch) 278 ((eq file-notify--library 'gfilenotify) 'gfile-add-watch)
269 ((eq file-notify-support 'inotify) 'inotify-add-watch) 279 ((eq file-notify--library 'inotify) 'inotify-add-watch)
270 ((eq file-notify-support 'w32notify) 'w32notify-add-watch))) 280 ((eq file-notify--library 'w32notify) 'w32notify-add-watch)))
271 281
272 ;; Determine respective flags. 282 ;; Determine respective flags.
273 (if (eq file-notify-support 'gfilenotify) 283 (if (eq file-notify--library 'gfilenotify)
274 (setq l-flags '(watch-mounts send-moved)) 284 (setq l-flags '(watch-mounts send-moved))
275 (when (memq 'change flags) 285 (when (memq 'change flags)
276 (setq 286 (setq
277 l-flags 287 l-flags
278 (cond 288 (cond
279 ((eq file-notify-support 'inotify) '(create modify move delete)) 289 ((eq file-notify--library 'inotify) '(create modify move delete))
280 ((eq file-notify-support 'w32notify) 290 ((eq file-notify--library 'w32notify)
281 '(file-name directory-name size last-write-time))))) 291 '(file-name directory-name size last-write-time)))))
282 (when (memq 'attribute-change flags) 292 (when (memq 'attribute-change flags)
283 (add-to-list 293 (add-to-list
284 'l-flags 294 'l-flags
285 (cond 295 (cond
286 ((eq file-notify-support 'inotify) 'attrib) 296 ((eq file-notify--library 'inotify) 'attrib)
287 ((eq file-notify-support 'w32notify) 'attributes))))) 297 ((eq file-notify--library 'w32notify) 'attributes)))))
288 298
289 ;; Call low-level function. 299 ;; Call low-level function.
290 (setq desc (funcall func dir l-flags 'file-notify-callback)))) 300 (setq desc (funcall func dir l-flags 'file-notify-callback))))
@@ -311,9 +321,9 @@ DESCRIPTOR should be an object returned by `file-notify-add-watch'."
311 (funcall handler 'file-notify-rm-watch descriptor) 321 (funcall handler 'file-notify-rm-watch descriptor)
312 (funcall 322 (funcall
313 (cond 323 (cond
314 ((eq file-notify-support 'gfilenotify) 'gfile-rm-watch) 324 ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch)
315 ((eq file-notify-support 'inotify) 'inotify-rm-watch) 325 ((eq file-notify--library 'inotify) 'inotify-rm-watch)
316 ((eq file-notify-support 'w32notify) 'w32notify-rm-watch)) 326 ((eq file-notify--library 'w32notify) 'w32notify-rm-watch))
317 descriptor))) 327 descriptor)))
318 328
319 (remhash descriptor file-notify-descriptors))) 329 (remhash descriptor file-notify-descriptors)))
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 14fb8575fff..56c0ee2dc2d 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -108,6 +108,9 @@
108 (file-writable-p . tramp-adb-handle-file-writable-p) 108 (file-writable-p . tramp-adb-handle-file-writable-p)
109 (file-local-copy . tramp-adb-handle-file-local-copy) 109 (file-local-copy . tramp-adb-handle-file-local-copy)
110 (file-modes . tramp-handle-file-modes) 110 (file-modes . tramp-handle-file-modes)
111 (file-notify-add-watch . ignore)
112 (file-notify-rm-watch . ignore)
113 (file-notify-supported-p . ignore)
111 (expand-file-name . tramp-adb-handle-expand-file-name) 114 (expand-file-name . tramp-adb-handle-expand-file-name)
112 (find-backup-file-name . tramp-handle-find-backup-file-name) 115 (find-backup-file-name . tramp-handle-find-backup-file-name)
113 (directory-files . tramp-handle-directory-files) 116 (directory-files . tramp-handle-directory-files)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index c2fdc0491b6..526408140c2 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -435,6 +435,9 @@ Every entry is a list (NAME ADDRESS).")
435 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 435 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
436 ;; `file-name-sans-versions' performed by default handler. 436 ;; `file-name-sans-versions' performed by default handler.
437 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 437 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
438 (file-notify-add-watch . ignore)
439 (file-notify-rm-watch . ignore)
440 (file-notify-supported-p . ignore)
438 (file-ownership-preserved-p . ignore) 441 (file-ownership-preserved-p . ignore)
439 (file-readable-p . tramp-gvfs-handle-file-readable-p) 442 (file-readable-p . tramp-gvfs-handle-file-readable-p)
440 (file-regular-p . tramp-handle-file-regular-p) 443 (file-regular-p . tramp-handle-file-regular-p)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index c92eacd4473..d2fc1b9979e 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -867,7 +867,8 @@ of command line.")
867 (set-file-acl . tramp-sh-handle-set-file-acl) 867 (set-file-acl . tramp-sh-handle-set-file-acl)
868 (vc-registered . tramp-sh-handle-vc-registered) 868 (vc-registered . tramp-sh-handle-vc-registered)
869 (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch) 869 (file-notify-add-watch . tramp-sh-handle-file-notify-add-watch)
870 (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch)) 870 (file-notify-rm-watch . tramp-sh-handle-file-notify-rm-watch)
871 (file-notify-supported-p . tramp-sh-handle-file-notify-supported-p))
871 "Alist of handler functions. 872 "Alist of handler functions.
872Operations not mentioned here will be handled by the normal Emacs functions.") 873Operations not mentioned here will be handled by the normal Emacs functions.")
873 874
@@ -3498,6 +3499,13 @@ Fall back to normal file name handler if no Tramp handler exists."
3498 (tramp-message proc 6 (format "Kill %S" proc)) 3499 (tramp-message proc 6 (format "Kill %S" proc))
3499 (kill-process proc)) 3500 (kill-process proc))
3500 3501
3502(defun tramp-sh-handle-file-notify-supported-p (file-name)
3503 "Like `file-notify-supported-p' for Tramp files."
3504 (with-parsed-tramp-file-name (expand-file-name file-name) nil
3505 (and (or (tramp-get-remote-gvfs-monitor-dir v)
3506 (tramp-get-remote-inotifywait v))
3507 t)))
3508
3501;;; Internal Functions: 3509;;; Internal Functions:
3502 3510
3503(defun tramp-maybe-send-script (vec script name) 3511(defun tramp-maybe-send-script (vec script name)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 65c52ae4f3c..d9bb5057e7a 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -209,6 +209,9 @@ See `tramp-actions-before-shell' for more info.")
209 (file-name-nondirectory . tramp-handle-file-name-nondirectory) 209 (file-name-nondirectory . tramp-handle-file-name-nondirectory)
210 ;; `file-name-sans-versions' performed by default handler. 210 ;; `file-name-sans-versions' performed by default handler.
211 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) 211 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
212 (file-notify-add-watch . ignore)
213 (file-notify-rm-watch . ignore)
214 (file-notify-supported-p . ignore)
212 (file-ownership-preserved-p . ignore) 215 (file-ownership-preserved-p . ignore)
213 (file-readable-p . tramp-handle-file-exists-p) 216 (file-readable-p . tramp-handle-file-exists-p)
214 (file-regular-p . tramp-handle-file-regular-p) 217 (file-regular-p . tramp-handle-file-regular-p)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 3513701d20e..fd5435bd3d4 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1980,8 +1980,8 @@ ARGS are the arguments OPERATION has been called with."
1980 ;; Emacs 22+ only. 1980 ;; Emacs 22+ only.
1981 'set-file-times 1981 'set-file-times
1982 ;; Emacs 24+ only. 1982 ;; Emacs 24+ only.
1983 'file-acl 'file-notify-add-watch 'file-selinux-context 1983 'file-acl 'file-notify-add-watch 'file-notify-supported-p
1984 'set-file-acl 'set-file-selinux-context 1984 'file-selinux-context 'set-file-acl 'set-file-selinux-context
1985 ;; XEmacs only. 1985 ;; XEmacs only.
1986 'abbreviate-file-name 'create-file-buffer 1986 'abbreviate-file-name 'create-file-buffer
1987 'dired-file-modtime 'dired-make-compressed-filename 1987 'dired-file-modtime 'dired-make-compressed-filename