;; Time-stamp: <2024-09-24 17h43 EDT (6e0a849e)> (use-package savehist :ensure t :init (savehist-mode)) ;; ----------------------------------------------------------------------------- ;; General configuration (use-package emacs :init ;; Add prompt indicator to `completing-read-multiple'. (defun crm-indicator (args) (cons (concat "[CRM] " (car args)) (cdr args))) (advice-add #'completing-read-multiple :filter-args #'crm-indicator) ;; Grow and shrink minibuffer ;;(setq resize-mini-windows t) ;; Do not allow the cursor in the minibuffer prompt (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) ;; Enable recursive minibuffers (setq enable-recursive-minibuffers t)) ;; ----------------------------------------------------------------------------- ;; Vertico (use-package vertico :ensure t :bind (:map vertico-map ("" . vertico-insert) ("DEL" . vertico-directory-delete-char)) :init (vertico-mode) (setq vertico-cycle t) (setq completion-styles '(substring))) ;; ----------------------------------------------------------------------------- ;; Orderless (use-package orderless :ensure t :config (setq orderless-component-separator 'orderless-escapable-split-on-space completion-styles '(orderless basic) completion-category-overrides '((file (styles basic))))) ;; ----------------------------------------------------------------------------- ;; Consult (use-package consult :ensure t :bind (;; C-c bindings (mode-specific-map) ("C-c M-x" . consult-mode-command) ("C-c h" . consult-history) ("C-c k" . consult-kmacro) ("C-c m" . consult-man) ("C-c i" . consult-info) ([remap Info-search] . consult-info) ;; C-x bindings (ctl-x-map) ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ("C-x t b" . consult-buffer-other-tab) ;; orig. switch-to-buffer-other-tab ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) ;; orig. yank-pop (" a" . consult-apropos) ;; orig. apropos-command ;; M-g bindings (goto-map) ("M-g e" . consult-compile-error) ("M-g M-g" . consult-goto-line) ;; orig. goto-line ("M-g g" . consult-goto-line) ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) ("M-g I" . consult-imenu-multi) ;; M-s bindings (search-map) ("M-s d" . consult-find) ;; Alternative: consult-fd ("M-s c" . consult-locate) ("M-s g" . consult-grep) ("M-s G" . consult-git-grep) ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("M-s L" . consult-line-multi) ("M-s k" . consult-keep-lines) ("M-s u" . consult-focus-lines) ) :hook (completion-list-mode . consult-preview-at-point-mode) :init ;; Optionally configure the register formatting. This improves the register ;; preview for `consult-register', `consult-register-load', ;; `consult-register-store' and the Emacs built-ins. (setq register-preview-delay 0 register-preview-function #'consult-register-format) ;; Optionally tweak the register preview window. ;; This adds thin lines, sorting and hides the mode line of the window. (advice-add #'register-preview :override #'consult-register-window) ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) :config (defun previous-history-or-next () (interactive) (if (string= "" (minibuffer-contents-no-properties)) (progn (previous-history-element 1) (end-of-line)) (vertico-next))) (defvar my-consult-line-map (let ((map (make-sparse-keymap))) (define-key map "\C-s" #'previous-history-or-next) map)) (consult-customize consult-line :keymap my-consult-line-map consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file consult-xref consult--source-bookmark consult--source-file-register consult--source-recent-file consult--source-project-recent-file) ;; Optionally configure the narrowing key. ;; Both < and C-+ work reasonably well. (setq consult-narrow-key "<") ;; (kbd "C-+") (setq consult-buffer-sources '(consult--source-hidden-buffer consult--source-modified-buffer consult--source-buffer consult--source-recent-file consult--source-file-register consult--source-bookmark)) ;; Ues consult for capfs (setq completion-in-region-function #'consult-completion-in-region)) ;; ----------------------------------------------------------------------------- ;; Marginalia (use-package marginalia :ensure t :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) :init (marginalia-mode))