Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start Treemacs with prog-mode? #1091

Open
JPRuehmann opened this issue Feb 23, 2024 · 5 comments
Open

Start Treemacs with prog-mode? #1091

JPRuehmann opened this issue Feb 23, 2024 · 5 comments

Comments

@JPRuehmann
Copy link

Hello
I try to find a Way to open treemacs automaticaly with prog-mode.
I've tried :hook (prog-mode . treemacs) and :init (add-hook 'pog-mode-hook 'treemacs.
But both did not work, instead a second Window (scratch) with treemacs gets opened beside the dashboard at startup.

My Goal is to get treemacs started at opening a project with projectile.
Thanks,

Copy link

stale bot commented Apr 25, 2024

This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).

@stale stale bot added the stale label Apr 25, 2024
@Alexander-Miller
Copy link
Owner

I don' think a general hook is the right approach, as that means you'd call treemacs for every new prog buffer, especially the ones you don't expect to derive from prog-mode. You'd need to add some extra config to make sure treemacs opens only once.

It might be easier to integrate treemacs with your projectile workflow - how exactly do you open your projects?

@JPRuehmann
Copy link
Author

Via click on the Link in the Dashboard.

@Alexander-Miller
Copy link
Owner

In that case you need to find out what function this click invokes. Maybe there is already a hook for it, maybe you need to use advice. Either way you need something like this:

(defun open-treemacs-after-click ()
  (save-selected-window (treemacs-select-window)))
(add-hook 'dashboard-after-click-hook #'open-treemacs-after-click)
(advice-add #'dashboard-click :after #'open-treemacs-after-click)

Copy link

stale bot commented Jul 10, 2024

This issue has been automatically marked as stale because it has not had recent activity (this bot only works as a reminder, it will not close issues).

@stale stale bot added the stale label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants