(or emacs irrelevant)

Happy New Year 2022!

Intro

In 2020, I managed to squeeze out just one post. Well, 2021 ran out just as fast as 2020. So here we are:

   2020-12-31-happy-new-year.md
  +2021-12-31-happy-new-year.md

This year, I'll review a really cool package I've found. It's not new, I just didn't manage to stumble upon it over the years. So it's new to me, and might be a useful pointer to others as well.

Emmet-mode

Emmet-mode is a wonderful Emacs package which greatly improves HTML code generation. It's based on Emmet, so you can read up on the syntax here. I've discovered it quite recently after reading Arjen Wiersma's 22-years-of-emacs.

The gist is that ul#nav>li.item$*4>a{Item $} will expand to:

<ul id="nav">
    <li class="item1"><a href="">Item 1</a></li>
    <li class="item2"><a href="">Item 2</a></li>
    <li class="item3"><a href="">Item 3</a></li>
    <li class="item4"><a href="">Item 4</a></li>
</ul>

The above reminded me of tiny.el, the concept of using *4 to create four items, and $ for automatic numbering is very similar.

Emmet goes above and beyond the 3 yasnippets I had in my config for inserting HTML tags. Note also the handy html:5 snippet, which expands to:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <title>Document</title>
  </head>
  <body></body>
</html>

And as a cherry on top, when used in clojure-mode, these snippets will produce hiccup.

Getting emmet-mode for free

As I wrote earlier (feels like ages ago), I like to get functionality for free, i.e. without having to sacrifice any old key bindings or learning new key bindings. So I've integrated the code of emmet-expand-line with C-o (ora-open-line).
Here is the relevant cond branch:

((and
  (require 'emmet-mode)
  (setq expr (emmet-expr-on-line))
  (setq markup (emmet-transform (first expr))))
 (delete-region (second expr) (third expr))
 (emmet-insert-and-flash markup)
 (emmet-reposition-cursor expr))

We check if emmet-mode has detected a valid snippet at point. In that case, expand it. This allows us to chain multiple snippet engines (like yasnippet, auto-yasnippet, tiny, emmet-mode), and even provide a hydra as a fallback for even more easy to reach commands on C-o!

Personal

Our son, Lev, was born on May 7, 2021. He is our love, happiness, our shining light in 2021. And also the reason why I didn't have too much free time to do Emacs stuff. Big thanks to Basil L. Contovounesios for helping me maintain Ivy! I'm hoping to be much more active on Github in 2022.

Lev

In other personal news, I'm currently looking for a new job as a Software Engineer. If you'd like me to work with you, please get in touch via LinkedIn or Twitter. Also, a big thanks to everyone donating to support my open-source work. It means a lot.

Outro

I wish everyone reading this good health in 2022! And happy hacking!