[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dtache 6b83cf1131: Make dtache-log-mode handle ansi seq
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dtache 6b83cf1131: Make dtache-log-mode handle ansi sequences |
Date: |
Sat, 5 Feb 2022 08:57:26 -0500 (EST) |
branch: externals/dtache
commit 6b83cf11317118979fb9321b42c374bae6132b41
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>
Make dtache-log-mode handle ansi sequences
This commit adds the function dtache--ansi-color-output to the
dtache-log-mode-hook. This enables dtache to handle the possible
escape sequences when viewing a session output.
---
README.org | 9 +++++++++
dtache.el | 15 ++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/README.org b/README.org
index 833a293414..314901120e 100644
--- a/README.org
+++ b/README.org
@@ -372,6 +372,15 @@ The package can be integrated with
[[https://github.com/bbatsov/projectile][proj
(advice-add 'projectile-run-compilation :override
#'my/dtache-projectile-run-compilation)
#+end_src
+** ANSI escape sequences
+
+The =dtache-log-mode= which is the major mode used when either
=dtache-compile-session= or =dtache-view-session= is called. The hook of the
mode runs the function =dtache--ansi-color-output= which removes the potential
escape sequences present in the log. If you don't mind the sequences there is
always the option to remove the function from the =dtache-log-mode-hook=.
+
+To get the =ansi-color= on the output when being attached to a session with
=dtache-compile= add the following hook to your configuration.
+
+#+begin_src elisp
+ (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter)
+#+end_src
* Versions
diff --git a/dtache.el b/dtache.el
index 5d583fdd84..86fc7086e4 100644
--- a/dtache.el
+++ b/dtache.el
@@ -34,7 +34,7 @@
;; When a session is created, dtache makes sure that Emacs is attached
;; to it the same time, which makes it a seamless experience for the
-;; users. The `dtache' package internaly creates a `dtache-session'
+;; users. The `dtache' package internally creates a `dtache-session'
;; for all commands.
;; [1] https://github.com/crigler/dtach
@@ -43,6 +43,7 @@
;;;; Requirements
+(require 'ansi-color)
(require 'autorevert)
(require 'notifications)
(require 'filenotify)
@@ -134,6 +135,11 @@ If set to a non nil value the latest entry to
:type 'string
:group 'dtache)
+(defcustom dtache-log-mode-hook '(dtache--ansi-color-output)
+ "Hook for customizing `dtache-log' mode."
+ :type 'hook
+ :group 'dtache)
+
;;;;; Public
(defvar dtache-enabled nil)
@@ -1078,6 +1084,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--update-session-time (session &optional approximate)
"Update SESSION's time property.
@@ -1257,8 +1267,7 @@ If event is cased by an update to the `dtache' database,
re-initialize
;;;###autoload
(define-derived-mode dtache-log-mode nil "Dtache Log"
- "Major mode for dtache logs."
- (read-only-mode t))
+ "Major mode for `dtache' logs.")
(defvar dtache-tail-mode-map
(let ((map (make-sparse-keymap)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/dtache 6b83cf1131: Make dtache-log-mode handle ansi sequences,
ELPA Syncer <=