(or emacs irrelevant)

Ivy-mode 0.7.0 is out

Intro

Ivy-mode is a completion method that's similar to Ido, but with emphasis on simplicity and customizability. Currently, there are two related packages on MELPA: swiper and counsel:

  • swiper provides an isearch replacement, using ivy-read for completion, as well as the basic ivy-mode.
  • counsel provides some extra commands that use ivy-read, like -M-x, -ag, -load-theme etc.

Release Notes

The release notes are available at the homepage as usual. There are 220 commits since the last release, which was on Aug 5, roughly 4 months ago. Slowly but surely, the contributors list has grown to 20 people, besides me. A few people even got their Emacs Copyright Assignment just to make large contributions. Statistically, Org-mode is probably the prime package that leads to the most CA, but I'm glad that Ivy is there as well, contributing in a small way.

The release notes are made in Org-mode, each new version is a level 1 heading. With time, hopefully, their parts will make their way into the manual, which is also in Org-mode.

In addition, I also export each new release notes to Markdown using pandoc, since that's what Github prefers.

Release Process

Since the release notes for 0.7.0 are huge, I don't embed them into the post, they're listed separately. You can go through them at your own pace, or wait until I make some highlights for each piece either or the blog or in the manual. The manual, by the way, is a work in progress but is already distributed in MELPA. Use C-h i followed by g (ivy) to read it. If you're new to reading the info pages, there's info on info in info format: use dg (info) to access it.

Today, I'll describe some cool stuff that I used to generate the Markdown notes from Changelog.org.

Org-mode's org-narrow-to-subtree

Since Changelog.org already has a 0.6.0 branch that I didn't want to see, I've narrowed the buffer to only the 0.7.0 branch. This is possible to do thanks to Emacs' narrowing feature and org-narrow-to-subtree. After this command, the buffer behaves as if the 0.6.0 branch isn't there and the only content is 0.7.0 branch. But if I perform any edits and save the file, everything that was hidden is still there.

As a shortcut, I'm using my worf to narrow faster. Pressing [ while worf-mode is active goes back to the current heading start. While at heading start, pressing alphanumeric keys calls commands instead of self-inserting:

  • N calls org-narrow-to-subtree,
  • W calls widen, which turns narrowing off.

There are, of course, many more commands and bindings in worf. Check it out if you like Org's Speed Keys feature, but feel like it could use more structure.

pandoc-mode

pandoc-mode is an Emacs interface to pandoc - a tool that allows to export documents from one format to another. The Elisp package is available in MELPA. And I installed pandoc-1.15.2-1-amd64.deb from its homepage with:

sudo dpkg -i pandoc-1.15.2-1-amd64.deb

After that, M-x pandoc-mode and I'm on easy street: C-c / calls pandoc-main-hydra/body:

  • Set the output format to Github-flavored Markdown with OG.
  • Set the input format to Org-mode with bIo.
  • Export with C-c / r.
  • View the resulting buffer with C-c / V.

Add table of contents to Markdown

I used M-x markdown-toc/generate-toc for this. The MELPA package markdown-toc provides this function. The resulting table of contents is a list with a bunch of links, which turned out to be dead, because of the way Github renders Markdown for releases.

Since swiper works with regexps, here's what I input to match each link:

\[\(.*?\)\](.*?)

This matches anything in brackets (non-greedy), followed by anything in parens; the bracket's content is captured in a group.

Then I press M-q (swiper-query-replace) and enter \1 as replacement - the first captured group. After this, I confirm each replacement with y or confirm them all at once with !.

Use rectangle-mark-mode to promote TOC one level

Since all entries in the TOC were children to a single 0.7.0 entry, I wanted to remove that entry and promote its children one level. This can be done with rectangle-mark-mode, bound by default to C-x SPC.

In my config, I use this instead:

(global-set-key (kbd "C-x SPC") 'hydra-rectangle/body)

Where, hydra-rectangle/body is provided by hydra-examples.el and is also described in an earlier post. I really liked the hydra-rectangle/body idea and use it all the time. Here's a key sequence I used to delete a 4x95 rectangle in order to promote the list items: C-x SPC 4l95jdo.

When copy-pasting from the commit log into Changelog.org, I quickly tired of putting the each issue link as e.g. [[https://github.com/abo-abo/swiper/issues/244][#244]]. So I wrote e.g. #244 instead, and used this code in the end to make the transformation:

(defun ora-quote-github-issues ()
  (interactive)
  (let ((base "https://github.com/abo-abo/swiper/issues/"))
    (goto-char (point-min))
    (while (re-search-forward "\\([^[]\\)#\\([0-9]+\\)" nil t)
      (replace-match
       (format "%s[[%s%s][#%s]]"
               (match-string 1)
               base
               (match-string 2)
               (match-string 2))))))

If anyone reading the blog wants to start with some basic Elisp, the above function is a nice intro to a lot of useful functions. And I expect that many people face this sort of automation scenario pretty often. I'm pretty sure that M-% query-replace-regexp could work here as well, but it's easier for me to just write out the code and save it for later.

Outro

Thanks to everyone who contributed issues, code and documentation. Enjoy the new release.