38 lines
1.5 KiB
Org Mode
38 lines
1.5 KiB
Org Mode
:PROPERTIES:
|
|
:ID: cce/midnight_mode
|
|
:ROAM_ALIASES: sudo-edit "Midnight Mode"
|
|
:END:
|
|
#+TITLE: Clean Buffers at a Regular Interval with Midnight Mode
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+PROPERTY: header-args:emacs-lisp :tangle midnight-mode.el
|
|
|
|
#+ARCOLOGY_KEY: cce/midnight-mode
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
#+ARROYO_EMACS_MODULE: midnight-mode
|
|
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
|
|
|
|
I feel a little weird just enabling this, let's see what I think about auto-killing any buffer older than six hours. It won't run often, if I want it to run hourly, I could put it in to a repeating timer, myself.
|
|
|
|
#+begin_src emacs-lisp
|
|
(provide 'cce/midnight-mode)
|
|
(setq clean-buffer-list-delay-general 0.5)
|
|
(midnight-mode 1)
|
|
(setq clean-buffer-list-kill-never-buffer-names
|
|
(append clean-buffer-list-kill-never-buffer-names
|
|
(list "*Group*")))
|
|
#+end_src
|
|
|
|
I really wish this =clean-buffers= functionality could exclude based on mode, what an oversight! We can cheese it, however, with this function which can be added to [[help:clean-buffer-list-kill-never-regexps]].
|
|
|
|
#+begin_src emacs-lisp
|
|
(defun cce/check-kill-exwm-mode (buffer-name)
|
|
"Checks whether the buffer backing [`buffer-name'] is an EXWM-mode buffer to exclude from midnight-mode.
|
|
|
|
To enable this, add it to [`clean-buffer-list-kill-never-regexps'], which will get it funcall'd in the midnight-mode hook."
|
|
(with-current-buffer buffer-name
|
|
(eq major-mode 'exwm-mode)))
|
|
|
|
(add-to-list 'clean-buffer-list-kill-never-regexps #'cce/check-kill-exwm-mode)
|
|
#+end_src
|