@@ -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,64 @@ 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+ (completion-regexp-list '(" [^/]\\ '" ))
167+ (all (file-name-all-completions " " dir))
168+ res)
169+ (dolist (file all)
170+ (unless (directory-name-p file)
171+ (push
172+ (if (equal dir " ./" )
173+ file
174+ (concat dir file))
175+ res)))
176+ res))
177+ dired-subdir-alist))
178+
179+ (defun diff-hl-dir-status-ignored-files (backend dir files update-function )
180+ (cond
181+ ((eq backend 'Git )
182+ (vc-git-dir-status-goto-stage
183+ (make-vc-git-dir-status-state :stage 'ls-files-ignored
184+ :files files
185+ :update-function update-function)))
186+ ((eq backend 'Hg )
187+ (let ((default-directory dir))
188+ (apply #'vc-hg-command '(t nil ) 'async files
189+ " status" " -i"
190+ (if (version<= " 4.2" (vc-hg--program-version))
191+ '(" --config" " commands.status.relative=1" )
192+ '(" re:" " -I" " ." ))))
193+ (vc-run-delayed-success 0
194+ (vc-hg-after-dir-status update-function)))
195+ ; ; No specialized solution for "list only ignored state", list all.
196+ ; ; If the backend doesn't use several process calls (like Git), the
197+ ; ; difference should be trivial.
198+ (t
199+ (vc-call-backend backend 'dir-status-files dir files
200+ update-function))))
147201
148202(defun diff-hl-dired-highlight-items (alist )
149203 " Highlight ALIST containing (FILE . TYPE) elements."
0 commit comments