summaryrefslogtreecommitdiffhomepage
path: root/consult.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-03-22 19:03:32 +0000
committerjao <jao@gnu.org>2021-03-22 19:03:32 +0000
commit24924040c6189db824b2ff32a74f5ca3b124c151 (patch)
tree2a0c7ef2c8a1585f66f477729fc81f702554329f /consult.org
parent6e17fcc8b793684eaf4b4d894c93e070cd575ee1 (diff)
downloadelibs-24924040c6189db824b2ff32a74f5ca3b124c151.tar.gz
elibs-24924040c6189db824b2ff32a74f5ca3b124c151.tar.bz2
finally using orderless (for now, without prescient sorting)
Diffstat (limited to 'consult.org')
-rw-r--r--consult.org93
1 files changed, 25 insertions, 68 deletions
diff --git a/consult.org b/consult.org
index 6c99e77..027e60d 100644
--- a/consult.org
+++ b/consult.org
@@ -1,14 +1,26 @@
#+title: Completion configuration using selectrum, consult and friends
-* completion styles
+* completion styles: orderless
#+begin_src emacs-lisp
- (setq completion-styles '(basic partial-completion emacs22))
+ (use-package orderless
+ :ensure t
+ :custom ((completion-styles '(orderless))
+ ;; orderless-literal comes in handy when using selectrum's
+ ;; quick-keys, for instance after it inserts the full selected
+ ;; line in a consult-line session.
+ (orderless-matching-styles
+ '(orderless-regexp orderless-initialism orderless-literal)))
+ :init
+ :bind
+ ((:map minibuffer-local-completion-map ("SPC" . self-insert-command))))
#+end_src
* prescient
- #+begin_src emacs-lisp
+ #+begin_src emacs-lisp :load no
(use-package prescient
:ensure t
:custom ((prescient-sort-full-matches-first t)))
+
+ (use-package selectrum-prescient :ensure t)
#+end_src
* selectrum
#+begin_src emacs-lisp
@@ -21,8 +33,6 @@
(selectrum-show-indices nil)
(selectrum-count-style 'current/matches)) ;; 'matches
:bind (("C-R" . selectrum-repeat)))
-
- (use-package selectrum-prescient :ensure t)
#+end_src
* marginalia
#+begin_src emacs-lisp
@@ -326,71 +336,18 @@
(add-to-list 'embark-transformer-alist '(url . jao-embark-targets--refine-url))
(add-to-list 'embark-keymap-alist '(video-url . jao-embark-targets-video-url-map))
#+end_src
-*** embark as selectrum lite
- #+begin_src emacs-lisp
- (defun jao-embark--shrink-selectrum ()
- (when (eq embark-collect--kind :live)
- (with-selected-window (active-minibuffer-window)
- (when (bound-and-true-p selectrum-active-p)
- (setq-local selectrum-num-candidates-displayed 1)))))
-
- (add-to-list 'display-buffer-alist
- '("\\`\\*Embark Collect.*\\*"
- (display-buffer-below-selected)
- (window-height . 0.25)
- (window-parameters (mode-line-format . none))))
-
- (defun jao-embark-select-first-completion ()
- (interactive)
- (embark-switch-to-collect-completions)
- (push-button))
-
- (defun jao-embark-prescient-candidates ()
- (prescient-sort (cdr (embark-minibuffer-candidates))))
-
- (defun jao-remember-candidate-on-exit ()
- (prescient-remember (minibuffer-contents)))
-
- (defun jao-embark-remember-target (_action target &optional _exit)
- (prescient-remember target))
-
- (defun jao-embark-compui-enable ()
- (interactive)
- (setq completion-styles '(flex initials substring))
-
- (when (bound-and-true-p selectrum-mode)
- (selectrum-mode -1))
- (push #'jao-embark-prescient-candidates
- embark-candidate-collectors)
- (defalias 'switch-to-completions
- 'embark-switch-to-collect-completions)
- (add-hook 'minibuffer-exit-hook
- #'jao-remember-candidate-on-exit)
- (advice-add 'embark--act :before #'jao-embark-remember-target)
- (define-key minibuffer-local-map (kbd "C-SPC")
- #'embark-collect-completions)
- (define-key minibuffer-local-map (kbd "M-SPC")
- #'embark-collect-completions)
- (define-key minibuffer-local-map (kbd "C-n")
- #'embark-switch-to-collect-completions)
- (define-key minibuffer-local-map (kbd "RET")
- #'jao-embark-select-first-completion))
-
- (defun jao-embark-compui-disable ()
- (interactive)
- (setq completion-styles '(basic partial-completion emacs22))
- (remove-hook 'minibuffer-exit-hook
- #'jao-remember-candidate-on-exit)
- (advice-remove 'embark--act #'jao-embark-remember-target)
- (when (boundp selectrum-mode)
- (define-key minibuffer-local-map (kbd "C-n")
- 'selectrum-next-candidate)
- (selectrum-mode 1)))
- #+end_src
* startup
#+begin_src emacs-lisp
(selectrum-mode 1)
- (selectrum-prescient-mode 1)
- (prescient-persist-mode 1)
+
+ ;; Use prescient, but only for sorting:
+ ;; (setq selectrum-prescient-enable-filtering nil)
+ ;; (selectrum-prescient-mode 1)
+ ;; (prescient-persist-mode 1)
+
+ ;; Highlighting only the visible matches:
+ (setq orderless-skip-highlighting (lambda () selectrum-is-active))
+ (setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
+
(marginalia-mode 1)
#+end_src