All Projects → 0x7ffc → lain-emacs

0x7ffc / lain-emacs

Licence: MIT License
A modern(?) day Emacs configuration for the stubborn dvorak vimmer

Programming Languages

emacs lisp
2029 projects
shell
77523 projects

Projects that are alternatives of or similar to lain-emacs

evil-lispy
precision Lisp editing with Evil and Lispy
Stars: ✭ 72 (+414.29%)
Mutual labels:  evil-mode
GnusSolution
A complete working solution of gnus+offlineimap+dovecot+msmtp+cron
Stars: ✭ 18 (+28.57%)
Mutual labels:  emacs-configuration
emacs.d
My personal Emacs configuration
Stars: ✭ 20 (+42.86%)
Mutual labels:  emacs-configuration
.emacs.d
My literate Emacs configuration
Stars: ✭ 139 (+892.86%)
Mutual labels:  emacs-configuration
ihsec
ihsec - I hate Switching Emacs Configs - A symlink machine to change your ~/.emacs.d quickly and efficiently.
Stars: ✭ 61 (+335.71%)
Mutual labels:  emacs-configuration
doom-todo-ivy
Display all TODO and FIXME entries for a project or buffer in ivy. Extracted from doom-emacs.
Stars: ✭ 31 (+121.43%)
Mutual labels:  emacs-configuration
dot.me
me dot files
Stars: ✭ 33 (+135.71%)
Mutual labels:  emacs-configuration
dotfiles
Custom dotfile configurations and settings
Stars: ✭ 12 (-14.29%)
Mutual labels:  evil-mode
emacs-config
A literate emacs configuration for C#, python, ivy, yasnippet, ...
Stars: ✭ 31 (+121.43%)
Mutual labels:  emacs-configuration
dotfiles
Personal config and utils for emacs, vim, tmux, i3, git, etc.
Stars: ✭ 29 (+107.14%)
Mutual labels:  emacs-configuration
dvorakjp-romantable
Google 日本語入力用DvorakJPローマ字テーブル / DvorakJP Roman Table for Google Japanese Input
Stars: ✭ 43 (+207.14%)
Mutual labels:  dvorak
keymacs
Ergonomic keyboard layout for nonergonomic keyboards.
Stars: ✭ 22 (+57.14%)
Mutual labels:  dvorak
Emacs Configuration
Emacs Configuration Using Purcell's Structure
Stars: ✭ 22 (+57.14%)
Mutual labels:  emacs-configuration
sniem
Hands-eased united editing method for emacs.
Stars: ✭ 17 (+21.43%)
Mutual labels:  dvorak
nema
Nayuki's EMAcs distro
Stars: ✭ 19 (+35.71%)
Mutual labels:  emacs-configuration
emacs.d
My emacs config
Stars: ✭ 32 (+128.57%)
Mutual labels:  emacs-configuration
Denny-s-emacs-configuration
🤖 Emacs shapes me to be a better programmer
Stars: ✭ 40 (+185.71%)
Mutual labels:  emacs-configuration
tree-edit
🌲 Structural editing in Emacs for any™ language!
Stars: ✭ 211 (+1407.14%)
Mutual labels:  evil-mode
jcs-emacs
Emacs configuration works across all OSs
Stars: ✭ 37 (+164.29%)
Mutual labels:  emacs-configuration
dotfiles
My customized configuration files
Stars: ✭ 12 (-14.29%)
Mutual labels:  emacs-configuration

Modern Day Emacs?

Journey of me writing modern(?) day .emacs.d using:

  • use-package
  • general.el
  • evil-mode
  • which-key

Table of Contents

MY PROBLEM

./img/meme0.jpg ./img/meme1.jpg

./img/meme2.jpg ./img/meme3.jpg

./img/meme4.jpg

My Journey

These problems are getting bigger and my Spacemacs config are getting messier. So I decided to write my own .emacs.d. After writing some code I really feel like that everyone should write their own Emacs configuration, here is why:

  • Different people emphasize on different tech stack, you don’t need EVERYTHING
  • Some prefer emacs key bindings while others prefer vim key bindings
  • There EXIST people who use keyboard layout other than QWERTY
  • The problem with large configuration like spacemacs is the same with any complex enough IDE:
    • Their is a learning curve before you can be productive.
    • Even you think you are productive, you still just use, like 10% of what it offers.
    • Configuration generally separates into two parts, the default part, or core if you prefer, and more flexible part, or module. And to be honest, I find it difficult to distinguish them. Because you still need to change the configuration if you want to tweak it no matter which part it from. Code is code.

I know that my problem is unique that not everybody is using emacs with evil-mode on a dvorak keyboard. But after writing some lisp myself. I find it quite satisfying and enjoyable:

I also read a lot Doom, Prelude and Spacemacs source code. I learned a lot even just by copy-pasting their code. I check every variable and every function I see with C-h so that I know what they do.

Actually, Spacemacs internally use use-package an which-key. I think with this approach the ideal configuration should look something like this:

./img/use-package-fold.png

Just bunch of use-package forms.

That being said, there are some minor issues:

  • use-package doesn’t offer a convenient why to write code dependent on multiple packages, here is an issue that describes it. Spacemacs solves it by create it’s own layer loading mechanism. but it’s excessive as long as you aren’t writing that much code. You can just use our old friend with-eval-after-load. Or don’t use anything, just make sure your packages are load in order.
  • Need quite some time to figure out how to glue these five packages together. I haven’t found one single .emacs.d on github that uses all five package, let alone one with DVORAK keybindings support (I can’t type on QWERTY).
  • Need to RTFM. Like, a LOT. And some of them are confusing, like buffers and windows.

Once having a basic setup, one can extend it with ease and efficiency. By saying basic setup, I meant to write Emacs Lisp comfortably:

  • basic theme/font/ui setup that doesn’t give me eyesore
  • a package manager that doesn’t suck, e.g. straight.el, el-get, quelpa
  • an autocomplete framework, e.g. company, auto-complete
  • a completion framework, e.g. ivy, helm
  • a lisp Structural Editing framework, e.g. smartparens, paredit
  • a lisp Structural Editing framework that works with evil-mode, e.g. evil-cleverparen

Then, just extend Emacs with bunch of use-package forms.

Anyway, here I am trying to achieve this. My configuration is optimized for DVORAK keyboard. You may not be using DVORAK, but apart from that it’s still a good reference to get started hacking Emacs. It’s using “htns” instead of “hjkl” to move around. It also tries to remap possible “C-j” “C-k” “C-n” “C-p” to “C-t” “C-n”. And it works with evil-mode. It has a fast startup time, but I usually use emacs daemon (see scripts directory). Check the tasks list for what I’ve been doing and what will be implemented in the future.

Hope you find my experience helpful.

The Workflow

I guess not everybody is gonna read all the code (not too much TBH), so I’ll describe what my typical workflow looks like (keep in mind that this is entry level stuff, don’t laugh at me):

  • Run ec in terminal to fire up Emacs server and connect to it (export PATH=”$PATH:$HOME/.emacs.d/scripts/).
  • Switch to a project using SPC p p, or SPC f f to navigate to a file in a new project.
  • Use SPC p f to find file in a project.
  • In case of projectile couldn’t find a newly created file or still showing deleted file, run SPC p I
  • File related keybindings are in SPC f, e.g.
    • SPC f f get a list of files in current directory to open with
    • SPC f D delete current file and its buffer
    • SPC f R rename current file and its buffer

    but I usually find myself using ranger to manage file (press -)

  • Buffer related keybindings are in SPC b, e.g.
    • SPC b b get a list of buffers to switch to
    • SPC b d kill current buffer, but its window is still there
    • SPC b x kill current buffer and its window
    • SPC b D get a list of buffers and choose one to kill
    • SPC b t next buffer
    • SPC b n previous buffer
  • Window related keybindings are in SPC w, e.g.
    • SPC w 2 split window vertically
    • SPC w 3 split window horizontally
    • SPC w h/t/n/s move to the left/down/up/right window
    • SPC 1/2.../9 switch to a window by number
    • SPC w d delete current window
  • While editing a file
    • C-s to search text in current buffer
    • SPC / to search text in current project (using rg)
    • :%s/from/to/g to find and replace text in current buffer
  • After editing some file, I fire up magit: SPC g s
    • gu go to the unstaged changes
    • s y stage all the changes
    • c c write my commit message and “C-c C-c”
    • P p push to origin
    • q quit magit
  • C-x C-c or SPC e q to exit Emacs

Some editing notes:

  • Parentheses are paired using smartparens, and evil-cleverparens to provide evil integration. Some keybindings I use most:
    • M-( wrap an expression in parentheses
    • M-a insert at end of an expression
    • M-i insert at beginning of an expression
    • M-r raise an expression
    • M-s splice an expression
    • < and > to slurp expression
    • _ move to the first non opening character
    • dd will not break parenthesis and keep our s-expression correct
  • evil-commentary add comment operator, e.g.
    • gcap to comment current paragraph
  • evil-surround can emulates surround.vim, e.g.
    • =ysW”= to wrap to word with =”=
    • csW"( change surrounding of a word from =”= to (
  • evil-lion add align text operator, e.g.
    • =glap’= to align current paragraph using =’=
  • expand-region is integrated with evil. For example, in the string (hello “foo| oo”):
    • double press v it will select “foo”
    • then “"foo"”
    • then “hello "foooo"”
    • then the whole expression with the parenthesis.
  • If you’ve seen emacsrocks episode1, you may wonder how to do this in evil-mode
    • in normal state press C-v which calls evil-visual-block
    • move to the space before l however you want (avy isearch swiper)
    • press R, now anything typed will only show up on the first line, but when one returns to normal state, by pressing ESC, then the typed characters will appear on each line of the block/rectangle.
  • ivy is integrated with wgrep, so you can edit your search result:
    • while searching with counsel-rg/swiper, press C-c C-o to run ivy-occur, it’ll bring up a new buffer with all search result.
    • then press w to enter editable state if you want to edit it, at last press C-c C-c to save or C-c C-k to abort.

Details

TASKS [37/48]

  • [X] company (? seems hard to manage all the backends, need to investigate more)
  • [ ] imenu
    • custom imenu regular expressions with different languages
    • imenu-list
    • imenu-everywhere
    • counsel-imenu (? counsel-org-goto)
  • [ ] text folding with evil (? evil-vimish-fold and hideshow)
  • [ ] ediff (? magit)
  • [ ] snippet
  • [ ] custom dashboard (? maybe)
  • [ ] org-mode
  • [X] popup management)
  • [ ] workspace management (? but how)
  • [ ] terminal (? is emacs really suitable for terminal usage)
  • [ ] flycheck
  • [ ] email client (? notmuch / mu4e)
  • [-] various programming languages (? do we use language server)
    • [X] Emacs-Lisp
    • [X] Clojure
    • [X] Ocaml
    • [ ] …
  • [X] basic emacs setup (speed up hacks, basic ui tweaks)
  • [X] use-package
  • [X] general.el
  • [X] which-key
  • [X] basic evil setup
  • [X] basic build-in libraries (hideshow parens hl-line recentf saveplace …)
  • [X] basic theme support
  • [X] smartparens
  • [X] evil-cleverparen
  • [X] fira code ligature
  • [X] basic evil setup with dvorak keybindings
  • [X] expand-region with evil
  • [X] avy
  • [X] basic ivy
  • [X] ivy-occur with evil
  • [X] basic buffer management
  • [X] basic counsel
  • [X] projectile
  • [X] counsel-projectile
  • [X] macrostep with evil
  • [X] page break (ui)
  • [X] magit and evil-magit
  • [X] ranger with evil
  • [X] edebug with evil
  • [X] expand-region with evil
  • [X] esup with evil
  • [X] indent guide
  • [X] whitespace cleanup
  • [X] aggressive-indent (? any better auto indent options out there)
  • [X] xref with evil
  • [X] multiple-cursor (evil-multiedit)
  • [X] window management
    • [X] winum
    • [X] evil-window-map
    • [X] ace-window
  • [X] auto-compile (? don’t bother to compile our .emacs.d)
  • [X] mode-line ui (doom-modeline seems decent enough)
  • [X] leetcode module (solve leetcode problem without leaving emacs)

How to Use

I’m using Emacs version 26, so I can’t guarantee it’ll be working on lower version.

mv ~/.emacs.d ~/.emacs.d.backup
git clone https://github.com/ACEMerlin/lain-emacs.git ~/.emacs.d
cp ~/.emacs.d/personal/lain.el.example ~/.emacs.d/personal/lain.el

Customize lain.el to your needs. (“SPC e I” to open it)

Also any lisp files inside personal directory will be loaded.

To use fancy icons M-x all-the-icons-install-fonts

Note about SPEED

Emacs will initialize tool-bar/menu-bar even if you have disabled them in your configuration, to avoid this:

cp ~/.emacs.d/.Xresources.example ~/.Xresources
xrdb ~/.Xresources

You may want to put last line in your zshrc or bashrc.

Note about RSI

You are gonna use your pinky a lot, and this will result in RSI if not handled properly. To avoid this, first I recommend reading xah’s blog “How to Avoid Emacs Pinky”.

Now here are some additional methods which are not mentioned in the blog post:

  • If you’re using a thinkpad as I do, remap the two keys above touchpad and below spacebar to the keys you like.
  • Use spacebar as control: Pressing and releasing results in space as normal, but if held while pressing other keys it acts like control. You can achieve this by using xcape if you’re on linux and karabiner if on OSX. Both provide additonal features like generate the Escape key when Left Control is pressed and released on its own, it plays nicely with evil-mode(Vim). Also I’m on WSL, it works fine with X server.

If these two doesn’t suit you, I think at least you should swap keys around, or use sticky keys….

Good luck my fellow Emacsers.

External Programs

To use my config, you’ll also need these.

I’m on debian so…

ripgrep

curl -LO https://github.com/BurntSushi/ripgrep/releases/download/0.10.0/ripgrep_0.10.0_amd64.deb
sudo dpkg -i ripgrep_0.10.0_amd64.deb

fira code symbol

curl -LO https://github.com/tonsky/FiraCode/files/412440/FiraCode-Regular-Symbol.zip
curl -LO https://github.com/tonsky/FiraCode/releases/download/1.206/FiraCode_1.206.zip

fd

curl -LO https://github.com/sharkdp/fd/releases/download/v7.2.0/fd_7.2.0_amd64.deb

lain-ocaml.el

opam install utop ocamlformat ocp-indent dune merlin

Happy hacking!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].