Skip to content

Commit

Permalink
fix: use buffer local
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 12, 2024
1 parent e78962d commit 8ea64a7
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions diminish-buffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; Author: Shen, Jen-Chieh <[email protected]>
;; URL: https://github.com/jcs-elpa/diminish-buffer
;; Version: 0.2.0
;; Package-Requires: ((emacs "24.4") (ht "2.0"))
;; Package-Requires: ((emacs "24.4"))
;; Keywords: convenience diminish hide buffer menu

;; This file is NOT part of GNU Emacs.
Expand All @@ -33,8 +33,6 @@

(require 'cl-lib)

(require 'ht)

(defgroup diminish-buffer nil
"Diminish (hide) buffers from `buffer-menu'."
:prefix "diminish-buffer-"
Expand All @@ -59,8 +57,8 @@
(defconst diminish-buffer-menu-name "*Buffer List*"
"Buffer name for *Buffer List*.")

(defvar diminish-buffer--cache (make-hash-table)
"Filter cache.")
(defvar diminish-buffer--cache nil
"Cache to recording filter.")

;;
;; (@* "Util" )
Expand Down Expand Up @@ -101,12 +99,14 @@
"Filter out the BUFFER."
(with-current-buffer buffer
(let* ((name (buffer-name))
(answer (or (ht-get diminish-buffer--cache name)
(diminish-buffer--contain-list-string-regex major-mode
diminish-buffer-mode-list)
(diminish-buffer--contain-list-string-regex name
diminish-buffer-list))))
(ht-set diminish-buffer--cache name answer)
(answer (cond (diminish-buffer--cache
(equal diminish-buffer--cache t))
(t
(or (diminish-buffer--contain-list-string-regex
major-mode diminish-buffer-mode-list)
(diminish-buffer--contain-list-string-regex
name diminish-buffer-list))))))
(setq diminish-buffer--cache (if answer t 'no))
answer)))

;; XXX This is the default filter from Emacs itself; leave this feature as is it.
Expand Down

0 comments on commit 8ea64a7

Please sign in to comment.