Function: treemacs--stop-filewatch-for-current-buffer

treemacs--stop-filewatch-for-current-buffer is a byte-compiled function defined in treemacs-filewatch-mode.el.

Signature

(treemacs--stop-filewatch-for-current-buffer)

Documentation

Called when a treemacs buffer is torn down/killed.

Will stop file watch on every path watched by this buffer.

Source Code

;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-filewatch-mode.el
(defun treemacs--stop-filewatch-for-current-buffer ()
  "Called when a treemacs buffer is torn down/killed.
Will stop file watch on every path watched by this buffer."
  (let ((buffer (treemacs-get-local-buffer))
        (to-remove))
    (treemacs--maphash treemacs--filewatch-index (watched-path watch-info)
      (-let [(watching-buffers . watch-descr) watch-info]
        (when (memq buffer watching-buffers)
          (if (= 1 (length watching-buffers))
              (progn
                (file-notify-rm-watch watch-descr)
                (ht-remove! treemacs--collapsed-filewatch-index watched-path)
                (push watched-path to-remove))
            (setcar watch-info (delq buffer watching-buffers))))))
    (dolist (it to-remove)
      (ht-remove! treemacs--filewatch-index it))))