chore(navigation/consult): update consult and custom query functions

This commit is contained in:
2022-05-12 00:34:01 +01:00
parent 8e686b7826
commit c8a1170641
2 changed files with 37 additions and 37 deletions

View File

@@ -150,7 +150,7 @@ DIR can be project, not-project, nil or a path."
(dir (expand-file-name dir))))
(cl-defun siren-consult--buffer-query (&key sort directory mode as predicate (filter t)
include (exclude consult-buffer-filter))
include (exclude consult-buffer-filter))
"Buffer query function.
DIRECTORY can either be project, not-project or a path.
SORT can be visibility, alpha or nil.
@@ -163,40 +163,40 @@ AS is a conversion function."
;; This function is the backbone of most `consult-buffer' source. The
;; function supports filtering by various criteria which are used throughout
;; Consult.
(when-let (root (or (siren-consult--normalize-directory directory) t))
(let ((buffers (buffer-list))
(not-project (eq directory 'not-project)))
(when sort
(setq buffers (funcall (intern (format "consult--buffer-sort-%s" sort)) buffers)))
(when (or filter mode as (stringp root))
(let ((mode (consult--ensure-list mode))
(exclude-re (consult--regexp-filter exclude))
(include-re (consult--regexp-filter include)))
(consult--keep! buffers
(and
(or (not mode)
(apply #'provided-mode-derived-p
(buffer-local-value 'major-mode it) mode))
(pcase-exhaustive filter
('nil t)
((or 't 'invert)
(eq (eq filter t)
(and
(or (not exclude)
(not (string-match-p exclude-re (buffer-name it))))
(or (not include)
(not (not (string-match-p include-re (buffer-name it)))))))))
(or (not (stringp root))
(when-let (dir (buffer-local-value 'default-directory it))
(let ((in-project (string-prefix-p root
(if (and (/= 0 (length dir)) (eq (aref dir 0) ?/))
dir
(expand-file-name dir)))))
(or (and not-project (not in-project))
(and (not not-project) in-project)))))
(or (not predicate) (funcall predicate it))
(if as (funcall as it) it)))))
buffers))))
(let ((root (siren-consult--normalize-directory directory))
(buffers (buffer-list))
(not-project (eq directory 'not-project)))
(when sort
(setq buffers (funcall (intern (format "consult--buffer-sort-%s" sort)) buffers)))
(when (or filter mode as root)
(let ((mode (ensure-list mode))
(exclude-re (consult--regexp-filter exclude))
(include-re (consult--regexp-filter include)))
(consult--keep! buffers
(and
(or (not mode)
(apply #'provided-mode-derived-p
(buffer-local-value 'major-mode it) mode))
(pcase-exhaustive filter
('nil t)
((or 't 'invert)
(eq (eq filter t)
(and
(or (not exclude)
(not (string-match-p exclude-re (buffer-name it))))
(or (not include)
(not (not (string-match-p include-re (buffer-name it)))))))))
(or (not root)
(when-let (dir (buffer-local-value 'default-directory it))
(let ((in-project (string-prefix-p root
(if (and (/= 0 (length dir)) (eq (aref dir 0) ?/))
dir
(expand-file-name dir)))))
(or (and not-project (not in-project))
(and (not not-project) in-project)))))
(or (not predicate) (funcall predicate it))
(if as (funcall as it) it)))))
buffers)))
(provide 'siren-consult)
;;; siren-consult.el ends here

View File

@@ -20,8 +20,8 @@
("company-mode" . "d5145006b948f93e673f439a766da01f636d39fc")
("company-nginx" . "8a9f1a5653fe2d9a5042bfb9377d54f37fcc64c8")
("compat" . "65cd985320536065beea311a2b40219ffea49146")
("consult" . "a568960aa2603e1c976d11b826110e21e743526b")
("consult-lsp" . "a8eb3a062feb2715f174500d0624d3a85e000cf7")
("consult" . "1dfdf55f3d941f08089e5d0e611cd9daa8a44b19")
("consult-lsp" . "19606a03cf854e1b0930c4526ed92c4560dccdc2")
("copilot.el" . "b9c8816bf97d34cdbd22bee189235596e6d3801a")
("cucumber.el" . "e204d9e204b767cf95d6a051ff283f05dc51e9d3")
("dap-mode" . "ea437b24b059ad5be8ccf7ac8c17838c95657f23")