ema2159 / centaur-tabs

Emacs plugin aiming to become an aesthetic, modern looking tabs plugin
GNU General Public License v3.0
739 stars 50 forks source link

Tabs don't show properly when running from emacsclient #127

Open nixin72 opened 3 years ago

nixin72 commented 3 years ago

I use systemctl to start an Emacs server running as a daemon, and then whenever I open Emacs I use emacsclient. However, when I use emacsclient, centaur-tabs doesn't seem to display properly.

Without changing my config at all, here's centaur-tabs when using emacsclient image And here's it using regular Emacs. image

If I try disabling centaur-tabs-mode and re-enabling it, it doesn't make a difference, I just can't seem to get it to work using emacsclient.

ema2159 commented 3 years ago

I'm aware of this. PR #122 should fix this, but I'm yet to review it.

nixin72 commented 3 years ago

Oh, my bad, I didn't see that! I looked at the open issues to see if there was anything about this, but didn't look for open PRs.

I'll switch to that branch in the meantime, thank you so much!

ema2159 commented 3 years ago

Please don't hesitate to tell the PR author about any problems that may arise!

cloudnine commented 3 years ago

Your client mode issue might be related to the daemon launching in the terminal. You could test that by reloading your init from the client. If that fixes it, you would only need to isolate the code that isn't initializing and put it in a function that evaluates when the client launches, e.g. emacsclient.exe -c -n -a "" -e '(your-custom-function).'

In other news, just now explore centaur-tabs. Is there a quick way I missed to gather select buffers into a group?

vpcano commented 3 years ago

I also use emacsclient and when I opened a new client centaur-tabs-set-bar and centaur-tabs-show-navigation-buttons didn't work. I ended solving it by enabling centaur-tabs-mode on server-after-make-frame-hook: (add-hook 'server-after-make-frame-hook 'centaur-tabs-mode) Hope this helps solving your issue!

jhilker98 commented 3 years ago

I'm also having this issue. I've used your hook @vpcano and it doesn't work for me

MoritzMaxeiner commented 3 years ago

I've updated #122 and it now works for me. CORRECTION: My issues, which do not include the issue described by OP, appear to be fixed by it.

If you start the daemon mode without display graphics, load centaur-tabs, and then later connect with a frame that is display graphics capable, some faces may not have been setup correctly, though. I don't think that is a centaur-tabs bug strictly speaking, but I'm not sure, so I haven't included the fix for that in my PR.

One way to work around that is to enable centaur-tabs like this (somewhere in one's init.el):

;; Enable centaur-tabs without faulty theming in daemon mode.
(if (not (daemonp))
     (centaur-tabs-mode)

  (defun centaur-tabs-daemon-mode (frame)
     (unless (and (featurep 'centaur-tabs) (centaur-tabs-mode-on-p))
        (run-at-time nil nil (lambda () (centaur-tabs-mode)))))
  (add-hook 'after-make-frame-functions #'centaur-tabs-daemon-mode))

Note the run-at-time with immediate timeout: Without that delay until "first idle", the faces may still be broken (and themes may look wrong).

c02y commented 3 years ago

I've updated #122 and ~it now works for me.~ CORRECTION: My issues, which do not include the issue described by OP, appear to be fixed by it.

If you start the daemon mode without display graphics, load centaur-tabs, and then later connect with a frame that is display graphics capable, some faces may not have been setup correctly, though. I don't think that is a centaur-tabs bug strictly speaking, but I'm not sure, so I haven't included the fix for that in my PR.

One way to work around that is to enable centaur-tabs like this (somewhere in one's init.el):

;; Enable centaur-tabs without faulty theming in daemon mode.
(if (not (daemonp))
   (centaur-tabs-mode)

  (defun centaur-tabs-daemon-mode (frame)
   (unless (and (featurep 'centaur-tabs) (centaur-tabs-mode-on-p))
      (run-at-time nil nil (lambda () (centaur-tabs-mode)))))
  (add-hook 'after-make-frame-functions #'centaur-tabs-daemon-mode))

Note the run-at-time with immediate timeout: Without that delay until "first idle", the faces may still be broken (and themes may look wrong).

Not work.

c02y commented 3 years ago

The problem is centaur-tabs-set-bar, if it is left, then the whole tab bar will be empty.

Besides I'm using Spaemacs, under or over will not work at all(https://github.com/ema2159/centaur-tabs/issues/86).

lebensterben commented 2 years ago

I confirm the bug as described by @c02y

uskebasi commented 2 years ago

I solved the problem by applying a "dirty hack", waiting for a fix. I added these lines of code to my init.el file (defun tdr/fix-centaur-tabs () (centaur-tabs-mode -1) (centaur-tabs-mode) (centaur-tabs-headline-match)

) (if (daemonp) (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame (tdr/fix-centaur-tabs))) (tdr/fix-centaur-tabs)) )

Each time a new frame is ceated, centaur-tabs-mode is switched off and switched on again. No issue so far. I hope this may be useful to other users

dusanx commented 1 year ago

As none of suggested hacks work for me, fix for this problem would be greatly appreciated. Thank you.

ramuyk commented 9 months ago

Well, the workaround that solved the issue for me was restarting centaur tabs all the times that I focus on an emacs window:

(defun tdr/fix-centaur-tabs ()
  "Reset Centaur Tabs."
  (centaur-tabs-mode -1) ; Disable Centaur Tabs
  (centaur-tabs-mode 1)  ; Re-enable Centaur Tabs
  (centaur-tabs-headline-match)) ; Update tabs

(add-hook 'focus-in-hook 'tdr/fix-centaur-tabs)
dusanx commented 9 months ago

Thanks @ramuyk , that snippet seems to work well, if I spot anything wrong I'll report here.

ahan98 commented 8 months ago

None of the above proposed solutions worked for me either. In case it helps anyone, the following snippet fixes the rendering issue and is compatible with emacs and emacsclient.

(use-package centaur-tabs
  :custom
  (centaur-tabs-style "bar")
  (centaur-tabs-set-bar 'left)
  ;; other settings here
  :init
  (if (daemonp)
      (add-hook 'server-after-make-frame-hook 'centaur-tabs-mode)
    (add-hook 'after-init-hook 'centaur-tabs-mode))
  )

The tricky thing is that, as in the sample configuration in the repo's README.org, :demand is needed so that the tabs are displayed after the frame is initialized. But, :demand broke compatibility with emacsclient for me. I encountered some other quirks too, but the TLDR is that the above snippet handled those quirks (for example, in emacs, the scratch buffer icon would prematurely display the ELisp icon before updating to the Lisp Interaction icon), whereas previous attempts involving different combinations of :config, :init, and hooks broke compatibility with emacsclient, emacs, or both.

Lastly, note that I only needed the above workaround when centaur-tabs-set-bar was set to 'left. For 'over or 'under, a typical configuration such as below suffices:

(use-package centaur-tabs
  :demand
  :custom
  (centaur-tabs-style "bar")
  (centaur-tabs-set-bar 'over)
  ;; (x-underline-at-descent-line t) ;; for 'under
  ;; other settings here
  :config
  (centaur-tabs-mode)
  )