ApplyFunctionOnMultipleRegions

The idea is to be able to execute a function/command on multiple regions”. An example of usage would be to upcase several portions of a buffer using a single command.

See also: EmacsIdeasApplyRegionFunctionOnMultipleRegions.

For XEmacs

This works on XEmacs, I don’t know if this will work on GnuEmacs. Simple usage is walk throught text selecting region and pressing C-M-m a to add them to list of multiple regions, when you are done, just press C-M-m ..., where ... is normal Emacs command key sequence, like C-M-m M-u will uppercase all regions. Code available at: http://lgarc.n_a_r_o_d.ru/xemacs-tips/multr.el.

ZajcevEvgeny has this in his ~/.emacs:

    (require 'multr)
    (define-global-map (kbd "C-M-m") mr-regions-map)

For Gnu Emacs

Zones

See Zones and MultipleNarrowings for one treatment of multiple regions. The regions can be persistent, as a bookmark, if you use Bookmark+. With Icicles you can you can activate them or search them selectively.

multi-select.el

Yet another treatment, written a long time ago. Available at http://sites.google.com/site/steveyemacsutils/multi-select-el.

Lets you select noncontiguous regions with mouse or by regular expression. Provides some convenience functions for executing commands over the regions, and also manipulate all the regions as a single region (e.g. kill them all together).

multi-region.el

https://github.com/wence-/elisp/blob/master/multi-region.elLawrenceMitchell

Cool, but I tried (in XEmacs version) to avoid naroving, which causes user unexpected things if command you are executing perform some I/O in minibuffer, for example C-M-m x M-x ispell-region RET, or C-M-m x C-x r t, is it possible for GNU Emacs? --ZajcevEvgeny

Yes, you can temporarily set transient-mark-mode to t (this is the GnuEmacs equivalent of zmacs-regions). You then just have to rely on the goodwill of package authors to perform operations in the marked region if TransientMarkMode is active. The narrowing solution, while ugly, avoids this problem. --LawrenceMitchell

To do:

  • Make the code work in both XEmacs and GnuEmacs. Comment from Stefan Monnier in gnu.emacs.sources:
Making it work for XEmacs should be just a (require ‘overlay) away, plus or minus some very minor fixups. Why have two packages when you can have just one?
  • New commands. A couple of utility commands could be useful in combination with this:
    • multi-region-fetch-from-higlight – creates “regions” by looping through all highlighted regions (see HighlightTemporarily)
    • multi-region-fetch-from-face – same as above but use text with a certain face as input
    • multi-region-fetch-from-latest-isearch – use latest isearch string to create regions
    • and so on… 😊

EmacsIdeas CategoryRegion CategoryWishList