From 3f66400d62cd5c3ceecf5ef6fbb7275e374afeb2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 16 Jul 2024 11:23:11 -0400 Subject: [PATCH] fix(treemacs): open last treemacs session if in $HOME or non-project `treemacs-add-and-display-current-project-exclusively' seems to confuse some people and please others when it is used in $HOME. To reduce confusion, SPC o p will now resume from the last session if default-directory isn't a valid project OR if it's $HOME. It will also emit a warning informing them of that. Fix: #7948 Amend: f9dfb7e92ad1 --- modules/ui/treemacs/autoload.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ui/treemacs/autoload.el b/modules/ui/treemacs/autoload.el index 06b397b0f..2713f1409 100644 --- a/modules/ui/treemacs/autoload.el +++ b/modules/ui/treemacs/autoload.el @@ -12,6 +12,8 @@ Use `treemacs' command for old functionality." (require 'treemacs) (pcase (treemacs-current-visibility) (`visible (delete-window (treemacs-get-local-window))) - (_ (if (treemacs--find-current-user-project) - (treemacs-add-and-display-current-project-exclusively) - (treemacs))))) + (_ (let ((project (treemacs--find-current-user-project))) + (if (and project (not (file-equal-p project "~"))) + (treemacs-add-and-display-current-project-exclusively) + (message "No valid project in current buffer; opening last treemacs session") + (treemacs))))))