Function: tramp-sh-inotifywait-process-filter

tramp-sh-inotifywait-process-filter is a byte-compiled function defined in tramp-sh.el.gz.

Signature

(tramp-sh-inotifywait-process-filter PROC STRING)

Documentation

Read output from "inotifywait" and add corresponding file-notify events.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
(defun tramp-sh-inotifywait-process-filter (proc string)
  "Read output from \"inotifywait\" and add corresponding `file-notify' events."
  (let ((events (process-get proc 'tramp-events)))
    (tramp-message proc 6 "%S\n%s" proc string)
    (dolist (line (split-string string (rx (+ (any "\r\n"))) 'omit))
      ;; Check, whether there is a problem.
      (unless (string-match
	       (rx bol (+ (not blank)) (+ blank) (group (+ (not blank)))
		   (? (+ blank) (group (+ (not (any "\r\n"))))))
	       line)
	(tramp-error proc 'file-notify-error line))

      (let ((object
	     (list
	      proc
	      (mapcar
	       (lambda (x) (intern-soft (string-replace "_" "-" (downcase x))))
	       (split-string (match-string 1 line) "," 'omit))
	      (or (match-string 2 line)
		  (file-name-nondirectory
		   (process-get proc 'tramp-watch-name))))))
        ;; Add an Emacs event now.
	;; `insert-special-event' exists since Emacs 31.
	(when (member (caadr object) events)
	  (tramp-compat-funcall
              (if (fboundp 'insert-special-event)
                  'insert-special-event
                (lookup-key special-event-map [file-notify]))
	    `(file-notify ,object file-notify-callback)))))))