reddit / emacs

[ANN] DIFF-ANSI view DIFF's with external tools (+ magit support) now on Melpa

ideasman_42 · 2022-01-23 22:49
ispinfx · 2022-01-24 00:37
Got something like Debugger entered--Lisp error: (error "Invalid face" ansi-color-black) internal-get-lisp-face-attribute(ansi-color-black :foreground nil) face-attribute(ansi-color-black :foreground) diff-ansi--face-attr-to-hex-literal(ansi-color-black :foreground) diff-ansi--multiprocess-impl(293 777 nil) diff-ansi-region(293 777) diff-ansi--magit-insert-revision-diff-advice-fn(#f(compiled-function () #<bytecode 0x1ff90e04835d>)) apply(diff-ansi--magit-insert-revision-diff-advice-fn #f(compiled-function () #<bytecode 0x1ff90e04835d>) nil) magit-insert-revision-diff() apply(magit-insert-revision-diff nil) magit-run-section-hook(magit-revision-sections-hook) magit-revision-refresh-buffer() apply(magit-revision-refresh-buffer nil) magit-refresh-buffer() magit-setup-buffer-internal(magit-revision-mode nil ((magit-buffer-revision "e1cab5e") (magit-buffer-range "e1cab5e^..e1cab5e") (magit-buffer-diff-args ("--stat" "--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-diff-files-suspended nil))) magit-revision-setup-buffer("e1cab5e" ("--stat" "--no-ext-diff") nil) magit-show-commit("e1cab5e" ("--stat" "--no-ext-diff") nil nil) funcall-interactively(magit-show-commit "e1cab5e" ("--stat" "--no-ext-diff") nil nil) call-interactively(magit-show-commit nil nil) command-execute(magit-show-commit)
ideasman_42 · 2022-01-24 01:27
It turns out this was added in emacs-28.1, updated the package not to use this (will take a while for melpa to pick up the changes).
ispinfx · 2022-01-24 03:23
Thanks for the quick reply. But then I got something like [this](https://i.w3tt.com/2022/01/24/TmZYC.png) in a `magit-revision` buffer...
ideasman_42 · 2022-01-24 03:40
That's odd, what version of emacs are you using? Also, could you try setting: `(setq diff-ansi-method 'immediate)` - which is the most straightforward method of displaying ANSI text.
ispinfx · 2022-01-24 04:43
Hi, it's `GNU Emacs 27.2 (build 1, x86_64-apple-darwin21.1.0, Carbon Version 165 AppKit 2113) of 2021-11-18`. Setting `diff-ansi-method` changes nothing. There's indeed an [error](https://i.w3tt.com/2022/01/24/Tmy5L.png), I missed it in my last reply, sorry.
ideasman_42 · 2022-01-24 05:33
Fixed the error, however it looks like true-color ANSI support isn't working in Emacs-27, only Emacs-28+ (which isn't released yet). For `delta` at least, other diff tools may display better though.
ispinfx · 2022-01-24 06:49
That works now...I may try other diff tools. Thanks.
wargxs · 2022-01-24 21:57
Why not use ediff? imho the best diff tool there is!
ideasman_42 · 2022-01-24 22:18
I'd like to, although I ran into some roadblocks. Firstly I want to quickly view changes in a commit, reading commits to a project like emails, to see what was changed ([this package](https://gitlab.com/ideasman42/emacs-magit-commit-mark) marks commits as read - like email). - Ediff loads each file separately, so it's not convenient to scroll down through changes to all files (you have to choose which file to ediff). - Ediff loads the full buffer for both, since emacs supports hiding content it would have to be possible to hide unchanged regions (maybe it's supported out of the box?), I wasn't able to find it. Both these issues make it difficult to use ediff to review commits, or - it would be useful to review commits in some situations if I were reviewing them in more detail and needed to see the surrounding context (but this is something I only do rarely). It may be possible to use ediff, but from what I can tell it would involve some non-trivial changed to ediff's default behavior. - Load all buffers at once, or - automate loading multiple ediff buffers then merge them into buffer for viewing. - Hide unchanged regions so the buffers are vertically aligned. ---- I did check if it would be possible to use ediff in this scenario, see [this question](https://emacs.stackexchange.com/q/70187/2418).