This repository holds the configuration I use for emacs. This configuration sets up emacs to be used as my primary IDE, Rest Client, Notes System, Jira Interface, and Document Editor. Below I will specify how I accomplish each of these tasks. Feel free to use this configuration if you feel it is helpful. However, it is aimed at solving the needs that I come across.
The environment that I find primarily find myself in is doing dotnet development on a Windows machine. Because of this, my configuration is geared toward this scenario. However, I am using LSP whenever possible for IDE features. This means that, while I am focused more on dotnet, this configuration will work for any programming language that has an accessible Language Server.
The Windows OS may be a bigger difference though. Being a dotnet (prior to core) developer, I have historically needed to be on a Windows machine. Because of that restriction, I have setup many things that work for Windows. I configure my Windows machine to run Bash and all of my pathing is expecting as much. This means that, in theory, the configuration should work on a Unix machine. However, Some of the configuration is specifically to allow some things to work on Windows. Feel free to try the configuration on a Unix machine, but it should be noted that some issues may be found.
Create a transparent and consistent text editing environment
One of the things I disliked about many of the configurations for emacs was that it was difficult to know what packages I had pulled in, and what purpose each part of the configuration served. So, when creating this configuration, I aimed to create a config that was as transparent as possible. Both in terms of the packages that I have installed and for the custom code/configuration that I have setup.
To aid in the transparency of packages that are installed, I created a custom pacakage manager. This ‘package manage’ aims to only keep a record of all the packages that are installed. This record exists in the packages.db file. This file contains all of the packages that are used for this configuration. The package-manager.el will simply iterate over this file and ensure that all of the mentioned packages are installed.
To download packages I am using straight. This mostly arose as a way to work around being on VPNs that don’t allow me to connect to other package repositories. I have not yet found any VPN that doesn’t allow me to access GitHub (or whatever server is used by the packages I currently have installed). Because of this restriction, every package that I pull in is done via straight.
I am a developer by trade and one of my pet peeves is cluttered files. Many of the configurations that I see for emacs have every (or almost everything) shoved into their init.el file. I couldn’t stand doing this when I was using other configuration.
To solve this problem I created separate files that can be loaded in from the init file. At first this caused my startup time to be rather slow, but I was eventually able to solve that problem a combination or compiling the files and preemptively launching an emacs server. I will explain more about each of these later on, but wanted to mention them as well.
To help keep files organized and focused, I have all of the custom code located underneath the custom directory. Underneath that directory are several more directories that allow for further categorization of the code files. For the most part, that is as far as the structure goes. There are a few exceptions, however, I am aiming to clean them up with a bit more thought and effort.
The other issue that I found myself butting up against with other configurations was consistency (mostly regarding key-bindings). Emacs has key binding conventions, and I wanted to ensure that my configuration followed this convention when possible. I realize that many people will likely prefer to follow some other convention. Simply put, that isn’t what I set out to do, or prefer.
As mentioned above, the extra files do cause some start-up performance issues. To help to mitigate this, I created some functions (defined in the init due to the need of them before loading any files) that will check for compiled versions of the custom files. If there is not a compiled file found with a modified time stamp later than its ‘.el’ counterpart, than the file is compiled. The first time this is performed there is some additional overhead in compiling the files. However, after the initial start-up the files are loaded much quicker reducing the overall wait time.
If that reduction in start-up time is still too little, You may be interested in the later section that details launching a server on system (Windows) start-up. This does not actually reduce the start-up time, but instead has all of the start-up time happening silently in the background. From there you can launch clients instantly that talk to the already started server.
Org-Mode is a mark up language used to do many different tasks such as notes, literate programming, to-do lists, agendas, etc. This mode is built into Emacs out of the box.
C-c a
- Open agenda
C-c c
- Capture
C-c C-t
- Todo Progress
After installing Dropbox by default it will look in your home directory in the ~/Dropbox folder. This configuration is set up to have a gtd (Get Things Done) folder under the ~/Dropbox folder. This is to sync those specific documents to a cloud storage location. These todo / tasks / etc can now be accessed on multiple devices. For utilization on phones download and app that is an org file view that can integrate with Dropbox. Ex. Orgzly for Android.
RestClient is a tool to manually explore and test HTTP REST services from a plain-text buffer.
C-c C-c
- run query under cursor
TAB
- hide/show current region / request.
Emacs is my primary (and for the most part sole) IDE. I have been using emacs for several years now, and, when I started, there was a decent amount of configuration and setup need to get languages setup for programming. With the introduction of the Language Server Protocol by Microsoft, the setup for a new language became almost trivial. For every language that I am able to I am using lsp-mode. This library is only getting better overtime and installing servers is becoming easier and easier.
Many of the languages that I use have the ability to automatically install their language servers. If you are able to do this, I would highly recommend it. However, there are a few that need manual installation (though fewer and fewer all the time).
As of right now the only language that is manually setup in my configuration is for Angular. To get this working, I followed manual instructions for angular server. However, I wasn’t able to get this working with a global install of the LSP. Because of this, you will want your project to have a local reference to the angular language service.
A few languages do have language specific configurations. All of these can be found in the languages directory in the file named after the language.
As mentioned in the ‘Performance’ section, I have emacs setup to silently launch a server in the background when I log onto my machine. To do this there are a few things you will want to setup.
- Environment Variables
- HOME
- You will want to set this variable to your home directory.
- Create a startup task
- Set the task to launch the silent-launch.vbs file
Launching the client isn’t anything too fancy. However, I want to be able to launch this with the tool launchy.
To accomplish this there is a little bit more involved than entering a command to launch an emacs client. If you
simply want to launch the emacs client via a terminal you can use emacsclientw -c -F "'(fullscreen . maximized)'"
.
For the rest of this section, I am going to assume that you are familiar with launchy or you have some sort of equivalent application launcher.
- Create a shortcut to the launch-client.bat file
- If you want it to feel more ‘real’ you can attempt to change the icon to the emacs logo.
- Move that file to a directory that is indexed by your application launcher
- Ensure that your application launcher sees your new shortcut (for launchy you will need to rescan the catalog)