diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-03-03 14:02:33 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-03-03 14:19:34 +0100 |
| commit | 1b7ca9a8b500250c4e560e01ff1190daa906109f (patch) | |
| tree | 9225f3fb09b3aa9083298d5b197e400c69acba25 | |
| parent | e7b81ae428918e7ee5bdb8ec9c6333c8d4ca3b78 (diff) | |
Extract orderless--metadata helper function
The helper function can be reused for other style modifiers, for example a style
matching against the group title returned by the `group-function', which is also
specified by the completion metadata.
| -rw-r--r-- | orderless.el | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/orderless.el b/orderless.el index 4c96137..821bc67 100644 --- a/orderless.el +++ b/orderless.el @@ -286,14 +286,17 @@ which can invert any predicate or regexp." (lambda (str) (not (orderless--match-p pred regexp str)))) +(defun orderless--metadata () + "Return completion metadata." + (when-let (((minibufferp)) + (table minibuffer-completion-table)) + (completion-metadata (buffer-substring-no-properties + (minibuffer-prompt-end) (point)) + table minibuffer-completion-predicate))) + (defun orderless-annotation (pred regexp) "Match candidates where the annotation matches PRED and REGEXP." - (when-let (((minibufferp)) - (table minibuffer-completion-table) - (metadata (completion-metadata - (buffer-substring-no-properties - (minibuffer-prompt-end) (point)) - table minibuffer-completion-predicate)) + (when-let ((metadata (orderless--metadata)) (fun (or (completion-metadata-get metadata 'annotation-function) (plist-get completion-extra-properties |
