GNU Emacs Configuration of Wenshan Ren
- clone this repository and run
git submodule update --initto clone submodules.
<path-to-wenshan-emacs>with the actual path):
(defvar wenshan-emacs-root-dir (file-truename "<path-to-wenshan-emacs>/site-lisp")) (defun add-subdirs-to-load-path (dir) "Recursive add directories to `load-path'." (let ((default-directory (file-name-as-directory dir))) (add-to-list 'load-path dir) (normal-top-level-add-subdirs-to-load-path))) (add-subdirs-to-load-path wenshan-emacs-root-dir) (require 'init)
- start emacs, some external programs such as python-pylint might be required for certain features, but you can install them when needed.
Add New Extensions
- select the sub init file it should go into, e.g.
- find the extension’s git url and add it by
- if needed, add corresponding keybindings to
Remove an Extension
M-x magit-submodule-popup, tick
Force, then press
k, followed with the extension path.
- it requires git v2.12.0
~/.emacsadd all sub directories of
wenshan-emacs/site-lisp/config/init.el: the central configuration file.
init.elcalls a list of sub configuration files that are in
- extensions are in
wenshan-emacs/site-lisp/extensions/: some of them are git submodules.
- static data (dictionaries, etc) are in
use-packageis used to reduce init time,
M-x describe-personal-keybindingslists keybindings defined with
- other keybindings are defined in
wenshan-emacs/site-lisp/config/init-keybinding.el: easier for maintenance and lookup.
Major Features and Reasoning
I tried various color themes in the past, now I just want to use the default Emacs theme to avoid troubles because any well-designed extension should support the default theme.
Modify Emacs Defaults
- disable tool bar,
menu barand scroll bar, I don’t use them.
- answer y/n instead of yes/no, less typing.
- disable bell, it’s annoying.
- type gpg password inside emacs, rather than in a pop-up window, it’s troublesome when Emacs is full-screen.
- set fill-column to 120, which suits my screen size better.
- disable cursor blinking, it’s too distracting.
- remember recently opened files
- remember windows configuration: see winner-mode’s manual for details
- use spaces for indentation instead of tabs: make it consistent
- turn on org-mode for txt files: most of my txt files are in org format
After using auto-save for a while, I decided to switch back to super-save.
I don’t need to save files on idle, e.g. when working on a nodejs project with nodemon enabled, I don’t want auto-save triggers re-run all the time.
I use lazycat’s auto-save extension, it saves the buffer if Emacs has been idle for 1 second (by default, customizable). I prefer it over super-save because:
- can be configured to be silent -> I don’t like seeing the message again and again in the mini-buffer
- does smart white space trailing
- works out of box
I don’t use it very often, going to find out more about it.
Find it is useful when bundled with
vi-navigate. I bound it to
/, so in read-only modes such as Info-mode, I can press
/, followed with two keystrokes to get to where I want (so I can then press
y to trigger sdcv for translation).
It’s easier for me to press single keys to move around in read only modes,
vi-navigate adds keybindings to a list modes that are supposed to be read-only.
e for previous page,
space for next page, and jklh for four directions.
Also, Emacs has a built-in
view-mode, I’ve changed its keybindings to match
Watch Emacs Rocks to find out its awesomeness.
Move things up and down, sometimes it’s easier than kill and yank.
It’s distracting to use a laptop when you touch the touch-pad without intention and it changes where your cursor is all the time.
Move selected region left/right based on indentation, especially useful for major modes such as
Buffers And Windows Switching
Label each window with a number and press M-<num> to jump to it, best way of windows switching in my opinion.
awesome-tab: don’t find using it often after trying for a while.
Undo And Redo
Emacs has a powerful undo system, undo-tree makes it easier to use by visualizing edits history as a tree.
Dejavu Sans Mono for English and Wenquanyi （文泉驿） for Chinese, reasons:
- available on Debian GNU/Linux
- free software
- can be aligned nicely in org-mode tables
Self Defined Functions
Edit any text areas in Firefox/Chrome, need to install corresponding browser plugins.
The best git interface.
I use mplayer as its player and emms just works out of box.
I like eshell and aweshell is an enhanced eshell.
I prefer paredit over smartparens for its simplicity. Then Lazycat published awesome-pair based on the idea of paredit and I switched to it.
Used to use yafoding, but it seems hs-minor-mode is sufficient after configuration.
jedi Trying out for python hacking. => replaced by lsp, which provides better python hacking experience.
replaced by lsp
lsp language server protocol
- emacs-lsp integrates well with flycheck, native completion-at-point, eldoc, imenu, and xref-find-definition/references.
- it also provides some refactoring features.
- can be used with dap-mode to provide better debugging experience.
I use Anki to help remembering things: reading notes, ideas, etc.
anki-editor provides a way to add Anki card from Emacs.
在 GNU/Linux 下，经常碰到 Emacs 无法调用系统输入法的问题。我之前自己改写了 eim，以便使用双拼，后来发现了源于 eim 的 pyim，简单易用且支持双拼，于是换用 pyim。
后来又在一些机器上改用 rime 作为输入法后端，配置见 http://wenshanren.org/?p=1070
王勇写的星际译王插件，可以在 Emacs 中调用字典查词。
All keybindings are set in
site-lisp/config/init-keybinding.el. This is to have a central place for finding keybindings.
Besides that, hydra is used to provide “menus”, by default you can press
s-c to start the top menu.
one-key from lazycat, I do forget keybindings from time to time.-> hydra seems to work fine
yafolding, need to compare the existing code folding extensions first-> built-in hs-minor-mode seems to be sufficient