diff --git a/unravel-emacs.org b/unravel-emacs.org index b2761fa..781f3d3 100644 --- a/unravel-emacs.org +++ b/unravel-emacs.org @@ -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~ diff --git a/unravel-modules/unravel-window.el b/unravel-modules/unravel-window.el index 5d046ee..7b38945 100644 --- a/unravel-modules/unravel-window.el +++ b/unravel-modules/unravel-window.el @@ -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