From 088688b8433325c81c96a561f78e9166107e1aa4 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Fri, 26 Aug 2022 16:02:24 +0100 Subject: Add version of orderless-strict-leading-initialism --- .emacs.d/lisp/init-completion.el | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.emacs.d/lisp/init-completion.el b/.emacs.d/lisp/init-completion.el index 4c42716..429a6f5 100644 --- a/.emacs.d/lisp/init-completion.el +++ b/.emacs.d/lisp/init-completion.el @@ -67,6 +67,15 @@ (setq-local orderless-matching-styles '(orderless-literal) orderless-style-dispatchers nil)) :config + (defun orderless-strict-leading-initialism (component) + "Match a component as a strict leading initialism. +This means the characters in COMPONENT must occur in the +candidate, in that order, at the beginning of words, with +no words in between, beginning with the first word." + (orderless--separated-by '(seq (zero-or-more word) (zero-or-more punct)) + (cl-loop for char across component collect `(seq word-start ,char)) + '(seq string-start))) + ;; Recognizes the following patterns: ;; * ~flex flex~ ;; * =literal literal= @@ -90,17 +99,15 @@ ((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1))) ((string-suffix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 0 -1))) ;; Initialism matching - ((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1))) - ((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1))) + ((string-prefix-p "`" pattern) `(orderless-strict-leading-initialism . ,(substring pattern 1))) + ((string-suffix-p "`" pattern) `(orderless-strict-leading-initialism . ,(substring pattern 0 -1))) ;; Literal matching ((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1))) ((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1))) ;; Flex matching ((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1))) ((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1))))) - ;; (setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism) - ;; orderless-style-dispatchers '(my/orderless-dispatch)) - (setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-initialism) + (setq orderless-matching-styles '(orderless-literal orderless-prefixes orderless-regexp orderless-strict-leading-initialism) orderless-style-dispatchers '(my/orderless-dispatch))) ;; code completion - corfu -- cgit 1.4.1-2-gfad0