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

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

[elpa] externals/dtache 948c110bbd: Add variable to filter out ansi sequ


From: ELPA Syncer
Subject: [elpa] externals/dtache 948c110bbd: Add variable to filter out ansi sequences
Date: Sun, 6 Feb 2022 06:57:29 -0500 (EST)

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

    Add variable to filter out ansi sequences
    
    Add a variable that users can use to enable/disable usage of
    ansi-color in dtache. It is enabled by default.
---
 README.org        | 40 ++++++++++++++++------------------------
 dtache-compile.el |  2 ++
 dtache.el         | 14 +++++++++++---
 3 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/README.org b/README.org
index 314901120e..5de0f38b5d 100644
--- a/README.org
+++ b/README.org
@@ -227,21 +227,22 @@ Examples of the different sources are featured in this 
[[https://niklaseklund.gi
 
 The package provides the following customizable variables.
 
-| Name                               | Description                             
                     |
-|------------------------------------+--------------------------------------------------------------|
-| dtache-session-directory           | A host specific directory to store 
sessions in               |
-| dtache-db-directory                | A localhost specific directory to store 
the database         |
-| dtache-dtach-program               | Name or path to the =dtach= program     
                       |
-| dtache-shell-program               | Name or path to the =shell= that 
=dtache= should use             |
-| dtache-timer-configuration         | Configuration of the timer that runs on 
remote hosts         |
-| dtache-env                         | Name or path to the =dtache-env= script 
                       |
-| dtache-annotation-format           | A list of annotations that should be 
present in completion   |
-| dtache-max-command-length          | How many characters should be used when 
displaying a command |
-| dtache-tail-interval               | How often =dtache= should refresh the 
output when tailing      |
-| dtache-nonattachable-commands      | A list of commands that should be 
considered nonattachable   |
-| dtache-notification-function       | Specifies which function to issue 
notifications with         |
-| dtache-detach-key                  | Specifies which keybinding to use to 
detach from a session   |
-| dtache-shell-command-initial-input | Enables latest value in history to be 
used as initial input  |
+| Name                               | Description                             
                               |
+|------------------------------------+------------------------------------------------------------------------|
+| dtache-session-directory           | A host specific directory to store 
sessions in                         |
+| dtache-db-directory                | A localhost specific directory to store 
the database                   |
+| dtache-dtach-program               | Name or path to the =dtach= program     
                                 |
+| dtache-shell-program               | Name or path to the =shell= that 
=dtache= should use                       |
+| dtache-timer-configuration         | Configuration of the timer that runs on 
remote hosts                   |
+| dtache-env                         | Name or path to the =dtache-env= script 
                                 |
+| dtache-annotation-format           | A list of annotations that should be 
present in completion             |
+| dtache-max-command-length          | How many characters should be used when 
displaying a command           |
+| dtache-tail-interval               | How often =dtache= should refresh the 
output when tailing                |
+| dtache-nonattachable-commands      | A list of commands that should be 
considered nonattachable             |
+| dtache-notification-function       | Specifies which function to issue 
notifications with                   |
+| dtache-detach-key                  | Specifies which keybinding to use to 
detach from a session             |
+| dtache-shell-command-initial-input | Enables latest value in history to be 
used as initial input            |
+| dtache-filter-ansi-sequences       | Specifies if dtache will use ansi-color 
to filter out escape sequences |
 
 Apart from those variables there is also the different =action= variables, 
which can be configured differently depending on the origin of the session.
 
@@ -372,15 +373,6 @@ 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-compile.el b/dtache-compile.el
index 63731d83f8..931abd7731 100644
--- a/dtache-compile.el
+++ b/dtache-compile.el
@@ -118,6 +118,8 @@ Optionally EDIT-COMMAND."
   (when dtache-enabled
     (setq dtache--buffer-session dtache--current-session)
     (dtache-compile--replace-modesetter)
+    (when dtache-filter-ansi-sequences
+      (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter 0 t))
     (add-hook 'comint-preoutput-filter-functions 
#'dtache--dtache-env-message-filter 0 t)
     (add-hook 'comint-preoutput-filter-functions 
#'dtache--dtach-eof-message-filter 0 t)))
 
diff --git a/dtache.el b/dtache.el
index aabde2aa52..b1f212cdd1 100644
--- a/dtache.el
+++ b/dtache.el
@@ -135,7 +135,12 @@ If set to a non nil value the latest entry to
   :type 'string
   :group 'dtache)
 
-(defcustom dtache-log-mode-hook '(dtache--ansi-color-output)
+(defcustom dtache-filter-ansi-sequences t
+  "Variable to instruct `dtache' to use `ansi-filter'."
+  :type 'bool
+  :group 'dtache)
+
+(defcustom dtache-log-mode-hook '()
   "Hook for customizing `dtache-log' mode."
   :type 'hook
   :group 'dtache)
@@ -1270,7 +1275,10 @@ 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.")
+  "Major mode for `dtache' logs."
+  (when dtache-filter-ansi-sequences
+    (dtache--ansi-color-output))
+  (read-only-mode t))
 
 (defvar dtache-tail-mode-map
   (let ((map (make-sparse-keymap)))
@@ -1280,7 +1288,7 @@ If event is cased by an update to the `dtache' database, 
re-initialize
 
 ;;;###autoload
 (define-derived-mode dtache-tail-mode auto-revert-tail-mode "Dtache Tail"
-  "Major mode for tailing dtache logs."
+  "Major mode to tail `dtache' logs."
   (setq-local auto-revert-interval dtache-tail-interval)
   (setq-local tramp-verbose 1)
   (setq-local auto-revert-remote-files t)



reply via email to

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