Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make `auto-revert-mode' work with dired-subtree #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions dired-subtree.el
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ Return a string suitable for insertion in `dired' buffer."
(overlay-put ov 'dired-subtree-name dir-name)
(overlay-put ov 'dired-subtree-parent parent)
(overlay-put ov 'dired-subtree-depth depth)
(overlay-put ov 'dired-subtree-modtime (file-attribute-modification-time (file-attributes dir-name)))
(overlay-put ov 'evaporate t)
(push ov dired-subtree-overlays))
(goto-char beg)
Expand Down Expand Up @@ -778,6 +779,24 @@ Optional argument means return a file name relative to `default-directory'."
;; dir is not in `dired-subdir-alist'.
cur-dir))))

;; The check for a directory change only works with the passed dirname and the
;; buffer-wise modtime. Make an internal function accept both as arguments...
(defun dired-directory-changed-p--compat (dirname modtime)
(not (let ((attributes (file-attributes dirname)))
(or (eq modtime 0)
(not (eq (file-attribute-type attributes) t))
(equal (file-attribute-modification-time attributes) modtime)))))

;; ...so that the original function can consider all subtrees as well.
(defun dired-directory-changed-p (dirname)
(or (dired-directory-changed-p--compat dirname (visited-file-modtime))
(seq-some
(lambda (ov)
(dired-directory-changed-p--compat
(overlay-get ov 'dired-subtree-name)
(overlay-get ov 'dired-subtree-modtime)))
dired-subtree-overlays)))

(provide 'dired-subtree)

;;; dired-subtree.el ends here