Butingtaon's Corner

Posts by type
Other

Emacs Notes

This was inevitable

I've been using for over 6 years now, I think, but always using evil-mode to use my nearly 2 years of consistently using Vim before switching to Emacs.

Then, recently, when I was trying to get GNU Guix working on a spare computer, while trying to edit the guix config file on a machine I was setting up, I found myself thinking:

I need the functionality emacs has, but I can't be bothered to set up evil-mode on a system that's gonna get overwritten by the installer anyways... I guess I'll learn default Emacs keybindings...

A note about keyboard key naming conventions

Emacs keybindings in the internal documentation looks like

C-x C-s or

M-x or

C-c C-l and so on

In these contexts, `C` means the Control or `Ctrl` key on most keyboards today. This means a command like `C-x C-s` means "Press `Ctrl+x` and then `Ctrl+l`". `M` means Meta, a key usually assigned to `Alt` in today's keyboards.

Emacs is a very old platform, and its keybindings clearly reflect its history and baggage from all the way back during the LispMachine days.

Setting up training wheels

After making a new literate configuration file and pointing my `init.el` file to load it, I added the following source block to it, after the theming and layout configurations.

         (require 'which-key)
         (which-key-mode 1)

         (require 'icomplete)
         (fido-vertical-mode 1)
        

This one-two combo of which-key and fido-vertical-mode allows me to see in near-real time what commands and options are available. Especially now that I need to learn the prefix chords and default keybindings, which-key is a real life-saver. And when I can't find the keybindings for a certain action, I can always try and sus out the actual emacs command I need with `M-x` and letting fido try and fuzzy-find the command I need.

Overview of Prefix Chords

Just a few things I want to keep note of per prefix-chord. Not an exhaustive list.

C-x

This prefix chord usually begins a keysequence for global keybindings, commands that are available throughout Emacs, regardless of major/minor modes.

Key Sequence Command Description
C-x C-c save-buffers-kill-terminal Offer to save each buffer, then kill the current connection.
C-x b switch-to-buffer Display a list of active emacs buffers and select one to switch the window to.
C-x o other-window Switch to another window within the emacs frame.
C-x k kill-buffer Prompt for which buffer to kill, default current buffer
C-x 0 delete-window Delete current visible emacs window
C-x g magit-status Open Magit in the current directory to check git status
C-x d dired Open Dired (textmode file browser) in current directory

Open a revision in Magit, run M-x magit-toggle-buffer-lock, and open another revision. This prevents the revision that you are currently looking at from being replaced with the value of the other revision you wanted to look at

Taken from this reddit comment