Questions tagged [balanced-parentheses]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
43 views

How to support `<` and `>` as balanced parens without impacting ability to use them as comparison operators?

Languages like Erlang and Elixir use << >> for binaries and bit-string syntax, but they also use the classical < and > for comparison operators as well as -> and <- in list ...
0
votes
1answer
31 views

Any existing function to fix comma-separated list in parens-pair?

I am looking a way to programatically fix invalidly formatted code for programming languages that use relatively simple list expression of elements separated by commas (ie, not in C++). For example I'...
3
votes
1answer
63 views

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 &...
1
vote
1answer
48 views

How to prevent smartparens slurp from slurping item separator?

I am looking into Erlang support for smartparens and would like to be able to slurp a string into the current list without including the Erlang statement termination colon in the list. In an erlang-...
0
votes
1answer
26 views

rainbow-delimiters does not properly highlight unmatched parenthesis

Would it be possible to highlight unmatched parenthesis if they are at the beginning of a function like func((((()? Related: How can I find missing or mismatched braces / parens in emacs? minimal.el ...
0
votes
0answers
56 views

Scan error: "Unbalanced parentheses" in fresh emacs installations, without config files

When I start emacs and run M-x up-list in the initial buffer (the about Emacs buffer, in fundamental mode) I get Scan error: "Unbalanced parentheses". If I move the mark to the end of the ...
0
votes
0answers
63 views

AUCTeX pairing large parenthesis for `\left(`

I'd like to automatically close \left( with \right) in LaTeX via AUCTeX in Emacs 27. The following should work: (add-hook 'LaTeX-mode-hook (lambda () (set (make-local-variable 'TeX-...
0
votes
1answer
44 views

Paste Inserts Extra Characters because of Electric Mode

I have this defined: (setq electric-pair-pairs ...
0
votes
1answer
189 views

Blinking Paren Mode

I'm trying to get Paren Mode to be a little more clear, cause I can hardly see the other matching pair of parenthesis. Is there any way I could make this blinking yellow?;) I'm in gnome-terminal. Here ...
1
vote
4answers
736 views

How to delete surrounding brackets?

I'd like to be able delete the innermost brackets around the current point. What's a good way to do this? While the evil-surround package can do this, it needs to take a bracket type as input, so ...
1
vote
1answer
238 views

How to find the matching bracket at a point in elisp?

What is a reliable way to find the matching balanced bracket (eg: {}, [], () in C or Python), which doesn't get confused by brackets in strings, or escaped brackets for e.g. Example: ["Foo]" ?\] 0 [...
1
vote
1answer
224 views

How can I skip 'Scan-error: "Unbalanced parentheses"...'?

I want to write a script in order to correct spaces inside section command in a LaTeX code, that's to say \section{Lorem ipsum dolor sit amet consectetuer adipiscing elit} should be \section{...
1
vote
0answers
43 views

Test if I am inside a paired delimiter

I have been having a problem where I want an up-sexp command that treats paired delimiters like $ in LaTeX-mode just as if they were pairs of balanced parentheses. There are hacks I can use that get ...
3
votes
1answer
127 views

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 ...
2
votes
2answers
389 views

Can't type unbalanced closing curly brace in Clojure mode

When I open a Clojure file, and I'm not using Paredit, I expect to be able to type unbalanced parentheses and brackets. I can type any of these characters: ()[]{, balanced on not. But if I try to type ...
0
votes
0answers
31 views

fault-tolerant `check-parens` resp. `scan-lists`

Looking for a way to have a fault-tolerant navigation. I.e. in case of broken syntax, uncomplete forms etc. --when check-paren fails--, it should try some heuristics. Unfortunatly can't use check-...
1
vote
1answer
631 views

emacs regex to match balanced parenthesis

How can emacs lisp match balanced parenthesis? for example: "foo(bar(),hee()) out()" should be match "foo(bar(),hee())". I try below statement but it doesn't work: #!/usr/bin/env emacs --script (...
5
votes
2answers
425 views

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 {...
10
votes
5answers
1k views

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 ...
2
votes
1answer
84 views

Smarter smart bracket matching

It's kind of weird how un-ergonomically placed the parenthesis keys are. I'd like a function that smartly brackets my stuff for me based on context: If the mark is active, the region should be ...
3
votes
2answers
589 views

automatically close type parens in C++

Does anybody know of a way or a package that can recognize < and > when occuring in template contexts and automatically writes a > either right after the < or after the selected region ...
1
vote
2answers
45 views

How to capture show-paren-mode region into the kill ring?

I'm enjoying show-paren-mode using the "expression" style, which highlights a parenthesized region in a contrasting color. I'd like to define an Emacs Lisp function that could capture the region into ...
2
votes
1answer
563 views

Auto-completion of round bracket in Auctex

When using Auctex to type tex files, round bracket ( can't auto-complete for me. But [ and { can do. How can I fix it? According to introduction of LaTeX-electric-left-right-brace, this variable is ...
1
vote
0answers
106 views

Parenthesis-type-specific show-paren-mode

For unfortunate reasons, I need to write, by hand, expressions that look like the following: .....((((((((((((((((.....+))))))))[[[[[[[[[[[[[[[[{{{{{{{{{{{{{{{{))))))))+ ((((((((]]]]]]]]]]]]]]]]}}}}}}...
0
votes
0answers
59 views

Syntax highlight the opening parenthesis line printed in echo area

With respect to this answer, is there any way to enable syntax highlighting for the text printed in echo area by blink-matching-open? I am asking for something similar to what Lua Block mode does. ...
2
votes
3answers
5k views

How to complete brackets automatically?

I use an auto complete tool in emacs, which can complete brackets. But I want to find out that how it determines whether it should complete the bracket. For example, assuming | stands for the point. ...
1
vote
1answer
453 views

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 \...
1
vote
1answer
922 views

enable show-paren-mode in init.el

I would like to enable show-paren-mode in my configuration file init.el, which is very convenient for debugging. As it is a minor mode as I've understood, I don't know how to proceed...Thank you very ...
3
votes
0answers
104 views

Working around preprocessor blocks

I am trying to navigate a C project that has lots of preprocessor directives like this: #ifdef SOME_COMPILE_TIME_VARIABLE for ( idx=0; idx<FOO; idx++ ) { #else for ( idx=0; idx<BAR; idx+...
4
votes
0answers
134 views

Add spaces between braces and content

I would like to automatically add spaces between braces and content when using emacs, for example: std::vector<std::string> values{"content", "moreContent", "andMoreContent"}; becomes std::...
2
votes
1answer
962 views

How to disable underlining of highlighted matching brackets?

I want to have no underlining on highlighted matching brackets. I've done the following to achieve that: M-x customize-face show-paren-match And there I deactivated the underlining of matching ...
0
votes
1answer
86 views

Org mode flashes indentation of lines with parentheses

I've been having some issues using org-mode with paren matching. Here are a few screenshots of the problem. In short, when my mouse isn't on a line, the line is shown correctly, but when parenthesis ...
1
vote
2answers
127 views

delete-c-electric-paren deletes active region in CC mode with delete-selection-mode enabled

I've the delete-selection-mode enabled. In programming modes like Python and Lua, or in general modes like Fundamental or Text, when there's an active region, pressing ( rightly wraps the region with ...
1
vote
0answers
595 views

How can I make Spacemacs stop deleting my parentheses?

I've recently switched from emacs to spacemacs (develop branch), and I'm still getting used to the new defaults. I added smartparens to my excluded-packages in my config file, because I don't like ...
2
votes
2answers
153 views

Modifying AucTeX bracket indentation locally

I am currently using songs package, which via some TeX trickery uses escaped brackets to mark chords (for example \[G] is G-major, while \[a] is a-minor). This causes problems with indentation, for ...
5
votes
2answers
537 views

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?
3
votes
0answers
67 views

Indent parenthesized Python expression

I have emacs set up to indent Python code like so: foo( bar, baz ) That works fine. However, that style in a particular program I'm working on very often means I find myself with text like this:...
9
votes
2answers
2k views

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. ...
8
votes
2answers
4k views

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 ...
8
votes
4answers
810 views

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[ | ], ...
4
votes
1answer
500 views

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, ...
1
vote
0answers
109 views

How does forward-list work for "<>" in c++-mode?

I am trying to understand how forward-list matches template delimiters <> in c++-mode. forward-list in lisp.el calls scan-lists with the appropriate arguments. The documentation for scan-lists ...
9
votes
3answers
280 views

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 ...
2
votes
1answer
296 views

Disable mic-paren in the minibuffer (or at least in ido)

I'm replacing a buggy code that was suppose to show a matching brace in the minibuffer in case it was off-screen with the following: (paren-activate) ;; activates mic-paren (setq paren-match-face '...
1
vote
0answers
730 views

Paredit: paredit-forward and paredit-backward don't work

I've been having trouble with navigating in paredit. When I try using C-M-f and C-M-b to go forward and backward, nothing happens. The minibuffer doesn't respond and the point doesn't move. When I ...
10
votes
2answers
222 views

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 ...
9
votes
4answers
4k views

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 ...
15
votes
4answers
3k views

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 ...
7
votes
2answers
1k views

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 ...