diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-03-03 15:39:49 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-03-03 18:03:44 +0100 |
| commit | 5dcf92a6624911cd85d6fbf42a4cc2980d9afef3 (patch) | |
| tree | 36862f33a58bb3d7cbf0e7aa119985e36869b480 | |
| parent | ccd81cffcb5362b5498c350cab6459e423f278fc (diff) | |
Fix orderless--anchored-quoted-regexp: Detect \` instead of ^
This makes a difference for multi-line candidates. Multi-line candidates are
uncommon, but they exist, e.g., for read-from-kill-ring.
| -rw-r--r-- | orderless.el | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/orderless.el b/orderless.el index 880ae1f..66a7b53 100644 --- a/orderless.el +++ b/orderless.el @@ -223,7 +223,7 @@ is determined by the values of `completion-ignore-case', (defun orderless-prefix (component) "Match COMPONENT as a literal prefix string." - `(seq bol (literal ,component))) + `(seq bos (literal ,component))) (defun orderless--separated-by (sep rxs &optional before after) "Return a regexp to match the rx-regexps RXS with SEP in between. @@ -493,10 +493,10 @@ The predicate PRED is used to constrain the entries in TABLE." ;; 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), +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))) + (when (and (string-prefix-p "\\(?:\\`" regexp) (string-suffix-p "\\)" regexp)) + (let ((trimmed (substring regexp 6 -2))) (unless (string-match-p "[$*+.?[\\^]" (replace-regexp-in-string "\\\\[$*+.?[\\^]" "" trimmed @@ -515,7 +515,7 @@ then return (cons REGEXP u); else return nil." (defun orderless--filter (prefix regexps ignore-case table pred) "Filter TABLE by PREFIX, REGEXPS and PRED. The matching should be case-insensitive if IGNORE-CASE is non-nil." - ;; If there is a regexp of the form \(?:^quoted-regexp\) then + ;; 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-loop for r in regexps thereis (orderless--anchored-quoted-regexp r)) |
