Selectrum, etc

Tags:  CCE

high-chaos organization here… replacing Ivy and Counsel and Ivy Posframe with the new hotness, this constellation of packages:

Selectrum, Prescient, and Orderless

(use-package selectrum
  :config
  (selectrum-mode +1)
  (setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
  (global-set-key (kbd "C-x C-z") #'selectrum-repeat))

(use-package orderless
  :custom (completion-styles '(orderless)))

(use-package selectrum-prescient
  :after (selectrum)
  :config
  (setq selectrum-prescient-enable-filtering nil)
  (selectrum-prescient-mode +1)
  (prescient-persist-mode +1))

Mini Frame

The only interesting things here is that i set parent-frame to nil similar to how i have to configure Ivy Posframe – this is for EXWM windowing support. I also disable the mini-frame in a bunch of spots.

(use-package mini-frame
  :config
  (mini-frame-mode +1)
  (setq resize-mini-frames t)
  (setq mini-frame-show-parameters
        '((parent-frame . nil)
          (top . 25)
          (height . 1)
          (width . 0.7)
          (left . 0.5)))
  (dolist (cmd '(calcDigit-start
                 background-shell-command
                 evil-ex
                 consult-line
                 org-fc-type-text-input-setup
                 consult-ripgrep))
    (add-to-list 'mini-frame-ignore-commands cmd)))

Consult

Consult contains a bunch of nice builtin-replacements which utilize these other libraries to their fullest extent. consult-buffer in particular is quite nice, for example.

(use-package consult
  :init
  (setq xref-show-xrefs-function #'consult-xref
        xref-show-definitions-function #'consult-xref)
  :config
  (setq consult-narrow-key "<")
  (autoload 'projectile-project-root "projectile")
  (setq consult-project-root-function #'projectile-project-root)

  :bind
  ("C-x b" . consult-buffer)
  ("C-x 4 b" . consult-buffer-other-window)
  ("C-x 5 b" . consult-buffer-other-frame)
  ("C-c h" . consult-history)
  ("C-c k" . consult-kmacro)
  (:map evil-leader--default-map
        ("b" . consult-buffer)
        ("<SPC>" . execute-extended-command))
  (:map evil-normal-state-map
        ("M-y" . consult-yank-pop) 
        ("/" . consult-line)))

(use-package consult-flycheck
  :bind (:map flycheck-command-map
              ("!" . consult-flycheck)))

Consult Buffer shouldn't preview EXWM buffers

via consult wiki, to prevent Consult Buffer from always popping exwm buffers and moving things around, I apply this monkeypatch which filters them out of consideration for preview.

  (defun consult-buffer-state-no-x ()
    "Buffer state function that doesn't preview X buffers."
    (lexical-let ((orig-state (consult--buffer-state))
          (filter (lambda (cand restore)
                    (if (or restore
                            (let ((buffer (get-buffer cand)))
                              (and buffer
                                   (not (eq 'exwm-mode (buffer-local-value 'major-mode buffer))))))
                        cand
                      nil))))
      (lambda (cand restore)
        (funcall orig-state (funcall filter cand restore) restore))))

(with-eval-after-load "consult"
  (setq consult--source-buffer
        (plist-put consult--source-buffer :state #'consult-buffer-state-no-x)))

Embark and Marginalia

(use-package marginalia
  :config (marginalia-mode)
  :bind
  (("M-A" . marginalia-cycle)
   :map minibuffer-local-map
   ("M-A" . marginalia-cycle)))

(use-package embark
  :bind
  (("C-S-a" . embark-act)       ;; pick some comfortable binding
   ("C-h b" . embark-bindings)) ;; alternative for `describe-bindings'

  :init (setq prefix-help-command #'embark-prefix-help-command)

  :config
  ;; Hide the mode line of the Embark live/completions buffers
  (add-to-list 'display-buffer-alist
               '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
                 nil
                 (window-parameters (mode-line-format . none)))))

;; Consult users will also want the embark-consult package.
(use-package embark-consult
  :after (embark consult)
  :demand t ; only necessary if you have the hook below
  ;; if you want to have consult previews as you move around an
  ;; auto-updating embark collect buffer
  :hook
  (embark-collect-mode . embark-consult-preview-minor-mode))

This is Referenced

''

in "Navigating Projects With Projectile"

in "Emacs Session Startup"

in "The Complete Computing Environment"

in "Consult-Buffer Org Roam Source"