aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-01-29 17:03:40 +0100
committerMichael Albinus2013-01-29 17:03:40 +0100
commit2f52b5608c5dd7b5f1a4f339f1de8bfa43619ba1 (patch)
tree7b1a24900c8ba73c8f3c3b4c246a70c7ee3dabac
parentea55064c0b56c497ec1ecb9345212449f07ab580 (diff)
downloademacs-2f52b5608c5dd7b5f1a4f339f1de8bfa43619ba1.tar.gz
emacs-2f52b5608c5dd7b5f1a4f339f1de8bfa43619ba1.zip
* autorevert.el (auto-revert-use-notify): Use
`custom-initialize-default' for initialization. (Bug#13583)
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/autorevert.el1
-rw-r--r--lisp/net/tramp-sh.el66
3 files changed, 69 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ba982253949..807e44b3583 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12013-01-29 Michael Albinus <michael.albinus@gmx.de> 12013-01-29 Michael Albinus <michael.albinus@gmx.de>
2 2
3 * autorevert.el (auto-revert-use-notify): Use
4 `custom-initialize-default' for initialization. (Bug#13583)
5
3 * net/ange-ftp.el (ange-ftp-skip-msgs): Add another message. 6 * net/ange-ftp.el (ange-ftp-skip-msgs): Add another message.
4 7
5 * net/tramp-sh.el (tramp-sh-handle-start-file-process): Catch 8 * net/tramp-sh.el (tramp-sh-handle-start-file-process): Catch
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 9270b98ac83..e44d4a88eda 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -289,6 +289,7 @@ variable through Custom only."
289 (with-current-buffer buf 289 (with-current-buffer buf
290 (when (symbol-value 'auto-revert-notify-watch-descriptor) 290 (when (symbol-value 'auto-revert-notify-watch-descriptor)
291 (auto-revert-notify-rm-watch))))))) 291 (auto-revert-notify-rm-watch)))))))
292 :initialize 'custom-initialize-default
292 :version "24.4") 293 :version "24.4")
293 294
294(defcustom auto-revert-notify-exclude-dir-regexp 295(defcustom auto-revert-notify-exclude-dir-regexp
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 63e966b91b2..65a514c8e36 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -988,7 +988,8 @@ This is used to map a mode number to a permission string.")
988 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context) 988 (set-file-selinux-context . tramp-sh-handle-set-file-selinux-context)
989 (file-acl . tramp-sh-handle-file-acl) 989 (file-acl . tramp-sh-handle-file-acl)
990 (set-file-acl . tramp-sh-handle-set-file-acl) 990 (set-file-acl . tramp-sh-handle-set-file-acl)
991 (vc-registered . tramp-sh-handle-vc-registered)) 991 (vc-registered . tramp-sh-handle-vc-registered)
992 (inotify-add-watch . tramp-sh-handle-inotify-add-watch))
992 "Alist of handler functions. 993 "Alist of handler functions.
993Operations not mentioned here will be handled by the normal Emacs functions.") 994Operations not mentioned here will be handled by the normal Emacs functions.")
994 995
@@ -3487,6 +3488,64 @@ Fall back to normal file name handler if no Tramp handler exists."
3487 ;; Default file name handlers, we don't care. 3488 ;; Default file name handlers, we don't care.
3488 (t (tramp-run-real-handler operation args))))))) 3489 (t (tramp-run-real-handler operation args)))))))
3489 3490
3491(defun tramp-sh-handle-inotify-add-watch (file-name aspect callback)
3492 "Like `inotify-add-watch' for Tramp files."
3493 (setq file-name (expand-file-name file-name))
3494 (unless (consp aspect) (setq aspect (cons aspect nil)))
3495 (with-parsed-tramp-file-name file-name nil
3496 (let* ((default-directory (file-name-directory file-name))
3497 (command (tramp-get-remote-inotifywait v))
3498 (aspect (mapconcat
3499 (lambda (x)
3500 (replace-regexp-in-string "-" "_" (symbol-name x)))
3501 aspect ","))
3502 (p (and command
3503 (start-file-process
3504 "inotifywait" nil command "-mq" "-e" aspect localname))))
3505 (when (processp p)
3506 (tramp-compat-set-process-query-on-exit-flag p nil)
3507 (set-process-filter p 'tramp-sh-inotify-process-filter)
3508 (tramp-set-connection-property p "inotify-callback" callback)
3509 ;; Return the file-name vector as watch-descriptor.
3510 (tramp-set-connection-property p "inotify-watch-descriptor" v)))))
3511
3512(defun tramp-sh-inotify-process-filter (proc string)
3513 "Read output from \"inotifywait\" and add corresponding inotify events."
3514 (tramp-message
3515 (tramp-get-connection-property proc "vector" nil) 6
3516 (format "%s\n%s" proc string))
3517 (dolist (line (split-string string "[\n\r]+" 'omit-nulls))
3518 ;; Check, whether there is a problem.
3519 (unless
3520 (string-match
3521 "^[^[:blank:]]+[[:blank:]]+\\([^[:blank:]]+\\)+\\([[:blank:]]+\\([^[:blank:]]+\\)\\)?[[:blank:]]*$" line)
3522 (tramp-error proc 'filewatch-error "%s" line))
3523
3524 (let* ((object
3525 (list
3526 (tramp-get-connection-property
3527 proc "inotify-watch-descriptor" nil)
3528 ;; Aspect symbols. We filter out MOVE and CLOSE, which
3529 ;; are convenience macros. See INOTIFY(7).
3530 (mapcar
3531 (lambda (x)
3532 (intern-soft (replace-regexp-in-string "_" "-" (downcase x))))
3533 (delete "MOVE" (delete "CLOSE"
3534 (split-string (match-string 1 line) "," 'omit-nulls))))
3535 ;; We cannot gather any cookie value. So we return 0 as
3536 ;; "don't know".
3537 0 (match-string 3 line)))
3538 (callback
3539 (tramp-get-connection-property proc "inotify-callback" nil))
3540 (event `(file-inotify ,object ,callback)))
3541
3542 ;; Usually, we would add an Emacs event now. Unfortunately,
3543 ;; `unread-command-events' does not accept several events at
3544 ;; once. Therefore, we apply the callback directly.
3545 ;(setq unread-command-events (cons event unread-command-events)))))
3546 (let ((last-input-event event))
3547 (funcall callback object)))))
3548
3490;;; Internal Functions: 3549;;; Internal Functions:
3491 3550
3492(defun tramp-maybe-send-script (vec script name) 3551(defun tramp-maybe-send-script (vec script name)
@@ -5046,6 +5105,11 @@ This is used internally by `tramp-file-mode-from-int'."
5046 (tramp-message vec 5 "Finding a suitable `trash' command") 5105 (tramp-message vec 5 "Finding a suitable `trash' command")
5047 (tramp-find-executable vec "trash" (tramp-get-remote-path vec)))) 5106 (tramp-find-executable vec "trash" (tramp-get-remote-path vec))))
5048 5107
5108(defun tramp-get-remote-inotifywait (vec)
5109 (with-tramp-connection-property vec "inotifywait"
5110 (tramp-message vec 5 "Finding a suitable `inotifywait' command")
5111 (tramp-find-executable vec "inotifywait" (tramp-get-remote-path vec) t t)))
5112
5049(defun tramp-get-remote-id (vec) 5113(defun tramp-get-remote-id (vec)
5050 (with-tramp-connection-property vec "id" 5114 (with-tramp-connection-property vec "id"
5051 (tramp-message vec 5 "Finding POSIX `id' command") 5115 (tramp-message vec 5 "Finding POSIX `id' command")