Skip to content

Possible orderless support for grep patterns #381

@minad

Description

@minad

In order to support this the functions consult--compile-regexp and consult--convert-regexp must be replaced by Orderless/Pcre2el or an alternative more powerful converter.

consult/consult.el

Lines 593 to 611 in d9e7a6b

(defun consult--emacs-to-extended-regexp (regexp)
"Convert Emacs REGEXP to extended regexp syntax (ERE).
This function only changes the escaping of parentheses, braces and pipes."
(replace-regexp-in-string
"\\\\\\\\\\|\\\\?[(){}|]"
(lambda (x)
(cond
((equal x "\\\\") x)
((= 1 (length x)) (concat "\\\\" x))
(t (substring x 1))))
regexp))
(defun consult--compile-regexp (str type)
"Compile STR to a list of regexps of TYPE."
(setq str (split-string str nil 'omit-nulls))
(pcase-exhaustive type
((or 'basic 'emacs) str)
((or 'lookahead 'extended)
(mapcar #'consult--emacs-to-extended-regexp str))))

See also the discussion in #380.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions