[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/modus-themes b9fdda5e5d 4/4: Make completion candidates
From: |
ELPA Syncer |
Subject: |
[elpa] externals/modus-themes b9fdda5e5d 4/4: Make completion candidates a table with 'theme' category |
Date: |
Tue, 18 Jul 2023 00:59:30 -0400 (EDT) |
branch: externals/modus-themes
commit b9fdda5e5d3f4a580c34b11775622d677ec5ce63
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make completion candidates a table with 'theme' category
This allows the user to target the 'theme' completion category in
order to affect the relevant functions. For example, to set
completion styles with 'completion-category-overrides' or define a
custom annotation function with the 'marginalia' package.
---
modus-themes.el | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/modus-themes.el b/modus-themes.el
index c4ca2b2b09..2127bc9b1d 100644
--- a/modus-themes.el
+++ b/modus-themes.el
@@ -1326,13 +1326,24 @@ symbol, which is safe when used as a face attribute's
value."
(doc-string (get symbol 'theme-documentation)))
(format " -- %s" (car (split-string doc-string "\\.")))))
+(defun modus-themes--completion-table (category candidates)
+ "Pass appropriate metadata CATEGORY to completion CANDIDATES."
+ (lambda (string pred action)
+ (if (eq action 'metadata)
+ `(metadata (category . ,category))
+ (complete-with-action action candidates string pred))))
+
+(defun modus-themes--completion-table-candidates ()
+ "Render `modus-themes--list-known-themes' as completion with theme category."
+ (modus-themes--completion-table 'theme (modus-themes--list-known-themes)))
+
(defun modus-themes--select-prompt ()
"Minibuffer prompt to select a Modus theme."
(let ((completion-extra-properties `(:annotation-function
,#'modus-themes--annotate-theme)))
(intern
(completing-read
"Select Modus theme: "
- (modus-themes--list-known-themes)
+ (modus-themes--completion-table-candidates)
nil t nil
'modus-themes--select-theme-history))))
@@ -1425,7 +1436,8 @@ Helper function for `modus-themes-list-colors'."
(completion-extra-properties `(:annotation-function
,#'modus-themes--annotate-theme)))
(completing-read
(format "Use palette from theme [%s]: " def)
- (modus-themes--list-known-themes) nil t nil
+ (modus-themes--completion-table-candidates)
+ nil t nil
'modus-themes--list-colors-prompt-history def)))
(defun modus-themes-list-colors (theme &optional mappings)