(or emacs irrelevant)

Introducing amaranth Hydras

An amaranth planted in a garden near a Rose-Tree, thus addressed it: "What a lovely flower is the Rose, a favorite alike with Gods and with men. I envy you your beauty and your perfume." The Rose replied, "I indeed, dear Amaranth, flourish but for a brief season! If no cruel hand pluck me from my stem, yet I must perish by an early doom. But thou art immortal and dost never fade, but bloomest for ever in renewed youth."

Prompted by the "Avoid exiting the hydra on hitting a wrong key" issue, I decided to add a new body color for Hydra. Turns out that there exists a color that represents immortality, and it's called amaranth. It's also very pretty.

So what amaranth Hydras do basically, is make it impossible to quit them. Of course, it would be totally lame if there wasn't at least one way to quit them. And what better to utilize for this purpose, than the good-old quitters - the blue Hydra heads.

An Example code

(global-set-key
 (kbd "C-z")
 (defhydra hydra-vi
     (:pre
      (set-cursor-color "#e52b50")
      :post
      (set-cursor-color "#ffffff")
      :color amaranth)
   "vi"
   ("l" forward-char)
   ("h" backward-char)
   ("j" next-line)
   ("k" previous-line)
   ("m" set-mark-command "mark")
   ("a" move-beginning-of-line "beg")
   ("e" move-end-of-line "end")
   ("d" delete-region "del" :color blue)
   ("y" kill-ring-save "yank" :color blue)
   ("q" nil "quit")))

This Hydra has only three exit points:

  • q, which does nothing
  • y, which copies the active region
  • d, which deletes the active region

In addition to the usual arrows on hjkl, a and e move to beginning and end of line respectively.

Outro

I hope that you like the new idea, also thanks to @vkazanov for the push in this direction. Things should be backwards-compatible, so this feature costs you nothing if you're not using it. See the release notes for 0.8.0.

One more thanks goes to Sridhar Ratnakumar for this suggestion that lead to an improvement in auto-yasnippet. Thanks to this improvement, I was able to quickly wrap words like this:

<font color="#FF007F">Rose</font>