@@ -108,9 +108,8 @@ status indicators."
108108 (diff-hl-dired-status-files
109109 backend def-dir
110110 (when diff-hl-dired-extra-indicators
111- (cl-loop for file in (directory-files def-dir)
112- unless (member file '(" ." " .." " .hg" ))
113- collect file))
111+ (with-current-buffer buffer
112+ (diff-hl-dired-nondirectory-files)))
114113 (lambda (entries &optional more-to-come )
115114 (when (buffer-live-p buffer)
116115 (with-current-buffer buffer
@@ -141,9 +140,63 @@ status indicators."
141140 )))))
142141
143142(defun diff-hl-dired-status-files (backend dir files update-function )
144- " Using version control BACKEND, return list of (FILE STATE EXTRA) entries
145- for DIR containing FILES. Call UPDATE-FUNCTION as entries are added."
146- (vc-call-backend backend 'dir-status-files dir files update-function))
143+ " Using VC BACKEND, fetch list of (FILE STATE EXTRA) entries for DIR.
144+ Call UPDATE-FUNCTION as entries are added."
145+ (vc-call-backend
146+ backend 'dir-status-files
147+ dir nil
148+ (lambda (entries &optional more-to-come )
149+ (if (or more-to-come
150+ (not diff-hl-dired-extra-indicators))
151+ (funcall update-function entries more-to-come)
152+ (diff-hl-dir-status-ignored-files
153+ backend
154+ dir
155+ files
156+ (lambda (ignored-entries &optional more-to-come )
157+ (funcall update-function ignored-entries t )
158+ (unless more-to-come
159+ (funcall update-function entries nil ))))
160+ ))))
161+
162+ (defun diff-hl-dired-nondirectory-files ()
163+ (cl-mapcan
164+ (lambda (entry )
165+ (let* ((dir (file-relative-name (car entry)))
166+ (all (file-name-all-completions " " dir))
167+ res)
168+ (dolist (file all)
169+ (unless (directory-name-p file)
170+ (push
171+ (if (equal dir " ./" )
172+ file
173+ (concat dir file))
174+ res)))
175+ res))
176+ dired-subdir-alist))
177+
178+ (defun diff-hl-dir-status-ignored-files (backend dir files update-function )
179+ (cond
180+ ((eq backend 'Git )
181+ (vc-git-dir-status-goto-stage
182+ (make-vc-git-dir-status-state :stage 'ls-files-ignored
183+ :files files
184+ :update-function update-function)))
185+ ((eq backend 'Hg )
186+ (let ((default-directory dir))
187+ (apply #'vc-hg-command '(t nil ) 'async files
188+ " status" " -i"
189+ (if (version<= " 4.2" (vc-hg--program-version))
190+ '(" --config" " commands.status.relative=1" )
191+ '(" re:" " -I" " ." ))))
192+ (vc-run-delayed-success 0
193+ (vc-hg-after-dir-status update-function)))
194+ ; ; No specialized solution for "list only ignored state", list all.
195+ ; ; If the backend doesn't use several process calls (like Git), the
196+ ; ; difference should be trivial.
197+ (t
198+ (vc-call-backend backend 'dir-status-files dir files
199+ update-function))))
147200
148201(defun diff-hl-dired-highlight-items (alist )
149202 " Highlight ALIST containing (FILE . TYPE) elements."
0 commit comments