My Emacs notes

Submitted by admin on Wed, 03/13/2024 - 21:43

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. Most of the time I work with PHP projects. This welcomes the php-mode package of Emacs.

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.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.