jlr / rainbow-delimiters

Emacs rainbow delimiters mode
http://www.emacswiki.org/emacs/RainbowDelimiters
112 stars 12 forks source link

With GNU Emacs 24.2.2, highlighting of added/removed lines in diffs is broken - only the +/- character is highlighted #14

Closed dcoshea closed 10 years ago

dcoshea commented 11 years ago

I am hitting this problem in GNU Emacs 24.2.2, but not in 23.3.1 with the same .emacs. I have narrowed it down to a simple test case without my .emacs:

  1. Start GNU Emacs 24.2.2 using 'emacs -q'
  2. Visit rainbow-delimiters.el from commit ID 6345c1f
  3. M-x eval-buffer RET
  4. Visit the diff file shown below.
  5. M-x customize-face RET diff-added RET
  6. Give the face a background colour and set it for the current session. At this point, the entire line starting with a "+" in the diff file is highlighted with the background colour.
  7. M-x rainbow-delimiters-mode RET At this point, only the "+" is highlighted with the background colour, and the close parens all have a foreground colour of red.

Workaround after hitting the issue in a buffer:

  1. M-x rainbow-delimiters-mode RET
  2. M-x font-lock-mode RET
  3. M-x font-lock-mode RET

The test diff file:

--- foo
+++ bar
@@ -3328,5 +3329,5 @@
 blah
 blah
-             foo))))
+             foo bar))))
 blah
 blah
dcoshea commented 11 years ago

I still see the issue in d38744e.

The issue seems to be related to the order in which highlighting occurs: if I follow these steps:

  1. Start GNU Emacs 24.2.2 using 'emacs -q'
  2. Visit rainbow-delimiters.el from commit ID d38744e
  3. M-x eval-buffer RET
  4. M-x global-rainbow-delimiters-mode RET
  5. Visit the diff file from the original issue report
  6. M-x customize-face RET diff-added RET
  7. Give the face a background colour and set it for the current session.

then at this point, the entire line starting with a "+" in the diff file is highlighted with the background colour (and, incidentally, no delimiters are highlighted). However, if I either:

a. issue M-x font-lock-mode RET twice; or b. type a single character at the start of the buffer, even if I then undo the change; or c. reverse the direction of the hunk using C-c C-r, even if I then undo the change;

then only the "+" is highlighted with the background colour, but the parens are highlighted in red.

It appears then that when diff-mode is first entered, if global-rainbow-delimiters-mode is enabled, diff-mode's highlighting takes precedence over rainbow-delimiters', but then if anything causes highlighting to be performed again, rainbow-delimiters' highlighting beats diff-mode's.

Fanael commented 10 years ago

Sounds very much like a duplicate of #10.