Questions tagged [balanced-parentheses]

56 questions
18
votes
4 answers

How to define additional mode-specific pairs for electric-pair-mode

electric-pair-mode is a built-in mode for automatically inserting matching pairs of delimiters (parentheses, square brackets, etc.) based on the current major mode. I know that I can define additional pairs (which will be global) like this: (push…
itsjeyd
  • 14,586
  • 3
  • 58
  • 87
14
votes
5 answers

How to replace matching parentheses?

I write (and rewrite) a lot of mathematical formulas in LaTeX with Emacs. I frequently run into situations where I want to change a pair of matching parentheses, to improve readability. My Emacs is kind enough to show me the matching delimiter, but…
Mankka
  • 243
  • 2
  • 8
10
votes
2 answers

What minor mode prints opening paren in the echo area?

This is a really nice feature, but it only displays when inserting a paren, not when changing to a cursor position. Is there an interactive command that I can call to display this? Can I configure it to show up on cursor move?
wdkrnls
  • 3,657
  • 2
  • 27
  • 46
9
votes
3 answers

Set region to include enclosing parentheses

Starting with the point or active region, how do I quickly (in one keystroke / command) 'expand' to include the next set of enclosing parentheses? If I start with: (| means point) (defn foo [x] (+ x |42)) Or if I start with: (< and > bracket the…
David J.
  • 1,809
  • 1
  • 13
  • 23
9
votes
4 answers

Automatically formatting brackets

I'm trying to create a function that places/aligns/indents curly brackets according to Allman-style formatting (for coding in C). Generally speaking, I am fan of Smartparens' interface available to users for customizing functionality. I've…
iceman
  • 1,078
  • 1
  • 9
  • 19
9
votes
2 answers

How to show matching parenthesis faster?

When you type closing parenthesis (or maybe it works for other paired symbols too), and opening parenthesis is not visible on the screen, Emacs “jumps” to opening parenthesis to show you where it is. This is very handy. I want to make period for…
Mark Karpov
  • 4,893
  • 1
  • 24
  • 53
9
votes
2 answers

Remove parentheses around region

Is there a better alternative to this function I use to remove parens around a region? I'm looking for an Emacs builtin, or something better written, something that will remove any pairs around the selected region (ex: brackets, curly brackets,…
Nsukami _
  • 6,341
  • 2
  • 22
  • 35
8
votes
4 answers

How can I find surrounding parenthesis (from emacs lisp)?

Is there a way to find out the type of the surrounding parenthesis (i.e. '(', '[' or '{') around point? For example (using | to represent point) { abc, | df } should return '{', and { abc[ | ], 123 } should return '['. Ideally I would like it to…
dshepherd
  • 1,281
  • 6
  • 18
7
votes
2 answers

What are the differences between autopair and smartparens?

Both autopair and smartparens provide functionality for inserting matching pairs of delimiters automatically. How do they differ from each other in practice (if at all)? What are some use cases that are covered by one of these packages but not by…
itsjeyd
  • 14,586
  • 3
  • 58
  • 87
6
votes
2 answers

Insert parens while completing functions in company mode

If i select first option it will become l.remove But as the completion candidate is function type, how can i make it to l.remove() so that i don't have to manually type parens?
Chillar Anand
  • 4,042
  • 1
  • 23
  • 52
5
votes
2 answers

Remove extra braces

I have some text like this This is a {{text}} with { { {some {extra} unneeded { {and ugly}} braces }}}. Is there a way to remove the extra unneeded parenthesis so that the result is This is a {text} with {some {extra} unneeded {and ugly} braces…
Tohiko
  • 1,589
  • 1
  • 10
  • 22
4
votes
1 answer

Is there a command/package to pretty print based on parentheses?

I'm dealing with large files of output from Haskell code, most of which is debug info of stuff generating using Haskell's show. The important thing about that is that it's a large file of things, nested in either parentheses, or…
jmite
  • 183
  • 6
4
votes
0 answers

Add spaces between braces and content

I would like to automatically add spaces between braces and content when using emacs, for example: std::vector values{"content", "moreContent", "andMoreContent"}; becomes std::vector values{ "content", "moreContent",…
jagged
  • 41
  • 2
3
votes
1 answer

How can I make `forward-sexp` handle other balanced character-pairs such as < and > or << and >>?

I am trying to find an easy and efficient way to modify the behaviour of forward-sexp to handle balanced pairs of characters not normally supported by it, such as balanced < and > and balanced << and >>. My specific case is to enhance the support of…
PRouleau
  • 744
  • 3
  • 10
3
votes
1 answer

Check latex \left \right balance

I've found a function for checking parenthesis/brackets balance. Full code is in the bottom. I wanted to use it to check LaTeX commands like \left(/\right), \[/\] etc. How can I modify this function to accept such constructs? (defun…
Sergey
  • 249
  • 1
  • 8
1
2 3 4