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 'events)))
    (tramp-message proc 6 "%S\n%s" proc string)
    (dolist (line (split-string string "[\n\r]+" 'omit))
      ;; Check, whether there is a problem.
      (unless (string-match
	       (concat "^[^[:blank:]]+"
		       "[[:blank:]]+\\([^[:blank:]]+\\)"
		       "\\([[:blank:]]+\\([^\n\r]+\\)\\)?")
	       line)
	(tramp-error proc 'file-notify-error line))

      (let ((object
	     (list
	      proc
	      (mapcar
	       (lambda (x)
		 (intern-soft
		  (tramp-compat-string-replace "_" "-" (downcase x))))
	       (split-string (match-string 1 line) "," 'omit))
	      (or (match-string 3 line)
		  (file-name-nondirectory (process-get proc '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.
	(when (member (cl-caadr object) events)
	  (tramp-compat-funcall
	   (lookup-key special-event-map [file-notify])
	   `(file-notify ,object file-notify-callback)))))))