(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))
(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)
(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."