manateelazycat / awesome-tab

Emacs package to provide out-of-the-box configuration to use tabs.
384 stars 38 forks source link

Buffers/Files from the same project are being put in separate groups #115

Closed swarnendubiswas closed 2 years ago

swarnendubiswas commented 2 years ago

awesome-tab is placing buffers from the same project into different groups. For example, all the .el files in the .emacs.d are in one group, but the README.org and other .org files are in another group. This is counter-intuitive.

I am using Emacs 28.1 with the latest version of awesome-tab.

manateelazycat commented 2 years ago

please read https://github.com/manateelazycat/awesome-tab#grouprules

this can be custom

swarnendubiswas commented 2 years ago

I have set this. @manateelazycat Any suggestions?

(use-package awesome-tab
   :preface
   (defun sb/awesome-tab-buffer-groups ()
     (list
      (cond
       ((or (string-equal "*" (substring (buffer-name) 0 1))
            (memq major-mode '(magit-process-mode
                               magit-status-mode
                               magit-diff-mode
                               magit-log-mode
                               magit-file-mode
                               magit-blob-mode
                               magit-blame-mode
                               )))
        "Emacs")
       (t
        (awesome-tab-get-group-name (current-buffer))))))
   :straight (:type git :host github :repo "manateelazycat/awesome-tab")
   :hook
   (after-init-hook . awesome-tab-mode)
   :bind*
   (("M-<right>" . awesome-tab-forward-tab)
    ("M-<left>" . awesome-tab-backward-tab)
    ("M-]" . awesome-tab-ace-jump))
   :custom-face
   (awesome-tab-selected-face ((t (:inherit default :height 1.0))))
   (awesome-tab-unselected-face ((t (:inherit default :height 0.8))))
   :custom
   (awesome-tab-label-fixed-length 14)
   (awesome-tab-buffer-groups-function #'sb/awesome-tab-buffer-groups)
   (awesome-tab-cycle-scope 'groups))

However, org, .sh files are still grouped separately. What am I doing wrong?

swarnendubiswas commented 2 years ago

I have got my awesome-tab setup to work. The variable awesome-tab-buffer-groups-function is declared with defvar, and so customizing it with :custom in use-package will not work.

(use-package awesome-tab
  :preface
  (defun sb/awesome-tab-buffer-groups ()
    "`awesome-tab-buffer-groups' control buffers' group rules.
  Group awesome-tab with mode if buffer is derived from
  `eshell-mode' `emacs-lisp-mode' `dired-mode' `org-mode'
  `magit-mode'. All buffer name start with * will group to
  \"Emacs\". Other buffer group by `awesome-tab-get-group-name'
  with project name."
    (list
     (cond
      ((or (string-equal "*" (substring (buffer-name) 0 1))
           (memq major-mode '(magit-process-mode
                              magit-status-mode
                              magit-diff-mode
                              magit-log-mode
                              magit-file-mode
                              magit-blob-mode
                              magit-blame-mode
                              )))
       "Emacs")
      (t
       (awesome-tab-get-group-name (current-buffer))))))
  :straight
  (:type git :host github :repo "manateelazycat/awesome-tab")
  :hook (after-init-hook . awesome-tab-mode)
  :bind
  (("M-<right>" . awesome-tab-forward-tab)
   ("M-<left>" . awesome-tab-backward-tab)
   ("M-]" . awesome-tab-ace-jump))
  :custom-face
  (awesome-tab-selected-face ((t (:inherit default :height 1.0))))
  (awesome-tab-unselected-face ((t (:inherit default :height 0.8))))
  :custom
  (awesome-tab-label-fixed-length 14)
  (awesome-tab-cycle-scope 'tabs)
  :config
  ;; The variable is declared with a `defvar', so modifying it with `:custom' will not work.
  (setq awesome-tab-buffer-groups-function #'sb/awesome-tab-buffer-groups))