From e4fbdda8edd37e6ed1c1792432702280438b4b21 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 26 Sep 2025 01:04:27 +0200 Subject: [PATCH] [Misc] hide .jj directories by default. This commit adds the equivalent of `treemacs-hide-dot-git-directory` for jujutsu repositories. The new `treemacs-hide-dot-jj-directory` behaves almost the same way as `treemacs-hide-dot-git-directory` does, except it hides `.jj` directories instead of `.git` directories. --- Changelog.org | 1 + README.org | 2 ++ src/elisp/treemacs-core-utils.el | 5 ++++- src/elisp/treemacs-customization.el | 7 +++++++ test/treemacs-test.el | 9 ++++++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Changelog.org b/Changelog.org index 4953038e..d94ea7a0 100644 --- a/Changelog.org +++ b/Changelog.org @@ -6,6 +6,7 @@ *** Added ~treemacs-buffer-name-function~ *** Added ~treemacs-file-follow-ignore-functions~ *** Added ~treemacs-buffer-name-prefix~ +*** Added ~treemacs-hide-dot-jj-directory~ ** v3.1 - Deprecated ~treemacs-window-background-color~ in favour of ~treemacs-window-background-face~ and ~treemacs-hl-line-face~ diff --git a/README.org b/README.org index 502b25f7..2d6bf59c 100644 --- a/README.org +++ b/README.org @@ -471,6 +471,7 @@ discoverability. treemacs-goto-tag-strategy 'refetch-index treemacs-header-scroll-indicators '(nil . "^^^^^^") treemacs-hide-dot-git-directory t + treemacs-hide-dot-jj-directory t treemacs-indentation 2 treemacs-indentation-string " " treemacs-is-never-other-window nil @@ -641,6 +642,7 @@ Treemacs offers the following configuration options (~describe-variable~ will us | treemacs-find-workspace-method | 'find-for-file-or-pick-first | Determines how treemacs selects the workspace when it first starts. | | treemacs-header-scroll-indicators | '(nil . "^^^^^^") | Indicators used for ~treemacs-indicate-top-scroll-mode~. | | treemacs-hide-dot-git-directory | t | Indicates whether ~.git~ directories should always be hidden. | +| treemacs-hide-dot-jj-directory | t | Indicates whether ~.jj~ directories should always be hidden. | | treemacs-project-follow-into-home | nil | Indicates whether ~treemacs-project-follow-mode~ can follow into the $HOME directory. | | treemacs-move-files-by-mouse-dragging | t | When non-nil treemacs will move files by dragging with your mouse inside treemacs. | | treemacs-buffer-name-function | #'treemacs-default-buffer-name | Determines the names of treemacs buffers. | diff --git a/src/elisp/treemacs-core-utils.el b/src/elisp/treemacs-core-utils.el index ceab49c8..c1149ce1 100644 --- a/src/elisp/treemacs-core-utils.el +++ b/src/elisp/treemacs-core-utils.el @@ -1034,7 +1034,8 @@ Will return t when FILE 3) ends with \"~\" (backup files) 4) is surrounded with \"#\" (auto save files) 5) is \".git\" (see also `treemacs-hide-dot-git-directory') -6) is \".\" or \"..\" (default dirs)" +6) is \".jj\" (see also `treemacs-hide-dot-jj-directory') +7) is \".\" or \"..\" (default dirs)" (declare (side-effect-free t) (pure t)) (inline-letevals (file) (inline-quote @@ -1046,6 +1047,8 @@ Will return t when FILE (string-equal ,file "..") (and treemacs-hide-dot-git-directory (string-equal ,file ".git")) + (and treemacs-hide-dot-jj-directory + (string-equal ,file ".jj")) (string-prefix-p "flycheck_" ,file)))))) (define-inline treemacs--mac-ignore-file-predicate (file _) diff --git a/src/elisp/treemacs-customization.el b/src/elisp/treemacs-customization.el index 63ded878..d285e382 100644 --- a/src/elisp/treemacs-customization.el +++ b/src/elisp/treemacs-customization.el @@ -328,6 +328,13 @@ of `treemacs-toggle-show-dotfiles'." :type 'boolean :group 'treemacs) +(defcustom treemacs-hide-dot-jj-directory t + "Indicates whether the .jj directory should be hidden. +When this is non-nil the .jj dir will be hidden regardless of current setting +of `treemacs-toggle-show-dotfiles'." + :type 'boolean + :group 'treemacs) + (defcustom treemacs-sorting 'alphabetic-asc "Indicates how treemacs will sort its files and directories. Files will still always be shown after directories. diff --git a/test/treemacs-test.el b/test/treemacs-test.el index 3fd69446..e49b5070 100644 --- a/test/treemacs-test.el +++ b/test/treemacs-test.el @@ -160,7 +160,11 @@ (it "Accepts .git when it is not hidden" (-let [treemacs-hide-dot-git-directory nil] - (expect (treemacs--reject-ignored-files "~/A/B/C/.git") :to-be t)))) + (expect (treemacs--reject-ignored-files "~/A/B/C/.git") :to-be t))) + + (it "Accepts .jj when it is not hidden" + (-let [treemacs-hide-dot-jj-directory nil] + (expect (treemacs--reject-ignored-files "~/A/B/C/.jj") :to-be t)))) (describe "Rejecting" @@ -229,6 +233,9 @@ (it "Rejects .git" (expect (treemacs--reject-ignored-and-dotfiles "~/A/B/C/.git") :to-be nil)) + (it "Rejects .jj" + (expect (treemacs--reject-ignored-and-dotfiles "~/A/B/C/.jj") :to-be nil)) + (it "Rejects dot" (expect (treemacs--reject-ignored-and-dotfiles ".") :to-be nil))