branch: externals/consult commit ac4da6bfe32e1c5c7713b8c2e424acd7796ff7f9 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Add consult--split-nil See also recent discussion in #393 --- README.org | 5 +++-- consult.el | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.org b/README.org index f692c0f..0fcdd81 100644 --- a/README.org +++ b/README.org @@ -522,13 +522,14 @@ their descriptions. This two-level filtering is possible by splitting the input string. Part of the input string is treated as input to grep and part of the input is used for filtering. There are multiple splitting styles available, configured in - ~consult-async-split-styles-alist~: =space=, =comma=, =semicolon= and =perl=. + ~consult-async-split-styles-alist~: =nil=, =space=, =comma=, =semicolon= and =perl=. The default splitting style is configured with the variable ~consult-async-split-style~. With the =space=, =comma= and =semicolon= splitting styles, the first word before the space/comma/semicolon is passed to grep, the remaining string is - used for filtering. + used for filtering. The =nil= splitting style does not perform any splitting, + the whole input is passed to grep. The =perl= splitting style splits the input string at a punctuation character, using a similar syntax as Perl regular expressions. diff --git a/consult.el b/consult.el index effc791..4244553 100644 --- a/consult.el +++ b/consult.el @@ -116,13 +116,15 @@ This applies to asynchronous commands, e.g., `consult-grep'." (defcustom consult-async-split-style 'perl "Async splitter style, see `consult-async-split-styles-alist'." - :type '(choice (const :tag "Space" space) + :type '(choice (const :tag "No splitting" nil) + (const :tag "Space" space) (const :tag "Comma" comma) (const :tag "Semicolon" semicolon) (const :tag "Perl" perl))) (defcustom consult-async-split-styles-alist - '((space :separator ?\s :type separator) + '((nil :type nil) + (space :separator ?\s :type separator) (comma :separator ?, :type separator) (semicolon :separator ?\; :type separator) (perl :initial "#" :type perl)) @@ -1361,6 +1363,10 @@ separator. Examples: \"/async/filter\", \"#async#filter\"." ,@(and (match-end 2) `((,(match-beginning 2) . ,(match-end 2))))))) `(,str "" 0))) +(defun consult--split-nil (str _point) + "Treat the complete input STR as async input." + `(,str "" 0)) + (defun consult--split-separator (sep str point) "Split input STR in async input and filtering part at the first separator SEP. POINT is the point position." @@ -1482,6 +1488,7 @@ SPLIT is the splitting function." ('separator (apply-partially #'consult--split-separator (plist-get style :separator))) ('perl #'consult--split-perl) + ('nil #'consult--split-nil) (type (user-error "Invalid style type `%s'" type)))))) (lambda (action) (pcase action