Forgetting how to set up Emacs every time I get a new computer

1 minute read

We’re rocking Doom. This is not exactly complex but it’s enough that I have to relearn it every time I have to install it again, so writing it down this time. These are self notes, if they help someone else that’s cool too though.

Emacs itself

Doom recommends emacs-mac and that’s what I went with. I was also using emacs-plus for a bit but I could not get the window to take focus like it should. I actually still have that issue w/ emacs-mac too and I have no idea why it happens, but it’s less often. Like if emacs is launched as the $EDITOR for a git commit, I cannot type in the GUI, all keystrokes to go the Terminal. If this rings a bell with anyone let me know :bow:.

Brew install emacsmacport. First dependencies.

 brew install git ripgrep coreutils fd
brew tap railwaycat/emacsmacport
brew install emacs-mac --with-modules
ln -s /usr/local/opt/emacs-mac/Emacs.app /Applications/Emacs.app

Then install Doom

Install Doom and symlink the Doom files from rcs.

git clone https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install
ln -s ~/rcs/doom/init.el ~/.doom.d/init.el
ln -s ~/rcs/doom/config.el ~/.doom.d/config.el
ln -s ~/rcs/doom/packages.el ~/.doom.d/packages.el
doom sync
doom install
doom doctor

Configure

I basically can’t type if Caps Lock isn’t mapped to Control and kj escapes insert mode. This should also be tracked in the doom/config.el rcs on GitHub, but just in case I need another reference, here is:

(after! evil
  (setq evil-escape-key-sequence "kj"))

(setq doom-font (font-spec :family "Monaco" :size 14))

(use-package! protobuf-mode)

(after! go-mode
  (setq gofmt-command "goimports")
  (add-hook 'go-mode-hook
            (lambda ()
              (add-hook 'before-save-hook 'gofmt nil 'make-it-local))))

Go and Gopls (or )

Repeat for other language dependencies, but focused on Go at the moment.

brew install gopls
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/x-motemen/gore/cmd/gore@latest
go install github.com/stamblerre/gocode@latest
go install golang.org/x/tools/cmd/godoc@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/tools/cmd/gorename@latest
go install golang.org/x/tools/cmd/guru@latest
go install github.com/cweill/gotests/...@latest
go install github.com/fatih/gomodifytags@latest

Linking the app

For the CLI, the --with-starter option on install should take care of it, but if not double-check this doc here. It should take over system emacs in priority, too.

For the GUI, just link in /Applications.

ln -s $(brew --prefix)/opt/emacs-mac/Emacs.app /Applications/Emacs.app

Leave a Comment