5

So currently diff-mode outputs standard git patches, something like

@@ -8,6 +8,8 @@
-foo bar
+baz

I.e. the + and - are part of the buffer text. Sometimes I would find it convenient if the +/- was displayed in the left FRINGE instead of as part of the output. So something like a diff-mode-toggle-fringe-annotation function. I haven't found one however. Does it exist?

  • 1
    The command to scan the visible portion in all open windows with this bufffer and place fringe bitmaps would need to run every command loop and will slow things down. Limiting the fringe bitmaps to only the active window would speed things up. And, of course, there would need to be an invisible text property or overlay with the invisible property to cover up the +/- in the buffer. Due to the slow-down caused by this happening (placement) / un-happening (removal) every command loop, I am hesitant to write-up an answer .... There could be some optimizations, but still ... cumbersome. – lawlist May 25 '18 at 14:56
  • Well lots of stuff with the same limitations or worse are implemented, like fci-mode, linum-mode, etc. In this case it's probably got more to do with the fact that ediff exists so people rightfully don't care about diff-mode features. I kinda temporarily forgot ediff existed when I asked the question :P – Benjamin Lindqvist May 25 '18 at 19:35
3

Sounds like a great addition, to diff-mode. It should be pretty easy to do that in the font-lock-keywords by adding some appropriate display text property which would both hide the "+" from the buffer and add it to the fringe. Contrary to @lawlist I wouldn't expect any serious performance issue.

EDIT: this has since been added to Emacs-27's development code: just set diff-font-lock-prettify to t.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.