From 3c1f98064e592c702af8a17a3146d036faed2f06 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 15 Sep 2021 23:32:25 -0500 Subject: Steal jao-buffer-same-mode --- lisp/acdw.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/acdw.el b/lisp/acdw.el index 472b4ab..d3b0bf9 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -671,5 +671,18 @@ When called with PREFIX, just kill Emacs without confirmation." (ignore-errors (delete-frame)))) + +;;; cribbed + +;; https://jao.io/blog/2021-09-08-high-signal-to-noise-emacs-command.html +(defun jao-buffer-same-mode (&rest modes) + "Pop to a buffer with a mode among MODES, or the current one if not given." + (interactive) + (let* ((modes (or modes (list major-mode))) + (pred (lambda (b) + (let ((b (get-buffer (if (consp b) (car b) b)))) + (member (buffer-local-value 'major-mode b) modes))))) + (pop-to-buffer (read-buffer "Buffer: " nil t pred)))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81