summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-10-01 13:48:59 +0800
committerJSDurand <mmemmew@gmail.com>2022-10-01 13:48:59 +0800
commit13820428f80bb537bd56451c192c1db27db9b8b2 (patch)
tree6e14dd0678b54f4b1a361615d7c5e6c650bafdd0
parent00e9684bc563024284b2e0521a9baa636a38f100 (diff)
ibuffer: silence ibuffer
* ibuffer.el (durand-ibuffer): Silence the function `ibuffer'.
-rw-r--r--ibuffer.el69
1 files changed, 67 insertions, 2 deletions
diff --git a/ibuffer.el b/ibuffer.el
index 60617cd..c9f41b0 100644
--- a/ibuffer.el
+++ b/ibuffer.el
@@ -302,8 +302,8 @@ derived modes of `ibuffer-mode'.")))
;;; key-bindings
-(define-key global-map (vector 24 2) #'ibuffer)
-(define-key global-map (vector ?\s-h) #'ibuffer)
+(define-key global-map (vector 24 2) #'durand-ibuffer)
+(define-key global-map (vector ?\s-h) #'durand-ibuffer)
(define-key global-map (vector ?\M-\s-b) #'switch-to-buffer-same-mode)
(define-key global-map (vector ?\s-b) #'switch-to-buffer)
(define-key global-map (vector ?\s-B) #'switch-to-buffer-other-window)
@@ -319,6 +319,71 @@ derived modes of `ibuffer-mode'.")))
;; close paren is bound to unprotect
(define-key ibuffer-mode-map (vector 41) #'ibuffer-do-unprotect)
+;;; Make ibuffer silent
+
+(defun durand-ibuffer
+ (&optional other-window-p name qualifiers noselect shrink
+ filter-groups formats)
+ "\\<ibuffer-mode-map>Begin using Ibuffer to edit a list of buffers.
+Type \\[describe-mode] after entering ibuffer for more information.
+
+All arguments are optional.
+OTHER-WINDOW-P says to use another window.
+NAME specifies the name of the buffer (defaults to \"*Ibuffer*\").
+QUALIFIERS is an initial set of filtering qualifiers to use;
+ see `ibuffer-filtering-qualifiers'.
+NOSELECT means don't select the Ibuffer buffer.
+SHRINK means shrink the buffer to minimal size. The special
+ value `onewindow' means always use another window.
+FILTER-GROUPS is an initial set of filtering groups to use;
+ see `ibuffer-filter-groups'.
+FORMATS is the value to use for `ibuffer-formats'.
+ If specified, then the variable `ibuffer-formats' will have
+ that value locally in this buffer.
+
+Modified by Durand to make it silent. -- 2022-10-01 12:31:37.532012"
+ (interactive "P")
+ (when ibuffer-use-other-window
+ (setq other-window-p t))
+ (let ((buf (get-buffer-create (or name "*Ibuffer*"))))
+ (if other-window-p
+ (or (and noselect (display-buffer buf t))
+ (pop-to-buffer buf t))
+ (funcall (if noselect #'display-buffer #'switch-to-buffer) buf))
+ (with-current-buffer buf
+ (save-selected-window
+ ;; We switch to the buffer's window in order to be able
+ ;; to modify the value of point
+ (select-window (get-buffer-window buf 0))
+ (or (derived-mode-p 'ibuffer-mode)
+ (ibuffer-mode))
+ (when shrink
+ (setq ibuffer-shrink-to-minimum-size shrink))
+ (when qualifiers
+ (require 'ibuf-ext)
+ (setq ibuffer-filtering-qualifiers qualifiers))
+ (when filter-groups
+ (require 'ibuf-ext)
+ (setq ibuffer-filter-groups filter-groups))
+ (when formats
+ (setq-local ibuffer-formats formats))
+ ;; NOTE: `ibuffer-update' has an argument to be silent. But
+ ;; it sometimes talks about formats being changed and
+ ;; recompiling formats. So I just use this hack to stop it
+ ;; from talking, at all.
+ (advice-add #'message :override #'ignore)
+ (ibuffer-update nil)
+ (advice-remove #'message #'ignore)
+ ;; Skip the group name by default.
+ (ibuffer-forward-line 0 t)
+ (unwind-protect
+ (progn
+ (setq buffer-read-only nil)
+ (run-hooks 'ibuffer-hook))
+ (setq buffer-read-only t))
+ (unless ibuffer-expert
+ (message "Commands: m, u, t, RET, g, k, S, D, Q; q to quit; h for help"))))))
+
;;; filter for bongo
;;;###autoload