[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 7c99212dd3 17/25: Alternative 2: Compile comp
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 7c99212dd3 17/25: Alternative 2: Compile component before passing it to orderless-annotation |
Date: |
Wed, 21 Feb 2024 12:58:52 -0500 (EST) |
branch: externals/orderless
commit 7c99212dd3297281a1c430f13d32c807d7ad5503
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Alternative 2: Compile component before passing it to orderless-annotation
---
orderless.el | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/orderless.el b/orderless.el
index e4a4d30e0d..3ca76282b9 100644
--- a/orderless.el
+++ b/orderless.el
@@ -273,15 +273,14 @@ regexp."
string-end)))))
string-end))
-(defun orderless-without (component compile)
+(defun orderless-without (component)
"Match strings that do *not* match COMPONENT."
- (pcase-let ((`(,pred . ,regexp) (funcall compile component)))
- (when (or pred regexp)
- (lambda (str)
- (not (or (and pred (funcall pred str))
- (and regexp (string-match-p regexp str))))))))
+ (pcase-let ((`(,pred . ,regexp) component))
+ (lambda (str)
+ (not (or (and pred (funcall pred str))
+ (and regexp (string-match-p regexp str)))))))
-(defun orderless-annotation (component compile)
+(defun orderless-annotation (component)
"Match candidates where the annotation matches COMPONENT."
(when-let (((minibufferp))
(table minibuffer-completion-table)
@@ -293,12 +292,11 @@ regexp."
(when-let ((aff (or (completion-metadata-get metadata
'affixation-function)
(plist-get
completion-extra-properties :affixation-function))))
(lambda (cand) (caddr (funcall aff (list cand))))))))
- (pcase-let ((`(,pred . ,regexp) (funcall compile component)))
- (when (or pred regexp)
- (lambda (str)
- (when-let ((ann (funcall fun str)))
- (and (or (not pred) (funcall pred ann))
- (or (not regexp) (string-match-p regexp ann)))))))))
+ (pcase-let ((`(,pred . ,regexp) component))
+ (lambda (str)
+ (when-let ((ann (funcall fun str)))
+ (and (or (not pred) (funcall pred ann))
+ (or (not regexp) (string-match-p regexp ann))))))))
;;; Highlighting matches
@@ -388,19 +386,24 @@ DEFAULT as the list of styles."
(defun orderless--compile-component (component idx total styles dispatchers)
"Compile COMPONENT at IDX of TOTAL components with STYLES and DISPATCHERS."
- (pcase-let ((compile (lambda (c) (orderless--compile-component c idx total
styles dispatchers)))
- (`(,newsty . ,newcomp) (orderless--dispatch dispatchers styles
component idx total)))
+ (pcase-let ((`(,newsty . ,newcomp) (orderless--dispatch dispatchers styles
component idx total)))
(when (functionp newsty)
(setq newsty (list newsty)))
(cl-loop
with pred = nil
for style in newsty
- for res = (condition-case nil
- (funcall style newcomp)
- (wrong-number-of-arguments (funcall style newcomp compile)))
+ ;; TODO orderless-without and orderless-annotation are hardcoded here.
+ ;; Changed this such that orderless-affix-dispatch-alist contains a flag
or
+ ;; introduce a new configuration variable.
+ for newcomp2 = (if (memq style '(orderless-without orderless-annotation))
+ (orderless--compile-component newcomp idx total styles
dispatchers)
+ newcomp)
+ when newcomp2
+ for res = (funcall style newcomp2)
if (functionp res) do (cl-callf orderless--predicate-and pred res)
else if res collect (if (stringp res) `(regexp ,res) res) into regexps
- finally return (cons pred (and regexps (rx-to-string `(or ,@(delete-dups
regexps))))))))
+ finally return
+ (and (or pred regexps) (cons pred (and regexps (rx-to-string `(or
,@(delete-dups regexps)))))))))
(defun orderless-compile (pattern &optional styles dispatchers)
"Build regexps to match the components of PATTERN.
- [elpa] externals/orderless 87640f7061 12/25: orderless-without: orderless--compile-component can return nil, (continued)
- [elpa] externals/orderless 87640f7061 12/25: orderless-without: orderless--compile-component can return nil, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 45d5d457b2 20/25: Update commentary, recommend (setq completion-styles '(orderless basic)), ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 7af2ee23d8 22/25: orderless-compile: Expand docstring, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 9e810f43f0 21/25: Simplify orderless--compile-component, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 91df48c8e1 25/25: Merge pull request #162 from minad/annotation-matching, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 71a4557269 19/25: Rename orderless-without to orderless-not, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless c1def76024 01/25: Pattern compiler: Compile to regexps and a predicate function, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless b770a4de47 05/25: Remove orderless--predicate-or, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 10bce1bcde 02/25: orderless-annotation, orderless-without-regexp: Check validity, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 0e9fe2e902 03/25: orderless-annotation: Also check completion-extra-properties, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 7c99212dd3 17/25: Alternative 2: Compile component before passing it to orderless-annotation,
ELPA Syncer <=
- [elpa] externals/orderless b56db3eea4 18/25: Turn orderless-annotation/without into a "pattern transformer", ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 37c0083736 14/25: orderless--dispatch: Explicitly specify the arguments, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 766a194b90 13/25: Use orderless--dispatch in orderless--compile-component, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless fe5b6672b4 15/25: Add comment regarding the orderless--component-compiler calls, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless 258b9f54e1 23/25: README: Fix language after renaming of orderless-pattern-compiler, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless f172c80136 04/25: Extend orderless-without-literal comment, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless c484594875 11/25: Update documentation of orderless-style-dispatchers, ELPA Syncer, 2024/02/21
- [elpa] externals/orderless add8d5af3a 24/25: Break long lines, ELPA Syncer, 2024/02/21