Add beframe integration with consult-buffer

This commit is contained in:
Vedang Manerikar 2024-11-18 14:27:49 +05:30
parent 819bb7be0f
commit a614f70a1f
2 changed files with 54 additions and 2 deletions

View file

@ -2932,6 +2932,8 @@ best changes I ever did to boost my productivity:
+ Backronym: Buffers Encapsulated in Frames Realise Advanced
Management of Emacs.
Note: I also add ~beframe~ as a source for ~consult-buffers~. This code comes from the ~beframe~ manual and lets me look at frame-specific buffers first when using ~consult-buffer~.
#+begin_src emacs-lisp :tangle "unravel-modules/unravel-window.el"
;;; Frame-isolated buffers
;; Another package of mine. Read the manual:
@ -2948,7 +2950,32 @@ best changes I ever did to boost my productivity:
("C-x C-b" . beframe-buffer-menu)
("C-x B" . select-frame-by-name)
:config
(setq beframe-functions-in-frames '(project-prompt-project-dir)))
(setq beframe-functions-in-frames '(project-prompt-project-dir))
(defvar consult-buffer-sources)
(declare-function consult--buffer-state "consult")
(with-eval-after-load 'consult
(defface beframe-buffer
'((t :inherit font-lock-string-face))
"Face for `consult' framed buffers.")
(defun my-beframe-buffer-names-sorted (&optional frame)
"Return the list of buffers from `beframe-buffer-names' sorted by visibility.
With optional argument FRAME, return the list of buffers of FRAME."
(beframe-buffer-names frame :sort #'beframe-buffer-sort-visibility))
(defvar beframe-consult-source
`( :name "Frame-specific buffers (current frame)"
:narrow ?F
:category buffer
:face beframe-buffer
:history beframe-history
:items ,#'my-beframe-buffer-names-sorted
:action ,#'switch-to-buffer
:state ,#'consult--buffer-state))
(add-to-list 'consult-buffer-sources 'beframe-consult-source)))
#+end_src
** The =unravel-window.el= configuration of ~undelete-frame-mode~ and ~winner-mode~

View file

@ -111,7 +111,32 @@
("C-x C-b" . beframe-buffer-menu)
("C-x B" . select-frame-by-name)
:config
(setq beframe-functions-in-frames '(project-prompt-project-dir)))
(setq beframe-functions-in-frames '(project-prompt-project-dir))
(defvar consult-buffer-sources)
(declare-function consult--buffer-state "consult")
(with-eval-after-load 'consult
(defface beframe-buffer
'((t :inherit font-lock-string-face))
"Face for `consult' framed buffers.")
(defun my-beframe-buffer-names-sorted (&optional frame)
"Return the list of buffers from `beframe-buffer-names' sorted by visibility.
With optional argument FRAME, return the list of buffers of FRAME."
(beframe-buffer-names frame :sort #'beframe-buffer-sort-visibility))
(defvar beframe-consult-source
`( :name "Frame-specific buffers (current frame)"
:narrow ?F
:category buffer
:face beframe-buffer
:history beframe-history
:items ,#'my-beframe-buffer-names-sorted
:action ,#'switch-to-buffer
:state ,#'consult--buffer-state))
(add-to-list 'consult-buffer-sources 'beframe-consult-source)))
;;; Frame history (undelete-frame-mode)
(use-package frame