Searching As You Like It

Álvaro Ramírez likes that Emacs’ customizability means that you can make it behave exactly the way you want it to. He illustrates this with a simple but useful bit of Elisp that implements what he describes as a DWIM search.

Ramírez is a fan of abo-abo’s great Swiper search function but doesn’t like the way it interacts with keyboard macros and multiple-cursors. To fix that, his function checks if he’s defining a keyboard macro and if so, falls back to the default isearch-forward. If he’s not defining a keyboard macro, the function checks if he’s currently invoked multiple cursors. If so, it calls phi-search to do the search. Phi-search is search/replace package that works well with multiple cursors. Finally, in the default case he simply calls Swiper but arranges for searches to wrap around and automatically use any highlighted region as the search term.

All of this is simple and easy to do but arranges for searches to act just the way Ramírez wants them to. Like yesterday’s post, this serves as another example of how Emacs allows us to automate tasks we do all the time so that our workflow is more frictionless.

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