Fanael / rainbow-delimiters

Emacs rainbow delimiters mode
GNU General Public License v3.0
685 stars 33 forks source link

Double duty parentheses #63

Closed danielsz closed 3 years ago

danielsz commented 3 years ago

Given a language where parentheses are part of a two-character comment (see syntax table below), it appears that rainbow-delimiters will leave those comments alone (which is good), but will also leave alone all other instances of parentheses, even when they are used by themselves as a grouping construct.

Thank you for for your work (and for further advice/corrections/suggestions/ideas).

  (let ((table (make-syntax-table)))
    (modify-syntax-entry ?\( ". 1" table)
    (modify-syntax-entry ?\) ". 4" table)
    (modify-syntax-entry ?* ". 23" table)
    table) 
Fanael commented 3 years ago

This is the correct behavior, as this syntax table indicates that parentheses are generic unpaired punctuation, rather than a grouping pair; rainbow-delimiters is only concerned with the latter.

What you probably want is this syntax table instead:

(let ((table (make-syntax-table)))
  (modify-syntax-entry ?\( "()1" table)
  (modify-syntax-entry ?\) ")(4" table)
  (modify-syntax-entry ?* ". 23" table)
  table)

This works just fine for me: x

danielsz commented 3 years ago

That is such a perfect answer. Thank you and apologies for the noise.