emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/orderless d6eb575714 165/204: Merge pull request #44 fr


From: ELPA Syncer
Subject: [elpa] externals/orderless d6eb575714 165/204: Merge pull request #44 from minad/invalid-regexp
Date: Tue, 11 Jan 2022 12:58:27 -0500 (EST)

branch: externals/orderless
commit d6eb575714f2d86ec7b0d5c42f9acb23ac439a02
Merge: 150155ce3c e5cb3f7b57
Author: Omar AntolĂ­n Camarena <omar.antolin@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #44 from minad/invalid-regexp
    
    Minor invalid regexp improvements
---
 README.org   | 10 +++-------
 orderless.el | 32 ++++++++++++++++----------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/README.org b/README.org
index 5d809d3342..e0680a9dc2 100644
--- a/README.org
+++ b/README.org
@@ -100,11 +100,8 @@ define new matching styles. The predefined ones are:
 - orderless-regexp :: the component is treated as a regexp that must
   match somewhere in the candidate.
 
-  If the component is not a valid regexp, it matches literally.
-  (Having the component be invalid is actually pretty common while you
-  are typing, so be prepared for the results to be a little funny
-  before you close a bracket or parentheses, etc.)
-  
+  If the component is not a valid regexp, it is ignored.
+
 - orderless-literal :: the component is treated as a literal string
   that must occur in the candidate.
 
@@ -117,7 +114,7 @@ define new matching styles. The predefined ones are:
   probably don't want to use this style directly in
   =orderless-matching-styles= but with a style dispatcher instead. There
   is an example in the section on style dispatchers.
-  
+
 - orderless-prefixes :: the component is split at word endings and
   each piece must match at a word boundary in the candidate, occurring
   in that order.
@@ -406,4 +403,3 @@ you get out of order matching!
 
 - Ivy has =ivy-restrict-to-matches=, bound to =S-SPC=, so you can get the
   effect of out of order matching without using =ivy--regex-ignore-order=.
-
diff --git a/orderless.el b/orderless.el
index 5be0a12193..921fa0931c 100644
--- a/orderless.el
+++ b/orderless.el
@@ -187,10 +187,10 @@ is determined by the values of `completion-ignore-case',
 ;;; Matching styles
 
 (defun orderless-regexp (component)
-  "Match a component as a regexp."
+  "Match COMPONENT as a regexp."
   (condition-case nil
       (progn (string-match-p component "") component)
-    (invalid-regexp (regexp-quote component))))
+    (invalid-regexp nil)))
 
 (defalias 'orderless-literal #'regexp-quote
   "Match a component as a literal string.
@@ -397,7 +397,9 @@ compilers."
      (rx-to-string
       `(or
         ,@(cl-loop for style in newstyles
-                   collect `(regexp ,(funcall style newcomp))))))))
+                   for result = (funcall style newcomp)
+                   if result
+                   collect `(regexp ,result)))))))
 
 ;;; Completion style implementation
 
@@ -411,19 +413,17 @@ The predicate PRED is used to constrain the entries in 
TABLE."
 (defun orderless-filter (string table &optional pred)
   "Split STRING into components and find entries TABLE matching all.
 The predicate PRED is used to constrain the entries in TABLE."
-  (condition-case nil
-      (save-match-data
-        (pcase-let* ((`(,prefix . ,pattern)
-                      (orderless--prefix+pattern string table pred))
-                     (completion-regexp-list
-                      (funcall orderless-pattern-compiler pattern))
-                     (completion-ignore-case
-                      (if orderless-smart-case
-                          (cl-loop for regexp in completion-regexp-list
-                                   always (isearch-no-upper-case-p regexp t))
-                        completion-ignore-case)))
-          (all-completions prefix table pred)))
-    (invalid-regexp nil)))
+  (save-match-data
+    (pcase-let* ((`(,prefix . ,pattern)
+                  (orderless--prefix+pattern string table pred))
+                 (completion-regexp-list
+                  (funcall orderless-pattern-compiler pattern))
+                 (completion-ignore-case
+                  (if orderless-smart-case
+                      (cl-loop for regexp in completion-regexp-list
+                               always (isearch-no-upper-case-p regexp t))
+                    completion-ignore-case)))
+      (all-completions prefix table pred))))
 
 ;;;###autoload
 (defun orderless-all-completions (string table pred _point)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]