Alexander-Miller / treemacs

GNU General Public License v3.0
2.11k stars 154 forks source link

Open treemacs on startup in every tab-frame (tab-bar-mode) #920

Open darim1 opened 2 years ago

darim1 commented 2 years ago

I've added a startup hook in order to auto-run treemacs:

(add-hook 'emacs-startup-hook 'treemacs)

This works fine when using a single tab of tab-bar-mode. For multiple tabs, however, this hook would only launch treemacs on the selected tab. For the remaining tabs treemacs has to be launched manually.

What can I do in order to run treemacs on every tab-frame?

Alexander-Miller commented 2 years ago

I don't use tabs myself. Can you give me an example for a config with multiple tabs?

darim1 commented 2 years ago

Sorry fo the late reply!

Please proceed as follows:

  1. Enable tab-bar-mode. This will allow you to switch between multiple collections of open buffers.
  2. Add second tab.
  3. Launch treemacs
  4. Observe, that you can switch tabs. Treemacs will be visible for both tabs. In addition it will follow by project, if you have follow-mode enabled. Nice!
  5. Enable desktop-mode.
  6. Close your emacs session. If set up, this will store the complete buffer setup, i.e. also both tabs from tab-bar-mode including the associated buffers.
  7. Relaunch emacs.
  8. Observe that treemacs was enabled on the first vvisible tab, but not on the second tab.

Is this thourough enough or do you need additional information?

Thanks!

Alexander-Miller commented 2 years ago

Observe that treemacs was enabled on the first vvisible tab, but not on the second tab.

Thanks to treemacs' scoping mechanism restoring treemacs with desktop-mode is not as simple as popping up a new buffer. I have to wait until all scopes, be it frames or tabs, are restored and then assign them their individual treemacs buffers. The problem is that buffers are loaded before frames are (and probably tabs as well). Working around that would be a hack, adding in lazy desktop restoration and it turns into just pain.

The point is: treemacs should not be enabled in any tab. It is explicitly set up to not be saved by desktop-mode. The expected behavior is that you need to call treemacs manually after your tabs are restored or add its start to your config.

darim1 commented 2 years ago

OK, thanks for the thourough explanation! Once I got used to the behavior, it's not really an issue anymore. Instead tab-bar, treemacs as well as desktop mode integrate pretty well.

IMO we can therefore close the issue. Thanks!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity.