Added consult

This commit is contained in:
Seth Morabito 2023-09-15 18:09:59 -07:00
parent d9ba808dbf
commit 82bf3c84f2
1 changed files with 118 additions and 65 deletions

View File

@ -1,7 +1,7 @@
#+AUTHOR: Seth Morabito
#+EMAIL: web@loomcom.com
#+TITLE: GNU Emacs Configuration File
#+OPTIONS: toc:1 ':t
#+OPTIONS: toc:nil ':t
#+STARTUP: showall
* Table of Contents
@ -49,25 +49,12 @@ rely on /lexical binding/, so that gets turned on first!
;; -*- lexical-binding: t; -*-
#+END_SRC
** Native Compilation
** Where to Store Customization
If (and only if) Emacs has native compilation available, set it up to
do its thing.
#+BEGIN_SRC emacs-lisp
(when (and (fboundp #'native-comp-available-p)
(native-comp-available-p)
(functionp #'json-serialize))
(setq comp-deferred-compilation t))
#+END_SRC
** Where to store Customization
First things first. Because I use =org-babel= and literate programming
style for my config, I want my =init.el= file to be as small as
possible. For that reason, I want Emacs to put all of its generated
fluff into a separate file that is actually outside the Emacs
directory.
First things first. Because I use =org-babel= and literate programming style
for my config, I want my =init.el= file to be as small as possible. For that
reason, I want Emacs to put all of its generated fluff into a separate
file that is actually outside the Emacs directory.
#+BEGIN_SRC emacs-lisp
(let ((local-custom-file "~/.emacs-custom.el"))
@ -79,9 +66,8 @@ directory.
** Default Directory
Some builds of emacs on exotic operating systems don't automatically
know that I want my home directory to be the default find-file
directory.
Some builds of emacs on exotic operating systems don't automatically know
that I want my home directory to be the default find-file directory.
#+BEGIN_SRC emacs-lisp
(setq default-directory (expand-file-name "~/"))
@ -90,8 +76,8 @@ directory.
** Reducing Clutter
Next, I like to immediately reduce what I consider to be visual
clutter. Your milage may vary, but for me this means turning off
startup messages, the splash screen, tool bar, and tooltips.
clutter. Your milage may vary, but for me this means turning off startup
messages, the splash screen, tool bar, and tooltips.
#+BEGIN_SRC emacs-lisp
(setq warning-minimum-level :emergency
@ -141,6 +127,24 @@ I prefer to use ~ibuffer~ when listing buffers
(global-set-key [remap list-buffers] 'ibuffer)
#+END_SRC
I completely disable lockfiles, which I don't need, and which only cause
trouble for me.
#+BEGIN_SRC emacs-lisp
(setq create-lockfiles nil)
#+END_SRC
** Turn Off Suspending Emacs with Control-Z
I disable the default "Control-Z" behavior of suspending emacs, because I
find that I accidentally hit this key combo way too often when my clumsy
fingers are trying to hit "Control-X"
#+BEGIN_SRC emacs-lisp
(global-unset-key [(control z)])
(global-unset-key [(control x)(control z)])
#+END_SRC
** Long line improvements
Here are a few settings that help improve Emacs performance when
@ -191,59 +195,43 @@ me).
(setq delete-old-versions t)
#+END_SRC
Spelling is important (I'm terrible at spelling).
** Spelling
Spelling is important (I'm terrible at spelling). This block configures
=ispell=. It relies on an external dictionary program; first it will check
to see if =aspell= is available, and if so, set it as the default spell
checking program. If that's not found, it will search for =hunspell= and set
that. If neither is found, oh well, no spell checking program for us.
#+BEGIN_SRC emacs-lisp
(setq ispell-local-dictionary "en_US"
ispell-local-dictionary-alist
'(("en_US" "[[:alpha]]" "[^[:alpha:]]" "[']"
nil ("-d" "en_US") nil utf-8)))
(cond
((executable-find "aspell")
(setq ispell-program-name "aspell"))
((executable-find "hunspell")
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "en_US")
(setq ispell-local-dictionary-alist
'(("en_US" "[[:alpha]]" "[^[:alpha:]]" "[']"
nil ("-d" "en_US") nil utf-8))))
(setq ispell-program-name "hunspell"))
(t (setq ispell-program-name nil)))
#+END_SRC
On macOS, I turn off ~--dired~ (because ~ls~ does not support it).
#+BEGIN_SRC emacs-lisp
(when (string= system-type "darwin")
(setq dired-use-ls-dired nil))
#+END_SRC
I completely disable lockfiles, which I don't need, and which only
cause trouble.
#+BEGIN_SRC emacs-lisp
(setq create-lockfiles nil)
#+END_SRC
Lastly, I disable the default "Control-Z" behavior of suspending
emacs, because I find that I accidentally hit this key combo way too
often when my clumsy fingers are trying to hit "Control-X"
#+BEGIN_SRC emacs-lisp
(global-unset-key [(control z)])
(global-unset-key [(control x)(control z)])
#+END_SRC
** Scrolling
=scroll-step= controls the number of lines that the window will scroll
automatically when the cursor moves off the screen. By default, it
will jump you so that the cursor is centered (vertically) after
scrolling. I really don't like this behavior, so I set it to =1= so the
window will only move by a single line.
automatically when the cursor moves off the screen. By default, it will
jump you so that the cursor is centered (vertically) after scrolling. I
really don't like this behavior, so I set it to =1= so the window will only
move by a single line.
#+BEGIN_SRC emacs-lisp
(setq scroll-step 1)
#+END_SRC
Next, setting =scroll-conservatively= to a very large number will
further prevent automatic centering. The value =10,000= comes from a
suggestion on the [[https://www.emacswiki.org/emacs/SmoothScrolling][Emacs Wiki]].
Next, setting =scroll-conservatively= to a very large number will further
prevent automatic centering. The value =10,000= comes from a suggestion on
the [[https://www.emacswiki.org/emacs/SmoothScrolling][Emacs Wiki]].
#+BEGIN_SRC emacs-lisp
(setq scroll-conservatively 10000)
@ -301,8 +289,7 @@ The first thing I like to do is set the default connection method.
(setq tramp-default-method "ssh")
#+END_SRC
Then, I up some default values to make editing large directories
happy.
Then, I up some default values to make editing large directories happy.
#+BEGIN_SRC emacs-lisp
(setq max-lisp-eval-depth 10000) ; default is 400
@ -320,8 +307,8 @@ Keep a list of recently opened files
** Exec Path
If certain directories exist, they should be added to ~exec-path~,
and the ~PATH~ environment variable.
If certain directories exist, they should be added to =exec-path= and the
=PATH= environment variable.
#+BEGIN_SRC emacs-lisp
(setq loomcom-append-to-path
@ -741,7 +728,8 @@ often.
** Completion UI - Vertico
I recently switched to Vertico for completion UI, which replaces Helm / Ivy.
I recently switched to Vertico and Consult for completion and completion,
which replaces Helm / Ivy.
#+BEGIN_SRC emacs-lisp
(use-package vertico
@ -758,6 +746,71 @@ I recently switched to Vertico for completion UI, which replaces Helm / Ivy.
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
(use-package consult
:ensure t
:hook (completion-list-mode . consult-preview-at-point-mode)
:bind (("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 b" . consult-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-x 5 b" . consult-buffer-other-frame)
("C-x r b" . consult-bookmark)
("C-x p b" . consult-project-buffer)
("M-#" . consult-register-load)
("M-'" . consult-register-store)
("C-M-#" . consult-register)
("M-y" . consult-yank-pop)
("M-g e" . consult-compile-error)
("M-g f" . consult-flymake)
("M-g g" . consult-goto-line)
("M-g M-g" . consult-goto-line)
("M-g o" . consult-outline)
("M-g m" . consult-mark)
("M-g k" . consult-global-mark)
("M-g i" . consult-imenu)
("M-g I" . consult-imenu-multi)
("M-s d" . consult-find)
("M-s D" . 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)
("M-s e" . consult-isearch-history)
:map isearch-mode-map
("M-e" . consult-isearch-history)
("M-s e" . consult-isearch-history)
("M-s l" . consult-line)
("M-s L" . consult-line-multi)
:map minibuffer-local-map
("M-s" . consult-history)
("M-r" . consult-history))
:init
(setq register-preview-delay 0.5
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
(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 '(:debounce 0.4 any))
(setq consult-narrow-key "<"))
#+END_SRC
** Org Mode