[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult eddc6d3: consult--buffer-query: Add generalized
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult eddc6d3: consult--buffer-query: Add generalized directory argument |
Date: |
Mon, 26 Jul 2021 03:57:07 -0400 (EDT) |
branch: externals/consult
commit eddc6d3d69457c4a03fb2c59f186bc8a5a6b7fe8
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
consult--buffer-query: Add generalized directory argument
---
consult-imenu.el | 2 +-
consult.el | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/consult-imenu.el b/consult-imenu.el
index 6b552b5..146b9d3 100644
--- a/consult-imenu.el
+++ b/consult-imenu.el
@@ -215,7 +215,7 @@ same major mode as the current buffer are used. See also
(interactive)
(consult-imenu--select
(consult-imenu--all-items
- (or (consult--buffer-query :project t
+ (or (consult--buffer-query :directory 'project
:mode major-mode
:sort 'alpha)
(list (current-buffer))))))
diff --git a/consult.el b/consult.el
index 364fc37..812ec1f 100644
--- a/consult.el
+++ b/consult.el
@@ -3536,9 +3536,9 @@ The command supports previewing the currently selected
theme."
nil)))
(nconc (nreverse hidden) buffers (list (current-buffer)))))
-(cl-defun consult--buffer-query (&key sort (filter t) project mode as)
+(cl-defun consult--buffer-query (&key sort (filter t) directory mode as)
"Buffer query function.
-PROJECT can be set to t to consider only project-specific buffers.
+DIRECTORY can either be project or a path.
SORT can be visibility, alpha or nil.
FILTER can be t, hidden or nil.
MODE can be a mode or a list of modes to restrict the returned buffers.
@@ -3547,11 +3547,14 @@ AS is a conversion function."
;; allocations. It is the backbone of most `consult-buffer' source. The
;; function supports filtering by various criteria which are used throughout
;; Consult.
- (when-let (root (or (not project) (consult--project-root)))
+ (when-let (root (pcase-exhaustive directory
+ ('project (consult--project-root))
+ ('nil t)
+ ((pred stringp) (expand-file-name directory))))
(let ((buffers (buffer-list)))
(when sort
(setq buffers (funcall (intern (format "consult--buffer-sort-%s"
sort)) buffers)))
- (when (or filter mode project as)
+ (when (or filter mode as (stringp root))
(let ((mode (if (listp mode) mode (list mode)))
(re (consult--regexp-filter consult-buffer-filter)))
(consult--keep! buffers
@@ -3563,14 +3566,12 @@ AS is a conversion function."
('nil t)
('hidden (string-match-p re (buffer-name it)))
('t (not (string-match-p re (buffer-name it)))))
- (pcase-exhaustive project
- ('nil t)
- ('t
- (when-let (dir (buffer-local-value 'default-directory it))
- (string-prefix-p root
- (if (and (/= 0 (length dir)) (eq (aref dir
0) ?/))
- dir
- (expand-file-name dir))))))
+ (or (not (stringp root))
+ (when-let (dir (buffer-local-value 'default-directory it))
+ (string-prefix-p root
+ (if (and (/= 0 (length dir)) (eq (aref dir
0) ?/))
+ dir
+ (expand-file-name dir)))))
(if as (funcall as it) it)))))
buffers)))
@@ -3620,7 +3621,7 @@ If NORECORD is non-nil, do not record the buffer switch
in the buffer list."
:items
,(lambda ()
(consult--buffer-query :sort 'visibility
- :project t
+ :directory 'project
:as #'buffer-name)))
"Project buffer candidate source for `consult-buffer'.")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/consult eddc6d3: consult--buffer-query: Add generalized directory argument,
ELPA Syncer <=