Treemacs: How to show treemacs automatically when emacsclient opens a frame?

Created on 13 Feb 2020  路  6Comments  路  Source: Alexander-Miller/treemacs

More related to emacsclient than treemacs,
but perhaps others might search here as well.

Enhancement

Most helpful comment

(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.

All 6 comments

(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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alexander-Miller picture Alexander-Miller  路  12Comments

Compro-Prasad picture Compro-Prasad  路  12Comments

ianpan870102 picture ianpan870102  路  4Comments

zentetsukenz picture zentetsukenz  路  12Comments

semla picture semla  路  12Comments