From: Michael Albinus Date: Fri, 7 Feb 2025 13:41:58 +0000 (+0100) Subject: Use insert-special-event in Tramp X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1a0fdb9d7ad37f131c71ef74e7b2ec741b656144;p=emacs.git Use insert-special-event in Tramp * 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) --- diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 10b171b697e..e0099e9cd6c 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -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)) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 32311444756..3f5cb90a752 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -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."