notes from /dev/null

by Charles Choi 최민수


18 Jul 2024

Emacs Regexps: The Small Print

With my recent work with Casual RE-Builder, I found to my surprise that not all Emacs regexp commands take an Emacs-style regexp. 🤯

Apparently some commands take a grep-style of regex like dired-do-find-regexp and dired-do-find-regexp-and-replace. For such commands, the regexp syntax is dependent on the type of grep that is installed and configured for use by Emacs. If you are using GNU grep, the good news is that the regexp syntax is largely the same as Emacs.

I qualify this as largely because with interactive commands, the escaping rules are different between Emacs and grep-style regexps. I suspect this has only added to the frustration of using plain RE-Builder which only provides export for a Emacs-style regexp to be used in code.

To alleviate this, Casual RE-Builder now has a new command to export specifically to interactive grep-style regex commands. This presumes that the GNU grep is being called.

Also the search & replace menu in Casual Dired has been modified to highlight such grep-style regex commands.

One last note: While I’ve taken effort to verify that this new command is doing all the right escaping, I would not be surprised if it has bugs. Because Elisp does not have support for raw strings like Python and Swift, I’m at a loss to know how to write a unit-test to automate its verification. For now I’m doing it manually, with test regexps that hopefully cover enough escaping behavior. If you find a bug, please report an issue with your regexp and the target text so I can troubleshoot. I’d also qualify that my knowledge of Elisp regexps is not that deep. I’d be happy to get guidance from more enlightened readers.

With all that said, I invite you to try this new feature out in Casual RE-Builder. I think you’ll be delighted that you did.

emacs

Past Articles

15
JUL
2024

Announcing Casual RE-Builder

Stop worrying and learn to love Emacs regular expressions. Announcing Casual RE-Builder, a porcelain for the venerable RE-Builder package, now on MELPA.

read more
8
JUL
2024

Announcing Casual IBuffer

Announcing Casual IBuffer, a porcelain for Emacs IBuffer.

read more
2
JUL
2024

TIL Imenu

Recently I learned that Imenu is a thing. Here I share my thoughts on it.

read more
24
JUN
2024

Announcing Casual Suite

Announcing Casual Suite, a single package install solution for all Casual porcelains, now on MELPA.

read more
12
JUN
2024

An accidental lock-in feature of the Apple ecosystem

All the flowers to the developers who keep Emacs keybindings alive in Apple products.

read more
8
JUN
2024

Announcing a plan to change some Casual package names

The Casual project has grown beyond just working with Calc. Better to introduce some breaking name changes now than later.

read more
3
JUN
2024

Announcing Casual Info

Annoucing Casual Info, a Transient menu for the Emacs Info reader.

read more
28
MAY
2024

Announcing Casual Avy

Announcing Casual Avy, an opinionated Transient-based menu for Avy, GNU Emacs package for jumping to visible text using a character-based decision tree.

read more
9
MAY
2024

Sunrise and Sunset in Emacs

If you don’t know sunrise-sunset in Emacs, now you know.

read more

Page 1 / 12   >

 

AboutMastodonInstagramGitHub

Feeds & TagsGet Captee for macOS

Powered by Pelican