home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

config-buffers.el (3708B)


      1 ;;; config-buffers.el --- -*- lexical-binding: t; -*-
      2 ;;; Commentary:
      3 ;;; Buffer related configurations
      4 ;;; Code:
      5 
      6 (use-package savehist
      7   :unless noninteractive
      8   :init
      9   (setq savehist-file (no-littering-expand-var-file-name "savehist"))
     10   :config
     11   (setq-default history-length 10000
     12                 savehist-save-minibuffer-history t
     13 		savehist-delete-duplicates t
     14                 savehist-autosave-interval 180
     15                 savehist-additional-variables '(extended-command-history
     16                                                 search-ring
     17                                                 regexp-search-ring
     18                                                 comint-input-ring
     19                                                 compile-history
     20                                                 last-kbd-macro
     21                                                 shell-command-history
     22                                                 projectile-project-command-history))
     23   (savehist-mode 1))
     24 
     25 (use-package uniquify
     26   :unless noninteractive
     27   :config
     28   (setq-default uniquify-buffer-name-style 'post-forward
     29                 uniquify-separator ":"
     30                 uniquify-ignore-buffers-re "^\\*"
     31                 uniquify-after-kill-buffer-p t))
     32 
     33 (use-package ibuffer
     34   :unless noninteractive
     35   :commands (ibuffer)
     36   :bind (("C-x C-b" . ibuffer)
     37          ([remap list-buffers] . ibuffer))
     38   :config
     39   (setq-default ibuffer-expert t
     40                 ibuffer-filter-group-name-face 'font-lock-doc-face
     41                 ibuffer-default-sorting-mode 'filename/process
     42                 ibuffer-use-header-line t
     43                 ibuffer-show-empty-filter-groups nil)
     44   ;; Use human readable Size column instead of original one
     45   (define-ibuffer-column size-h
     46     (:name "Size" :inline t)
     47     (cond
     48      ((> (buffer-size) 1000000) (format "%7.1fM" (/ (buffer-size) 1000000.0)))
     49      ((> (buffer-size) 1000) (format "%7.1fk" (/ (buffer-size) 1000.0)))
     50      (t (format "%8d" (buffer-size)))))
     51 
     52   ;; (setq ibuffer-formats
     53   ;;       '((mark modified read-only " "
     54   ;;               (name 18 18 :left :elide)
     55   ;;               " "
     56   ;;               (size-h 9 -1 :right)
     57   ;;               " "
     58   ;;               (mode 16 16 :left :elide)
     59   ;;               " "
     60   ;;               filename-and-process)
     61   ;;         (mark modified read-only " "
     62   ;;               (name 18 18 :left :elide)
     63   ;;               " "
     64   ;;               (size 9 -1 :right)
     65   ;;               " "
     66   ;;               (mode 16 16 :left :elide)
     67   ;;               " "
     68   ;;               (vc-status 16 16 :left)
     69   ;;               " "
     70   ;;               filename-and-process)))
     71   )
     72 
     73 (use-package ibuffer-vc
     74   :unless noninteractive
     75   :commands (ibuffer-vc-set-filter-groups-by-vc-root)
     76   :hook (ibuffer . (lambda ()
     77                      (ibuffer-vc-set-filter-groups-by-vc-root)
     78                      (unless (eq ibuffer-sorting-mode 'filename/process)
     79                        (ibuffer-do-sort-by-filename/process)))))
     80 
     81 (unless noninteractive
     82   (require 'popper)
     83   (setq popper-reference-buffers
     84         '("\\*Messages\\*"
     85           "Output\\*$"
     86           "\\*Async Shell Command\\*"
     87           help-mode
     88 	  helpful-mode
     89           compilation-mode
     90 	  flymake-diagnostics-buffer-mode
     91 	  flymake-project-diagnostics-mode
     92 	  Man-mode
     93 	  woman-mode))
     94   (global-set-key (kbd "C-`") 'popper-toggle)
     95   (global-set-key (kbd "M-`") 'popper-cycle)
     96   (global-set-key (kbd "C-M-`") 'popper-toggle-type)
     97   (popper-mode +1)
     98 
     99   ;; For echo-area hints
    100   (require 'popper-echo)
    101   (popper-echo-mode +1))
    102 
    103 (use-package goto-addr
    104   :hook ((text-mode . goto-address-mode)
    105          (prog-mode . goto-address-prog-mode)))
    106 
    107 (provide 'config-buffers)
    108 ;;; config-buffers.el ends here