From 1440189cd6a020e645dd29c1339b92c864028479 Mon Sep 17 00:00:00 2001 From: Ivan Popovych Date: Sun, 6 Mar 2022 21:14:32 +0200 Subject: Add consult integration --- README.md | 11 +++++++++++ perspective.el | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 2c9eeee..917dd6a 100644 --- a/README.md +++ b/README.md @@ -246,6 +246,17 @@ show buffers in all perspectives. In addition, Perspective adds actions to to the prefix-argument version) and to remove buffers from the current perspective. +**Consult**: Perspective provides `persp-consult-source` source that will list +buffers in current perspective. You can hide default buffer source +and add `persp-consult-source` to `consult-buffer-sources` for consult +to only list buffers in current perspective, note that you can access +list of all buffers by filtering with `b` key. Example configuration: + +```emacs-lisp +(consult-customize consult--source-buffer :hidden t :default nil) +(add-to-list consult-buffer-sources persp-consult-source) +``` + **Ivy / Counsel**: Perspective provides two commands for listing buffers using Ivy and Counsel: `persp-ivy-switch-buffer` and `persp-counsel-switch-buffer`. When these functions are called normally, they show a list of buffers filtered diff --git a/perspective.el b/perspective.el index d51f09c..806197c 100644 --- a/perspective.el +++ b/perspective.el @@ -1546,6 +1546,20 @@ PERSP-SET-IDO-BUFFERS)." (ibuffer)) (ibuffer))) +;; Buffer switching integration: Consult + +(defvar persp-consult-source + (list :name "Perspective" + :narrow ?s + :category 'buffer + :state #'consult--buffer-state + :history 'buffer-name-history + :default t + :items + (lambda () (consult--buffer-query :sort 'visibility + :predicate 'persp-is-current-buffer + :as #'buffer-name)))) + ;; Buffer switching integration: Ivy. ;; ;; An alternative implementation, which has the drawback of not allowing a -- cgit v1.0