Wenshan's emacs configuration
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
site-lisp
.gitignore Initial commit Oct 22, 2018
.gitmodules Remove awesome-tab: turned out not to use it much, also it slows down… Feb 15, 2019
LICENSE Initial commit Oct 22, 2018
README.org Remove awesome-tab: turned out not to use it much, also it slows down… Feb 15, 2019

README.org

GNU Emacs Configuration of Wenshan Ren

Setup

  • clone this repository and run git submodule update --init to clone submodules.
  • in ~/.emacs (replace <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 are 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. init-startup.el.
  • find the extension’s git url and add it by M-x magit-submodule-add (path: wenshan-emacs/site-lisp/extensions/<library-name>, name: <library-name>).
  • if needed, add corresponding keybindings to init-keybinding.el.

Remove an Extension

  • M-x magit-submodule-popup, tick Force, then press k, followed with the extension path.
  • it requires git v2.12.0

Architecture

  • ~/.emacs add all sub directories of wenshan-emacs/site-lisp to load-path.
  • and ~/.emacs requires wenshan-emacs/site-lisp/config/init.el: the central configuration file.
  • init.el calls a list of sub configuration files that are in wenshan-emacs/site-lisp/config/.
  • extensions are in wenshan-emacs/site-lisp/extensions/: some of them are git submodules.
  • static data (dictionaries, etc) are in wenshan-emacs/site-lisp/data/.
  • keybindings are placed in wenshan-emacs/site-lisp/config/init-keybinding.el: easier for maintenance and lookup.

Major Features and Reasoning

General Setup

No theme

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 bar and 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

Auto Save

super-save

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.

auto-save

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

Cursor Moving

ace-jump

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).

vi-navigate

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 vi-navigate.

multiple-cursors

Watch Emacs Rocks to find out its awesomeness.

drag-stuff

Move things up and down, sometimes it’s easier than kill and yank.

disable-mouse

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.

Buffers And Windows Switching

window-numbering

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 use it often after trying for a while.

An improved version of tabbar, I use it in combination with helm buffer switching. It reduces the burden of remembering opened buffer names.

Helm

Undo And Redo

undo-tree

Emacs has a powerful undo system, undo-tree makes it easier to use by visualizing edits history as a tree.

Font Settings

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

atomic-chrome

Edit any text areas in Firefox/Chrome, need to install corresponding browser plugins.

Version Control

magit

The best git interface.

magithub

Media Player

emms

I use mplayer as its player and emms just works out of box.

Project Interaction

projectile

color-rg

Shell

aweshell

I like eshell and aweshell is an enhanced eshell.

Hacking

parenthesis completion

I prefer paredit over smartparens for its simplicity. Then Lazycat published awesome-pair based on the idea of paredit and I switched to it.

flycheck

code folding

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.

js2-mode

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.

Anki

I use Anki to help remembering things: reading notes, ideas, etc.

anki-editor provides a way to add Anki card from Emacs.

中文

pyim

在 GNU/Linux 下,经常碰到 Emacs 无法调用系统输入法的问题。我之前自己改写了 eim,以便使用双拼,后来发现了源于 eim 的 pyim,简单易用且支持双拼,于是换用 pyim。

这也是自由软件的妙处之一:源码可以活得更久远。

sdcv

王勇写的星际译王插件,可以在 Emacs 中调用字典查词。

company-english-helper

英文写作提示,蛮好用的。

Keybindings

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.

Plans

  • one-key from lazycat, I do forget keybindings from time to time. -> hydra seems to work fine
  • expand-region
  • yafolding, need to compare the existing code folding extensions first -> built-in hs-minor-mode seems to be sufficient