Add configurable directory face mode for git status#1187
Open
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
Open
Add configurable directory face mode for git status#1187rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
rain-64 wants to merge 1 commit intoAlexander-Miller:masterfrom
Conversation
Parent directories of changed files were hardcoded to
treemacs-git-modified-face regardless of the children's actual git
status. For example, a directory containing only staged/added files
would show as "modified" instead of "added".
Introduce treemacs-git-directory-face-mode defcustom with three modes:
- modified (default): preserves existing behavior — directories always
get treemacs-git-modified-face.
- severity: uses a configurable hierarchy to pick the most severe child
status. The default hierarchy (highest to lowest) is:
conflict (U) > modified (M) > untracked (?) > added (A) > renamed (R)
Rationale: states requiring user action rank higher — conflicts block
merges, modified files represent a dirty working tree, untracked files
risk being left out of commits, while added/renamed files reflect
deliberate user actions. Customize via
treemacs-git-directory-face-severity-list.
- custom function: a user-provided function that receives the git-info
hash table for post-processing. The Python script resolves directory
faces using severity logic as a baseline; the custom function then runs
on the Emacs side to adjust the result. This means the function
operates on already-resolved severity faces, not raw status codes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
treemacs-git-modified-faceregardless of children's actual git status (e.g., a directory with only staged/added files showed as "modified")treemacs-git-directory-face-modedefcustom with three modes:modified(default, preserves existing behavior),severity(inherits highest-severity child status), and custom functiontreemacs-git-directory-face-severity-listdefcustom for configuring the severity hierarchyThe three modes
modified(default) — directories always gettreemacs-git-modified-face. This is the existing behavior; no user configuration changes are needed.severity— resolves directory faces using a severity hierarchy. When all children share the same status, the directory inherits that status. When children have mixed statuses, the highest-severity status wins. Default hierarchy (highest to lowest):The hierarchy is customizable via
treemacs-git-directory-face-severity-list.Custom function — a user-provided function that receives the git-info hash table for post-processing. The Python script resolves directory faces using severity logic as a baseline; the custom function then runs on the Emacs side to adjust the result (it operates on already-resolved severity faces, not raw status codes).
Files changed
src/elisp/treemacs-customization.el— new defcustom variablessrc/elisp/treemacs-async.el— helper function, pass mode to Python, custom function post-processingsrc/scripts/treemacs-git-status.py— two-pass directory resolution for severity modesrc/extra/treemacs-magit.el— pass mode arg, custom function post-processingBackward compatibility
Default mode is
modified, producing identical behavior to current code. No existing configuration breaks.Test plan
modifiedmode: verify directories showtreemacs-git-modified-face(unchanged behavior)severitymode:git addnew files only → parent directories showtreemacs-git-added-face; add a modified file → directory switches totreemacs-git-modified-face