emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 2ee72ed487 4/5: Add consult-project-buffer


From: ELPA Syncer
Subject: [elpa] externals/consult 2ee72ed487 4/5: Add consult-project-buffer
Date: Tue, 15 Feb 2022 12:57:22 -0500 (EST)

branch: externals/consult
commit 2ee72ed487063d201d3936bf65e8f2e36e71a9e9
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add consult-project-buffer
---
 CHANGELOG.org |  2 ++
 README.org    |  7 ++++++-
 consult.el    | 23 ++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 3df6d23c94..0e431802ef 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -10,6 +10,8 @@
   =consult-project-root-function=. The =consult-project-function= is used to
   retrieve the project directories and is preconfigured with a default 
function,
   which uses project.el.
+- Add =consult-project-buffer=, a variant of =consult-buffer= restricted to the
+  current project.
 
 * Version 0.15 (2022-01-31)
 
diff --git a/README.org b/README.org
index 1722fb750c..4abc5ce6ee 100644
--- a/README.org
+++ b/README.org
@@ -90,6 +90,7 @@ their descriptions.
  #+findex: consult-buffer
  #+findex: consult-buffer-other-window
  #+findex: consult-buffer-other-frame
+ #+findex: consult-project-buffer
  #+findex: consult-recent-file
  #+findex: consult-bookmark
  - =consult-buffer= (=-other-window=, =-other-frame=): Enhanced version
@@ -101,7 +102,10 @@ their descriptions.
    - f Files (Requires =recentf-mode=)
    - m Bookmarks
    - p Project
-   - Arbitrary [[#multiple-sources][other sources]] configured in 
=consult-buffer-sources=.
+   - Custom [[#multiple-sources][other sources]] configured in 
=consult-buffer-sources=.
+ - =consult-project-buffer=: Variant of =consult-buffer= restricted to buffers 
and
+   recent files of the current project. You can add custom sources to
+   =consult-project-buffer-sources=.
  - =consult-bookmark=: Select or create bookmark. To select bookmarks you 
might use the
    =consult-buffer= as an alternative, which can include a bookmark virtual 
buffer
    source. Note that =consult-bookmark= supports preview of bookmarks and
@@ -795,6 +799,7 @@ configuration examples.
             ("C-x 4 b" . consult-buffer-other-window) ;; orig. 
switch-to-buffer-other-window
             ("C-x 5 b" . consult-buffer-other-frame)  ;; orig. 
switch-to-buffer-other-frame
             ("C-x r b" . consult-bookmark)            ;; orig. bookmark-jump
+            ("C-x p b" . consult-project-buffer)      ;; orig. 
project-switch-to-buffer
             ;; Custom M-# bindings for fast register access
             ("M-#" . consult-register-load)
             ("M-'" . consult-register-store)          ;; orig. 
abbrev-prefix-mark (unrelated)
diff --git a/consult.el b/consult.el
index d86983da14..0adf8443e4 100644
--- a/consult.el
+++ b/consult.el
@@ -216,8 +216,14 @@ character, the *Completions* buffer and a few log buffers."
     consult--source-project-recent-file
     consult--source-project-root)
   "Sources used by `consult-buffer'.
+See also `consult-project-buffer-sources'.
+See `consult--multi' for a description of the source data structure."
+  :type '(repeat symbol))
 
-See `consult--multi' for a description of the source values."
+(defcustom consult-project-buffer-sources nil
+  "Sources used by `consult-project-buffer'.
+See also `consult-buffer-sources'.
+See `consult--multi' for a description of the source data structure."
   :type '(repeat symbol))
 
 (defcustom consult-mode-command-filter
@@ -4094,6 +4100,13 @@ If NORECORD is non-nil, do not record the buffer switch 
in the buffer list."
                               recentf-list))))))
   "Project file candidate source for `consult-buffer'.")
 
+;; Populate `consult-project-buffer-sources'.
+(setq consult-project-buffer-sources
+      (list
+       `(:hidden nil :narrow ?b ,@consult--source-project-buffer)
+       `(:hidden nil :narrow ?f ,@consult--source-project-recent-file)
+       `(:hidden nil :narrow ?r ,@consult--source-project-root)))
+
 ;;;###autoload
 (defun consult-buffer ()
   "Enhanced `switch-to-buffer' command with support for virtual buffers.
@@ -4116,6 +4129,14 @@ order to determine the project-specific files and 
buffers, the
     (unless (cdr buffer)
       (consult--buffer-action (car buffer)))))
 
+;;;###autoload
+(defun consult-project-buffer ()
+  "Enhanced `project-switch-to-buffer' command with support for virtual 
buffers.
+See `consult-buffer' for more details."
+  (interactive)
+  (let ((consult-buffer-sources consult-project-buffer-sources))
+    (consult-buffer)))
+
 ;;;###autoload
 (defun consult-buffer-other-window ()
   "Variant of `consult-buffer' which opens in other window."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]