]> git.eshelyaron.com Git - emacs.git/commitdiff
Use insert-special-event in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 7 Feb 2025 13:41:58 +0000 (14:41 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Feb 2025 08:43:42 +0000 (09:43 +0100)
* lisp/net/tramp-gvfs.el (tramp-gvfs-monitor-process-filter):
* lisp/net/tramp-sh.el (tramp-sh-gio-monitor-process-filter)
(tramp-sh-inotifywait-process-filter): Use `insert-special-event'
if possible.

(cherry picked from commit 8be3be7330953dd015df28369c1f071178248bb4)

lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el

index 10b171b697e825090dbe97f68faec1bffc484ffa..e0099e9cd6cad6d844c2cdbd1f3da4e10f058613 100644 (file)
@@ -1569,11 +1569,15 @@ If FILE-SYSTEM is non-nil, return file system attributes."
        (when (and (member action '(moved deleted))
                   (string-equal file (process-get proc 'tramp-watch-name)))
          (delete-process proc))
-       ;; Usually, we would add an Emacs event now.  Unfortunately,
-       ;; `unread-command-events' does not accept several events at
-       ;; once.  Therefore, we apply the callback directly.
+        ;; Add an Emacs event now.
+       ;; `insert-special-event' exists since Emacs 31.
        (when (member action events)
-         (file-notify-callback (list proc action file file1)))))
+         (tramp-compat-funcall
+              (if (fboundp 'insert-special-event)
+                  'insert-special-event
+               (lookup-key special-event-map [file-notify]))
+           `(file-notify
+              ,(list proc action file file1) file-notify-callback)))))
 
     ;; Save rest of the string.
     (when (string-empty-p string) (setq string nil))
index 323114447567d872d2a16fa73ad706ea5874393f..3f5cb90a752efc51f880746cfba1bb6a55085f27 100644 (file)
@@ -3906,13 +3906,14 @@ Fall back to normal file name handler if no Tramp handler exists."
                 (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.
+          ;; Add an Emacs event now.
+         ;; `insert-special-event' exists since Emacs 31.
          (when (member (cl-caadr object) events)
            (tramp-compat-funcall
-            (lookup-key special-event-map [file-notify])
-            `(file-notify ,object file-notify-callback))))))
+                (if (fboundp 'insert-special-event)
+                    'insert-special-event
+                 (lookup-key special-event-map [file-notify]))
+             `(file-notify ,object file-notify-callback))))))
 
     ;; Save rest of the string.
     (while (string-match (rx bol "\n") string)
@@ -3942,13 +3943,14 @@ Fall back to normal file name handler if no Tramp handler exists."
              (or (match-string 2 line)
                  (file-name-nondirectory
                   (process-get proc 'tramp-watch-name))))))
-       ;; 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.
+        ;; Add an Emacs event now.
+       ;; `insert-special-event' exists since Emacs 31.
        (when (member (cl-caadr object) events)
          (tramp-compat-funcall
-          (lookup-key special-event-map [file-notify])
-          `(file-notify ,object file-notify-callback)))))))
+              (if (fboundp 'insert-special-event)
+                  'insert-special-event
+               (lookup-key special-event-map [file-notify]))
+           `(file-notify ,object file-notify-callback)))))))
 
 (defun tramp-sh-handle-file-system-info (filename)
   "Like `file-system-info' for Tramp files."