diff options
| author | Omar Antolín <omar.antolin@gmail.com> | 2020-04-14 11:20:59 -0500 |
|---|---|---|
| committer | Omar Antolín <omar.antolin@gmail.com> | 2020-04-14 11:20:59 -0500 |
| commit | ae36760f610d25693f089dde31b51d4e9c5f9363 (patch) | |
| tree | d2eeb3657c563714b3e1e738e99a6c3e69bad66a | |
| parent | 7752cb4abbd8720b8d53c8005cfa5621f3313fe2 (diff) | |
Colorize matching portions of candidates
| -rw-r--r-- | orderless.el | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/orderless.el b/orderless.el index 22ac799..c515056 100644 --- a/orderless.el +++ b/orderless.el @@ -45,6 +45,15 @@ ;;; Code: +(defun orderless-highlight-match (regexp string) + (when (string-match regexp string) + (font-lock-prepend-text-property + (match-beginning 0) + (match-end 0) + 'face 'completions-common-part + string) + t)) + (defun orderless-all-completions (string table pred _point) (let* ((lim (car (completion-boundaries string table pred ""))) (prefix (substring string 0 lim)) @@ -55,10 +64,12 @@ (condition-case nil (progn (setq all - (cl-loop for candidate in all - when (cl-loop for regexp in regexps - always (string-match-p regexp candidate)) - collect candidate)) + (save-match-data + (cl-loop for candidate in all + when (cl-loop for regexp in regexps + always (orderless-highlight-match + regexp candidate)) + collect candidate))) (when all (nconc all (length prefix)))) (invalid-regexp nil)))) |
