|
93 | 93 | (t :foreground "yellow")) |
94 | 94 | "Face for matches of components numbered 3 mod 4.") |
95 | 95 |
|
96 | | -(defcustom orderless-component-separator #'orderless-escapable-split-on-space |
| 96 | +(defcustom orderless-component-separator #'orderless-escapable-split |
97 | 97 | "Component separators for orderless completion. |
98 | 98 | This can either be a string, which is passed to `split-string', |
99 | 99 | or a function of a single string argument." |
100 | 100 | :type `(choice (const :tag "Spaces" " +") |
101 | 101 | (const :tag "Spaces, hyphen or slash" " +\\|[-/]") |
102 | | - (const :tag "Escapable space" |
103 | | - ,#'orderless-escapable-split-on-space) |
| 102 | + (const :tag "Escapable character" ,#'orderless-escapable-split) |
104 | 103 | (const :tag "Quotable spaces" ,#'split-string-and-unquote) |
105 | 104 | (regexp :tag "Custom regexp") |
106 | 105 | (function :tag "Custom function"))) |
107 | 106 |
|
| 107 | +(defcustom orderless-escapable-separator ?\ ; space character |
| 108 | + "Character to be used as component separator by `orderless-escapable-split'." |
| 109 | + :type 'character) |
| 110 | + |
108 | 111 | (defcustom orderless-match-faces |
109 | 112 | [orderless-match-face-0 |
110 | 113 | orderless-match-face-1 |
@@ -362,15 +365,20 @@ converted to a list of regexps according to the value of |
362 | 365 |
|
363 | 366 | ;;; Compiling patterns to lists of regexps |
364 | 367 |
|
365 | | -(defun orderless-escapable-split-on-space (string) |
366 | | - "Split STRING on spaces, which can be escaped with backslash." |
367 | | - (mapcar |
368 | | - (lambda (piece) (replace-regexp-in-string (string 0) " " piece)) |
369 | | - (split-string (replace-regexp-in-string |
370 | | - "\\\\\\\\\\|\\\\ " |
371 | | - (lambda (x) (if (equal x "\\ ") (string 0) x)) |
372 | | - string 'fixedcase 'literal) |
373 | | - " +"))) |
| 368 | +(defun orderless-escapable-split (string) |
| 369 | + "Split STRING on `orderless-escapable-separator' characters, |
| 370 | +which can be escaped with backslash." |
| 371 | + (let* ((separator (string orderless-escapable-separator)) |
| 372 | + (encoded-string |
| 373 | + (string-replace |
| 374 | + (concat "\\" separator) |
| 375 | + (string 0) string)) |
| 376 | + (encoded-components |
| 377 | + (split-string encoded-string separator t))) |
| 378 | + (mapcar |
| 379 | + (lambda (component) |
| 380 | + (string-replace (string 0) separator component)) |
| 381 | + encoded-components))) |
374 | 382 |
|
375 | 383 | (defun orderless--dispatch (dispatchers default string index total) |
376 | 384 | "Run DISPATCHERS to compute matching styles for STRING. |
|
0 commit comments