Use nicer colours with org(latex)diff

This commit is contained in:
TEC 2021-09-18 22:40:41 +08:00
parent 3e6732e2ec
commit 71548fc917
Signed by: tec
GPG Key ID: 779591AFDB81F06C
2 changed files with 23 additions and 2 deletions

View File

@ -5008,8 +5008,29 @@ written a package to streamline the process.
(package! orgdiff :recipe (:local-repo "lisp/orgdiff"))
#+end_src
The only little annoyance is the fact that =latexdiff= uses ~#FF0000~ and ~#0000FF~ as
the red/blue change indication colours. We can make this a bit nicer by
post-processing the =latexdiff= result.
#+begin_src emacs-lisp :tangle yes
(use-package! orgdiff :defer t)
(use-package! orgdiff
:defer t
:config
(defun +orgdiff-nicer-change-colours ()
(goto-char (point-min))
;; Set red/blue based on whether chameleon is being used
(if (search-forward "%% make document follow Emacs theme" nil t)
(setq red (substring (doom-blend 'red 'fg 0.8) 1)
blue (substring (doom-blend 'blue 'teal 0.6) 1))
(setq red "c82829"
blue "00618a"))
(when (and (search-forward "%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF" nil t)
(search-forward "\\RequirePackage{color}" nil t))
(when (re-search-forward "definecolor{red}{rgb}{1,0,0}" (cdr (bounds-of-thing-at-point 'line)) t)
(replace-match (format "definecolor{red}{HTML}{%s}" red)))
(when (re-search-forward "definecolor{blue}{rgb}{0,0,1}" (cdr (bounds-of-thing-at-point 'line)) t)
(replace-match (format "definecolor{blue}{HTML}{%s}" blue)))))
(add-to-list 'orgdiff-latexdiff-postprocess-hooks #'+orgdiff-nicer-change-colours))
#+end_src
*** Behaviour
[[xkcd:1319]]

@ -1 +1 @@
Subproject commit 4512f8aa0fd15ab27a447217c020f8c7644097f3
Subproject commit fa8eabcbf7d9f61521cc703917d4cafbd1bc222a