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!
- Preamble
- Bootstrap straight.el
- Util functions
- Misc config
- ⭐ Mode line
- In buffer completion (company)
- Generic stripes
- ⭐ Theme
- ⭐ Per window echo area
- ⭐ Message to per window echo area
- Time
- Appearances
- Indent and whitespace
- General Programming Utilities
- TeX
- ⭐ Completion system
- EXWM
- Misc key bindings
- Lisp development
- Version control
- Fast cursor movement
- window/buffer/frame/workspaces movement
- ⭐ Multi media
- ⭐ Blink cursor
- Scheme
- ⭐ System utils
- Org
- ERC
- Input Method
- ⭐ Misc handy commands
- ⭐ Status area
- Vampire timezone
- telega.el
- Undo Tree
- ⭐ Org index generation
- Finale
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 vlf
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’
- Function company–create-lines, company-fill-propertize
⭐ Don’t let `company-elisp’ quickhelp hijack `*Help*’ buffer
- Advice company-capf, help-buffer
Use posframe so that company works in minibuffer
- Package company-posframe
I prefer using text-property to color stuff, but when I don’t feel like trying I use `stripes’ overlays.
- Package stripes
Package hl-line
Patch `hl-line-make-overlay’ so that front advance is T
- Function hl-line-make-overlay
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.
- Function k-set-fonts
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.
- Function k-load-faces: Generate and set faces.
- Function k-theme-switch: Elegantly switch to k-theme with STYLE.
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-echo-area-window: Return the k-echo-area window for WINDOW.
- Function k-echo-area-main-window: Return the window whose k-echo-area is WINDOW.
- Function k-echo-area-display: Display BUF in a k-echo-area window created for MAIN-WINDOW.
- Function k-echo-area-clear: Remove the k-echo-area window for MAIN-WINDOW.
- Function k-echo-area-clear-1: Remove the k-echo-area window.
- Function k-echo-area-clear-all: Remove all k-echo-area window, for debug purpose only.
- 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 time
- Package all-the-icons, volatile-highlights, highlight-indent-guides, highlight-parentheses, topsy, outline
- Package dtrt-indent, ws-butler, snap-indent
Package flycheck
- Function k-flycheck-display-error-messages
- Package lsp-mode
- Package lsp-ltex
Package tex
to use pdfview with auctex
to have the buffer refresh after compilation
- Function init-latex
- Package cdlatex
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’
- Function vertico–truncate-multiline: Truncate multiline CAND. Ignore MAX-WIDTH, use `k-vertico-multiline-max-lines’ instead.
- Function k-string-pixel-height: Return the width of STRING in pixels.
Patch `vertico–compute-scroll’
- Function vertico–compute-scroll: Update scroll position.
Zebra strips, for better visualization of multiline candidates
Patch `vertico–display-candidates’
- Function vertico–display-candidates: Update candidates overlay `vertico–candidates-ov’ with LINES.
Package vertico-buffer
we use `fit-window-to-buffer’ instead and ignore HEIGHT
- Function vertico–resize-window
Customize vertico prompt
- Function vertico–format-count: Format the count string.
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.
- Function k-minibuffer-message-advice
Make `vertico-buffer’ use k-echo-area
- Function vertico–setup
Package marginalia
Automatically give more generous field width
- Function marginalia–affixate: Affixate CANDS given METADATA and Marginalia ANNOTATOR.
- Package orderless, consult
Package embark
- Function k-grep-in-1: Grep in current embark target.
- Function k-grep-in: Grep in FILENAME.
- Package embark-consult
- Package exwm-randr
Package exwm
- Function k-exwm-update-title
- Package kmacro, comment-dwim-2, crux
Package emacs
- Function k-info-rename-buffer: Rename info buffer according to current node.
- Advice eval-last-sexp
Package macrostep
To fix the outdated naming in (define-minor-mode macrostep-mode …) TODO: Remove once upstream fix this.
Package comment-or-uncomment-sexp
#+nil structural comment for Common Lisp
- Macro advance-save-excursion, structured-comment-maybe
- Function structured-comment-advice
- Function structured-comment-defun: Use #+nil to comment a top-level form for Common Lisp.
- Package paredit
Package paxedit
- Function paxedit-copy-1, paxedit-kill-1
- Advice eval-last-sexp
Package slime
Handy slime commands and key bindings
- Function ensure-slime
- Function slime-undefine: Undefine toplevel definition at point.
slime-scratch
- Function switch-to-scratch: Switch to scratch buffer.
Slime mode line
- Function slime-mode-line
Hacks to make slime-autodoc works better
Enable Paredit and Company in Lisp related minibuffers
- Function k-slime-command-p, sexp-minibuffer-hook
Slime debug window non-prolifiration
Package slime-repl
- Function slime-repl-sync: Switch to Slime REPL and synchronize package/directory.
Package slime-company
- Function company-slime: Company mode backend for slime.
- Package slime-mrepl
- Package vc-hooks
Package diff-mode
show whitespace in diff-mode
Package magit
- Function cloc-magit-root: Run Count Line Of Code for current Git repo.
Package transient
Make `transient’ and thus `magit’ use k-echo-area
- Function transient–delete-window
Package smerge-mode
ensure keymap precedence over flycheck
Package avy
- Function hyper-ace, my-avy–regex-candidates
Package ace-link
- Function ace-link–widget-action
- Function ace-link–widget-collect: Collect the positions of visible widgets in current buffer.
- Function ace-link-widget: Open or go to a visible widget.
- Package goto-last-change
Package buffer-move
Intuitively, this works like windmove but move buffer together with cursor.
- Package framemove
Package windmove
Moving between window/buffer/frame/workspaces in 4 directions
- Function next-workspace
- Advice windmove-find-other-window: If there is an error, try framemove in that direction.
- Package winner
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
- Function k-emms-mode-line
- Function k-emms-toggle-video: TELL MPV player to switch to video/no-video mode.
- Function emms-playing-time-display: Display playing time on the mode line.
- Function k-emms-player-mpv-event-function, k-emms-generate-theme, k-emms-bpm-cursor, k-emms-bpm-cursor-stop-hook, k-emms-player-mpv-volume-change
Package emms-playlist-mode
Patch `emms-playlist-mode-overlay-selected’ so that overlay extend to full line Also set a `priority’
- Function emms-playlist-mode-overlay-selected: Place an overlay over the currently selected track.
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
- Function ytel–insert-video: Insert `VIDEO’ in the current buffer.
- Function ytel-play: Play video at point with EMMS.
- Function ytel-add: Add video at point to EMMS playlist.
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 scheme
Package geiser
- Function geiser-mode-maybe
- Package geiser-racket, racket-mode
Terminal (vterm)
Package vterm
Ad-hoc workaround: interaction with wide fringe/padding
- Function vterm–get-margin-width
Web browsing
Package exwm
- Function k-browse-url-chromium
Package eww
- Function k-eww-after-render-hook: Save `k-eww-history’.
Move page title from header line to buffer name instead
- Advice eww-update-header-line-format: Update EWW buffer title.
- Function k-eww-read-url: Read URL with global history completion from `k-eww-history’. If inside a Google Search buffer, use the search keyword as default input.
- Function eww-new-buffer
- Advice url-http: Redirect to old.reddit.com
Package exwm
- Function k-eww-reload-in-chromium
- Package pdf-tools
Package image-mode
Disable transient map because we’ve already put those bindings into the main `image-mode-map’
- Function k-screenshot: Save a screenshot and copy its path.
- Function k-get-volume: Get volume.
- Function k-set-volume: Change volume.
- Function k-set-volume-decrease, k-set-volume-increase
- Package sudo-edit, system-packages
Package insecure-lock
- Function insecure-lock-hide
Package org
- Function check-latex-fragment, k-org-mode-hook
- Package org-contrib, org-variable-pitch, org-superstar, poly-org
- Function k-polymode-init-inner-hook
- Package engrave-faces
Package erc
- Function erc-insert-timestamp-right
- Function insert-plist, k-format-relative-date
- Package message
Package notmuch
Custom email entry formatting
- Function notmuch-search-show-result: Insert RESULT at POS.
- Function k-ensure-davmail: Make sure davmail is running.
- Function k-update-notmuch-unread-count
- Function k-update-notmuch: Update email database asynchronously.
- Function k-notmuch-unread-status
- Package smtpmail
Package pyim
- Function k-pyim-probe
- Package pyim-basedict, pyim-greatdict
- 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.
- Function k-time-status: Status function for current time.
- Function k-battery-status: Status function for battery status.
- Function k-telega-status
- Function k-status-update: Update status area.
How much sun-protection-free time left?
- Function time-to-vampire-time
- Function vampire-time-status: Status function for vampire time zone.
A heavily modified telega.el to tweak its appearance to my liking.
Package telega
- Function k-telega-chatbuf-attach-sticker
- Advice telega-chars-xheight, telega-sticker–create-image, telega–fmt-text-faces, telega-ins–special, telega-ins–message0, telega-ins–date
- Function k-telega-load-all-history: Load all history in current chat.
- Package enwc, proced
- Package undo-tree
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
- Package undo-fu-session
- Package toc-org
- Function k-generate-org-index: Read Emacs Lisp from current buffer and write org index to OUTPUT-BUFFER. SOURCE-FILENAME is used for generate relative link with line numbers. Processing starts from the point in current buffer and write to the point in OUTPUT-BUFFER. Both points are advanced during processing.
- Function k-generate-org-index-init: Generate README.org from init.el.
- Function k-generate-org-index–magit-post-stage-hook
load up the theme
perform GC