This project defines a GNU Emacs
package, insert-pair-edit
. This package supplies commands that are
a more feature rich alternative to the standard M-(
Emacs
keybinding, (insert-parentheses
).
The insert-pair-edit
package supplies commands to insert (and
also, update, edit and delete) "PAIRs" within an Emacs
buffer. These PAIRs consist of OPEN and CLOSE strings that
delimit text in some fashion. (This could be a simple open and close
parentheses, (
and )
, or, it could be a more complex pair of
strings that are used within a programming language.)
The main entry point to the insert-pair-edit
package is the
Emacs interactive command insert-pair-edit
. When executed, this
command will prompt the user to enter a MNEMONIC identifying a
(customizable) PAIR via the Emacs minibuffer
.
Selection of a MNEMONIC will cause two overlays to be inserted into the buffer. These overlays represent the OPEN and CLOSE strings of the PAIR to be inserted.
These overlays can then be either: immediately inserted into the buffer, or, more importantly, moved about the buffer to correctly surround the text to be enclosed by the PAIR.
After adding the OPEN and CLOSE overlays into the buffer, the
insert-pair-edit
command starts ipe-edit-mode
to enter the
Insert Pair Edit (ipe) minor mode.
The Insert Pair Edit (ipe) minor mode supplies commands to
move these OPEN and CLOSE overlays about the buffer. When
positioned correctly, these OPEN and CLOSE overlays can then
either be inserted <RET>
(ipe-edit--insert-pair
), or discarded
C-g
(ipe-edit--abort
).
The Insert Pair Edit (ipe) minor mode also supplies additional commands to:
- Change the PAIR to be inserted on-the-fly.
- Change the 'lexical units' used by the movement commands.
- Operate on the CONTENTS of the PAIR (i.e. the text between the OPEN and CLOSE overlays.) Text can be copied, deleted, replaced and case converted.
- Search for (and edit) other PAIRs.
- Operate on multiple PAIRs at once.
- Escape characters between the OPEN and CLOSE strings.
Customizations for the mode can be found under the ipe
group.
The set of PAIRs available for editing are defined per-major-mode.
Example PAIR Definitions are supplied for:
- TexInfo
- HTML
- Markdown
Most of the functionality of the Insert Pair Edit (ipe) package
can also be accessed via the Emacs menubar. If running Emacs
in an environment which supports menus, the insert-pair-edit
package
can add an extra Pairs
sub-menu to the standard Emacs Edit
menu item.
The set of PAIRs listed under the Pairs
-> Insert PAIR
/
Update PAIR
/ Delete PAIR
sub-menus will change dynamically based
upon the current buffer's major-mode
.
Selecting a menu item under Insert PAIR
will insert the selected
PAIR into the current buffer around POINT, and enter
ipe-edit-mode
.
Selecting a menu item under Update PAIR
will update the nearest
PAIR (of the given type) and enter ipe-edit-mode
.
Selecting a menu item under Delete PAIR
will delete the nearest
PAIR (of the given type) and remain in the current Emacs mode.
Download the insert-pair-edit
project:
git clone https://github.com/BriansEmacs/insert-pair-edit.el <path-to-download-dir>/ipe
Add the following to your .emacs
file:
(add-to-list 'load-path "<path-to-download-dir>/ipe"))
(add-to-list 'load-path "<path-to-download-dir>/ipe/modes"))
(require 'insert-pair-edit)
(global-set-key (kbd "M-(") 'insert-pair-edit)
After installation: from the Emacs Edit
menu:
Edit >
Pairs >
Info
Help
From the keyboard:
M-x ipe-help
M-x ipe-help--info