Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI Escape sequences printed verbatim with realgud:ipdb #1

Open
rocky opened this issue Aug 9, 2019 · 0 comments
Open

ANSI Escape sequences printed verbatim with realgud:ipdb #1

rocky opened this issue Aug 9, 2019 · 0 comments

Comments

@rocky
Copy link
Contributor

rocky commented Aug 9, 2019

@stnbu commented on Thu Apr 20 2017

I'm quite new to emacs so please forgive any stupid...

I have the following in my ~/.emacs

(add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
(add-to-list 'comint-output-filter-functions 'ansi-color-process-output)

This does address a similar problem (re ANSI color sequences) with elpy+ipython.

But when I

M-x load-library [RET] realgud [RET]
M-x realgud:ipdb [RET]

from within a python buffer, I get a new ipdb interpreter in another window (that appears to be working as expected). But I get the above mentioned ANSI color escape sequence problem:

Current directory: /foo/
Command: ipdb /foo/__init__.py
> /foo/__init__.py(1)<module>()
----> 1 import paramiko
      2 
      3 

�[6n�[Jipdb> �[6D�[6C
�[6D�[Jipdb> �[6D
�[J�[6n�[Jipdb> �[6D�[6C�[6D�[J�[6n�[Jipdb> �[6D�[6C

From my package listing buffer:

 realgud       20170218.740  installed

@eflanigan00 commented on Thu Jul 13 2017

Anyone know anything about this? I'm having the same problem.


@xkal36 commented on Sun Aug 13 2017

I came across this problem also. I detailed my fix here: https://emacs.stackexchange.com/questions/34854/ipdb-displaying-ansi-color-escape-sequences


@rocky commented on Sun Aug 13 2017

@xkal36 I'd be grateful if you documented the workaround in off of https://github.com/realgud/realgud/wiki

Although beggars can't be choosers, my suggestion would be to document the problem in general: ANSI escape codes in Emacs shells, and then under ipdb notes add a mention to that along with your sample shell script that disables ANSI control codes. Thanks in advance.

I've added entries to the wiki. I may also try more aggressive ANSI Escape code filtering in the future.


@rocky commented on Tue Aug 15 2017

@stnbu @eflanigan00 @xkal36 I have just created a branch that may address this by filtering out all ANSI escape codes. Try this patch and let me know if this helps:

diff --git a/realgud/common/track.el b/realgud/common/track.el
index f26a0ed..3097de0 100644
--- a/realgud/common/track.el
+++ b/realgud/common/track.el
@@ -41,6 +41,11 @@
   :type 'symbolp
   :group 'realgud)
 
+(defcustom realgud-strip-ansi? nil
+"If non-nil, set strip ANSI control characters from output text we see"
+  :type 'symbolp
+  :group 'realgud)
+
 (declare-function fn-p-to-fn?-alias                   'realgud-helper)
 (declare-function realgud-bp-add-info                 'realgud-bp)
 (declare-function realgud-bp-del-info                 'realgud-bp)
@@ -182,7 +187,8 @@ evaluating (realgud-cmdbuf-info-loc-regexp realgud-cmdbuf-info)"
 
   (interactive "r")
   (if (> from to) (psetq to from from to))
-  (let* ((text (buffer-substring-no-properties from to))
+  (let* ((raw-text (buffer-substring-no-properties from to))
+	 (text (if realgud-strip-ansi? (ansi-color-filter-apply raw-text) raw-text))
 	 (loc (realgud-track-loc text cmd-mark))
 	 ;; If we see a selected frame number, it is stored
 	 ;; in frame-num. Otherwise, nil.

It is also in the strip-ansi-var branch on github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant