branch: externals/consult commit d949871387cb5d9f659b30aa23524c4c22ab3742 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-themes: Support regexps --- CHANGELOG.org | 1 + consult.el | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index b436764119..b460c1cbc2 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -11,6 +11,7 @@ - =consult-grep=: Respect =grep-find-ignored-directories/files= - =consult-org-heading=: Add tags to completion candidates - Add =consult-preview-excluded-files= +- =consult-themes=: Support regexps * Version 0.18 (2022-05-25) diff --git a/consult.el b/consult.el index cee30dcac8..a7e89e85f8 100644 --- a/consult.el +++ b/consult.el @@ -142,9 +142,9 @@ The histories can be rings or lists." :type '(alist :key-type symbol :value-type symbol)) (defcustom consult-themes nil - "List of themes to be presented for selection. + "List of themes (symbols or regexps) to be presented for selection. nil shows all `custom-available-themes'." - :type '(repeat symbol)) + :type '(repeat (choice symbol regexp))) (defcustom consult-after-jump-hook '(recenter) "Function called after jumping to a location. @@ -3876,12 +3876,13 @@ This is an alternative to `minor-mode-menu-from-indicator'." The command supports previewing the currently selected theme." (interactive (list - (let ((avail-themes - (seq-filter (lambda (x) (or (not consult-themes) - (memq x consult-themes))) - (cons 'default (custom-available-themes)))) - (saved-theme - (car custom-enabled-themes))) + (let* ((regexp (consult--regexp-filter + (mapcar (lambda (x) (if (stringp x) x (format "\\`%s\\'" x))) + consult-themes))) + (avail-themes (seq-filter + (lambda (x) (string-match-p regexp (symbol-name x))) + (cons 'default (custom-available-themes)))) + (saved-theme (car custom-enabled-themes))) (consult--read (mapcar #'symbol-name avail-themes) :prompt "Theme: "