Skip to content

kchanqvq/.emacs.d

Repository files navigation

kchan’s Emacs config

This org file is an index automatically generated from init.el. Links in the file are clickable on GitHub and bring you to the source code. The more non-trivial parts of my config are marked with ⭐, which I think some people may find interesting. Have fun!

Table of Contents

Turn off GC during startup

Reset some variables, so that hot loading via eval-buffer/load-file has more faithful behavior.

Misc libraries

  • Package alist, s
  • Macro globalize: Define a global minor mode from MODE, and add to `emacs-startup-hook’.
  • Function k-guix-p
  • Macro k-use-guix-maybe
  • Function delete-from-list
  • Macro with-advice: Temporarily add ADVICE to SYMBOL during evaluation of BODY.
  • Function k-run-helper-command: Run helper shell COMMAND in buffer with NAME. Run CONTINUATION once the shell process exited. If SILENT is non-nil, do not display the NAME buffer.
  • Function k-global-set-key: Bind KEY to COMMAND, also works in EXWM windows.
  • Function k-fill-right: Prepend a variable space to STRING to make it right-aligned.
  • Function k-insert-fill-right: Insert STRING and make it right-aligned using a variable space. This is more correct than (insert (k-fill-right STRING)) in some cases, because it respect the current buffer settings, e.g. invisibility spec.
  • Function k-truncate-string-to-width: Truncate STRING to PIXEL-WIDTH. Use binary search.
  • Function k-ensure-prefix-map

Package which-key

Make `which-key’ popup use k-echo-area

  • Function k-pad-mode-line-format: Format the mode line as a string according to FORMAT and RIGHT-FORMAT. FORMAT is left-aligned and RIGHT-FORMAT is right-aligned. Add padding space at the left and right of the mode line so that the edge of the mode line align with left and right fringe.
  • Function k-set-selected-window, k-mode-line-selected-p
  • Function k-pad-header-line-after-advice: Add padding to header line using `k-pad-mode-line-format’. This is intended to be used as an :after advice or (normal or abnormal) hook. If OBJECT is not given, pad header line for current buffer. If OBJECT is a buffer, pad header line for it. If OBJECT is a frame, pad header line for all buffers displayed in it. The function should be idempotent and suitable for repeated invocation.
  • Function k-compute-tab-line: Add an empty tab line to windows in FRAME to simulate bottom dividers. Tab lines are not added to windows at the top and windows whose buffer has non-nill `k-inhibit-tab-line’.

    This differs from bottom dividers because it does not add space below window at the bottom (above echo area).

  • Package package

Package company

Zebra strips, to look consistent with vertico Patch `company–create-lines’ and `company-fill-propertize’

⭐ Don’t let `company-elisp’ quickhelp hijack `*Help*’ buffer

Use posframe so that company works in minibuffer

I prefer using text-property to color stuff, but when I don’t feel like trying I use `stripes’ overlays.

Package hl-line

Patch `hl-line-make-overlay’ so that front advance is T

I generate theme algorithmically from a list of hue and saturation values. There’re two hand-tune ones accessible using `k-theme-switch’, and my EMMS integration generate themes from YouTube video thumbnail when it is played.

Tweek fonts to match `window-text-pixel-size’

  • Function k-hsl-to-hex
  • Function k-generate-theme: Algorithmically generate and load theme. HUE-1 and SAT-1 is used for `k-*-blue’, HUE-2 and SAT-2 is used for `k-*-purple’, HUE-3 and SAT-3 is used for `k-*-pink’. CONTRAST is the hue used for `k-fg-red’. DARK-P specifies whether to generate a dark or light theme.

Try not to let underline touch the text. We use underline to draw a horizontal separator below header line, and this make it look better.

This displays “pseudo” echo areas under each window. I find it more comfy to look at than the global echo area. I also hacked `vertico-buffer’ to display vertico menu in this area, which appears above the main window’s mode line.

The implementation is a mega-hack: we split a echo area window under the main window, set the main window’s `mode-line-format’ window parameter to `none’, and copy its actual mode line to the echo area window, so that the echo area window appears to be above main window’s mode line.

  • Function k-message: Like `message’ but in k-echo-area. Format FORMAT-STRING with ARGS.
  • Function k-message-display: Refresh display of `k-message’ for current buffer.

Use `k-message’ for `eldoc’. Pretty comfy!

Package flycheck

Package tex

to use pdfview with auctex

to have the buffer refresh after compilation

Package vertico

Multiline candidates

Don’t collapse multiline into single line. I find this reads much better for, say, `yank-pop’

Patch `read-from-kill-ring’ so that it doesn’t collapse entries to single line

  • Function read-from-kill-ring: Read a `kill-ring’ entry using completion and minibuffer history. PROMPT is a string to prompt with.

Patch `vertico–truncate-multiline’

Patch `vertico–compute-scroll’

Zebra strips, for better visualization of multiline candidates

Patch `vertico–display-candidates’

we use `fit-window-to-buffer’ instead and ignore HEIGHT

Customize vertico prompt

Vertico insert echo messages into its input line. Without any patch, such echo message masks `k-echo-area–top-separator-overlay’, breaking our horizontal rule drawn by overline. The following resolves this.

Make `vertico-buffer’ use k-echo-area

Package marginalia

Automatically give more generous field width

Package embark

Package exwm

Package emacs

Package macrostep

To fix the outdated naming in (define-minor-mode macrostep-mode …) TODO: Remove once upstream fix this.

#+nil structural comment for Common Lisp

Package paxedit

Package slime

Handy slime commands and key bindings

slime-scratch

Slime mode line

Hacks to make slime-autodoc works better

Enable Paredit and Company in Lisp related minibuffers

Slime debug window non-prolifiration

Package slime-repl

  • Function slime-repl-sync: Switch to Slime REPL and synchronize package/directory.

Package diff-mode

show whitespace in diff-mode

Package magit

Package transient

Make `transient’ and thus `magit’ use k-echo-area

Package smerge-mode

ensure keymap precedence over flycheck

Package avy

Package ace-link

Package buffer-move

Intuitively, this works like windmove but move buffer together with cursor.

Package windmove

Moving between window/buffer/frame/workspaces in 4 directions

Package emms

  • Function k-emms: Switch to the current emms-playlist buffer, use emms-playlist-mode and query for a playlist to open.
  • Function k-emms-save: Save emms playlist buffer.

Eye candies

Patch `emms-playlist-mode-overlay-selected’ so that overlay extend to full line Also set a `priority’

Package exwm

  • Function k-exwm-update-class: Custom window management. Put mpv windows in the background as dynamic wallpapers. Hide davmail windows on startup.

Package ytel

Custom video entry formatting

It can synchronize to BPM which EMMS is playing! This works together with `k-emms-bpm-cursor’. It also uses absolute timing, otherwise Emacs timer will drift.

Package geiser

Terminal (vterm)

Package vterm

Ad-hoc workaround: interaction with wide fringe/padding

Web browsing

Package exwm

Package eww

Move page title from header line to buffer name instead

Package exwm

Package image-mode

Disable transient map because we’ve already put those bindings into the main `image-mode-map’

Package org

Package erc

Package notmuch

Custom email entry formatting

Package pyim

  • Function lookup-word
  • Function demolish-package: Nuke everything under namespace SYMBOL. This is useful when maintaining a long running Emacs image and you want to try reloading/updating a package.

https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c

  • Function k-reraise-error: Call function FUNC with ARGS and re-raise any error which occurs. Useful for debugging post-command hooks and filter functions, which normally have their errors suppressed.
  • Function toggle-debug-on-hidden-errors: Toggle hidden error debugging for function FUNC.
  • Function k-straight-freeze-versions: Run `straight-freeze-versions’ asynchronously in Emacs subprocess.

A status area at the right bottom corner (using the right side of global echo area). It is used for displaying battery, time, and vampire time zone.

How much sun-protection-free time left?

A heavily modified telega.el to tweak its appearance to my liking.

Package telega

Package vundo

Let vundo use k-echo-area

  • Function vundo: Display visual undo for the current buffer.
  • Function k-vundo-kill-buffer-advice: Let vundo use `k-echo-area-clear-1’ instead of `kill-buffer-and-window’. The latter would also delete the main window because it is atomic with k-echo-area.

`jit-lock-mode’ need to be passed nil to turn off

load up the theme

perform GC

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published