From 342307ce23c5f9f2c2cfdbd3b25d5a92d4295a76 Mon Sep 17 00:00:00 2001 From: Laurens Miers Date: Tue, 6 Jun 2023 09:56:07 +0200 Subject: [PATCH] feat: add kill-other-buffers function Convenience function to prune buffers. This will kill all buffers except for scratch and Messages --- config.org | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config.org b/config.org index 3cab2c9..a0762c6 100644 --- a/config.org +++ b/config.org @@ -10,6 +10,7 @@ - [[#emacs-262][Emacs 26.2]] - [[#utils][Utils]] - [[#custom-command-line-arguments][Custom command line arguments]] + - [[#kill-other-buffers][Kill other buffers]] - [[#global-variables][Global variables]] - [[#ripgrep][Ripgrep]] - [[#term][Term]] @@ -143,6 +144,23 @@ If it was found, we delete it from the list of command line arguments. found-switch)) #+END_SRC +** Kill other buffers + +Function to kill other buffers but the current open one (and some standard buffers which should be kept alive). +Stolen from https://www.emacswiki.org/emacs/KillingBuffers . + +#+BEGIN_SRC emacs-lisp + +(setq not-to-kill-buffer-list '("*scratch*" "*Messages*")) + +(defun kill-other-buffers () + "Kill all other buffers." + (interactive) + (if (member (buffer-name (current-buffer)) not-to-kill-buffer-list) + (bury-buffer) + (kill-buffer (current-buffer)))) +#+END_SRC + ** Global variables Some package behave strangely if we have custom command line parameters.