Steal jao-buffer-same-mode

This commit is contained in:
Case Duckworth 2021-09-15 23:32:25 -05:00
parent 5380cfb762
commit 3c1f98064e
1 changed files with 13 additions and 0 deletions

View File

@ -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