From e6a6bd812ce134fcba784dce16576dcbc56f7ee9 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 14 Oct 2020 00:01:47 +0200 Subject: [PATCH] Emacs: Fix ANSI color application in logfiles. --- init.d/text/misc.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/init.d/text/misc.el b/init.d/text/misc.el index 72a85cb..5cd32e6 100644 --- a/init.d/text/misc.el +++ b/init.d/text/misc.el @@ -1,6 +1,6 @@ ;;; misc.el --- Miscellaneous file formats. -*- lexical-binding: t; -*- -;; Time-stamp: <2020-10-13T23:36:21+0200> +;; Time-stamp: <2020-10-14T00:01:20+0200> ;;; Commentary: @@ -193,12 +193,17 @@ ;; Translate ANSI escape color codes. (use-package ansi-color - :config (defun my/display-ansi-colors () - (interactive) - (let ((inhibit-read-only t)) - (ansi-color-apply-on-region compilation-filter-start (point)))) - :mode ("\\.log$" . my/display-ansi-colors) - :hook (compilation-filter . my/display-ansi-colors)) + :config (progn + (defun my/apply-ansi-colors-on-buffer () + "Apply ANSI colors in the current buffer." + (interactive) + (ansi-color-apply-on-region (point-min) (point-max))) + (defun my/apply-ansi-colors-compilation () + "Apply ANSI colors in the compilation window." + (let ((inhibit-read-only t)) + (ansi-color-apply-on-region compilation-filter-start (point))))) + :mode ("\\.log$" . my/apply-ansi-colors-on-buffer) + :hook (compilation-filter . my/apply-ansi-colors-compilation)) ;; Syntax-highlighting mode for text/gemini. (use-package gemini-mode