I've been dipping back ito the world of free software, and have been having a huge amount of fun getting back into emacs. I'm using it more of an operating system than I ever did before, as a way to navigate the world using a text interface. I'd never thought I'd be done with the terminal, but this is the first time that I've got something better and more powerful.
First install emacs. You need emacs > 25 to use magit, so its probable that you'll need to upgrade the emacs in your system. If you are using linux I'll let you sort that out directly, but below are the instructions for OSX.
Installing on debian
The latest emacs (26 at the time of this writing) is on buster, so upgrade to that.
Documentation is not available in the
free part of debian. Don't ask me, something complicated. In order to get the info pages, you need to install the package
emacs-common-non-dfsg which is in the
Start up emacs and then you can do
C-x C-f /sudo::/etc/apt/sources.list to open up the sources file as
root! That's pretty neat, part of the
Tramp system which lets you use local buffers to edit things that are "remote", in this case as another user but also on different hosts.
non-free to the end of first line to have access to the other set of packages. Then do
M-x shell to startup a bash shell, and you can install the rest of it from there:
You may need to run
install-info to get emacs to recognize other stuff in the
Using homebrew to install emacs on OSX
If you are on OSX you'll also need to install some certs, and defined in this wonderful walkthrough. Simply:
And then in
Cleaning up backup files
One thing that's annoying is having the Emacs Backup Files everywhere. Lets stick everything in
~/.saves so we don't need to see it.
Changing the capslock key to control
System Preferences... ->
Keyboard and select
Modifier Keys. Switch caps lock key to be control. Totally worth it, but you still need to do a META dance with the options key, instead of the more obvious command key.
Another nice thing is to map your command-key to META, which is much more natural. Put this in
Emacs super basics
Emacs is something much more than an editor. It's an environment within which you can interact with your computer that could replace many of the tools that you use now. I normally use Terminal for example to interact with things and open up other programs to do specific tasks. Emacs could replace terminal, as well as all of the programs that are used to get into the nitty gritty of making computers do what you want. I recommend the Mastering Emacs book as a great way to get started in your emacs journey.
Misc but important
|get you out of most messes|
|also get you out|
|open a file|
|save a file|
|beginning of document|
|end of document|
Interative search is started with
|makes the current window full screen|
|Set a bookmark|
|Jump to bookmark|
Adding a new package registry
M-x customize and search for
package archives. Insert a new one named 'stable melpa' and add
https://stable.melpa.org/packages/. You can paste into emacs using
I also like to set
visual-line-mode globally to true.
Apply and Save, or do
Refresh the package list using
If you get an gpg error
customize again and change
package-check-signature to nil. Apply and save. Then
M-x package-install RET gnu-elpa-keyring-update RET. Then go back to customize and revert
Changing themes and fonts
M-x customize-themes to change your theme. I also like to have a much larger font, which you can adjust using
M-x customize-face and setting the
default size to something like 140.
2 spaced tabs
Open up your
.emacs file and add:
C-space to start a selection, the arrow keys to move around to select it all. Then type
M-x eval-region to run the lisp.
M-x package-install RET use-package RET
M-x package-install helm-ls-git which should install
helm as well. Another nice helm package is
helm-ag which will grep over your files to look for specific values. Then in your
Once you load everything, using
C-x C-d will let you open up files in a project which is defined as the files in the current git repository.
C-x f will let you use ag to file files (this overrides the fill-column command which I don't end up using).
I encourage you to read through the documentation.
M-x package-install RET flycheck and
M-x package-install RET company And then in
Once this is done, you need to install the specific linter for the languages you are interested in. For example:
M-x package-install emmet-mode
This is the big one. https://github.com/emacs-lsp/lsp-mode gives you a list of all of the languages supported and what needs to be installed, but lets focus on
M-x package-install RET lsp-ui RET
M-x package-install RET company-lsp RET
M-x package-install RET helm-lsp RET
M-x package-install RET magit RET
Magit is amazingly powerful, and I'm still trying to learn it.
Probably the best way to get into it is to first run
C-x g (or
M-x magit-status) and then use
C-h m, which will show you the documentation for the current mode, in this case magit. This is a good way to poke around, though it makes sense to check out the manual which is pretty extensive.
After I checkout my repo, I bookmark the base folder using
C-x r m. Then I can go there faster without having to navigate through the filesystem.
I start up a shell using
M-x shell to run commands. You can
M-x rename-buffer to give it a name, and then be able to start up additional shells if needed. Depending upon what you are doing,
C-x 2 splits horizontally so that can be nice to see the output of anything you need.
C-x C-d will locate files within that project, which is generally a good substitute for the find in project function that I normally use to move around.