Counting Check Marks

Here’s my solution to the last EmacsGolf challenge. I used the apparently little-known how-many command. I normally use how-many in Elisp to count the occurrences of some regex. Here’s an example from my old blog that leverages some code from the always useful EMACS-FU. It turns out that how-many is a command and thus callable interactively. That makes the solution straightforward.

Meta+xhmReturn Call how-many
cbMeta+/ cb → ✓
Return result returned in minibuffer

That does the job in 8 keystrokes.

The excellent flx-ido mapped hm to how-many on the first try despite the fact that I hadn’t used how-many in several months (and never before interactively). I map 【Meta+/】 to hippie-expand, which takes care of expanding the abbreviation.

This entry was posted in General and tagged . Bookmark the permalink.

3 Responses to Counting Check Marks

  1. mbork says:

    One thing escapes me: what is the difference between how-many and count-matches?

  2. Xah Lee says:

    interesting. Never used how-many before. Also noticed that occur isn’t the correction solution, when the char appears more than once in the same line. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>