thread314 / intuitive-tab-line-mode

GNU General Public License v3.0
21 stars 3 forks source link

initial buffer doesn't have a tab #6

Closed morgandavidson closed 1 year ago

morgandavidson commented 1 year ago

When my Emacs starts it automatically opens an org file:

(setq initial-buffer-choice "PATH/index.org")

Then index.org buffer doesn't have a tab. I have to do tab-line-switch-to-next-tab for its tab to appear.

Could the chosen initial buffer have a tab by default?

thread314 commented 1 year ago

The function intuitive-tab-line-load-initial-buffer-only will do this. I call it in my config after I load intuitive-tab-line, but I can see that it makes sense for this to be part of the package itself.

I'm made this change now, thanks for the suggestion.

morgandavidson commented 1 year ago

I upgraded intuitive-tab-line.el, but I have the same issue. When emacs starts, only two functions are available: intuitive-tab-line-shift-tab-left and intuitive-tab-line-shift-tab-right. Only using one of these makes the 7 others available.

thread314 commented 1 year ago

That is very strange, not the behaviour I get. :/

Are you setting initial-buffer-choice before you load intuitive-tab-line-mode?

As to why most functions aren't available after startup, this is really unusual. Can you share your config?

morgandavidson commented 1 year ago

Yes I'm setting initial-buffer-choice before loading intuitive-tab-line-mode. Here is how I configure intuitive-tab-line-mode:

  (use-package intuitive-tab-line
                      ;    :ensure nil
                      ;    :init (add-to-list 'load-path "~/.emacs.d/manual/")
    :load-path "~/.emacs.d/manual/"
    :custom
    (tab-line-tabs-function 'intuitive-tab-line-buffers-list)
    (tab-line-switch-cycling t)
    :config
    (global-tab-line-mode 1)
    (setq
     tab-line-new-button-show nil  ;; do not show add-new button
     tab-line-close-button-show nil  ;; do not show close button
     )
    :bind
    ("C-<prior>" . tab-line-switch-to-prev-tab)
    ("C-<iso-lefttab>" . tab-line-switch-to-prev-tab)
    ("C-<next>" . tab-line-switch-to-next-tab)
    ("C-<tab>" . tab-line-switch-to-next-tab)
    ("C-S-<prior>" . intuitive-tab-line-shift-tab-left)
    ("C-S-<next>" . intuitive-tab-line-shift-tab-right)
    ("C-c o h" . intuitive-tab-line-drop-tab)
    ("C-c o i" . intuitive-tab-line-manually-add-current-buffer-to-tab)
    )

Here is a link to my full init.

I had the same result with Emacs 28.2 and 29.0.91.

thread314 commented 1 year ago

Huh, ok I can replicate it now.

The issue is caused as soon as you bind keys inside the use-package call. As for why this is happening, I have no idea.

Simplest way to fix would be to bind keys outside the use-package call, as follows.

  (use-package intuitive-tab-line
                                          ;    :ensure nil
                                          ;    :init (add-to-list 'load-path "~/.emacs.d/manual/")
    :load-path "~/.emacs.d/manual/"
    :custom
    (tab-line-tabs-function 'intuitive-tab-line-buffers-list)
    (tab-line-switch-cycling t)
    :config
    (global-tab-line-mode 1)
    (setq
     tab-line-new-button-show nil  ;; do not show add-new button
     tab-line-close-button-show nil  ;; do not show close button
     ))

  (global-set-key (kbd "C-<prior>") 'tab-line-switch-to-prev-tab)
  (global-set-key (kbd "C-<iso-lefttab>") 'tab-line-switch-to-prev-tab)
  (global-set-key (kbd "C-<next>") 'tab-line-switch-to-next-tab)
  (global-set-key (kbd "C-<tab>") 'tab-line-switch-to-next-tab)
  (global-set-key (kbd "C-S-<prior>") 'intuitive-tab-line-shift-tab-left)
  (global-set-key (kbd "C-S-<next>") 'intuitive-tab-line-shift-tab-right)
  (global-set-key (kbd "C-c o h") 'intuitive-tab-line-drop-tab)
  (global-set-key (kbd "C-c o i") 'intuitive-tab-line-manually-add-current-buffer-to-tab)

I'll change the suggested config in the readme to match this.

morgandavidson commented 1 year ago

When I remove :bind, something strange happens. The initial buffer fonts are changed:

morgandavidson commented 1 year ago

My mistake was to use global-set-key inside use-package. This issue not only arises with :bind but with key binding inside use-package in general. This comes from tab-line.el. I will try to report the bug to the maintainer.

morgandavidson commented 1 year ago

Here is how to fix the issue while keeping :bind:

(use-package intuitive-tab-line                                                        
  :defer 0                                                                             
  :load-path "~/.emacs.d/manual/"                                                      
  :config                                                                              
  (global-tab-line-mode 1)                                                             
  :custom                                                                              
  (tab-line-tabs-function 'intuitive-tab-line-buffers-list)                            
  (tab-line-switch-cycling t)                                                          
  (tab-line-new-button-show nil)    ;; do not show add-new button                      
  (tab-line-close-button-show nil)  ;; do not show close button                        
  :bind                                                                                
  ("C-<prior>" . tab-line-switch-to-prev-tab)                                          
  ("C-<iso-lefttab>" . tab-line-switch-to-prev-tab)                                    
  ("C-<next>" . tab-line-switch-to-next-tab)                                           
  ("C-<tab>" . tab-line-switch-to-next-tab)                                            
  ("C-S-<prior>" . intuitive-tab-line-shift-tab-left)                                  
  ("C-S-<next>" . intuitive-tab-line-shift-tab-right)                                  
  ("C-c o h" . intuitive-tab-line-drop-tab)                                            
  ("C-c o i" . intuitive-tab-line-manually-add-current-buffer-to-tab)                  
  )                                                                                    

I received the following answer from tab-line maintainer:

Due to idiosyncrasies of use-package you have to add `:defer nil`:

:defer Defer loading of a package -- this is implied when using
`:commands', `:bind', `:bind*', `:mode', `:magic', `:hook',
`:magic-fallback', or `:interpreter'. This can be an integer,
to force loading after N seconds of idle time, if the package
has not already been loaded.