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

hide tabs still can be selected #237

Open
goodboylqs opened this issue Jul 7, 2024 · 8 comments
Open

hide tabs still can be selected #237

goodboylqs opened this issue Jul 7, 2024 · 8 comments

Comments

@goodboylqs
Copy link

goodboylqs commented Jul 7, 2024

Mr.ema2159,thanks for your hardworking to create centaur-tabs.Recently I found that the hide tabs use centaur-tabs-forward/backward still can be selected which doesn't happen before,just like buffer eaf in my configuration is hided but it still can be selected use centaur-tabs-forward,it works very well before and my configuration hasn't change all the time.below is my configuration,please let me know if I make something wrong.

(use-package centaur-tabs
  :ensure t
  :demand
  :config
  (centaur-tabs-mode t)
  (centaur-tabs-headline-match)
  (centaur-tabs-group-by-projectile-project)
  (centaur-tabs-change-fonts "arial" 160)
  (setq centaur-tabs-style "wave"
        centaur-tabs-height 45
        centaur-tabs-set-modified-marker t
        centaur-tabs-show-navigation-buttons t)
  ;;(setq centaur-tabs-set-icons t)
  (setq centaur-tabs-plain-icons t)
  (setq centaur-tabs-gray-out-icons 'buffer)
  (setq centaur-tabs-set-bar 'under) 
  (setq centaur-tabs-set-close-button nil)
  (setq uniquify-separator "/")
  (setq uniquify-buffer-name-style 'forward)
  ;; :bind
  ;; ("C-b" . centaur-tabs-backward)
  ;; ("C-f" . centaur-tabs-forward)
  ;; ("C-c b" . centaur-tabs-backward-group)
  ;; ("C-c f" . centaur-tabs-forward-group)
  ;; ("C-c w" . kill-this-buffer)
  (defun centaur-tabs-hide-tab (x)
    "Do no to show buffer X in tabs."
    (let ((name (format "%s" x)))
      (or
       ;; Current window is not dedicated window.
       (window-dedicated-p (selected-window))
       ;; Buffer name not match below blacklist.
       (string-prefix-p "*epc" name)
       (string-prefix-p "*Calendar" name)     
       (string-prefix-p "*help" name)
       (string-prefix-p "*Help" name)
       (string-prefix-p "*mybuf" name)
       (string-prefix-p "*Compile-Log*" name)
       (string-prefix-p "*nov unzip*" name)
       (string-prefix-p "*Warning*" name)
       (string-prefix-p "*epc" name)
       (string-prefix-p "*helm" name)
       (string-prefix-p "*Helm" name)
       (string-prefix-p "*lsp" name)
       (string-prefix-p "*company" name)
       (string-prefix-p "*Flycheck" name)
       (string-prefix-p "*tramp" name)
       (string-prefix-p "*Mini" name)
       (string-prefix-p "*straight" name)
       (string-prefix-p "*temp" name)
       (string-prefix-p "*eaf" name)
       (string-prefix-p "*epc" name)
       (string-prefix-p "*popweb" name)
       (string-prefix-p "*httpd*" name)
       (string-prefix-p "emacs.org" name)
       (string-prefix-p "life.org" name)
       (string-prefix-p "work.org" name)
       (string-prefix-p "*popweb" name)
       (string-prefix-p "*clangd*" name)
       (string-prefix-p "*html-ls*" name)
       (string-prefix-p "*ts-ls*" name)
       (string-prefix-p "*blink-search" name)
       (string-prefix-p "*holo-layer" name)
       ;; Is not magit buffer.
       (and (string-prefix-p "magit" name)
            (not (file-name-extension name)))
       )
      )
    )
  )
@jcs090218
Copy link
Collaborator

Hmm... I may have break something. I'll look into it!

@goodboylqs
Copy link
Author

Mr.jcs090218,I have updated package to version 20240726,but the problem still exists....

@jcs090218
Copy link
Collaborator

Sorry, I was a little busy recently. I will try to look into it when I have time. 😓

@goodboylqs
Copy link
Author

thanks for your work Mrjcs090218,I mistakenly thought you had fixed the issue in your July 26 push.I didn't mean to rush you. I hope you can review this issue again when you are not busy

@jcs090218
Copy link
Collaborator

jcs090218 commented Sep 16, 2024

Sorry for the late reply!

Your config looks fine. Can you show me the steps to reproduce this with emacs -q? 🤔

Thanks!

@luiznux
Copy link

luiznux commented Oct 11, 2024

Hi! I have a different configuration than @goodboylqs , but I'm having the same problem.
I can reproduce this issue by following these steps:

  1. With this init.el:
(require 'package)

(setq package-archives '(("melpa" . "https://melpa.org/packages/")
                         ("gnu" . "https://elpa.gnu.org/packages/")))

(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(eval-when-compile
  (require 'use-package))

(setq use-package-always-ensure t
      use-package-always-defer t
      use-package-expand-minimally t)

(use-package magit)

(use-package evil
  :demand t
  :hook (after-init . evil-mode))

(use-package centaur-tabs
  :demand t
  :defines centaur-tabs-excluded-prefixes
  :commands (centaur-tabs-mode centaur-tabs-headline-match centaur-tabs-group-by-projectile-project)
  :init
  (setq centaur-tabs-style                    "box"
        centaur-tabs-height                   32
        centaur-tabs-set-bar                  'under
        centaur-tabs-set-icons                t
        centaur-tabs-show-new-tab-button      t
        centaur-tabs-set-modified-marker      t
        centaur-tabs-show-navigation-buttons  nil
        centaur-tabs-show-count               nil
        x-underline-at-descent-line           t)
  :config
  (centaur-tabs-mode)
  (centaur-tabs-headline-match)
  (centaur-tabs-group-by-projectile-project)
  (dolist
      (excluded-prefixes
       '( " *" "*Org Agenda*" "*Org Note*" "*Org Select*" "*Capture*" "*Calendar*" "*Flymake diagnostics" "*Kill Ring*"
          "*flycheck-posframe-buffer*" "*Shell Command Output*" "*dashboard*" "*Directory*" "*vterm*" "*compilation*"
          "magit:" "magit-" "*vc*"))
    (add-to-list 'centaur-tabs-excluded-prefixes excluded-prefixes)))
  1. Create a new directory, put this config on it and run emacs with emacs -q --init-directory "PATH" --load "PATH/init.el"
  2. Open any file versioned by git
  3. Press C-x g (magit-status)
  4. You'll see the "magit:" in the buffer bar
    image

If you also use the mouse scroll to switch between tabs, some tabs that shouldn't be listed appear, such as the completion minibuffer.

Some time ago, when I noticed that this behavior was happening, I tried to roll back some commits and test it again:

I hope this can help.

Thanks :)

@goodboylqs
Copy link
Author

Sorry for the late reply!

Your config looks fine. Can you show me the steps to reproduce this with emacs -q? 🤔

Thanks!

Thanks for reply!And I try to use emacs -q to reproduce the problem,I have these steps
step1:
using emacs -q start emacs and M-x load-file centaur-tabs-autoloads.el to load package
step2:
using C-x C-f open my config file and select config content of centaur-tabs,M-x eval-region to load config,M-x centaur-tabs-mode
my config sets buffer Help to be hidden,but I use centaur-tabs-forward to select buffer Help it still can be select
截图_选择区域_20241017145242
截图_emacs_20241017145306
I‘m not a programmer and I don't know if this is the right way to use emacs -q to reproduce the problem,I hope these steps can help.
Thanks again!

@djangoliv
Copy link

I have the same problem with this configuration:

(defun centaur-tabs-hide-tab (x)
        (let ((name (format "%s" x)))
          (or
           (string-prefix-p "*" name)
           (and (string-prefix-p "magit" name)
                (not (file-name-extension name)))
           )))

As @luiznux I am on the last commit that work as expected: c720296

My whole config:

 (use-package all-the-icons :straight t )
  (use-package centaur-tabs
    :straight (:host github :repo "ema2159/centaur-tabs")
    :defer 1
    :after all-the-icons
    :bind
    ("C-<prior>" . centaur-tabs-backward)
      ("C-<next>" . centaur-tabs-forward)
      ("C-S-<prior>" . centaur-tabs-move-current-tab-to-left)
      ("C-S-<next>" . centaur-tabs-move-current-tab-to-right)
      ("M-+" . centaur-tabs-backward-group)
      ("M--" . centaur-tabs-forward-group)
      :init
      (centaur-tabs-mode)
      (setq centaur-tabs-cycle-scope 'tabs)
      (setq centaur-tabs-set-modified-marker t)
      (setq centaur-tabs-icon-type 'all-the-icons)
      (setq centaur-tabs-gray-out-icons 'buffer)
      (setq centaur-tabs-set-icons t)
      :config
      (setq centaur-tabs-background-color (face-background 'default))
      (setq centaur-tabs-style "box")
      (setq centaur-tabs-set-bar 'over)
      (setq centaur-tabs-icon-scale-factor 0.8)
      ;; exclude
      (defun centaur-tabs-hide-tab (x)
        (let ((name (format "%s" x)))
          (or
           (string-prefix-p "*" name)
           (and (string-prefix-p "magit" name)
                (not (file-name-extension name)))
           )))
      ;; groups
      (defun centaur-tabs-buffer-groups ()
        (list
         (cond
          ((derived-mode-p 'prog-mode) "Editing")
          ((derived-mode-p 'dired-mode) "Dired")
          ((derived-mode-p 'image-mode) "Image")
          ((derived-mode-p 'nxml-mode) "nXml")
          ((derived-mode-p 'logview-mode) "Logs")
          ((derived-mode-p 'chatGPT) "Chatgpt")
          ((memq major-mode '(org-mode
                              org-agenda-clockreport-mode
                              org-src-mode
                              org-agenda-mode
                              org-beamer-mode
                              org-indent-mode
                              org-cdlatex-mode
                              org-agenda-log-mode
                              diary-mode))
           "OrgMode")
          ((derived-mode-p 'dired-mode)
           "Dired")
          ((memq major-mode '(csv-mode
                              text-mode
                              latex-mode
                              rst-mode
                              markdown-mode
                              fundamental-mode))
           "textMode")
          (t
           (centaur-tabs-get-group-name (current-buffer))))))
      )

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants