Some Emacs tips
When I was using mouse, I often get lost in the middle of something, as I was so attracted to some other shiny stuff so close to my mouse pointer. So I decided to come back to the Emacs world to have the full control of my time with keyboard so I can get focused. Here are a few tips that I found particularly useful during my journey.
Take advantage of native compilation of your elisp configs.
There have been a lot of compilations about Emacs responsiveness, especially when LSP is enabled, but native compilation is a game changer. Just install Emacs with the following commands and feel the difference.
brew tap d12frosted/emacs-plus
brew install emacs-plus@28 --with-native-comp
ref: https://xenodium.com/emacs-plus-with-native-comp/
Just use the raw Emacs, not Spacemacs or Doom.
It’s good to explore what Emacs can do but believe me in practice you’re not going to use all these features. Having more features than what you actually need will slow down your Emacs and will make your key bindings longer. In my vanilla Emacs configuration, I put all my customized key bindings under SPC and most of the work can be done with only key presses.
Make general and evil to work together
At least on my Mac, evil and general doesn’t work together, it keeps giving my a weird error like SPC
is not a valid key prefix. This can be solved by using the evil embedded version of general.
Example:
(general-evil-define key 'normal 'global
:prefix "SPC"
"s" 'save-buffer
)
How to recover the Org roam database
This is a common issue when you move org-roam files from one computer to another or trying to use a different Emacs installation.
- Find where the Database is located:
M-x
describe-variable org-roam-db-location
2. Delete this file
3. Rebuild cache with org-roam-db-sync
Speed up Emacs loading by not trying to install anything at startup
package-install
command allows you to install a package locally, you’ll only need to do it once, instead of trying to do it whenever you open Emacs.
Use Command as the Meta key
(setq mac-command-modifier 'meta)