Why did I Choose to use Emacs? ... Because its more fun than Minecraft! :) - of course not. But the possibilities on how to use Emacs is fascinating. The thing that caught my interest for Emacs is the simple userinterface on the surface and the massive possibilities the lisp foundation gives you. Emacs is build around the lisp language that gives you the possibility to create macros for everything. Most of the time I work with PHP projects. This welcomes the php-mode package of Emacs.
Install Emacs
I have decided to install emacs from the source code. This requires the build essentials package on ubuntu. My configure line is as follows :
../emacs/configure --prefix=/home/lars/opt/emacs --bindir=/home/lars/opt/bin -libdir=/home/lars/opt/lib --with-tree-sitter --with-x
Company and Ivy mode installed.
To switch between buffers there are several options. You can use C-c b
to see a list of buffers to switch to. To cycle through open buffers you can use C-x RIGHT
and C-x LEFT
.
Look and feel of Emacs
Emacs can be customized in all sort of ways. The look of Emacs is determined by the active theme. On this Emacs Theme page you can see examples of which themes you can install.
The look and feel also has a lot to do with usability. A small and simple improvement to the usability as to highlight the current active line. This is enabled with the following command M-x hl-line-mode
. To persist this function you should put the following line in your dot-emacs file(global-hl-line-mode 1)
Projectile
Project handling in Emacs can be done with a module called Projectile.
Inside a project you can press C-c p F
to select and open a file within the project.
Drupal in Emacs
I develop some Drupal projects. To run some basic tasks in Drupal I have made a Makefile in my project. For example I have a make target called cr
to clear the Drupal cache. Projectile has a shortcut to compile the project which can be invoked by C-X p c
then type make -k cr
. After the first invocation the command will be remembered. Next time you just press C-X p c RET
to clear your Drupal cache. The following is my Makefile so you can see some examples of my tasks.
theme:
cd web/themes/custom/linkhub && compass clean && compass compile
cr:
ddev drush cr
The compilation buffer
The output of the above commands will be displayed in the *compilation*
buffer. Compass uses ANSI colors to add some niceness the the experience. But by default these colorcodes are displayed raw. You need to enable support for ansi codes in the buffer by putting this in your .emacs
file.
(add-hook 'compilation-filter-hook 'ansi-color-compilation-filter)
You can read more about ansi colors in Emacs here.
You can see my dot-emacs file on github.