summaryrefslogtreecommitdiff
path: root/comb/orderless-conf.el
blob: 8af75e4b55867667a07d4ebc8d817631042be172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;;; -*- lexical-binding: t; -*-

(use-package "orderless" 'orderless
  (setq completion-styles '(orderless partial-completion)
	completion-category-defaults nil
	completion-flex-nospace nil
	completion-pcm-complete-word-inserts-delimiters t
	completion-show-help nil
	completion-ignore-case t
	read-file-name-completion-ignore-case t
	read-buffer-completion-ignore-case t
	resize-mini-windows t)

  (setq orderless-component-separator " +"
	orderless-matching-styles '(orderless-prefixes
				    orderless-literal
				    orderless-regexp
				    orderless-strict-leading-initialism)
	orderless-style-dispatchers '(equal-means-literal-dispatcher
				      comma-means-initial-dispatcher))

  ;; unbind space in the minibuffer
  (define-key minibuffer-local-completion-map (vector 32) nil)

  ;;; dispatchers

;;;###autoload
  (defun equal-means-literal-dispatcher (pattern _index _total)
    "If a pattern begins with an equal sign, then we use literals."
    (cond
     ((= (aref pattern 0) ?=)
      (cons 'orderless-literal (substring pattern 1)))))

;;;###autoload
  (defun comma-means-initial-dispatcher (pattern _index _total)
    "If a pattern begins with a comma, then we use initials to match."
    (cond
     ((= (aref pattern 0) ?,)
      (cons 'orderless-strict-leading-initialism (substring pattern 1))))))