1

For unfortunate reasons, I need to write, by hand, expressions that look like the following:

.....((((((((((((((((.....+))))))))[[[[[[[[[[[[[[[[{{{{{{{{{{{{{{{{))))))))+
((((((((]]]]]]]]]]]]]]]]}}}}}}}}}}}}}}}}((((((((+.....)))))))))))))))).....

This involves parentheses of different types that need, amongst each type, to be balanced without regard to other types. It would be very convenient if there was a way to get show-paren-mode to disregard mismatches entirely, and only show the matching parenthesis of the same type, but my suspicion is that, depending upon the way it is implemented, this may simply be impossible.

Is there any way to coax show-paren-mode, or some other similar mode, into doing this, or is it going to involve writing my own mode?

  • Sorry, this is just my curiosity: what is the unfortunate reason? Unless it's a secret. – wvxvw Apr 26 '17 at 9:04
  • show-paren-mode is based on Emacs' Parsing Expressions code, which has only a single depth counter, so I don't see how it could handle overlapping expressions like you want. You could possibly make just a single paren type the "primary" and switch between them manually by modifying the syntax table. – npostavs Apr 26 '17 at 16:33
  • 1
    @wvxvw : DNA secondary structure used by molecular programmers is often described in dot-paren or dot-bracket notation, which just uses parentheses to denote bases bound to the corresponding parentheses, and dots to indicate unbound bases. That this can be done with just parentheses means the complex has no pseudoknots. Unfortunately, the structures I deal with are very pseudoknotted, so I need to extend the notation to multiple types of brackets, and this is the usual way of doing so. – cge Apr 28 '17 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.