emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gc-buffers a8a66f3183 04/11: Add more buffer testing funct


From: ELPA Syncer
Subject: [nongnu] elpa/gc-buffers a8a66f3183 04/11: Add more buffer testing functions
Date: Sun, 27 Nov 2022 15:59:54 -0500 (EST)

branch: elpa/gc-buffers
commit a8a66f3183382bff7b68a20fe270b79261e1229f
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Add more buffer testing functions
---
 README.org    |  3 +--
 gc-buffers.el | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index 7b9b5ef335..accc7b91d3 100644
--- a/README.org
+++ b/README.org
@@ -4,8 +4,7 @@ There are many packages that create temporary buffers but don't 
kill those
 buffers, either because they don't do that or any unhandled error prevents
 it from doing that.  Over time, these "garbage" buffer can  pile up and eat
 up your memory.  For example, there were 1359 garbage buffers created by
-Flymake Emacs Lisp byte compiler backend over 5 days, which ate up half of
-my memory.
+Flymake Emacs Lisp byte compiler backend over 5 days.
 
 This package's purpose is to clear them automatically, so you can use your
 memory to edit more files, run more commands and to use other programs.
diff --git a/gc-buffers.el b/gc-buffers.el
index efa09a642a..b9a5346190 100644
--- a/gc-buffers.el
+++ b/gc-buffers.el
@@ -30,8 +30,7 @@
 ;; those buffers, either because they don't do that or any unhandled error
 ;; prevents it from doing that.  Over time, these "garbage" buffer can be
 ;; pile up and eat up your memory.  For example, there were 1359 garbage
-;; buffers created by Flymake Emacs Lisp byte compiler backend over 5 days,
-;; which ate up half of my memory.
+;; buffers created by Flymake Emacs Lisp byte compiler backend over 5 days.
 
 ;; This package's purpose is to clear them automatically, so you can use
 ;; your memory to edit more files, run more commands and to use other
@@ -54,7 +53,10 @@
   :prefix "gc-buffers-")
 
 (defcustom gc-buffers-functions (list #'gc-buffers-elisp-flymake
-                                      #'gc-buffers-elisp-flymake-stderr)
+                                      #'gc-buffers-elisp-flymake-stderr
+                                      #'gc-buffers-inactive-minibuffer
+                                      #'gc-buffers-flymake-diagnostics
+                                      #'gc-buffers-helpful-all)
   "Functions to find garbage buffers.
 
 Each function is called with the buffer to test, and if any of the
@@ -66,7 +68,11 @@ Warning: Putting wrong functions here may delete working 
buffers.  For
 example, never put `always' here, that would delete all buffers."
   :type 'hook
   :options (list #'gc-buffers-elisp-flymake
-                 #'gc-buffers-elisp-flymake-stderr))
+                 #'gc-buffers-elisp-flymake-stderr
+                 #'gc-buffers-inactive-minibuffer
+                 #'gc-buffers-flymake-diagnostics
+                 #'gc-buffers-flymake-diagnostics-all
+                 #'gc-buffers-helpful-all))
 
 (defcustom gc-buffers-ignore-functions (list #'gc-buffers-ignore-visible)
   "Functions to ignore buffers while killing.
@@ -133,7 +139,7 @@ not have any side-effect."
 
 Check if BUFFER is a garbage generated by `elisp-flymake-byte-compile'."
   (and (string-match-p (rx string-start " *elisp-flymake-byte-compile*"
-                           (zero-or-one "-" (zero-or-more digit))
+                           (zero-or-more not-newline)
                            string-end)
                        (buffer-name buffer))
        (not (get-buffer-process buffer))))
@@ -145,6 +151,40 @@ Check if the name of BUFFER is
  \" *stderr of elisp-flymake-byte-compile*\"."
   (string= (buffer-name buffer) " *stderr of elisp-flymake-byte-compile*"))
 
+(defun gc-buffers-inactive-minibuffer (buffer)
+  "Kill garbage (inactive) minibuffers.
+
+Check if BUFFER is an inactive minibuffer window."
+  (minibufferp buffer t))
+
+(defun gc-buffers-flymake-diagnostics (buffer)
+  "Kill garbage Flymake diagnostics buffers.
+
+A diagnostics buffer is considered garbage when the source buffer is
+killed.
+
+Check if BUFFER is a Flymake diagnostics buffer of a killed buffer."
+  (and (eq (buffer-local-value 'major-mode buffer)
+           'flymake-diagnostics-buffer-mode)
+       (buffer-live-p (buffer-local-value
+                       'flymake--diagnostics-buffer-source buffer))))
+
+(defun gc-buffers-flymake-diagnostics-all (buffer)
+  "Kill all Flymake diagnostics buffers.
+
+You would probably want to add `gc-buffers-ignore-visible' to ignore
+visible functions, otherwise it'll kill all Flymake diagnostics buffer.
+
+Check if the major mode of BUFFER is `flymake-diagnostics-buffer-mode'."
+  (eq (buffer-local-value 'major-mode buffer)
+      'flymake-diagnostics-buffer-mode))
+
+(defun gc-buffers-helpful-all (buffer)
+  "Kill garbage (all) Helpful buffers.
+
+Check if the major mode of BUFFER is `helpful-mode'."
+  (eq (buffer-local-value 'major-mode buffer) 'helpful-mode))
+
 
 ;;;; Ignore functions:
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]