1
votes

I'm using tabbar to define groups of files. Some are in the "Emacs buffer" group, others are in the "Dired" group and all others, ATM, are in the "User buffer" group.

I would like to add another group for when I'm using the agenda files - Instead of having the files all appear in the "User buffer" and litter my tabs view, I would like them to appear in a destined group called "Agenda buffers". How could that be done?

At the moment this is my configuration:

(defun tabbar-buffer-groups ()
  "Return the list of group names the current buffer belongs to.
This function is a custom function for tabbar-mode's tabbar-buffer-groups.
This function group all buffers into 3 groups:
Those Dired, those user buffer, and those emacs buffer.
Emacs buffer are those starting with “*”."
  (list
   (cond
    ((string-equal "*" (substring (buffer-name) 0 1)) "Emacs Buffer")
    ((eq major-mode 'dired-mode) "Dired")
    ((eq major-mode 'sr-mode) "Dired")
    (t "User Buffer")
    )))

(setq tabbar-buffer-groups-function 'tabbar-buffer-groups)
1
What are agenda files? org files, the *Org Agenda* buffer? - Nicolas Dudebout
All files in org-agenda-files list. - Devon Ville
Comment: better use (derived-mode-p 'dired-mode) instead of (eq major-mode 'dired-mode). - Stefan
Thanks. Can I also somehow combine dired-mode and sr-mode in the same rule? - Devon Ville

1 Answers

2
votes

Add a condition to the function as follows:

(defun tabbar-buffer-groups ()
  "Return the list of group names the current buffer belongs to.
This function is a custom function for tabbar-mode's tabbar-buffer-groups.
This function group all buffers into 3 groups:
Those Dired, those user buffer, and those emacs buffer.
Emacs buffer are those starting with “*”."
  (list
   (cond
    ((string-equal "*" (substring (buffer-name) 0 1)) "Emacs Buffer")
    ((member (buffer-file-name) (mapcar 'expand-file-name org-agenda-files)) "Agenda")
    ((eq major-mode 'dired-mode) "Dired")
    ((eq major-mode 'sr-mode) "Dired")
    (t "User Buffer")
    )))