Add ibuffer layer

This commit is contained in:
Aleksandr Guljajev 2015-04-20 19:44:44 +02:00 committed by syl20bnr
parent 56d028c7a7
commit 80a134c7e8
4 changed files with 115 additions and 0 deletions

18
contrib/ibuffer/config.el Normal file
View file

@ -0,0 +1,18 @@
;;; config.el --- Auto-completion configuration File for Spacemacs
;;
;; Copyright (c) 2012-2014 Aleksandr Guljajev
;; Copyright (c) 2014-2015 Aleksandr Guljajev & Contributors
;;
;; Author: Aleksandr Guljajev <gulj.aleks@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defvar ibuffer-group-by-major-mode t
"If non nil ibuffer will start with buffers grouped by major mode.")
(defvar ibuffer-group-by-projectile nil
"If non nil ibuffer will start with buffers grouped by projects.
Will be ignored if ibuffer-group-by-major-mode is non nil")

42
contrib/ibuffer/funcs.el Normal file
View file

@ -0,0 +1,42 @@
;;; funcs.el --- Ansible Layer extensions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2015 Aleksandr Guljajev & Contributors
;;
;; Author: Aleksandr Guljajev <gulj.aleks@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun ibuffer/get-major-modes-ibuff-rules-list (mm-list result-list)
(if mm-list
(let* ((cur-mm (car mm-list))
(next-res-list-el `(,(symbol-name cur-mm) (mode . ,cur-mm))))
(ibuffer/get-major-modes-ibuff-rules-list (cdr mm-list) (cons next-res-list-el result-list)))
result-list))
(defun ibuffer/get-major-modes-list ()
(mapcar
(function (lambda (buffer) (buffer-local-value 'major-mode (get-buffer buffer))))
(buffer-list (selected-frame))))
(defun ibuffer/create-buffs-group ()
(interactive)
(let* ((ignore-modes '(Buffer-menu-mode
compilation-mode
minibuffer-inactive-mode
ibuffer-mode
magit-process-mode
messages-buffer-mode
fundamental-mode
completion-list-mode
help-mode
Info-mode))
(cur-bufs (list (cons "Home"
(ibuffer/get-major-modes-ibuff-rules-list
(cl-set-difference
(remove-duplicates (ibuffer/get-major-modes-list)) ignore-modes) '())))))
(setq ibuffer-saved-filter-groups cur-bufs)
(ibuffer-switch-to-saved-filter-groups "Home")))

View file

@ -0,0 +1,53 @@
;;; packages.el --- ibuffer Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Aleksandr Guljajev & Contributors
;;
;; Author: Sylvain Benner <aleksandr.guljajev@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
;; List of all packages to install and/or initialize. Built-in packages
;; which require an initialization must be listed explicitly in the list.
(defvar ibuffer-packages
'(
cl
ibuffer
ibuffer-projectile
))
(defun init-buff-leader ()
(evilify ibuffer-mode ibuffer-mode-map)
(evil-leader/set-key
"B" 'ibuffer))
(defun ibuffer/init-ibuffer()
(use-package ibuffer
:defer t
:init
(progn
(init-buff-leader)
(if ibuffer-group-by-major-mode
(add-hook 'ibuffer-hook 'ibuffer/create-buffs-group))
)))
(defun ibuffer/init-ibuffer-projectile()
(use-package ibuffer-projectile
:defer t
:init
(progn
(init-buff-leader)
(if ibuffer-group-by-projectile
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-projectile-set-filter-groups)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))))))
;;
;; Often the body of an initialize function uses `use-package'
;; For more info on `use-package', see readme:
;; https://github.com/jwiegley/use-package

View file

@ -480,3 +480,5 @@ otherwise it is scaled down."
("=" spacemacs/reset-font-size)) ("=" spacemacs/reset-font-size))
;; end of Text Manipulation Micro State ;; end of Text Manipulation Micro State
;; ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)