emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 52a7460: Adapt Tramp file notification support


From: Michael Albinus
Subject: master 52a7460: Adapt Tramp file notification support
Date: Thu, 25 Mar 2021 07:03:07 -0400 (EDT)

branch: master
commit 52a74604160387230c104e3305a5e08fa8c3fdf6
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Adapt Tramp file notification support
    
    * lisp/net/tramp-integration.el (tramp-use-ssh-controlmaster-options):
    Declare it.
    
    * lisp/net/tramp-sh.el (tramp-sh-handle-file-notify-add-watch):
    Remove "gvfs-monitor-dir".
    (tramp-sh-gvfs-monitor-dir-process-filter)
    (tramp-get-remote-gvfs-monitor-dir): Remove.
    (tramp-get-remote-gio-file-monitor): Support also cygwin, and
    GFamDirectoryMonitor, GPollFileMonitor.
---
 lisp/net/tramp-integration.el |  1 +
 lisp/net/tramp-sh.el          | 81 +++----------------------------------------
 2 files changed, 5 insertions(+), 77 deletions(-)

diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
index 9d4dd7d..2931b4f 100644
--- a/lisp/net/tramp-integration.el
+++ b/lisp/net/tramp-integration.el
@@ -49,6 +49,7 @@
 (defvar recentf-exclude)
 (defvar tramp-current-connection)
 (defvar tramp-postfix-host-format)
+(defvar tramp-use-ssh-controlmaster-options)
 
 ;;; Fontification of `read-file-name':
 
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7182cd6..d6fdbb0 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3686,18 +3686,6 @@ Fall back to normal file name handler if no Tramp 
handler exists."
                '(created changed changes-done-hint moved deleted))
               ((memq 'attribute-change flags) '(attribute-changed)))
              sequence `(,command "monitor" ,localname)))
-       ;; "gvfs-monitor-dir".
-       ((setq command (tramp-get-remote-gvfs-monitor-dir v))
-       (setq filter #'tramp-sh-gvfs-monitor-dir-process-filter
-             events
-             (cond
-              ((and (memq 'change flags) (memq 'attribute-change flags))
-               '(created changed changes-done-hint moved deleted
-                         attribute-changed))
-              ((memq 'change flags)
-               '(created changed changes-done-hint moved deleted))
-              ((memq 'attribute-change flags) '(attribute-changed)))
-             sequence `(,command ,localname)))
        ;; None.
        (t (tramp-error
           v 'file-notify-error
@@ -3795,56 +3783,6 @@ Fall back to normal file name handler if no Tramp 
handler exists."
     (when string (tramp-message proc 10 "Rest string:\n%s" string))
     (process-put proc 'rest-string string)))
 
-(defun tramp-sh-gvfs-monitor-dir-process-filter (proc string)
-  "Read output from \"gvfs-monitor-dir\" and add corresponding \
-`file-notify' events."
-  (let ((events (process-get proc 'events))
-       (remote-prefix
-        (with-current-buffer (process-buffer proc)
-          (file-remote-p default-directory)))
-       (rest-string (process-get proc 'rest-string)))
-    (when rest-string
-      (tramp-message proc 10 "Previous string:\n%s" rest-string))
-    (tramp-message proc 6 "%S\n%s" proc string)
-    (setq string (concat rest-string string)
-         ;; Attribute change is returned in unused wording.
-         string (tramp-compat-string-replace
-                 "ATTRIB CHANGED" "ATTRIBUTE_CHANGED" string))
-
-    (while (string-match
-           (concat "^[\n\r]*"
-                   "Directory Monitor Event:[\n\r]+"
-                   "Child = \\([^\n\r]+\\)[\n\r]+"
-                   "\\(Other = \\([^\n\r]+\\)[\n\r]+\\)?"
-                   "Event = \\([^[:blank:]]+\\)[\n\r]+")
-           string)
-      (let* ((file (match-string 1 string))
-            (file1 (match-string 3 string))
-            (object
-             (list
-              proc
-              (list
-               (intern-soft
-                (tramp-compat-string-replace
-                 "_" "-" (downcase (match-string 4 string)))))
-              ;; File names are returned as absolute paths.  We must
-              ;; add the remote prefix.
-              (concat remote-prefix file)
-              (when file1 (concat remote-prefix file1)))))
-       (setq string (replace-match "" nil nil string))
-       ;; Usually, we would add an Emacs event now.  Unfortunately,
-       ;; `unread-command-events' does not accept several events at
-       ;; once.  Therefore, we apply the handler directly.
-       (when (member (cl-caadr object) events)
-         (tramp-compat-funcall
-          (lookup-key special-event-map [file-notify])
-          `(file-notify ,object file-notify-callback)))))
-
-    ;; Save rest of the string.
-    (when (zerop (length string)) (setq string nil))
-    (when string (tramp-message proc 10 "Rest string:\n%s" string))
-    (process-put proc 'rest-string string)))
-
 (defun tramp-sh-inotifywait-process-filter (proc string)
   "Read output from \"inotifywait\" and add corresponding `file-notify' 
events."
   (let ((events (process-get proc 'events)))
@@ -5658,7 +5596,7 @@ This command is returned only if 
`delete-by-moving-to-trash' is non-nil."
        ;; linked libraries of libgio.
        (when (tramp-send-command-and-check vec (concat "ldd " gio))
          (goto-char (point-min))
-         (when (re-search-forward "\\S-+/libgio\\S-+")
+         (when (re-search-forward "\\S-+/\\(libgio\\|cyggio\\)\\S-+")
            (when (tramp-send-command-and-check
                   vec (concat "strings " (match-string 0)))
              (goto-char (point-min))
@@ -5666,23 +5604,12 @@ This command is returned only if 
`delete-by-moving-to-trash' is non-nil."
               (format
                "^%s$"
                (regexp-opt
-                '("GFamFileMonitor" "GFenFileMonitor"
-                  "GInotifyFileMonitor" "GKqueueFileMonitor")))
+                '("GFamFileMonitor" "GFamDirectoryMonitor" "GFenFileMonitor"
+                  "GInotifyFileMonitor" "GKqueueFileMonitor"
+                  "GPollFileMonitor")))
               nil 'noerror)
              (intern (match-string 0)))))))))
 
-(defun tramp-get-remote-gvfs-monitor-dir (vec)
-  "Determine remote `gvfs-monitor-dir' command."
-  (with-tramp-connection-property vec "gvfs-monitor-dir"
-    (tramp-message vec 5 "Finding a suitable `gvfs-monitor-dir' command")
-    ;; We distinguish "gvfs-monitor-dir.exe" from cygwin in order to
-    ;; establish better timeouts in filenotify-tests.el.  Any better
-    ;; distinction approach would be welcome!
-    (or (tramp-find-executable
-        vec "gvfs-monitor-dir.exe" (tramp-get-remote-path vec) t t)
-       (tramp-find-executable
-        vec "gvfs-monitor-dir" (tramp-get-remote-path vec) t t))))
-
 (defun tramp-get-remote-inotifywait (vec)
   "Determine remote `inotifywait' command."
   (with-tramp-connection-property vec "inotifywait"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]