More related to emacsclient than treemacs,
but perhaps others might search here as well.
(add-hook 'after-make-frame-functions
(lambda (frame)
(run-with-timer
1 nil
(lambda ()
(with-selected-frame frame
(save-selected-window
(treemacs-select-window)))))))
It's a bit complicated because you need to run this after some other setup/compatibility code, so I'll package this up properly.
I only get
Error running timer: (void-variable frame)
any idea what might be wrong?
lexical-binding must be enabled.
That did it!
For others who don't know how to enable lexical binding:
Start your *.el file with
;;; -*- lexical-binding: t; -*-
That should be the default for all your code. You will be better off on every front when using lexical scope, it is faster and less error-prone https://nullprogram.com/blog/2016/12/22/
Yup, did that already everywhere.
I haven't seen it mentioned anywhere before though (just working with Emacs since 2 months)
Most helpful comment
It's a bit complicated because you need to run this after some other setup/compatibility code, so I'll package this up properly.