# Electric/smart parentheses: allow wrapping in a nontransient way

I like smart parentheses as much as the next person, but there is one situation in which I often get frustrated. Suppose I have a TeX line reading:

Lorem ipsum dolor sit amet


Now I wish to \emphasize dolor. Hence I go before it and write \emph{, resulting, with electric-pair-mode and the likes, in:

Lorem ipsum \emph{}|dolor sit amet


(where | is the point). Now the behavior I'd like to have, is that if I only thereafter move then insert }, then the automagically inserted } is removed. Graphically, I'd like to end up with:

Lorem ipsum \emph{dolor}| sit amet


rather than:

Lorem ipsum \emph{}dolor}| sit amet


Question: Is there a mode that implements that behavior? Note that I don't want to use the transient mark.

• Consider not bothering with "smartparens" or "electric-pair", if you haven't already. Just a suggestion. – Drew Nov 17 '16 at 16:22
• I spent the last 15 years happily emacs'ing without any smartness in my parentheses, so I certainly understand the suggestion. As a matter of fact, I'm mostly testing out electricity here; not sure I'll adopt it, especially if I cannot get the above question worked out. Thanks for the input, though! – Michaël Nov 17 '16 at 18:06
• Lots of people do like such "smart"/"electric" pairing. Some others (maybe mostly oldtimers?) do not. (To me, they're more of a bother than a help.) Hope you get an answer that helps. – Drew Nov 17 '16 at 18:10
• There is a specialized list for these modes: auctex@gnu.org – Andreas Röhler Nov 17 '16 at 18:32
• Why don't you want to use transient mark? That is the most direct solution: mark dolor, then C-c C-f C-e will wrap it with \emph{} – Tyler Nov 19 '16 at 13:34

• BTW, you can mark the word with C-M-SPC. – Stefan Aug 9 '18 at 16:31