emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dtache fb29761b4c: Add ansi-color to dtache-tail-mode


From: ELPA Syncer
Subject: [elpa] externals/dtache fb29761b4c: Add ansi-color to dtache-tail-mode
Date: Sun, 6 Feb 2022 16:57:24 -0500 (EST)

branch: externals/dtache
commit fb29761b4c33c8bc940e240a0728c15813bd05b3
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Add ansi-color to dtache-tail-mode
---
 CHANGELOG.org |  2 +-
 dtache.el     | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 228c1d0942..7764cb44e3 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -4,7 +4,7 @@
 
 * Development
 
-- The =dtache-log-mode-hook= is preconfigured to run a function which removes 
ANSI escape sequences
+- The package now uses =ansi-color= to handle ANSI escape sequences. This 
feature is enabled by default but can be turned of if 
=dtache-filter-ansi-sequences= is set to nil.
 
 * Version 0.5 (2022-02-02)
 
diff --git a/dtache.el b/dtache.el
index b1f212cdd1..b5ec254f41 100644
--- a/dtache.el
+++ b/dtache.el
@@ -1092,9 +1092,10 @@ If SESSION is nonattachable fallback to a command that 
doesn't rely on tee."
   (let ((remote (file-remote-p default-directory)))
     `(,(if remote (file-remote-p default-directory 'host) (system-name)) . 
,(if remote 'remote 'local))))
 
-(defun dtache--ansi-color-output ()
-  "Apply `ansi-color' on output."
-  (ansi-color-apply-on-region (point-min) (point-max)))
+(defun dtache--ansi-color-tail ()
+  "Apply `ansi-color' on tail output."
+  (let ((inhibit-read-only t))
+    (ansi-color-apply-on-region auto-revert-tail-pos (point-max))))
 
 (defun dtache--update-session-time (session &optional approximate)
   "Update SESSION's time property.
@@ -1277,7 +1278,7 @@ If event is cased by an update to the `dtache' database, 
re-initialize
 (define-derived-mode dtache-log-mode nil "Dtache Log"
   "Major mode for `dtache' logs."
   (when dtache-filter-ansi-sequences
-    (dtache--ansi-color-output))
+    (ansi-color-apply-on-region (point-min) (point-max)))
   (read-only-mode t))
 
 (defvar dtache-tail-mode-map
@@ -1297,6 +1298,9 @@ If event is cased by an update to the `dtache' database, 
re-initialize
   (auto-revert-set-timer)
   (setq-local auto-revert-verbose nil)
   (auto-revert-tail-mode)
+  (when dtache-filter-ansi-sequences
+    (add-hook 'after-revert-hook #'dtache--ansi-color-tail nil t)
+    (ansi-color-apply-on-region (point-min) (point-max)))
   (read-only-mode t))
 
 (provide 'dtache)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]