Skip to content

Comments

diff-hl-dired: Handle nested file paths#270

Open
rynffoll wants to merge 1 commit intodgutov:masterfrom
rynffoll:dired-nested-paths
Open

diff-hl-dired: Handle nested file paths#270
rynffoll wants to merge 1 commit intodgutov:masterfrom
rynffoll:dired-nested-paths

Conversation

@rynffoll
Copy link
Contributor

@rynffoll rynffoll commented Feb 8, 2026

I've made that changes to integrate diff-hl-dired with dired-subtree

Some details how it works before and how it'll work after

context:

We have some changes by paths:

go.mod
go.sum
cmd/service/main.go

before: highlight only first level
image

after: highlight first and nested paths
image

Notes

For better integration with dired-subree we can add this hook:

(add-hook 'dired-subtree-after-insert-hook #'diff-hl-dired-update)

@rynffoll
Copy link
Contributor Author

rynffoll commented Feb 8, 2026

I've tried to add hook:

(add-hook 'dired-subtree-after-insert-hook #'diff-hl-dired-update)

But I got an error:

error in process sentinel: vc-exec-after: Unexpected process state

When dired-subtree expands a subdirectory, diff-hl-dired-update is called while a previous VC process is still running. The existing code calls kill-process, which triggers the VC sentinel (vc-exec-after) with an unexpected process state.

I'm not an elisp expert, but replacing kill-process with delete-process seems to fix this - would that be the correct approach here?

@rynffoll rynffoll marked this pull request as draft February 9, 2026 16:43
- Support multi-level nested paths in VC status (e.g. a/b/c.txt)
- Debounce concurrent VC process calls with pending flag
- Move diff-hl-dired-clear to diff-hl-dired-highlight-items to avoid flicker
- Pass basename and full path to dired-goto-file-1 for nested entries
@rynffoll
Copy link
Contributor Author

rynffoll commented Feb 14, 2026

I've tried to add hook:

(add-hook 'dired-subtree-after-insert-hook #'diff-hl-dired-update)

But I got an error:

error in process sentinel: vc-exec-after: Unexpected process state

When dired-subtree expands a subdirectory, diff-hl-dired-update is called while a previous VC process is still running. The existing code calls kill-process, which triggers the VC sentinel (vc-exec-after) with an unexpected process state.

I'm not an elisp expert, but replacing kill-process with delete-process seems to fix this - would that be the correct approach here?

Resolved by debouncing instead of killing the process. When diff-hl-dired-update is called while a VC process is already running, it sets a
diff-hl-dired--pending flag and returns early. When the running process completes, it checks the flag and schedules a retry via run-at-time. This way N concurrent calls collapse into a single retry after the current process finishes.

Also moved diff-hl-dired-clear from diff-hl-dired-update to diff-hl-dired-highlight-items - clearing overlays right before redrawing avoids the flicker window between clear and async callback.

@rynffoll rynffoll marked this pull request as ready for review February 14, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant