commit efa1bb1a198b3f2abdd63900190059f8a3e503bd
parent 6671864d4ef7eb34f5c1a253d0184b2838a250eb
Author: dwrz <dwrz@dwrz.net>
Date: Sat, 9 Dec 2023 15:03:57 +0000
Update Emacs init
Diffstat:
M | emacs/init.el | | | 206 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ |
1 file changed, 176 insertions(+), 30 deletions(-)
diff --git a/emacs/init.el b/emacs/init.el
@@ -89,7 +89,6 @@
(fill-region (region-beginning) (region-end) nil)))
;; Packages
-;; TODO: try corfu, vertico, consult.
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
@@ -127,27 +126,41 @@
:ensure nil
:functions calendar-set-date-style)
-(use-package cc-vars :config (setq-default c-basic-offset 8) :ensure nil)
-
-(use-package company
- :bind (:map company-active-map
- ("<return>" . nil)
- ("<tab>" . company-complete-selection)
- ("RET". nil))
- :config
- (setq company-idle-delay 0
- company-minimum-prefix-length 1
- company-tooltip-align-annotations t)
- :ensure t
- :hook (company-mode . company-box-mode)
- :init (global-company-mode t))
-
-(use-package company-box :defer t :ensure t)
+(use-package cape
+ ;; Alternative prefix keys: C-c p, M-p, M-+, ...
+ ;; :bind (("C-c p p" . completion-at-point) ;; capf
+ ;; ("C-c p t" . complete-tag) ;; etags
+ ;; ("C-c p d" . cape-dabbrev) ;; or dabbrev-completion
+ ;; ("C-c p h" . cape-history)
+ ;; ("C-c p f" . cape-file)
+ ;; ("C-c p k" . cape-keyword)
+ ;; ("C-c p s" . cape-elisp-symbol)
+ ;; ("C-c p e" . cape-elisp-block)
+ ;; ("C-c p a" . cape-abbrev)
+ ;; ("C-c p l" . cape-line)
+ ;; ("C-c p w" . cape-dict)
+ ;; ("C-c p :" . cape-emoji)
+ ;; ("C-c p \\" . cape-tex)
+ ;; ("C-c p _" . cape-tex)
+ ;; ("C-c p ^" . cape-tex)
+ ;; ("C-c p &" . cape-sgml)
+ ;; ("C-c p r" . cape-rfc1345))
+ :init
+ (add-to-list 'completion-at-point-functions #'cape-dabbrev)
+ (add-to-list 'completion-at-point-functions #'cape-file)
+ (add-to-list 'completion-at-point-functions #'cape-elisp-block)
+ ;;(add-to-list 'completion-at-point-functions #'cape-history)
+ ;;(add-to-list 'completion-at-point-functions #'cape-keyword)
+ ;;(add-to-list 'completion-at-point-functions #'cape-tex)
+ ;;(add-to-list 'completion-at-point-functions #'cape-sgml)
+ ;;(add-to-list 'completion-at-point-functions #'cape-rfc1345)
+ ;;(add-to-list 'completion-at-point-functions #'cape-abbrev)
+ ;;(add-to-list 'completion-at-point-functions #'cape-dict)
+ ;;(add-to-list 'completion-at-point-functions #'cape-elisp-symbol)
+ ;;(add-to-list 'completion-at-point-functions #'cape-line)
+ :ensure t)
-(use-package company-quickhelp
- :config (setq company-quickhelp-delay 0.25)
- :ensure t
- :init (company-quickhelp-mode t))
+(use-package cc-vars :config (setq-default c-basic-offset 8) :ensure nil)
(use-package compile
:config (setq compilation-message-face 'default)
@@ -155,6 +168,115 @@
(use-package conf-mode :ensure nil)
+(use-package consult
+ :bind (("C-s" . consult-line)
+ ("C-r" . consult-ripgrep))
+ ;; :bind (;; C-c bindings in `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 in `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
+ ;; ;; M-g bindings in `goto-map'
+ ;; ("M-g e" . consult-compile-error)
+ ;; ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck
+ ;; ("M-g g" . consult-goto-line) ;; orig. goto-line
+ ;; ("M-g M-g" . consult-goto-line) ;; orig. 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 in `search-map'
+ ;; ("M-s d" . consult-find) ;; Alternative: consult-fd
+ ;; ("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)
+ ;; ;; Isearch integration
+ ;; ("M-s e" . consult-isearch-history)
+ ;; :map isearch-mode-map
+ ;; ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string
+ ;; ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string
+ ;; ("M-s l" . consult-line) ;; needed by consult-line to detect isearch
+ ;; ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch
+ ;; ;; Minibuffer history
+ ;; :map minibuffer-local-map
+ ;; ("M-s" . consult-history) ;; orig. next-matching-history-element
+ ;; ("M-r" . consult-history)) ;; orig. previous-matching-history-element
+ ;; Enable automatic preview at point in the *Completions* buffer. This is
+ ;; relevant when you use the default completion UI.
+ :hook (completion-list-mode . consult-preview-at-point-mode)
+ :init
+ (setq register-preview-delay 0
+ register-preview-function #'consult-register-format)
+ (advice-add #'register-preview :override #'consult-register-window)
+ (setq xref-show-xrefs-function #'consult-xref
+ xref-show-definitions-function #'consult-xref)
+ :config
+ ;; Optionally configure preview. The default value
+ ;; is 'any, such that any key triggers the preview.
+ ;; (setq consult-preview-key 'any)
+ ;; (setq consult-preview-key "M-.")
+ ;; (setq consult-preview-key '("S-<down>" "S-<up>"))
+ ;; For some commands and buffer sources it is useful to configure the
+ ;; :preview-key on a per-command basis using the `consult-customize' macro.
+ (consult-customize
+ consult-theme :preview-key '(:debounce 0.2 any)
+ 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
+ ;; :preview-key "M-."
+ :preview-key '(:debounce 0.4 any))
+
+ ;; Optionally configure the narrowing key.
+ ;; Both < and C-+ work reasonably well.
+ (setq consult-narrow-key "<") ;; "C-+"
+
+ ;; Optionally make narrowing help available in the minibuffer.
+ ;; You may want to use `embark-prefix-help-command' or which-key instead.
+ ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
+ :ensure t)
+
+(use-package corfu
+ :bind (:map corfu-map ("RET" . nil))
+ :custom
+ (corfu-auto t)
+ (corfu-auto-delay 0.1)
+ (corfu-auto-prefix 2)
+ (corfu-cycle t)
+ (corfu-scroll-margin 0)
+ :ensure t
+ :init (global-corfu-mode)
+ (setq tab-always-indent 'complete))
+
+(use-package corfu-terminal
+ :init (unless (display-graphic-p) (corfu-terminal-mode +1))
+ :ensure t)
+
+(use-package consult-lsp :ensure t)
+
+(use-package consult-notmuch :ensure t)
+
(use-package csv-mode :mode "\\.csv\\'" :ensure t)
(use-package css-mode :hook (web-mode . css-mode) :ensure nil)
@@ -188,6 +310,18 @@
:hook (emacs-lisp-mode . eldoc-mode)
:ensure nil)
+(use-package embark
+ :bind
+ (("C-." . embark-act)
+ ("C-," . embark-dwim)
+ ("C-'" . embark-bindings))
+ :ensure t)
+
+(use-package embark-consult
+ :ensure t
+ :hook
+ (embark-collect-mode . consult-preview-at-point-mode))
+
(use-package faces
:config (set-face-attribute
'default t
@@ -250,8 +384,6 @@
(use-package hydra :ensure t)
-(use-package icomplete :init (fido-vertical-mode) :ensure nil)
-
(use-package ido
:config (setq ido-default-buffer-method 'selected-window
ido-everywhere t
@@ -260,8 +392,6 @@
ido-enable-flex-matching t)
:ensure nil)
-(use-package isearch :config (setq isearch-allow-scroll t) :ensure nil)
-
(use-package ispell
:config (setq ispell-program-name "/usr/bin/aspell"
ispell-dictionary "en_US"
@@ -287,7 +417,11 @@
(use-package magit :bind ("C-x g" . magit-status) :ensure t)
-(use-package marginalia :init (marginalia-mode t) :defer t :ensure t)
+(use-package marginalia
+ :custom (marginalia-align 'right)
+ :init (marginalia-mode t)
+ :defer t
+ :ensure t)
(use-package markdown-mode :defer t :ensure t)
@@ -349,7 +483,6 @@
(setq notmuch-address-command 'internal
notmuch-address-internal-completion '(sent nil)
notmuch-address-save-filename "~/org/contacts/notmuch-contacts"
- notmuch-address-use-company t
notmuch-crypto-process-mime t
notmuch-fcc-dirs "sent"
notmuch-hello-hide-tags '("spam")
@@ -378,6 +511,13 @@
(use-package ol-notmuch :bind ("C-c l" . org-store-link) :defer t :ensure t)
+(use-package orderless
+ :ensure t
+ :custom
+ (orderless-matching-styles 'orderless-regexp)
+ (completion-styles '(orderless basic))
+ (completion-category-overrides '((file (styles basic partial-completion)))))
+
(use-package org
:bind (:map org-mode-map
("<M-right>" . nil)
@@ -432,7 +572,7 @@
"~/projects/home/home.org"
"~/projects/rz/rz.org"
"~/projects/src/src.org")
- work-agenda-files '("~/projects/museum-exchange/museum-exchange.org"))
+ work-agenda-files '("~/projects/eti/museum-exchange.org"))
(defun dwrz-switch-org-ctx (ctx)
"Switch org agenda context."
@@ -556,12 +696,12 @@
(use-package register
:config (set-register ?c '(file . "~/.config/"))
(set-register ?d '(file . "~/org/diary.org"))
+ (set-register ?e '(file . "~/projects/eti/"))
(set-register ?f '(file . "~/projects/finances/finances.org"))
(set-register ?g '(file . "~/org/gtd.org"))
(set-register ?h '(file . "~/projects/home/home.org"))
(set-register ?i '(file . "~/.config/emacs/init.el"))
(set-register ?j '(file . "~/journal/2023/2023.org"))
- (set-register ?m '(file . "~/projects/museum-exchange"))
(set-register ?o '(file . "~/org/")))
(use-package scroll-bar :config (scroll-bar-mode -1) :ensure nil)
@@ -622,6 +762,13 @@
(use-package tool-bar :config (tool-bar-mode -1) :ensure nil)
+(use-package vertico
+ :config
+ (setq vertico-cycle t
+ vertico-resize t)
+ :init (vertico-mode)
+ :ensure t)
+
(use-package visual-fill-column
:config (setq split-window-preferred-function
'visual-fill-column-split-window-sensibly)
@@ -726,7 +873,6 @@
(global-set-key (kbd "C-c y") nil)
(global-set-key (kbd "C-c z") nil)
(global-set-key (kbd "C-c #") 'display-line-numbers-mode)
-(global-set-key (kbd "C-r") 'rgrep)
(global-set-key (kbd "C-x 9") 'dwrz-split-window-two-thirds)
(global-set-key (kbd "C-x C-b") 'ibuffer)
(global-set-key (kbd "C-x t") 'dwrz-shell-in-current-directory)