Created
March 30, 2012 09:33
-
-
Save bamanzi/2250340 to your computer and use it in GitHub Desktop.
[emacs] Use frame to group buffers (similar to perspective feature)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; use `frame-bufs.el' to mimic perspective feature | |
(idle-require 'frame-bufs) | |
(defun frame-bufs-switch-buffer () | |
"Switch buffer, within buffers associated with current frame (`frame-bufs-buffer-list')" | |
(interactive) | |
(if (and (fboundp 'frame-bufs-mode) | |
frame-bufs-mode) | |
(let* ( (buffers (mapcar 'buffer-name (frame-bufs-buffer-list (selected-frame)))) | |
(buffers-rotated (append (cdr buffers) (cons (car buffers) nil))) | |
(target (ido-completing-read "Buffer: " buffers-rotated)) ) | |
(switch-to-buffer target)) | |
(call-interactively 'ido-switch-buffer))) | |
(eval-after-load "frame-bufs" | |
`(progn | |
(add-hook 'frame-bufs-mode-on-hook #'(lambda () | |
(global-set-key (kbd "C-x b") 'frame-bufs-switch-buffer) | |
(global-set-key (kbd "C-x B") 'ido-switch-buffer))) | |
(add-hook 'frame-bufs-mode-off-hook #'(lambda () | |
(global-set-key (kbd "C-x b") 'ido-switch-buffer))) | |
)) | |
;;and you need to modify your 'tabbar-buffer-groups-function' | |
(defun tabbar-ruler-tabbar-buffer-groups () | |
"Return the list of group names the current buffer belongs to. | |
Return a list of one element based on major mode." | |
(setq last-tabbar-ruler-tabbar-buffer-groups | |
(list | |
(cond | |
((= (aref (buffer-name) 0) ?*) | |
"Utils") | |
(t | |
"Files" | |
)))) | |
(if (and (fboundp 'frame-bufs-mode) | |
frame-bufs-mode | |
(memq (current-buffer) (frame-bufs-buffer-list (selected-frame)))) | |
(symbol-value 'last-tabbar-ruler-tabbar-buffer-groups))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment