[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 62f71c34ba 191/204: Extend prefix optimizatio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 62f71c34ba 191/204: Extend prefix optimization to anchored quoted regexps (fix #81) |
Date: |
Tue, 11 Jan 2022 12:58:30 -0500 (EST) |
branch: externals/orderless
commit 62f71c34baca0b7d0adeab4a1c07d85ffcee80d9
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Extend prefix optimization to anchored quoted regexps (fix #81)
---
orderless.el | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/orderless.el b/orderless.el
index 4ffd042f54..33d78fe4a8 100644
--- a/orderless.el
+++ b/orderless.el
@@ -390,6 +390,22 @@ The predicate PRED is used to constrain the entries in
TABLE."
(let ((limit (car (completion-boundaries string table pred ""))))
(cons (substring string 0 limit) (substring string limit))))
+;; Thanks to @jakanakaevangeli for writing a version of this function:
+;; https://github.com/oantolin/orderless/issues/79#issuecomment-916073526
+(defun orderless--anchored-quoted-regexp (regexp)
+ "Determine if REGEXP is a quoted regexp anchored at the beginning.
+If REGEXP is of the form \"\\(?:^q\\)\" for q = (regexp-quote u),
+then return (cons REGEXP u); else return nil."
+ (when (and (string-prefix-p "\\(?:^" regexp) (string-suffix-p "\\)" regexp))
+ (let ((trimmed (substring regexp 5 -2)))
+ (unless (string-match-p "[$*+.?[\\^]"
+ (replace-regexp-in-string
+ "\\\\[$*+.?[\\^]" "" trimmed
+ 'fixedcase 'literal))
+ (cons regexp
+ (replace-regexp-in-string "\\\\\\([$*+.?[\\^]\\)" "\\1"
+ trimmed 'fixedcase))))))
+
;;;###autoload
(defun orderless-filter (string table &optional pred)
"Split STRING into components and find entries TABLE matching all.
@@ -399,19 +415,18 @@ The predicate PRED is used to constrain the entries in
TABLE."
(orderless--prefix+pattern string table pred))
(completion-regexp-list
(orderless-pattern-compiler pattern))
- (initial
- ;; try to find a regexp of the form \(?:^literal\)
- (cl-find "\\`\\\\(\\?:\\^[^$*+.?[\\^]*\\\\)\\'"
- completion-regexp-list
- :test #'string-match-p))
(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)))
- (when initial
- (setq prefix (concat prefix (substring initial 5 -2))
- completion-regexp-list (delete initial completion-regexp-list)))
+ ;; If there is a regexp of the form \(?:^quoted-regexp\) then
+ ;; remove the first such and add the unquoted form to the prefix.
+ (pcase (cl-some #'orderless--anchored-quoted-regexp
+ completion-regexp-list)
+ (`(,regexp . ,literal)
+ (setq prefix (concat prefix literal)
+ completion-regexp-list (delete regexp completion-regexp-list))))
(all-completions prefix table pred))))
;;;###autoload
- [elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and dispatcher per category overrides (fix #31), (continued)
- [elpa] externals/orderless d1c0cbf87b 137/204: Add matching style and dispatcher per category overrides (fix #31), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5dcf4a6f2b 135/204: Corrected broken link, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 701b6a07c8 156/204: orderless-try-completions: Remove _metadata argument, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a609004d5f 159/204: Document that orderless-regexp matches invalid regexps literally, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d6eb575714 165/204: Merge pull request #44 from minad/invalid-regexp, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 87ab7e47e3 168/204: Merge pull request #46 from minad/remove-pattern-compiler-variable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d2891b807b 174/204: orderless+initialism example requires Marginalia (see #54), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless e4c38efcd6 176/204: README: Add variable category to orderless+initialism sample, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 871eb1d0f0 178/204: Use add-face-text-property, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless df4f29a4f4 183/204: Use minibuffer customization group, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 62f71c34ba 191/204: Extend prefix optimization to anchored quoted regexps (fix #81),
ELPA Syncer <=
- [elpa] externals/orderless 75d3398056 192/204: Have orderless-try-completion return t for exact match (fix #95), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c8731aacfa 197/204: Merge pull request #98 from minad/fix-try, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f22789f358 202/204: Merge pull request #94 from minad/strict-initialism, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 855255eb01 198/204: Mention Corfu and consult-completion-in-region (fix #99), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 269d7388ab 034/204: Merge pull request #6 from raxod502/patch-1, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ae466bc4f4 054/204: Rename orderless-regexp-separator to orderless-component-separator, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless aad0aa8a8d 017/204: Copy candidates to avoid permanently changing their face, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9218343171 043/204: Add command to temporarily change separator, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2750e15c74 065/204: Add ivy integration, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless fb6ad592b7 067/204: List more helpful functions for integration, ELPA Syncer, 2022/01/11