2019-10-14 17:38:14 +02:00
|
|
|
;;; buffers.el --- Default settings for buffers. -*- lexical-binding: t; -*-
|
|
|
|
|
2020-02-02 10:17:36 +01:00
|
|
|
;; Time-stamp: <2020-02-02T10:16:51+0100>
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; * Setup scratch buffer.
|
|
|
|
;; * Set fill-column.
|
|
|
|
;; * Define which buffers should be ignored.
|
|
|
|
;; * Enable auto-fill-mode.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(use-package emacs
|
|
|
|
:ensure nil
|
|
|
|
|
|
|
|
:custom
|
|
|
|
(initial-scratch-message nil) ; Make scratch buffer empty,
|
|
|
|
(initial-major-mode 'markdown-mode) ; and select mode.
|
|
|
|
|
|
|
|
:config
|
|
|
|
(defvar my/skippable-buffers '("^\\*" "^magit[:-]")
|
|
|
|
"Buffer names ignored by `next-buffer' and `previous-buffer'.")
|
|
|
|
(defvar my/never-skippable-buffers '("^\\*scratch\\*$" "^\\*Easy-hugo\\*$")
|
|
|
|
"Buffer names never ignored by `next-buffer' and `previous-buffer'.")
|
|
|
|
|
|
|
|
(defun my/buffer-predicate (buffer)
|
|
|
|
"Returns nil if buffer-name matches expression in `my/skippable-buffers'."
|
|
|
|
(catch 'return
|
|
|
|
;; Return t if buffer-name is on never-skippable list.
|
|
|
|
(dolist (expression my/never-skippable-buffers)
|
|
|
|
(if (string-match expression (buffer-name buffer))
|
|
|
|
(throw 'return t)
|
|
|
|
))
|
|
|
|
;; Return nil if buffer-name is on skippable list.
|
|
|
|
(dolist (expression my/skippable-buffers)
|
|
|
|
(if (string-match expression (buffer-name buffer))
|
|
|
|
(throw 'return nil)
|
|
|
|
))
|
|
|
|
t))
|
|
|
|
|
|
|
|
(set-frame-parameter nil 'buffer-predicate 'my/buffer-predicate)
|
2020-01-27 09:13:36 +01:00
|
|
|
|
|
|
|
:bind
|
|
|
|
;; Switch buffers.
|
|
|
|
("M-<left>" . previous-buffer)
|
|
|
|
("M-<right>" . next-buffer)
|
2019-10-14 17:38:14 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
;; Show and select buffers.
|
|
|
|
(use-package bs
|
|
|
|
:bind
|
|
|
|
("C-x C-b" . bs-show)
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Delete old buffers.
|
|
|
|
;; https://www.emacswiki.org/emacs/CleanBufferList
|
|
|
|
(use-package midnight
|
|
|
|
:defer 10
|
|
|
|
|
|
|
|
:init
|
|
|
|
(setq midnight-delay 30 ; 30 seconds after “midnight”.
|
|
|
|
midnight-period (* 2 60 60)) ; Clean every 2 hours.
|
|
|
|
|
|
|
|
:custom
|
|
|
|
(clean-buffer-list-delay-general 1) ; Clean normal bufs after 1d.
|
|
|
|
(clean-buffer-list-delay-special (* 30 60)) ; Clean special bufs after 30m.
|
|
|
|
|
|
|
|
:config
|
|
|
|
(setq clean-buffer-list-kill-regexps ; Add these to special buffers.
|
|
|
|
(nconc clean-buffer-list-kill-regexps
|
2019-12-26 08:44:45 +01:00
|
|
|
'("^magit-?.*:"
|
|
|
|
"\\.log$"
|
|
|
|
"^\\*rdm\\*$"
|
|
|
|
"^\\*Backtrace\\*$"
|
|
|
|
"^Pfuture-Callback"
|
|
|
|
)))
|
2019-10-14 17:38:14 +02:00
|
|
|
(midnight-mode t)
|
|
|
|
)
|
|
|
|
|
2020-01-21 02:52:03 +01:00
|
|
|
(use-package window-purpose
|
|
|
|
:pin melpa ; We need > 1.7 <https://github.com/bmag/emacs-purpose/issues/158>
|
2020-01-24 23:25:54 +01:00
|
|
|
:defer nil
|
2020-01-21 02:52:03 +01:00
|
|
|
|
|
|
|
:config
|
|
|
|
(purpose-mode)
|
|
|
|
(add-to-list 'purpose-user-mode-purposes '(c++-mode . cpp))
|
|
|
|
(add-to-list 'purpose-user-mode-purposes '(emacs-lisp-mode . elisp))
|
2020-01-31 06:00:40 +01:00
|
|
|
(add-to-list 'purpose-user-mode-purposes '(ebuild-mode . ebuild))
|
2020-02-02 10:17:36 +01:00
|
|
|
(add-to-list 'purpose-user-mode-purposes '(adoc-mode . adoc))
|
|
|
|
(add-to-list 'purpose-user-mode-purposes '(markdown-mode . markdown))
|
|
|
|
(add-to-list 'purpose-user-mode-purposes '(gfm-mode . markdown))
|
2020-01-21 02:52:03 +01:00
|
|
|
(add-to-list 'purpose-user-mode-purposes '(Man-mode . help-buffers))
|
2020-01-27 08:33:16 +01:00
|
|
|
(add-to-list 'purpose-user-mode-purposes '(help-mode . help-buffers))
|
|
|
|
(add-to-list 'purpose-user-mode-purposes '(info-mode . help-buffers))
|
2020-01-21 02:52:03 +01:00
|
|
|
(add-to-list 'purpose-special-action-sequences
|
2020-01-27 08:33:16 +01:00
|
|
|
'(help-buffers purpose-display-reuse-window-buffer))
|
|
|
|
(purpose-compile-user-configuration)
|
2020-01-21 02:52:03 +01:00
|
|
|
|
|
|
|
(require 'window-purpose-x)
|
2020-01-25 00:31:22 +01:00
|
|
|
(purpose-x-magit-single-on) ; All Magit buffers have the same purpose.
|
|
|
|
(purpose-x-kill-setup) ; Replace killed buffers with same purpose.
|
2020-01-24 23:25:54 +01:00
|
|
|
|
|
|
|
:bind
|
|
|
|
("<f2>" . purpose-toggle-window-purpose-dedicated)
|
|
|
|
("C-<f2>" . purpose-toggle-window-buffer-dedicated)
|
2020-01-27 08:37:38 +01:00
|
|
|
("M-<f2>" . purpose-load-window-layout)
|
2020-01-21 02:52:03 +01:00
|
|
|
)
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
(provide 'basics/buffers)
|
|
|
|
;;; buffers.el ends here
|